~ubuntu-branches/debian/sid/gource/sid

« back to all changes in this revision

Viewing changes to src/tinyxml/tinyxml.cpp

  • Committer: Package Import Robot
  • Author(s): Andrew Caudwell
  • Date: 2014-04-15 16:30:17 UTC
  • mfrom: (1.2.15)
  • Revision ID: package-import@ubuntu.com-20140415163017-ucdr2josj1spzrga
Tags: 0.41-1
* New upstream release
* Made VCS URIs canonical
* Changed watch file to look at Github for releases

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
www.sourceforge.net/projects/tinyxml
3
 
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
 
3
Original code by Lee Thomason (www.grinninglizard.com)
4
4
 
5
5
This software is provided 'as-is', without any express or implied
6
6
warranty. In no event will the authors be held liable for any
191
191
        if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT )
192
192
        {
193
193
                delete node;
194
 
                if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
 
194
                if ( GetDocument() ) 
 
195
                        GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
195
196
                return 0;
196
197
        }
197
198
 
214
215
{
215
216
        if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
216
217
        {
217
 
                if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
 
218
                if ( GetDocument() ) 
 
219
                        GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
218
220
                return 0;
219
221
        }
220
222
        TiXmlNode* node = addThis.Clone();
232
234
        }
233
235
        if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
234
236
        {
235
 
                if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
 
237
                if ( GetDocument() ) 
 
238
                        GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
236
239
                return 0;
237
240
        }
238
241
 
264
267
        }
265
268
        if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT )
266
269
        {
267
 
                if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
 
270
                if ( GetDocument() ) 
 
271
                        GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
268
272
                return 0;
269
273
        }
270
274
 
544
548
}
545
549
 
546
550
 
547
 
void TiXmlElement::operator=( const TiXmlElement& base )
 
551
TiXmlElement& TiXmlElement::operator=( const TiXmlElement& base )
548
552
{
549
553
        ClearThis();
550
554
        base.CopyTo( this );
 
555
        return *this;
551
556
}
552
557
 
553
558
 
662
667
}
663
668
 
664
669
 
 
670
int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* value ) const
 
671
{
 
672
        const TiXmlAttribute* node = attributeSet.Find( name );
 
673
        if ( !node )
 
674
                return TIXML_NO_ATTRIBUTE;
 
675
 
 
676
        int ival = 0;
 
677
        int result = node->QueryIntValue( &ival );
 
678
        *value = (unsigned)ival;
 
679
        return result;
 
680
}
 
681
 
 
682
 
 
683
int TiXmlElement::QueryBoolAttribute( const char* name, bool* bval ) const
 
684
{
 
685
        const TiXmlAttribute* node = attributeSet.Find( name );
 
686
        if ( !node )
 
687
                return TIXML_NO_ATTRIBUTE;
 
688
        
 
689
        int result = TIXML_WRONG_TYPE;
 
690
        if (    StringEqual( node->Value(), "true", true, TIXML_ENCODING_UNKNOWN ) 
 
691
                 || StringEqual( node->Value(), "yes", true, TIXML_ENCODING_UNKNOWN ) 
 
692
                 || StringEqual( node->Value(), "1", true, TIXML_ENCODING_UNKNOWN ) ) 
 
693
        {
 
694
                *bval = true;
 
695
                result = TIXML_SUCCESS;
 
696
        }
 
697
        else if (    StringEqual( node->Value(), "false", true, TIXML_ENCODING_UNKNOWN ) 
 
698
                          || StringEqual( node->Value(), "no", true, TIXML_ENCODING_UNKNOWN ) 
 
699
                          || StringEqual( node->Value(), "0", true, TIXML_ENCODING_UNKNOWN ) ) 
 
700
        {
 
701
                *bval = false;
 
702
                result = TIXML_SUCCESS;
 
703
        }
 
704
        return result;
 
705
}
 
706
 
 
707
 
 
708
 
665
709
#ifdef TIXML_USE_STL
666
710
int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const
667
711
{
899
943
}
900
944
 
901
945
 
902
 
void TiXmlDocument::operator=( const TiXmlDocument& copy )
 
946
TiXmlDocument& TiXmlDocument::operator=( const TiXmlDocument& copy )
903
947
{
904
948
        Clear();
905
949
        copy.CopyTo( this );
 
950
        return *this;
906
951
}
907
952
 
908
953
 
1171
1216
 
1172
1217
        if (value.find ('\"') == TIXML_STRING::npos) {
1173
1218
                if ( cfile ) {
1174
 
                fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
 
1219
                        fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
1175
1220
                }
1176
1221
                if ( str ) {
1177
1222
                        (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\"";
1179
1224
        }
1180
1225
        else {
1181
1226
                if ( cfile ) {
1182
 
                fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() );
 
1227
                        fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() );
1183
1228
                }
1184
1229
                if ( str ) {
1185
1230
                        (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'";
1241
1286
}
1242
1287
 
1243
1288
 
1244
 
void TiXmlComment::operator=( const TiXmlComment& base )
 
1289
TiXmlComment& TiXmlComment::operator=( const TiXmlComment& base )
1245
1290
{
1246
1291
        Clear();
1247
1292
        base.CopyTo( this );
 
1293
        return *this;
1248
1294
}
1249
1295
 
1250
1296
 
1361
1407
}
1362
1408
 
1363
1409
 
1364
 
void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy )
 
1410
TiXmlDeclaration& TiXmlDeclaration::operator=( const TiXmlDeclaration& copy )
1365
1411
{
1366
1412
        Clear();
1367
1413
        copy.CopyTo( this );
 
1414
        return *this;
1368
1415
}
1369
1416
 
1370
1417