Commit 6effc948 authored by Ulrich Kemloh's avatar Ulrich Kemloh

Enable STL and restore original tinyxml licence

parent 53fb69f7
...@@ -36,71 +36,76 @@ TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; ...@@ -36,71 +36,76 @@ TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
void TiXmlString::reserve (size_type cap) void TiXmlString::reserve (size_type cap)
{ {
if (cap > capacity()) { if (cap > capacity())
TiXmlString tmp; {
tmp.init(length(), cap); TiXmlString tmp;
memcpy(tmp.start(), data(), length()); tmp.init(length(), cap);
swap(tmp); memcpy(tmp.start(), data(), length());
} swap(tmp);
}
} }
TiXmlString& TiXmlString::assign(const char* str, size_type len) TiXmlString& TiXmlString::assign(const char* str, size_type len)
{ {
size_type cap = capacity(); size_type cap = capacity();
if (len > cap || cap > 3*(len + 8)) { if (len > cap || cap > 3*(len + 8))
TiXmlString tmp; {
tmp.init(len); TiXmlString tmp;
memcpy(tmp.start(), str, len); tmp.init(len);
swap(tmp); memcpy(tmp.start(), str, len);
} else { swap(tmp);
memmove(start(), str, len); }
set_size(len); else
} {
return *this; memmove(start(), str, len);
set_size(len);
}
return *this;
} }
TiXmlString& TiXmlString::append(const char* str, size_type len) TiXmlString& TiXmlString::append(const char* str, size_type len)
{ {
size_type newsize = length() + len; size_type newsize = length() + len;
if (newsize > capacity()) { if (newsize > capacity())
reserve (newsize + capacity()); {
} reserve (newsize + capacity());
memmove(finish(), str, len); }
set_size(newsize); memmove(finish(), str, len);
return *this; set_size(newsize);
return *this;
} }
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
{ {
TiXmlString tmp; TiXmlString tmp;
tmp.reserve(a.length() + b.length()); tmp.reserve(a.length() + b.length());
tmp += a; tmp += a;
tmp += b; tmp += b;
return tmp; return tmp;
} }
TiXmlString operator + (const TiXmlString & a, const char* b) TiXmlString operator + (const TiXmlString & a, const char* b)
{ {
TiXmlString tmp; TiXmlString tmp;
TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) ); TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
tmp.reserve(a.length() + b_len); tmp.reserve(a.length() + b_len);
tmp += a; tmp += a;
tmp.append(b, b_len); tmp.append(b, b_len);
return tmp; return tmp;
} }
TiXmlString operator + (const char* a, const TiXmlString & b) TiXmlString operator + (const char* a, const TiXmlString & b)
{ {
TiXmlString tmp; TiXmlString tmp;
TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) ); TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
tmp.reserve(a_len + b.length()); tmp.reserve(a_len + b.length());
tmp.append(a, a_len); tmp.append(a, a_len);
tmp += b; tmp += b;
return tmp; return tmp;
} }
#endif // TIXML_USE_STL #endif // TIXML_USE_STL
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
www.sourceforge.net/projects/tinyxml www.sourceforge.net/projects/tinyxml
Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com) Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
This software is provided 'as-is', without any express or implied This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any warranty. In no event will the authors be held liable for any
damages arising from the use of this software. damages arising from the use of this software.
Permission is granted to anyone to use this software for any Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions: redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must 1. The origin of this software must not be misrepresented; you must
...@@ -31,21 +31,22 @@ distribution. ...@@ -31,21 +31,22 @@ distribution.
// It also cleans up the code a bit. // It also cleans up the code a bit.
// //
const char* TiXmlBase::errorString[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] = { const char* TiXmlBase::errorString[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] =
"No error", {
"Error", "No error",
"Failed to open file", "Error",
"Error parsing Element.", "Failed to open file",
"Failed to read Element name", "Error parsing Element.",
"Error reading Element value.", "Failed to read Element name",
"Error reading Attributes.", "Error reading Element value.",
"Error: empty tag.", "Error reading Attributes.",
"Error reading end tag.", "Error: empty tag.",
"Error parsing Unknown.", "Error reading end tag.",
"Error parsing Comment.", "Error parsing Unknown.",
"Error parsing Declaration.", "Error parsing Comment.",
"Error document empty.", "Error parsing Declaration.",
"Error null (0) or unexpected EOF found in input stream.", "Error document empty.",
"Error parsing CDATA.", "Error null (0) or unexpected EOF found in input stream.",
"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.", "Error parsing CDATA.",
"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
}; };
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment