2 www.sourceforge.net/projects/tinyxml
3 Original file by Yves Berquin.
5 This software is provided 'as-is', without any express or implied
6 warranty. In no event will the authors be held liable for any
7 damages arising from the use of this software.
9 Permission is granted to anyone to use this software for any
10 purpose, including commercial applications, and to alter it and
11 redistribute it freely, subject to the following restrictions:
13 1. The origin of this software must not be misrepresented; you must
14 not claim that you wrote the original software. If you use this
15 software in a product, an acknowledgment in the product documentation
16 would be appreciated but is not required.
18 2. Altered source versions must be plainly marked as such, and
19 must not be misrepresented as being the original software.
21 3. This notice may not be removed or altered from any source
26 * THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005.
34 // Error value for find primitive
35 const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);
39 TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
42 void TiXmlString::reserve (size_type cap)
47 tmp.init(length(), cap);
48 memcpy(tmp.start(), data(), length());
54 TiXmlString& TiXmlString::assign(const char* str, size_type len)
56 size_type cap = capacity();
57 if (len > cap || cap > 3*(len + 8))
61 memcpy(tmp.start(), str, len);
66 memmove(start(), str, len);
73 TiXmlString& TiXmlString::append(const char* str, size_type len)
75 size_type newsize = length() + len;
76 if (newsize > capacity())
78 reserve (newsize + capacity());
80 memmove(finish(), str, len);
86 TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
89 tmp.reserve(a.length() + b.length());
95 TiXmlString operator + (const TiXmlString & a, const char* b)
98 TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
99 tmp.reserve(a.length() + b_len);
101 tmp.append(b, b_len);
105 TiXmlString operator + (const char* a, const TiXmlString & b)
108 TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
109 tmp.reserve(a_len + b.length());
110 tmp.append(a, a_len);
116 #endif // TIXML_USE_STL