TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) { TiXmlString tmp; tmp.reserve(a.length() + b.length()); tmp += a; tmp += b; return tmp; }
// TiXmlString copy constructor TiXmlString::TiXmlString (const TiXmlString& copy) { unsigned newlen; WCHAR * newstring; // Prevent copy to self! if ( © == this ) return; if (! copy.allocated) { allocated = 0; cstring = NULL; current_length = 0; return; } newlen = copy.length () + 1; newstring = new WCHAR [newlen]; // strcpy (newstring, copy.cstring); CopyMemory(newstring, copy.cstring, sizeof(WCHAR)*newlen); allocated = newlen; cstring = newstring; current_length = newlen - 1; }
TiXmlString operator + (const char* a, const TiXmlString & b) { TiXmlString tmp; TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( std::strlen(a) ); tmp.reserve(a_len + b.length()); tmp.append(a, a_len); tmp += b; return tmp; }
TiXmlString operator + (const TiXmlString & a, const char* b) { TiXmlString tmp; TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( std::strlen(b) ); tmp.reserve(a.length() + b_len); tmp += a; tmp.append(b, b_len); return tmp; }
bool TiXmlString::operator == (const TiXmlString & compare) const { if ( allocated && compare.allocated ) { assert( cstring ); assert( compare.cstring ); return ( strcmp( cstring, compare.cstring ) == 0 ); } else if ( length() == 0 && compare.length() == 0 ) { return true; } return false; }
// TiXmlString copy constructor TiXmlString ( const TiXmlString & copy) : rep_(0) { init(copy.length()); memcpy(start(), copy.data(), length()); }
inline bool operator == (const TiXmlString & a, const TiXmlString & b) { return ( a.length() == b.length() ) // optimization on some platforms && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare }