#include <XMLTag.hpp>

Public Member Functions | |
| ReferenceCounting< XMLAttribute > | findAttribute (const std::string &name, const std::string &defaultValue="") const |
| void | close (const std::string &name) |
| void | add (ReferenceCounting< XMLAttribute > xmlAttribute) |
| void | add (ReferenceCounting< XMLContentBase > xmlContent) |
| ReferenceCounting< XMLContentBase > | content () |
| ConstReferenceCounting < XMLContentBase > | content () const |
| const std::string & | name () const |
| XMLTag (const std::string &name) | |
Private Types | |
| typedef std::map< std::string, ReferenceCounting < XMLAttribute > > | AttributeList |
Private Attributes | |
| const std::string | __name |
| AttributeList | __attributes |
| ReferenceCounting< XMLContentBase > | __content |
Friends | |
| std::ostream & | operator<< (std::ostream &os, const XMLTag &xmlTag) |
Definition at line 42 of file XMLTag.hpp.
typedef std::map<std::string, ReferenceCounting<XMLAttribute> > XMLTag::AttributeList [private] |
Definition at line 46 of file XMLTag.hpp.
| XMLTag::XMLTag | ( | const std::string & | name | ) | [inline] |
| ReferenceCounting<XMLAttribute> XMLTag::findAttribute | ( | const std::string & | name, | |
| const std::string & | defaultValue = "" | |||
| ) | const [inline] |
Looks for an attribute according to its name
| name | name of the attribute | |
| defaultValue | value to use if attribute is not found |
Definition at line 66 of file XMLTag.hpp.
References __attributes, ErrorHandler::normal, and stringify().
00068 { 00069 AttributeList::const_iterator attribute = __attributes.find(name); 00070 if (attribute == __attributes.end()) { 00071 if (defaultValue.size() == 0) { 00072 throw ErrorHandler(__FILE__,__LINE__, 00073 "cannot find mandatory attribute '"+name+"' into <"+stringify(*this)+">", 00074 ErrorHandler::normal); 00075 } else { 00076 return new XMLAttribute(name,defaultValue); 00077 } 00078 } 00079 00080 return attribute->second; 00081 }

| void XMLTag::close | ( | const std::string & | name | ) | [inline] |
Closes a tag checking that the closure fits the opening
| name | closed tag name |
Definition at line 108 of file XMLTag.hpp.
References __name, and ErrorHandler::normal.
00109 { 00110 if (__name != name) { 00111 throw ErrorHandler(__FILE__,__LINE__, 00112 "tag <"+__name+"> closed by </"+name+">", 00113 ErrorHandler::normal); 00114 } 00115 }
| void XMLTag::add | ( | ReferenceCounting< XMLAttribute > | xmlAttribute | ) | [inline] |
Adds an attribute to a tag
| xmlAttribute | given attribute |
Definition at line 122 of file XMLTag.hpp.
References __attributes, __name, and ErrorHandler::normal.
Referenced by WriterVTK::__proceed().
00123 { 00124 if (__attributes.find(xmlAttribute->name()) != __attributes.end()) { 00125 throw ErrorHandler(__FILE__,__LINE__, 00126 "duplicated attribute '"+ 00127 xmlAttribute->name()+ 00128 "' in tag '"+__name+'\'', 00129 ErrorHandler::normal); 00130 } 00131 __attributes[xmlAttribute->name()] = xmlAttribute; 00132 }
| void XMLTag::add | ( | ReferenceCounting< XMLContentBase > | xmlContent | ) | [inline] |
| ReferenceCounting<XMLContentBase> XMLTag::content | ( | ) | [inline] |
Access to the content of the tag
Definition at line 151 of file XMLTag.hpp.
References __content.
00152 { 00153 return __content; 00154 }
| ConstReferenceCounting<XMLContentBase> XMLTag::content | ( | ) | const [inline] |
Read only access to the content of the tag
Definition at line 162 of file XMLTag.hpp.
References __content.
00163 { 00164 return __content; 00165 }
| const std::string& XMLTag::name | ( | ) | const [inline] |
Gets the tag name
Definition at line 173 of file XMLTag.hpp.
References __name.
00174 { 00175 return __name; 00176 }
| std::ostream& operator<< | ( | std::ostream & | os, | |
| const XMLTag & | xmlTag | |||
| ) | [friend] |
Writes a tag to a stream
| os | given output stream | |
| xmlTag | the tag to write |
Definition at line 91 of file XMLTag.hpp.
00093 { 00094 os << xmlTag.__name; 00095 for (AttributeList::const_iterator i = xmlTag.__attributes.begin(); 00096 i != xmlTag.__attributes.end(); ++i) { 00097 os << ' ' << i->second->name() << "=\"" 00098 << i->second->value() << '"'; 00099 } 00100 return os; 00101 }
const std::string XMLTag::__name [private] |
AttributeList XMLTag::__attributes [private] |
list of attributes
Definition at line 51 of file XMLTag.hpp.
Referenced by add(), and findAttribute().
ReferenceCounting<XMLContentBase> XMLTag::__content [private] |
content of the tag if any
Definition at line 54 of file XMLTag.hpp.
1.5.6