MCPcopy Create free account
hub / github.com/bruderstein/nppPluginManager / TiXmlHandle

Class TiXmlHandle

TinyXml/include/tinyxml/tinyxml.h:1210–1265  ·  view source on GitHub ↗

A TiXmlHandle is a class that wraps a node pointer with null checks; this is an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml DOM structure. It is a separate utility class. Take an example: @verbatim @endver

Source from the content-addressed store, hash-verified

1208 @endverbatim
1209*/
1210class TiXmlHandle
1211{
1212public:
1213 /// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
1214 TiXmlHandle( TiXmlNode* node ) { this->node = node; }
1215 /// Copy constructor
1216 TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; }
1217 /// assignment operator
1218 TiXmlHandle operator=(const TiXmlHandle& ref) { if (&ref != this) this->node = ref.node; return *this; }
1219
1220 /// Return a handle to the first child node.
1221 TiXmlHandle FirstChild() const;
1222 /// Return a handle to the first child node with the given name.
1223 TiXmlHandle FirstChild( const TCHAR * value ) const;
1224 /// Return a handle to the first child element.
1225 TiXmlHandle FirstChildElement() const;
1226 /// Return a handle to the first child element with the given name.
1227 TiXmlHandle FirstChildElement( const TCHAR * value ) const;
1228
1229 /** Return a handle to the "index" child with the given name.
1230 The first child is 0, the second 1, etc.
1231 */
1232 TiXmlHandle Child( const TCHAR* value, int index ) const;
1233 /** Return a handle to the "index" child.
1234 The first child is 0, the second 1, etc.
1235 */
1236 TiXmlHandle Child( int index ) const;
1237 /** Return a handle to the "index" child element with the given name.
1238 The first child element is 0, the second 1, etc. Note that only TiXmlElements
1239 are indexed: other types are not counted.
1240 */
1241 TiXmlHandle ChildElement( const TCHAR* value, int index ) const;
1242 /** Return a handle to the "index" child element.
1243 The first child element is 0, the second 1, etc. Note that only TiXmlElements
1244 are indexed: other types are not counted.
1245 */
1246 TiXmlHandle ChildElement( int index ) const;
1247
1248 #ifdef TIXML_USE_STL
1249 TiXmlHandle FirstChild( const std::generic_string& _value ) const { return FirstChild( _value.c_str() ); }
1250 TiXmlHandle FirstChildElement( const std::generic_string& _value ) const { return FirstChildElement( _value.c_str() ); }
1251
1252 TiXmlHandle Child( const std::generic_string& _value, int index ) const { return Child( _value.c_str(), index ); }
1253 TiXmlHandle ChildElement( const std::generic_string& _value, int index ) const { return ChildElement( _value.c_str(), index ); }
1254 #endif
1255
1256 /// Return the handle as a TiXmlNode. This may return null.
1257 TiXmlNode* Node() const { return node; }
1258 /// Return the handle as a TiXmlElement. This may return null.
1259 TiXmlElement* Element() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
1260 /// Return the handle as a TiXmlText. This may return null.
1261 TiXmlText* Text() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
1262
1263private:
1264 TiXmlNode* node;
1265};
1266
1267

Callers 4

FirstChildMethod · 0.85
FirstChildElementMethod · 0.85
ChildMethod · 0.85
ChildElementMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected