Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 17, 2008, 8:59:48 PM (15 years ago)
Author:
rgrieder
Message:

Merged revisions 1875-2278 of the buildsystem branch to buildsystem2.

Location:
code/branches/buildsystem2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/buildsystem2

  • code/branches/buildsystem2/src/tinyxml/ticpp.h

    r2087 r2509  
    1 #define TIXML_USE_TICPP
    2 
    31/*
    42http://code.google.com/p/ticpp/
     
    3028@date           04/11/2006
    3129
    32 @version  0.04b by nico@orxonox.net: gcc-4.3 compilation hotfixes
    3330@version        0.04a by edam@waxworlds.org: based Exception based on std::exception; added stream
    3431                                        << and >> support; added Document::Parse(); bug fix; improved THROW() macro.
     
    9491                file = file.substr( file.find_last_of( "\\/" ) + 1 );                           \
    9592                full_message << message << " <" << file << "@" << __LINE__ << ">";      \
     93                full_message << BuildDetailedErrorString();                                                     \
    9694                throw Exception( full_message.str() );                                                          \
    9795        }
     
    221219
    222220                /**
     221                Compare internal TiXml pointers to determine is both are wrappers around the same node
     222                */
     223                bool operator == ( const Base& rhs ) const
     224                {
     225                        return ( GetBasePointer() == rhs.GetBasePointer() );
     226                }
     227               
     228                /**
     229                Compare internal TiXml pointers to determine is both are wrappers around the same node
     230                */
     231                bool operator != ( const Base& rhs ) const
     232                {
     233                        return ( GetBasePointer() != rhs.GetBasePointer() );
     234                }
     235               
     236                /**
     237                Builds detailed error string using TiXmlDocument::Error() and others
     238                */
     239                std::string BuildDetailedErrorString() const
     240                {
     241                        std::ostringstream full_message;
     242                        #ifndef TICPP_NO_RTTI
     243                        TiXmlNode* node = dynamic_cast< TiXmlNode* >( GetBasePointer() );
     244                        if ( node != 0 )
     245                        {
     246                                TiXmlDocument* doc = node->GetDocument();
     247                                if ( doc != 0 )
     248                                {
     249                                        if ( doc->Error() )
     250                                        {
     251                                                full_message    << "\nDescription: " << doc->ErrorDesc()
     252                                                                                << "\nFile: " << (strlen( doc->Value() ) > 0 ? doc->Value() : "<unnamed-file>")
     253                                                                                << "\nLine: " << doc->ErrorRow()
     254                                                                                << "\nColumn: " << doc->ErrorCol();
     255                                        }
     256                                }
     257                        }
     258                        #endif
     259                        return full_message.str();
     260                }
     261
     262                /**
    223263                Destructor
    224264                */
    225265                virtual ~Base()
    226266                {
    227                         DeleteSpawnedWrappers();
    228267                }
    229268
     
    231270                mutable TiCppRCImp* m_impRC;    /**< Holds status of internal TiXmlPointer - use this to determine if object has been deleted already */
    232271
    233                 mutable std::vector< Base* > m_spawnedWrappers; /**< Remember all wrappers that we've created with 'new' - ( e.g. NodeFactory, FirstChildElement, etc. )*/
    234 
    235272                /**
    236273                @internal
     
    250287                                TICPPTHROW( "Internal TiXml Pointer is NULL" );
    251288                        }
    252                 }
    253 
    254                 /**
    255                 @internal
    256                 Delete all container objects we've spawned with 'new'.
    257                 */
    258                 void DeleteSpawnedWrappers()
    259                 {
    260                         std::vector< Base* >::reverse_iterator wrapper;
    261                         for ( wrapper = m_spawnedWrappers.rbegin(); wrapper != m_spawnedWrappers.rend(); ++wrapper )
    262                         {
    263                                 delete *wrapper;
    264                         }
    265                         m_spawnedWrappers.clear();
    266                 }
     289                }               
    267290
    268291                /**
     
    875898                bool NoChildren() const;
    876899
     900                #ifndef TICPP_NO_RTTI
    877901                /**
    878902                Pointer conversion ( NOT OBJECT CONVERSION ) - replaces TiXmlNode::ToElement, TiXmlNode::ToDocument, TiXmlNode::ToComment, etc.
     
    895919                        return pointer;
    896920                }
     921                #endif
    897922
    898923                /**
     
    10851110
    10861111                /// Constructor
    1087                 Iterator( const Iterator& it, const std::string& value  = "" )
    1088                         : m_p( it.m_p ), m_value( value )
     1112                Iterator( const Iterator& it )
     1113                        : m_p( it.m_p ), m_value( it.m_value )
    10891114                {
    10901115                }
     
    11031128                {
    11041129                        m_p = it.m_p;
     1130                        m_value = it.m_value;
    11051131                        return *this;
    11061132                }
     
    11211147
    11221148                /** Sets internal pointer to the Next Sibling, or Iterator::END, if there are no more siblings */
    1123                 Iterator& operator++(int)
    1124                 {
    1125                         return this->operator ++();
     1149                Iterator operator++(int)
     1150                {
     1151                        Iterator tmp(*this);
     1152                        ++(*this);
     1153                        return tmp;
    11261154                }
    11271155
     
    11341162
    11351163                /** Sets internal pointer to the Previous Sibling, or Iterator::END, if there are no prior siblings */
    1136                 Iterator& operator--(int)
    1137                 {
    1138                         return this->operator --();
     1164                Iterator operator--(int)
     1165                {                       
     1166                        Iterator tmp(*this);
     1167                        --(*this);
     1168                        return tmp;
    11391169                }
    11401170
    11411171                /** Compares internal pointer */
    1142                 bool operator!=( T* p ) const
    1143                 {
    1144                         return m_p != p;
     1172                bool operator!=( const T* p ) const
     1173                {
     1174                        if ( m_p == p )
     1175                        {
     1176                                return false;
     1177                        }
     1178                        if ( 0 == m_p || 0 == p )
     1179                        {
     1180                                return true;
     1181                        }
     1182                        return *m_p != *p;
    11451183                }
    11461184
     
    11481186                bool operator!=( const Iterator& it ) const
    11491187                {
    1150                         return m_p != it.m_p;
     1188                        return operator!=( it.m_p );
    11511189                }
    11521190
     
    11541192                bool operator==( T* p ) const
    11551193                {
    1156                         return m_p == p;
     1194                        if ( m_p == p )
     1195                        {
     1196                                return true;
     1197                        }
     1198                        if ( 0 == m_p || 0 == p )
     1199                        {
     1200                                return false;
     1201                        }
     1202                        return *m_p == *p;
    11571203                }
    11581204
     
    11601206                bool operator==( const Iterator& it ) const
    11611207                {
    1162                         return m_p == it.m_p;
     1208                        return operator==( it.m_p );
    11631209                }
    11641210
     
    12201266                        if ( 0 == tiXmlPointer )
    12211267                        {
    1222                                 TICPPTHROW( "Can not create a " << typeid( T ).name() );
     1268                                #ifdef TICPP_NO_RTTI
     1269                                        TICPPTHROW( "Can not create TinyXML objext" );
     1270                                #else
     1271                                        TICPPTHROW( "Can not create a " << typeid( T ).name() );
     1272                                #endif
    12231273                        }
    12241274                        SetTiXmlPointer( tiXmlPointer );
     
    12331283                virtual void operator=( const NodeImp<T>& copy )
    12341284                {
    1235                         DeleteSpawnedWrappers();
    1236 
    12371285                        // Dropping the reference to the old object
    12381286                        this->m_impRC->DecRef();
     
    12671315                virtual ~NodeImp()
    12681316                {
    1269                         // The spawnedWrappers need to be deleted before m_tiXmlPointer
    1270                         DeleteSpawnedWrappers();
    12711317                        m_impRC->DecRef();
    12721318                }
     
    16851731
    16861732                /**
     1733                Returns an attribute of @a name from an element.
     1734                Uses FromString to convert the string to the type of choice.
     1735
     1736                @param name                             The name of the attribute you are querying.
     1737                @param throwIfNotFound  [DEF]   If true, will throw an exception if the attribute doesn't exist
     1738                @throws Exception When the attribute doesn't exist and throwIfNotFound is true
     1739                @see GetAttributeOrDefault
     1740                */
     1741                template < class T >
     1742                        T GetAttribute( const std::string& name, bool throwIfNotFound = true ) const
     1743                {
     1744                        // Get the attribute's value as a std::string
     1745                        std::string temp;
     1746                        T value;
     1747                        if ( !GetAttributeImp( name, &temp ) )
     1748                        {
     1749                                if ( throwIfNotFound )
     1750                                {
     1751                                        TICPPTHROW( "Attribute does not exist" );
     1752                                }
     1753                        }
     1754                        else
     1755                        {
     1756                                // Stream the value from the string to T
     1757                                FromString( temp, &value );
     1758                        }
     1759
     1760                        return value;
     1761                }
     1762
     1763                /**
    16871764                Gets an attribute of @a name from an element.
    16881765                Uses FromString to convert the string to the type of choice.
     
    17271804                std::string GetAttribute( const std::string& name ) const;
    17281805
     1806                /**
     1807                Returns true, if attribute exists
     1808
     1809                @param name The name of the attribute you are checking.
     1810                @return Existence of attribute
     1811                */
     1812                bool HasAttribute( const std::string& name ) const;
     1813
     1814                /**
     1815                Removes attribute from element.
     1816
     1817                @param name The name of the attribute to remove.
     1818                */
     1819                void RemoveAttribute( const std::string& name );
     1820
    17291821        private:
    17301822
Note: See TracChangeset for help on using the changeset viewer.