|
From: <edu...@us...> - 2003-11-06 19:39:29
|
Update of /cvsroot/aedgui/aedGUI/src/tinyxml In directory sc8-pr-cvs1:/tmp/cvs-serv11490/src/tinyxml Modified Files: tinystr.cpp tinystr.h tinyxml.cpp tinyxml.h tinyxmlerror.cpp tinyxmlparser.cpp Log Message: Wow... indent sure makes a mess :) Index: tinystr.cpp =================================================================== RCS file: /cvsroot/aedgui/aedGUI/src/tinyxml/tinystr.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tinystr.cpp 20 Sep 2003 12:49:06 -0000 1.1 --- tinystr.cpp 6 Nov 2003 18:46:40 -0000 1.2 *************** *** 1,2 **** --- 1,3 ---- + /* www.sourceforge.net/projects/tinyxml *************** *** 35,44 **** // TiXmlString constructor, based on a C string ! TiXmlString::TiXmlString (const char* instring) { unsigned newlen; ! char * newstring; ! if (!instring) { allocated = 0; --- 36,45 ---- // TiXmlString constructor, based on a C string ! TiXmlString::TiXmlString(const char *instring) { unsigned newlen; ! char *newstring; ! if(!instring) { allocated = 0; *************** *** 47,53 **** return; } ! newlen = strlen (instring) + 1; ! newstring = new char [newlen]; ! memcpy (newstring, instring, newlen); // strcpy (newstring, instring); allocated = newlen; --- 48,55 ---- return; } ! newlen = strlen(instring) + 1; ! newstring = new char[newlen]; ! ! memcpy(newstring, instring, newlen); // strcpy (newstring, instring); allocated = newlen; *************** *** 57,70 **** // TiXmlString copy constructor ! TiXmlString::TiXmlString (const TiXmlString& copy) { unsigned newlen; ! char * newstring; ! // Prevent copy to self! ! if ( © == this ) ! return; ! if (! copy . allocated) { allocated = 0; --- 59,72 ---- // TiXmlString copy constructor ! TiXmlString::TiXmlString(const TiXmlString & copy) { unsigned newlen; ! char *newstring; ! // Prevent copy to self! ! if(© == this) ! return; ! if(!copy.allocated) { allocated = 0; *************** *** 73,80 **** return; } ! newlen = copy . length () + 1; ! newstring = new char [newlen]; // strcpy (newstring, copy . cstring); ! memcpy (newstring, copy . cstring, newlen); allocated = newlen; cstring = newstring; --- 75,83 ---- return; } ! newlen = copy.length() + 1; ! newstring = new char[newlen]; ! // strcpy (newstring, copy . cstring); ! memcpy(newstring, copy.cstring, newlen); allocated = newlen; cstring = newstring; *************** *** 83,101 **** // TiXmlString = operator. Safe when assign own content ! void TiXmlString ::operator = (const char * content) { unsigned newlen; ! char * newstring; ! if (! content) { ! empty_it (); return; } ! newlen = strlen (content) + 1; ! newstring = new char [newlen]; // strcpy (newstring, content); ! memcpy (newstring, content, newlen); ! empty_it (); allocated = newlen; cstring = newstring; --- 86,106 ---- // TiXmlString = operator. Safe when assign own content ! void ! TiXmlString::operator =(const char *content) { unsigned newlen; ! char *newstring; ! if(!content) { ! empty_it(); return; } ! newlen = strlen(content) + 1; ! newstring = new char[newlen]; ! // strcpy (newstring, content); ! memcpy(newstring, content, newlen); ! empty_it(); allocated = newlen; cstring = newstring; *************** *** 104,122 **** // = operator. Safe when assign own content ! void TiXmlString ::operator = (const TiXmlString & copy) { unsigned newlen; ! char * newstring; ! if (! copy . length ()) { ! empty_it (); return; } ! newlen = copy . length () + 1; ! newstring = new char [newlen]; // strcpy (newstring, copy . c_str ()); ! memcpy (newstring, copy . c_str (), newlen); ! empty_it (); allocated = newlen; cstring = newstring; --- 109,129 ---- // = operator. Safe when assign own content ! void ! TiXmlString::operator =(const TiXmlString & copy) { unsigned newlen; ! char *newstring; ! if(!copy.length()) { ! empty_it(); return; } ! newlen = copy.length() + 1; ! newstring = new char[newlen]; ! // strcpy (newstring, copy . c_str ()); ! memcpy(newstring, copy.c_str(), newlen); ! empty_it(); allocated = newlen; cstring = newstring; *************** *** 136,175 **** // append a const char * to an existing TiXmlString ! void TiXmlString::append( const char* str, int len ) { ! char * new_string; unsigned new_alloc, new_size, size_suffix; ! size_suffix = strlen (str); ! if (len < (int) size_suffix) size_suffix = len; ! if (! size_suffix) return; ! new_size = length () + size_suffix + 1; // check if we need to expand ! if (new_size > allocated) { // compute new size ! new_alloc = assign_new_size (new_size); // allocate new buffer ! new_string = new char [new_alloc]; ! new_string [0] = 0; // copy the previous allocated buffer into this one ! if (allocated && cstring) // strcpy (new_string, cstring); ! memcpy (new_string, cstring, length ()); // append the suffix. It does exist, otherwize we wouldn't be expanding // strncat (new_string, str, len); ! memcpy (new_string + length (), ! str, ! size_suffix); // return previsously allocated buffer if any ! if (allocated && cstring) ! delete [] cstring; // update member variables --- 143,182 ---- // append a const char * to an existing TiXmlString ! void ! TiXmlString::append(const char *str, int len) { ! char *new_string; unsigned new_alloc, new_size, size_suffix; ! size_suffix = strlen(str); ! if(len < (int) size_suffix) size_suffix = len; ! if(!size_suffix) return; ! new_size = length() + size_suffix + 1; // check if we need to expand ! if(new_size > allocated) { // compute new size ! new_alloc = assign_new_size(new_size); // allocate new buffer ! new_string = new char[new_alloc]; ! ! new_string[0] = 0; // copy the previous allocated buffer into this one ! if(allocated && cstring) // strcpy (new_string, cstring); ! memcpy(new_string, cstring, length()); // append the suffix. It does exist, otherwize we wouldn't be expanding // strncat (new_string, str, len); ! memcpy(new_string + length(), str, size_suffix); // return previsously allocated buffer if any ! if(allocated && cstring) ! delete[]cstring; // update member variables *************** *** 181,224 **** // we know we can safely append the new string // strncat (cstring, str, len); ! memcpy (cstring + length (), ! str, ! size_suffix); } current_length = new_size - 1; ! cstring [current_length] = 0; } // append a const char * to an existing TiXmlString ! void TiXmlString::append( const char * suffix ) { ! char * new_string; unsigned new_alloc, new_size; ! new_size = length () + strlen (suffix) + 1; // check if we need to expand ! if (new_size > allocated) { // compute new size ! new_alloc = assign_new_size (new_size); // allocate new buffer ! new_string = new char [new_alloc]; ! new_string [0] = 0; // copy the previous allocated buffer into this one ! if (allocated && cstring) ! memcpy (new_string, cstring, 1 + length ()); ! // strcpy (new_string, cstring); // append the suffix. It does exist, otherwize we wouldn't be expanding // strcat (new_string, suffix); ! memcpy (new_string + length (), ! suffix, ! strlen (suffix) + 1); // return previsously allocated buffer if any ! if (allocated && cstring) ! delete [] cstring; // update member variables --- 188,229 ---- // we know we can safely append the new string // strncat (cstring, str, len); ! memcpy(cstring + length(), str, size_suffix); } current_length = new_size - 1; ! cstring[current_length] = 0; } // append a const char * to an existing TiXmlString ! void ! TiXmlString::append(const char *suffix) { ! char *new_string; unsigned new_alloc, new_size; ! new_size = length() + strlen(suffix) + 1; // check if we need to expand ! if(new_size > allocated) { // compute new size ! new_alloc = assign_new_size(new_size); // allocate new buffer ! new_string = new char[new_alloc]; ! ! new_string[0] = 0; // copy the previous allocated buffer into this one ! if(allocated && cstring) ! memcpy(new_string, cstring, 1 + length()); ! // strcpy (new_string, cstring); // append the suffix. It does exist, otherwize we wouldn't be expanding // strcat (new_string, suffix); ! memcpy(new_string + length(), suffix, strlen(suffix) + 1); // return previsously allocated buffer if any ! if(allocated && cstring) ! delete[]cstring; // update member variables *************** *** 230,236 **** // we know we can safely append the new string // strcat (cstring, suffix); ! memcpy (cstring + length (), ! suffix, ! strlen (suffix) + 1); } current_length = new_size - 1; --- 235,239 ---- // we know we can safely append the new string // strcat (cstring, suffix); ! memcpy(cstring + length(), suffix, strlen(suffix) + 1); } current_length = new_size - 1; *************** *** 243,249 **** //} ! unsigned TiXmlString::length () const { ! if (allocated) // return strlen (cstring); return current_length; --- 246,253 ---- //} ! unsigned ! TiXmlString::length() const const { ! if(allocated) // return strlen (cstring); return current_length; *************** *** 252,263 **** ! unsigned TiXmlString::find (char tofind, unsigned offset) const { ! char * lookup; ! if (offset >= length ()) return (unsigned) notfound; ! for (lookup = cstring + offset; * lookup; lookup++) ! if (* lookup == tofind) return lookup - cstring; return (unsigned) notfound; --- 256,268 ---- ! unsigned ! TiXmlString::find(char tofind, unsigned offset) const const { ! char *lookup; ! if(offset >= length()) return (unsigned) notfound; ! for(lookup = cstring + offset; *lookup; lookup++) ! if(*lookup == tofind) return lookup - cstring; return (unsigned) notfound; *************** *** 265,303 **** ! bool TiXmlString::operator == (const TiXmlString & compare) const { ! if ( allocated && compare.allocated ) ! { ! assert( cstring ); ! assert( compare.cstring ); ! return ( strcmp( cstring, compare.cstring ) == 0 ); ! } ! return false; } ! bool TiXmlString::operator < (const TiXmlString & compare) const { ! if ( allocated && compare.allocated ) ! { ! assert( cstring ); ! assert( compare.cstring ); ! return ( strcmp( cstring, compare.cstring ) > 0 ); ! } ! return false; } ! bool TiXmlString::operator > (const TiXmlString & compare) const { ! if ( allocated && compare.allocated ) ! { ! assert( cstring ); ! assert( compare.cstring ); ! return ( strcmp( cstring, compare.cstring ) < 0 ); ! } ! return false; } ! #endif // TIXML_USE_STL --- 270,311 ---- ! bool ! TiXmlString::operator ==(const TiXmlString & compare) const const { ! if(allocated && compare.allocated) ! { ! assert(cstring); ! assert(compare.cstring); ! return (strcmp(cstring, compare.cstring) == 0); ! } ! return false; } ! bool ! TiXmlString::operator <(const TiXmlString & compare) const const { ! if(allocated && compare.allocated) ! { ! assert(cstring); ! assert(compare.cstring); ! return (strcmp(cstring, compare.cstring) > 0); ! } ! return false; } ! bool ! TiXmlString::operator >(const TiXmlString & compare) const const { ! if(allocated && compare.allocated) ! { ! assert(cstring); ! assert(compare.cstring); ! return (strcmp(cstring, compare.cstring) < 0); ! } ! return false; } ! #endif // TIXML_USE_STL Index: tinystr.h =================================================================== RCS file: /cvsroot/aedgui/aedGUI/src/tinyxml/tinystr.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tinystr.h 20 Sep 2003 12:49:06 -0000 1.1 --- tinystr.h 6 Nov 2003 18:46:40 -0000 1.2 *************** *** 1,2 **** --- 1,3 ---- + /* www.sourceforge.net/projects/tinyxml *************** *** 44,53 **** class TiXmlString { ! public : ! // TiXmlString constructor, based on a string ! TiXmlString (const char * instring); // TiXmlString empty constructor ! TiXmlString () { allocated = 0; --- 45,54 ---- class TiXmlString { ! public: ! // TiXmlString constructor, based on a string ! TiXmlString(const char *instring); // TiXmlString empty constructor ! TiXmlString() { allocated = 0; *************** *** 57,72 **** // TiXmlString copy constructor ! TiXmlString (const TiXmlString& copy); // TiXmlString destructor ! ~ TiXmlString () { ! empty_it (); } // Convert a TiXmlString into a classical char * ! const char * c_str () const { ! if (allocated) return cstring; return ""; --- 58,73 ---- // TiXmlString copy constructor ! TiXmlString(const TiXmlString & copy); // TiXmlString destructor ! ~TiXmlString() { ! empty_it(); } // Convert a TiXmlString into a classical char * ! const char *c_str() const { ! if(allocated) return cstring; return ""; *************** *** 74,147 **** // Return the length of a TiXmlString ! unsigned length () const; // TiXmlString = operator ! void operator = (const char * content); // = operator ! void operator = (const TiXmlString & copy); // += operator. Maps to append ! TiXmlString& operator += (const char * suffix) { ! append (suffix); ! return *this; } // += operator. Maps to append ! TiXmlString& operator += (char single) { ! append (single); ! return *this; } // += operator. Maps to append ! TiXmlString& operator += (TiXmlString & suffix) { ! append (suffix); ! return *this; } ! bool operator == (const TiXmlString & compare) const; ! bool operator < (const TiXmlString & compare) const; ! bool operator > (const TiXmlString & compare) const; // Checks if a TiXmlString is empty ! bool empty () const { ! return length () ? false : true; } // Checks if a TiXmlString contains only whitespace (same rules as isspace) ! // Not actually used in tinyxml. Conflicts with a C macro, "isblank", ! // which is a problem. Commenting out. -lee // bool isblank () const; // single char extraction ! const char& at (unsigned index) const { ! assert( index < length ()); ! return cstring [index]; } // find a char in a string. Return TiXmlString::notfound if not found ! unsigned find (char lookup) const { ! return find (lookup, 0); } // find a char in a string from an offset. Return TiXmlString::notfound if not found ! unsigned find (char tofind, unsigned offset) const; ! /* Function to reserve a big amount of data when we know we'll need it. Be aware that this ! function clears the content of the TiXmlString if any exists. ! */ ! void reserve (unsigned size) { ! empty_it (); ! if (size) { allocated = size; ! cstring = new char [size]; ! cstring [0] = 0; current_length = 0; } --- 75,149 ---- // Return the length of a TiXmlString ! unsigned length() const; // TiXmlString = operator ! void operator =(const char *content); // = operator ! void operator =(const TiXmlString & copy); // += operator. Maps to append ! TiXmlString & operator +=(const char *suffix) { ! append(suffix); ! return *this; } // += operator. Maps to append ! TiXmlString & operator +=(char single) { ! append(single); ! return *this; } // += operator. Maps to append ! TiXmlString & operator +=(TiXmlString & suffix) { ! append(suffix); ! return *this; } ! bool operator ==(const TiXmlString & compare) const; ! bool operator <(const TiXmlString & compare) const; ! bool operator >(const TiXmlString & compare) const; // Checks if a TiXmlString is empty ! bool empty() const { ! return length() ? false : true; } // Checks if a TiXmlString contains only whitespace (same rules as isspace) ! // Not actually used in tinyxml. Conflicts with a C macro, "isblank", ! // which is a problem. Commenting out. -lee // bool isblank () const; // single char extraction ! const char &at(unsigned index) const { ! assert(index < length()); ! return cstring[index]; } // find a char in a string. Return TiXmlString::notfound if not found ! unsigned find(char lookup) const { ! return find(lookup, 0); } // find a char in a string from an offset. Return TiXmlString::notfound if not found ! unsigned find(char tofind, unsigned offset) const; ! /* Function to reserve a big amount of data when we know we'll need it. Be aware that this ! function clears the content of the TiXmlString if any exists. ! */ ! void reserve(unsigned size) { ! empty_it(); ! if(size) { allocated = size; ! cstring = new char[size]; ! ! cstring[0] = 0; current_length = 0; } *************** *** 149,170 **** // [] operator ! char& operator [] (unsigned index) const { ! assert( index < length ()); ! return cstring [index]; } // Error value for find primitive ! enum { notfound = 0xffffffff, ! npos = notfound }; ! void append (const char *str, int len ); ! protected : // The base string ! char * cstring; // Number of chars allocated unsigned allocated; // Current string size unsigned current_length; --- 151,176 ---- // [] operator ! char &operator [] (unsigned index) const { ! assert(index < length()); ! return cstring[index]; } // Error value for find primitive ! enum ! { notfound = 0xffffffff, ! npos = notfound ! }; ! void append(const char *str, int len); ! protected: // The base string ! char *cstring; ! // Number of chars allocated unsigned allocated; + // Current string size unsigned current_length; *************** *** 172,176 **** // New size computation. It is simplistic right now : it returns twice the amount // we need ! unsigned assign_new_size (unsigned minimum_to_allocate) { return minimum_to_allocate * 2; --- 178,182 ---- // New size computation. It is simplistic right now : it returns twice the amount // we need ! unsigned assign_new_size(unsigned minimum_to_allocate) { return minimum_to_allocate * 2; *************** *** 178,185 **** // Internal function that clears the content of a TiXmlString ! void empty_it () { ! if (cstring) ! delete [] cstring; cstring = NULL; allocated = 0; --- 184,191 ---- // Internal function that clears the content of a TiXmlString ! void empty_it() { ! if(cstring) ! delete[]cstring; cstring = NULL; allocated = 0; *************** *** 187,208 **** } ! void append (const char *suffix ); // append function for another TiXmlString ! void append (const TiXmlString & suffix) { ! append (suffix . c_str ()); } // append for a single char. This could be improved a lot if needed ! void append (char single) { ! char smallstr [2]; ! smallstr [0] = single; ! smallstr [1] = 0; ! append (smallstr); } ! } ; /* --- 193,215 ---- } ! void append(const char *suffix); // append function for another TiXmlString ! void append(const TiXmlString & suffix) { ! append(suffix.c_str()); } // append for a single char. This could be improved a lot if needed ! void append(char single) { ! char smallstr[2]; ! ! smallstr[0] = single; ! smallstr[1] = 0; ! append(smallstr); } ! }; /* *************** *** 210,233 **** Only the operators that we need for TinyXML have been developped. */ ! class TiXmlOutStream : public TiXmlString { ! public : ! TiXmlOutStream () : TiXmlString () {} // TiXmlOutStream << operator. Maps to TiXmlString::append ! TiXmlOutStream & operator << (const char * in) { ! append (in); ! return (* this); } // TiXmlOutStream << operator. Maps to TiXmlString::append ! TiXmlOutStream & operator << (const TiXmlString & in) { ! append (in . c_str ()); ! return (* this); } ! } ; ! #endif // TIXML_STRING_INCLUDED ! #endif // TIXML_USE_STL --- 217,241 ---- Only the operators that we need for TinyXML have been developped. */ ! class TiXmlOutStream:public TiXmlString { ! public:TiXmlOutStream():TiXmlString() ! { ! } // TiXmlOutStream << operator. Maps to TiXmlString::append ! TiXmlOutStream & operator <<(const char *in) { ! append(in); ! return (*this); } // TiXmlOutStream << operator. Maps to TiXmlString::append ! TiXmlOutStream & operator <<(const TiXmlString & in) { ! append(in.c_str()); ! return (*this); } ! }; ! #endif // TIXML_STRING_INCLUDED ! #endif // TIXML_USE_STL Index: tinyxml.cpp =================================================================== RCS file: /cvsroot/aedgui/aedGUI/src/tinyxml/tinyxml.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** tinyxml.cpp 23 Sep 2003 18:12:47 -0000 1.2 --- tinyxml.cpp 6 Nov 2003 18:46:40 -0000 1.3 *************** *** 1,2 **** --- 1,3 ---- + /* www.sourceforge.net/projects/tinyxml *************** *** 26,114 **** #include "tinyxml.h" ! bool TiXmlBase::condenseWhiteSpace = true; [...2157 lines suppressed...] ! #ifdef TIXML_USE_STL ! TIXML_ISTREAM & operator >>(TIXML_ISTREAM & in, TiXmlNode & base) { ! TIXML_STRING tag; ! tag.reserve(8 * 1000); ! base.StreamIn(&in, &tag); ! ! base.Parse(tag.c_str()); ! return in; } #endif ! TIXML_OSTREAM & operator<<(TIXML_OSTREAM & out, const TiXmlNode & base) { ! base.StreamOut(&out); ! return out; } Index: tinyxml.h =================================================================== RCS file: /cvsroot/aedgui/aedGUI/src/tinyxml/tinyxml.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** tinyxml.h 23 Sep 2003 18:12:47 -0000 1.4 --- tinyxml.h 6 Nov 2003 18:46:40 -0000 1.5 *************** *** 1,2 **** --- 1,3 ---- + /* www.sourceforge.net/projects/tinyxml *************** *** 56,70 **** #ifdef TIXML_USE_STL ! #include <string> ! #ifdef TIXML_NEED_STREAM [...1876 lines suppressed...] ! errorDesc = errorString[errorId]; ! } ! protected: ! virtual void StreamOut(TIXML_OSTREAM * out) const; + // [internal use] + virtual TiXmlNode *Clone() const; + + #ifdef TIXML_USE_STL + virtual void StreamIn(TIXML_ISTREAM * in, TIXML_STRING * tag); #endif + private: + bool error; + int errorId; + TIXML_STRING errorDesc; + }; + + #endif Index: tinyxmlerror.cpp =================================================================== RCS file: /cvsroot/aedgui/aedGUI/src/tinyxml/tinyxmlerror.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tinyxmlerror.cpp 20 Sep 2003 12:49:06 -0000 1.1 --- tinyxmlerror.cpp 6 Nov 2003 18:46:40 -0000 1.2 *************** *** 1,2 **** --- 1,3 ---- + /* www.sourceforge.net/projects/tinyxml *************** *** 32,50 **** // ! const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] = ! { ! "No error", ! "Error", ! "Failed to open file", ! "Memory allocation failed.", ! "Error parsing Element.", ! "Failed to read Element name", ! "Error reading Element value.", ! "Error reading Attributes.", ! "Error: empty tag.", ! "Error reading end tag.", ! "Error parsing Unknown.", ! "Error parsing Comment.", ! "Error parsing Declaration.", ! "Error document empty." }; --- 33,51 ---- // ! const char * ! TiXmlBase::errorString[TIXML_ERROR_STRING_COUNT] = { ! "No error", ! "Error", ! "Failed to open file", ! "Memory allocation failed.", ! "Error parsing Element.", ! "Failed to read Element name", ! "Error reading Element value.", ! "Error reading Attributes.", ! "Error: empty tag.", ! "Error reading end tag.", ! "Error parsing Unknown.", ! "Error parsing Comment.", ! "Error parsing Declaration.", ! "Error document empty." }; Index: tinyxmlparser.cpp =================================================================== RCS file: /cvsroot/aedgui/aedGUI/src/tinyxml/tinyxmlparser.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** tinyxmlparser.cpp 20 Sep 2003 12:49:06 -0000 1.1 --- tinyxmlparser.cpp 6 Nov 2003 18:46:40 -0000 1.2 *************** *** 1,2 **** --- 1,3 ---- + /* www.sourceforge.net/projects/tinyxml *************** *** 30,940 **** // Note tha "PutString" hardcodes the same list. This // is less flexible than it appears. Changing the entries ! // or order will break putstring. ! TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] = [...1863 lines suppressed...] ! standalone = attrib.Value(); ! } ! else ! { ! // Read over whatever it is. ! while(p && *p && *p != '>' && !isspace(*p)) ! ++p; ! } ! } ! return 0; } ! bool ! TiXmlText::Blank() const const { ! for(unsigned i = 0; i < value.length(); i++) ! if(!isspace(value[i])) ! return false; ! return true; } |