mirror of https://github.com/AxioDL/tinyxml2.git
handles wip. not happy with const behavior
This commit is contained in:
parent
3ffdd39dbf
commit
5708f814a6
16
tinyxml2.h
16
tinyxml2.h
|
@ -1187,10 +1187,10 @@ class XMLHandle
|
|||
{
|
||||
public:
|
||||
/// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
|
||||
//XMLHandle( XMLNode* _node ) { node = _node; }
|
||||
XMLHandle( const XMLNode* _node ) { node = const_cast<XMLNode*>(_node); }
|
||||
//XMLHandle( XMLNode& _node ) { node = &_node; }
|
||||
XMLHandle( const XMLNode& _node ) { node = const_cast<XMLNode*>(&_node); }
|
||||
XMLHandle( XMLNode* _node ) { node = _node; }
|
||||
//XMLHandle( const XMLNode* _node ) { node = const_cast<XMLNode*>(_node); }
|
||||
XMLHandle( XMLNode& _node ) { node = &_node; }
|
||||
//XMLHandle( const XMLNode& _node ) { node = const_cast<XMLNode*>(&_node); }
|
||||
XMLHandle( const XMLHandle& ref ) { node = ref.node; }
|
||||
|
||||
XMLHandle operator=( XMLHandle ref ) { node = ref.node; return *this; }
|
||||
|
@ -1204,14 +1204,14 @@ public:
|
|||
XMLHandle LastChild() { return XMLHandle( node ? node->LastChild() : 0 ); }
|
||||
const XMLHandle LastChild() const { return XMLHandle( node ? node->LastChild() : 0 ); }
|
||||
|
||||
XMLHandle LastChildElement( const char* _value=0 ) { return XMLHandle( node ? node->LastChildElement() : 0 ); }
|
||||
const XMLHandle LastChildElement( const char* _value=0 ) const { return XMLHandle( node ? node->LastChildElement() : 0 ); }
|
||||
XMLHandle LastChildElement( const char* _value=0 ) { return XMLHandle( node ? node->LastChildElement( _value ) : 0 ); }
|
||||
const XMLHandle LastChildElement( const char* _value=0 ) const { return XMLHandle( node ? node->LastChildElement( _value ) : 0 ); }
|
||||
|
||||
XMLHandle PreviousSibling() { return XMLHandle( node ? node->PreviousSibling() : 0 ); }
|
||||
const XMLHandle PreviousSibling() const { return XMLHandle( node ? node->PreviousSibling() : 0 ); }
|
||||
|
||||
XMLHandle PreviousSiblingElement( const char* _value=0 ) { return XMLHandle( node ? node->PreviousSiblingElement() : 0 ); }
|
||||
const XMLHandle PreviousSiblingElement( const char* _value=0 ) const { return XMLHandle( node ? node->PreviousSiblingElement() : 0 ); }
|
||||
XMLHandle PreviousSiblingElement( const char* _value=0 ) { return XMLHandle( node ? node->PreviousSiblingElement( _value ) : 0 ); }
|
||||
const XMLHandle PreviousSiblingElement( const char* _value=0 ) const { return XMLHandle( node ? node->PreviousSiblingElement( _value ) : 0 ); }
|
||||
|
||||
XMLHandle NextSibling() { return XMLHandle( node ? node->NextSibling() : 0 ); }
|
||||
const XMLHandle NextSibling() const { return XMLHandle( node ? node->NextSibling() : 0 ); }
|
||||
|
|
16
xmltest.cpp
16
xmltest.cpp
|
@ -726,6 +726,22 @@ int main( int /*argc*/, const char ** /*argv*/ )
|
|||
XMLTest( "Clone and Equal", 4, count );
|
||||
}
|
||||
|
||||
// -------- Handles ------------
|
||||
{
|
||||
static const char* xml = "<element attrib='bar'><sub>Text</sub></element>";
|
||||
XMLDocument doc;
|
||||
doc.Parse( xml );
|
||||
const XMLDocument& docC = doc;
|
||||
|
||||
XMLElement* ele = XMLHandle( doc ).FirstChildElement( "element" ).FirstChild().ToElement();
|
||||
XMLTest( "Handle, success, mutable", ele->Value(), "sub" );
|
||||
|
||||
ele = XMLHandle( docC ).FirstChildElement( "element" ).FirstChild().ToElement();
|
||||
XMLTest( "Handle, success, mutable", ele->Value(), "sub" );
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ----------- Performance tracking --------------
|
||||
{
|
||||
#if defined( _MSC_VER )
|
||||
|
|
Loading…
Reference in New Issue