45#include "TreeUnordered.h"
73 typedef UnorderedMultiTree<xml_node_t,false, path_t> xml_tree_t;
123 drain::StringTools::import(++nextID,
id);
137 drain::StringTools::import(++nextID,
id);
166 T getNativeType()
const {
167 return static_cast<T
>(type);
187 const std::string &
getTag(
const T & type){
194 void set(
const NodeXML & node){
197 setType(node.getType());
199 else if (type == STYLE) {
201 mout.suspicious(
"copying STYLE from node: ", node);
203 drain::SmartMapTools::setValues<map_t>(getAttributes(), node.getAttributes());
207 void set(
const intval_t & type){
212 void set(
const std::string & s){
217 void set(
const char *s){
242 void set(
const std::initializer_list<std::pair<const char *,const Variable> > & args){
246 mout.
deprecating(
"Setting attributes/style of a STYLE element.");
256 for (
const auto & entry: args){
257 getAttributes()[entry.first] = entry.second;
266 void set(
const std::map<std::string, V> & args){
270 mout.deprecating(
"Setting attributes/style of a STYLE element: ", args);
280 drain::SmartMapTools::setValues<map_t,true>(getAttributes(), args);
288 void set(
const std::string & key,
const V & value){
292 mout.deprecating(
"Setting style as attributes of a STYLE element: ", key,
':', value);
293 setStyle(key, value);
295 else if (key ==
"style"){
297 mout.obsolete(
"Setting style as attribute: \"style\"=", value);
299 else if (key ==
"class"){
302 drain::StringTools::import(value, cls);
318 NodeXML & operator=(
const xml_tag_t & x){
325 NodeXML & operator=(
const Castable &c){
332 NodeXML & operator=(
const std::string &s){
338 NodeXML & operator=(
const char *s){
344 NodeXML & operator=(
const std::initializer_list<std::pair<const char *,const drain::Variable> > &l){
356 std::ostream &
nodeToStream(std::ostream & ostr, tag_display_mode mode=EMPTY_TAG)
const override;
361 std::ostream &
docToStream(std::ostream & ostr,
const V & tree){
362 V::node_data_t::xml_node_t::docTypeToStream(ostr);
363 V::node_data_t::xml_node_t::toStream(ostr, tree);
386 for (
const auto & entry: xmldoc_attribs){
429 static xmldoc_attrib_map_t xmldoc_attribs;
451typedef NodeXML<>::xml_tree_t TreeXML;
455template <
class E,
bool EX,
class P>
456struct TypeName<
drain::UnorderedMultiTree<NodeXML<E>,EX,P> > {
458 static const std::string & str(){
496 if (mode != CLOSING_TAG){
501 else if (isComment()){
503 if (mode != CLOSING_TAG){
509 if (mode==CLOSING_TAG){
516 if (getTag().empty()){
517 drain::Logger(__FILE__, __FUNCTION__).
unimplemented<LOG_ERR>(
"defaultTag for type=", getType(),
" requested by for ID=", getId(),
" attr=", getAttributes());
519 ostr <<
"defaultTag";
529 if (mode != CLOSING_TAG){
536 specificAttributesToStream(ostr);
541 for (
const auto & key: getAttributes().getKeyList()){
542 std::string v = get(key,
"");
545 xmlAttribToStream(ostr, key, v);
571 if (mode != OPENING_TAG){
577 else if (mode==EMPTY_TAG){
592std::ostream & operator<<(std::ostream &ostr,
const NodeXML<N> & node){
608template <
class E,
bool EX,
class P>
609std::ostream & operator<<(std::ostream &ostr,
const UnorderedMultiTree<
NodeXML<E>,EX,P> & tree){
Two-way mapping between strings and objects of template class T.
Definition Dictionary.h:63
LogSourc e is the means for a function or any program segment to "connect" to a Log.
Definition Log.h:312
Logger & unimplemented(const TT &... args)
Feature to be done. Special type of Logger::note().
Definition Log.h:511
Logger & deprecating(const TT &... args)
Feature will be removed. Special type of Logger::note().
Definition Log.h:521
A "handle" for specialized element classes, i.e. with members like width , height or radius .
Definition TreeXML.h:102
static std::ostream & docTypeToStream(std::ostream &ostr)
Write the XML definition beginning any XML document.
Definition TreeXML.h:384
virtual const std::string & getTag() const
Definition TreeXML.h:178
std::list< std::pair< std::string, std::string > > xmldoc_attrib_map_t
Internal function called after setType()
Definition TreeXML.h:428
virtual std::ostream & nodeToStream(std::ostream &ostr, tag_display_mode mode=EMPTY_TAG) const override
Dumps info. Future option: outputs leading and ending tag.
Definition TreeXML.h:492
static const std::string & getTag(const T &type)
Definition TreeXML.h:187
static std::ostream & docToStream(std::ostream &ostr, const V &tree)
Definition TreeXML.h:733
NodeXML & setText(const S &value)
Assign the text content of this node. If the node type is undefined, set it to CTEXT.
Definition TreeXML.h:619
std::map< xml_tag_t, xml_tag_t > xml_default_elem_map_t
Helps creating child elements. Like children of HTML element UL should be LI.
Definition TreeXML.h:395
NodeXML()
Default constructor.
Definition TreeXML.h:122
static std::ostream & toStream(std::ostream &ostr, const V &t, const std::string &defaultTag="", int indent=0)
"Forward definition" of Tree::toOstream
void set(const std::initializer_list< std::pair< const char *, const Variable > > &args)
Definition TreeXML.h:242
NodeXML(const NodeXML &node)
Copy constructor.
Definition TreeXML.h:136
static std::ostream & sequenceToStream(std::ostream &ostr, const T &x, const SprinterLayout &layout)
Convenience: if sequence type (array, list, set, map) not given, assume array.
Definition Sprinter.h:321
Definition StringBuilder.h:58
Base class for XML "nodes", to be data elements T for drain::Tree<T>
Definition TreeXML.h:80
void addClass(const TT &... args)
Style class.
Definition TreeXML.h:220
static void xmlAttribToStream(std::ostream &ostr, const std::string &key, const V &value)
Handy map for converting characters to XML entities. Example: '&' -> "&".
Definition XML.h:578
virtual void setAttribute(const std::string &key, const std::string &value)
Default implementation. Needed for handling units in strings, like "50%" or "640px".
Definition TreeXML.h:166
static N & xmlAssignNode(N &dst, const N &src)
Assign tree node (data) to another.
Definition XML.h:654
Definition DataSelector.cpp:1277
A container for a static dictionary of enumeration values.
Definition EnumFlags.h:69
static const std::string name
Default implementation: name returned by std::type_info::name()
Definition Type.h:558