Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4491 in orxonox.OLD for orxonox/trunk/src/lib


Ignore:
Timestamp:
Jun 3, 2005, 1:40:28 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: new tinyXML-lib installed (v-2.3.4)

Location:
orxonox/trunk/src/lib/tinyxml
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/lib/tinyxml/tinystr.cc

    r4261 r4491  
    3737TiXmlString::TiXmlString (const char* instring)
    3838{
    39     unsigned newlen;
     39    size_t newlen;
    4040    char * newstring;
    4141
     
    4747        return;
    4848    }
    49         //*ME:  warning C4267: convert 'size_t' to 'unsigned int'
    50         //*ME:  Use Cast: (unsigned)
    51     newlen = (unsigned)strlen (instring) + 1;
     49    newlen = strlen (instring) + 1;
    5250    newstring = new char [newlen];
    5351    memcpy (newstring, instring, newlen);
     
    6159TiXmlString::TiXmlString (const TiXmlString& copy)
    6260{
    63     unsigned newlen;
     61    size_t newlen;
    6462    char * newstring;
    6563
     
    8785void TiXmlString ::operator = (const char * content)
    8886{
    89     unsigned newlen;
     87    size_t newlen;
    9088    char * newstring;
    9189
     
    9593        return;
    9694    }
    97     newlen = (unsigned)strlen (content) + 1;
     95    newlen = strlen (content) + 1;
    9896    newstring = new char [newlen];
    9997    // strcpy (newstring, content);
     
    108106void TiXmlString ::operator = (const TiXmlString & copy)
    109107{
    110     unsigned newlen;
     108    size_t newlen;
    111109    char * newstring;
    112110
     
    128126
    129127// append a const char * to an existing TiXmlString
    130 void TiXmlString::append( const char* str, int len )
     128void TiXmlString::append( const char* str, size_t len )
    131129{
    132130    char * new_string;
    133     unsigned new_alloc, new_size, size_suffix;
     131    size_t new_alloc, new_size, size_suffix;
    134132       
    135133        // don't use strlen - it can overrun the len passed in!
     
    192190{
    193191    char * new_string;
    194     unsigned new_alloc, new_size;
     192    size_t new_alloc, new_size;
    195193
    196194    new_size = length () + strlen (suffix) + 1;
     
    252250unsigned TiXmlString::find (char tofind, unsigned offset) const
    253251{
    254         //*ME:  warning C4244: convert '__w64 int' to 'unsigned'
    255         //*ME:  Use Array-Arithmetic instead of Pointer
    256         //  char * lookup;
     252    char * lookup;
    257253
    258254    if (offset >= length ())
    259255        return (unsigned) notfound;
    260         //  for (lookup = cstring + offset; * lookup; lookup++)
    261         //      if (* lookup == tofind)
    262         //          return lookup - cstring;
    263     for( unsigned n=offset ; cstring[n] != '\0' ; n++ )
    264         if( cstring[n] == tofind )
    265             return  n ;
     256    for (lookup = cstring + offset; * lookup; lookup++)
     257        if (* lookup == tofind)
     258            return (unsigned)(lookup - cstring);
    266259    return (unsigned) notfound;
    267260}
     
    276269                return ( strcmp( cstring, compare.cstring ) == 0 );
    277270        }
     271        else if ( length() == 0 && compare.length() == 0 )
     272        {
     273                return true;
     274        }
    278275        return false;
     276}
     277
     278
     279bool TiXmlString::operator == (const char* compare) const
     280{
     281        if ( allocated && compare && *compare )
     282        {
     283                assert( cstring );
     284                return ( strcmp( cstring, compare ) == 0 );
     285        }
     286        else if ( length() == 0 && (!compare || !*compare ) )   // this is a little dubious, but try to duplicate behavior in other operator==
     287        {
     288                return true;
     289        }
     290        return false;   
    279291}
    280292
  • orxonox/trunk/src/lib/tinyxml/tinystr.h

    r4261 r4491  
    3232
    3333#ifdef _MSC_VER
    34 #pragma warning( disable : 4786 )       // Debugger truncating names.
     34#pragma warning( disable : 4530 )
     35#pragma warning( disable : 4786 )
    3536#endif
    3637
     
    4748{
    4849  public :
    49     // TiXmlString constructor, based on a string
    50     TiXmlString (const char * instring);
     50    // TiXmlString constructor, based on a string, mark explicit to force
     51        // us to find unnecessary casting.
     52    explicit TiXmlString (const char * instring);
    5153
    5254    // TiXmlString empty constructor
     
    5961
    6062    // TiXmlString copy constructor
    61     TiXmlString (const TiXmlString& copy);
     63    explicit TiXmlString (const TiXmlString& copy);
    6264
    6365    // TiXmlString destructor
     
    7678
    7779    // Return the length of a TiXmlString
    78     unsigned length () const
     80    size_t length () const
    7981        {
    8082                return ( allocated ) ? current_length : 0;
     
    108110    }
    109111    bool operator == (const TiXmlString & compare) const;
     112    bool operator == (const char* compare) const;
    110113    bool operator < (const TiXmlString & compare) const;
    111114    bool operator > (const TiXmlString & compare) const;
     
    159162            npos = notfound };
    160163
    161     void append (const char *str, int len );
     164    void append (const char *str, size_t len );
    162165
    163166  protected :
     
    166169    char * cstring;
    167170    // Number of chars allocated
    168     unsigned allocated;
     171    size_t allocated;
    169172    // Current string size
    170     unsigned current_length;
     173    size_t current_length;
    171174
    172175    // New size computation. It is simplistic right now : it returns twice the amount
    173176    // we need
    174     unsigned assign_new_size (unsigned minimum_to_allocate)
     177    size_t assign_new_size (size_t minimum_to_allocate)
    175178    {
    176179        return minimum_to_allocate * 2;
     
    239242} ;
    240243
     244#ifdef _MSC_VER
     245#pragma warning( default : 4530 )
     246#pragma warning( default : 4786 )
     247#endif
     248
    241249#endif  // TIXML_STRING_INCLUDED
    242250#endif  // TIXML_USE_STL
  • orxonox/trunk/src/lib/tinyxml/tinyxml.cc

    r4261 r4491  
    319319        for ( node = firstChild; node; node = node->next )
    320320        {
    321                 if ( node->SValue() == TIXML_STRING( _value ))
     321                if ( node->SValue() == _value )
    322322                        return node;
    323323        }
     
    331331        for ( node = firstChild; node; node = node->next )
    332332        {
    333                 if ( node->SValue() == TIXML_STRING( _value ))
     333                if ( node->SValue() == _value )
    334334                        return node;
    335335        }
     
    343343        for ( node = lastChild; node; node = node->prev )
    344344        {
    345                 if ( node->SValue() == TIXML_STRING (_value))
     345                if ( node->SValue() == _value )
    346346                        return node;
    347347        }
     
    354354        for ( node = lastChild; node; node = node->prev )
    355355        {
    356                 if ( node->SValue() == TIXML_STRING (_value))
     356                if ( node->SValue() == _value )
    357357                        return node;
    358358        }
     
    360360}
    361361
    362 const TiXmlNode* TiXmlNode::IterateChildren( TiXmlNode* previous ) const
     362const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const
    363363{
    364364        if ( !previous )
     
    386386}
    387387
    388 const TiXmlNode* TiXmlNode::IterateChildren( const char * val, TiXmlNode* previous ) const
     388const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const
    389389{
    390390        if ( !previous )
     
    417417        for ( node = next; node; node = node->next )
    418418        {
    419                 if ( node->SValue() == TIXML_STRING (_value))
     419                if ( node->SValue() == _value )
    420420                        return node;
    421421        }
     
    428428        for ( node = next; node; node = node->next )
    429429        {
    430                 if ( node->SValue() == TIXML_STRING (_value))
     430                if ( node->SValue() == _value )
    431431                        return node;
    432432        }
     
    439439        for ( node = prev; node; node = node->prev )
    440440        {
    441                 if ( node->SValue() == TIXML_STRING (_value))
     441                if ( node->SValue() == _value )
    442442                        return node;
    443443        }
     
    450450        for ( node = prev; node; node = node->prev )
    451451        {
    452                 if ( node->SValue() == TIXML_STRING (_value))
     452                if ( node->SValue() == _value )
    453453                        return node;
    454454        }
     
    723723void TiXmlElement::SetDoubleAttribute( const char * name, double val )
    724724{       
    725         char buf[128];
     725        char buf[256];
    726726        sprintf( buf, "%f", val );
    727727        SetAttribute( name, buf );
     
    11411141void TiXmlAttribute::SetDoubleValue( double _value )
    11421142{
    1143         char buf [64];
     1143        char buf [256];
    11441144        sprintf (buf, "%lf", _value);
    11451145        SetValue (buf);
     
    14131413}
    14141414
    1415 const TiXmlAttribute*   TiXmlAttributeSet::Find( const char * name ) const
     1415const TiXmlAttribute* TiXmlAttributeSet::Find( const char * name ) const
    14161416{
    14171417        const TiXmlAttribute* node;
  • orxonox/trunk/src/lib/tinyxml/tinyxml.h

    r4261 r4491  
    7373const int TIXML_MAJOR_VERSION = 2;
    7474const int TIXML_MINOR_VERSION = 3;
    75 const int TIXML_PATCH_VERSION = 3;
     75const int TIXML_PATCH_VERSION = 4;
    7676
    7777/*      Internal structure for tracking location of items
     
    483483                first. IterateChildren will return null when done.
    484484        */
    485         const TiXmlNode* IterateChildren( TiXmlNode* previous ) const;
     485        const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
    486486        TiXmlNode* IterateChildren( TiXmlNode* previous );
    487487
    488488        /// This flavor of IterateChildren searches for children with a particular 'value'
    489         const TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous ) const;
     489        const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
    490490        TiXmlNode* IterateChildren( const char * value, TiXmlNode* previous );
    491491
    492492    #ifdef TIXML_USE_STL
    493         const TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) const        {       return IterateChildren (_value.c_str (), previous);     }       ///< STL std::string form.
     493        const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const  {       return IterateChildren (_value.c_str (), previous);     }       ///< STL std::string form.
    494494        TiXmlNode* IterateChildren( const std::string& _value, TiXmlNode* previous ) {  return IterateChildren (_value.c_str (), previous);     }       ///< STL std::string form.
    495495        #endif
     
    14181418};
    14191419
    1420 
     1420#ifdef _MSC_VER
     1421#pragma warning( default : 4530 )
     1422#pragma warning( default : 4786 )
    14211423#endif
    14221424
     1425#endif
     1426
  • orxonox/trunk/src/lib/tinyxml/tinyxmlparser.cc

    r4261 r4491  
    2525#include "tinyxml.h"
    2626#include <ctype.h>
     27#include <stddef.h>
    2728
    2829//#define DEBUG_PARSER
     
    5051//                              ef bf bf
    5152
    52 const char TIXML_UTF_LEAD_0 = (const char)0xef;
    53 const char TIXML_UTF_LEAD_1 = (const char)0xbb;
    54 const char TIXML_UTF_LEAD_2 = (const char)0xbf;
     53const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
     54const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
     55const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
    5556
    5657const int TiXmlBase::utf8ByteTable[256] =
     
    117118
    118119
    119 /*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding )
     120/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ )
    120121{
    121122        // This will only work for low-ascii, everything else is assumed to be a valid
     
    138139
    139140
    140 /*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding )
     141/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ )
    141142{
    142143        // This will only work for low-ascii, everything else is assumed to be a valid
     
    202203        while ( p < now )
    203204        {
     205                // Treat p as unsigned, so we have a happy compiler.
     206                const unsigned char* pU = (const unsigned char*)p;
     207
    204208                // Code contributed by Fletcher Dunn: (modified by lee)
    205                 switch (*p) {
     209                switch (*pU) {
    206210                        case 0:
    207211                                // We *should* never get here, but in case we do, don't
     
    253257                                                // In these cases, don't advance the column. These are
    254258                                                // 0-width spaces.
    255                                                 if ( *(p+1)==TIXML_UTF_LEAD_1 && *(p+2)==TIXML_UTF_LEAD_2 )
     259                                                if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 )
    256260                                                        p += 3;
    257                                                 else if ( *(p+1)==(char)(0xbf) && *(p+2)==(char)(0xbe) )
     261                                                else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU )
    258262                                                        p += 3;
    259                                                 else if ( *(p+1)==(char)(0xbf) && *(p+2)==(char)(0xbf) )
     263                                                else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
    260264                                                        p += 3;
    261265                                                else
     
    309313                while ( *p )
    310314                {
     315                        const unsigned char* pU = (const unsigned char*)p;
     316                       
    311317                        // Skip the stupid Microsoft UTF-8 Byte order marks
    312                         if (    *(p+0)==TIXML_UTF_LEAD_0
    313                                  && *(p+1)==TIXML_UTF_LEAD_1
    314                                  && *(p+2)==TIXML_UTF_LEAD_2 )
     318                        if (    *(pU+0)==TIXML_UTF_LEAD_0
     319                                 && *(pU+1)==TIXML_UTF_LEAD_1
     320                                 && *(pU+2)==TIXML_UTF_LEAD_2 )
    315321                        {
    316322                                p += 3;
    317323                                continue;
    318324                        }
    319                         else if(*(p+0)==TIXML_UTF_LEAD_0
    320                                  && *(p+1)==(const char) 0xbf
    321                                  && *(p+2)==(const char) 0xbe )
     325                        else if(*(pU+0)==TIXML_UTF_LEAD_0
     326                                 && *(pU+1)==0xbfU
     327                                 && *(pU+2)==0xbeU )
    322328                        {
    323329                                p += 3;
    324330                                continue;
    325331                        }
    326                         else if(*(p+0)==TIXML_UTF_LEAD_0
    327                                  && *(p+1)==(const char) 0xbf
    328                                  && *(p+2)==(const char) 0xbf )
     332                        else if(*(pU+0)==TIXML_UTF_LEAD_0
     333                                 && *(pU+1)==0xbfU
     334                                 && *(pU+2)==0xbfU )
    329335                        {
    330336                                p += 3;
     
    421427        {
    422428                unsigned long ucs = 0;
    423                 //*ME:  warning C4244: convert '__w64 int' to 'unsigned'
    424                 //*ME:  Use size_t instead of unsigned (pointer-arithmetic)
    425                 size_t delta = 0;
     429                ptrdiff_t delta = 0;
    426430                unsigned mult = 1;
    427431
     
    708712        {
    709713                // Check for the Microsoft UTF-8 lead bytes.
    710                 if (    *(p+0) && *(p+0) == TIXML_UTF_LEAD_0
    711                          && *(p+1) && *(p+1) == TIXML_UTF_LEAD_1
    712                          && *(p+2) && *(p+2) == TIXML_UTF_LEAD_2 )
     714                const unsigned char* pU = (const unsigned char*)p;
     715                if (    *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0
     716                         && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1
     717                         && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 )
    713718                {
    714719                        encoding = TIXML_ENCODING_UTF8;
Note: See TracChangeset for help on using the changeset viewer.