Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4491 in orxonox.OLD for orxonox/trunk/src/lib/tinyxml/tinystr.cc


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)

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.