added tinyxml source
This commit is contained in:
parent
c091289ffa
commit
5480b896b4
7 changed files with 5744 additions and 0 deletions
8
tinyxml/.sconsign
Normal file
8
tinyxml/.sconsign
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
}q(Utinyxmlparser.osq(cSCons.Node.FS
|
||||||
|
BuildInfo
|
||||||
|
qoq}q(UbsigqU 3b15f27196beb6fc8d342079cbb4d105qU bimplicitq]q (U/usr/include/ctype.hq
|
||||||
|
Utinyxml/tinyxml.hqU/usr/include/bits/types.hqU/usr/include/endian.hq
U/usr/include/features.hqU/usr/include/xlocale.hqU/usr/include/assert.hqU/usr/include/stdio.hqU/usr/include/stdlib.hqU/usr/include/string.hqUtinyxml/tinystr.hqU/usr/include/bits/typesizes.hqU/usr/include/bits/wordsize.hqU/usr/include/bits/endian.hqU/usr/include/gnu/stubs.hqU/usr/include/sys/cdefs.hqU/usr/include/bits/stdio-ldbl.hqU/usr/include/bits/stdio.hqU/usr/include/bits/stdio2.hqU/usr/include/bits/stdio_lim.hqU/usr/include/bits/sys_errlist.hqU/usr/include/getopt.hqU/usr/include/libio.hq U/usr/include/alloca.hq!U/usr/include/bits/stdlib-ldbl.hq"U/usr/include/bits/stdlib.hq#U/usr/include/bits/waitflags.hq$U/usr/include/bits/waitstatus.hq%U/usr/include/sys/types.hq&U/usr/include/bits/string.hq'U/usr/include/bits/string2.hq(U/usr/include/bits/string3.hq)U/usr/include/gnu/stubs-32.hq*U/usr/include/gnu/stubs-64.hq+U/usr/include/_G_config.hq,U/usr/include/bits/libio-ldbl.hq-U/usr/include/bits/stdio-lock.hq.U /usr/include/bits/pthreadtypes.hq/U/usr/include/sys/select.hq0U/usr/include/sys/sysmacros.hq1U/usr/include/time.hq2U/usr/include/gconv.hq3U/usr/include/wchar.hq4U/usr/include/bits/libc-lock.hq5U/usr/include/bits/select.hq6U/usr/include/bits/sigset.hq7U/usr/include/bits/time.hq8U/usr/include/bits/wchar-ldbl.hq9U/usr/include/bits/wchar.hq:U/usr/include/bits/wchar2.hq;U/usr/include/wctype.hq<U/usr/include/pthread.hq=U/usr/include/bits/setjmp.hq>U/usr/include/sched.hq?U/usr/include/signal.hq@U/usr/include/bits/sched.hqAU/usr/include/bits/sigaction.hqBU/usr/include/bits/sigcontext.hqCU/usr/include/bits/siginfo.hqDU/usr/include/bits/signum.hqEU/usr/include/bits/sigstack.hqFU/usr/include/bits/sigthread.hqGU/usr/include/sys/ucontext.hqHeUbdependsqI]qJUbdependsigsqK]qLUbactsigqMU 1b5f699029656e4c248928d88a176771qNU
bimplicitsigsqO]qP(U 00837daf31513ddb9efcdbe263e308e5qQU 4aecfb7c99af3fbaa13197f8cc12cc6dqRU c879f7ba4b8895420c23d9906b38ab9aqSU 842fadea2a9f0546765ff04d06e62967qTU 414a080c648c4260bcd8142023fa150eqUU 19fdaa6e1408817d208fc02fd290f894qVU cdf2e4e7d7d8cfa02c8b1e1d6bb736c4qWU 3ef14c4f0793fc0aaba4b9c2f1f6f970qXU 6303c8f8a41b3cd547a428b086d3758bqYU 97f4bcf2a68b10df1ed4f542659a00a0qZU cf367876ee833646804f79b5dd331d83q[U af928b23500851e2da8cd3ec56d56edfq\U 30529eb770bdf401a7dc82c1659f4364q]U 93f54525ca894fe9c4f79236cd9b8bf3q^U 326ea516d2af549d9de3f71532c4e4e4q_U fc5d92924ea883f42d365cc93861c9d5q`U 7c11f8933ac7b548a32a01f73c77f421qaU 9e616d743e5168f8702488621bbd71fcqbU ea6cc4a9f17cdab6d6395bea155409e1qcU bc8b1b1d13e5e69133f85c645f7e2a06qdU e7734f693e8e68fcc97d98e790d024a1qeU d8703f5c9901bb223fc702fedfbd8c26qfU 0a85bb56583eaf5fc0a7c463e8f99db6qgU 2cd6c8d99645ffaa331ba97e071bca67qhU bd02283aea53c6987e065658626029aeqiU 7ec95934743cee49027e91666f902d22qjU 655eb29e7f589e68eb1016141f2ffe43qkU 8354b3a67075f5d1707f2ddc0f640057qlU ac5b3da3ea53cf7141c907159c436822qmU 70dede2383ed520334e91a4ced6cce0eqnU 09f0a8c5e15ffcd80e16d06f96ff2611qoU 7107d468e137449079ccca0c579ff9c0qpU b7a6db7b7113f0fada181c6551ed7628qqU 0e0d4bae163cca7306bbd31d566b1e7eqrU 1f3b5cd1da91bfb14be76d6ae6fa3b73qsU 11692a4c660a6580512982d342df569bqtU 2122e500b4fa13bc1c53a3f7c2b9743aquU b0b16c03afc71a223fe787e1dd60479fqvU 3ac38d7e2f9203f1343788fe7a736c4dqwU 699fc672171b2a03f9e3e6d66d43b46eqxU a701f3f77dc321259da9e5945328f3c5qyU 4f47ba062d4253ea801ef1e341976b8bqzU 956bf16b318fa7b0cb9c74bedde44720q{U 9ea7a1a26a3e1d1bb9e7f4a57ff36d2dq|U bb161dc5a7b233a76c3ac3c389cef8d8q}U 5be4663919ae70a2a63143f4cf3e23c1q~U 39b0c941e291970324de2709f164c3beqU 93ddad90561b2e439cfac383be62bdd0q€U 5410df383b37c676526e62554f9ac274q<34>U 81302455beb60e076adbb9ee5e79d339q‚U 571d50db99ee111540c2efa57c396936qƒU 86b69ed9e41beedefa3ae8025bf4087dq„U 569f5de580970655042e7b79f08ca930q…U 1813916f93a067876c1770d20b68bcfcq†U 141cee46916334fafee988d52eeb74abq‡U 087f4d86feab2e1d99ecb6b5b4c902c5qˆU 7083cc35df3247290d30d008513fef47q‰U 186444b0a87c414e012aa8d0f46e7fd9qŠU d9aea83a7368b5597a7d79f0075a90f4q‹U bc480b97ac477ff40a3ad689a1296f4dqŒU 97fdbb81a16c152c9c79dcbf576edea4q<34>U 273a1126f9bf268a25be640a9d932c00qŽU 73fc6a2a32678895efb9141fc7655e7fq<66>eUbactq<74>UÁg++ -ansi -Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG -DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL -fPIC -c -o tinyxmlparser.os tinyxmlparser.cppq‘Ubsourcesq’]q“Utinyxml/tinyxmlparser.cppq”aUbsourcesigsq•]q–U 4e570ff625b08425eea1f59c40808ae7q—aubUtinyxmlerror.cppq˜(hoq™}qš(U timestampq›Jˆó9EUcsigqœU cf5c6f205d9c15967401977bcef750c6q<36>ubU tinystr.hqž(hoqŸ}q (U timestampq¡J…ó9EUcsigq¢h[ubU
|
||||||
|
tinyxml.osq£(hoq¤}q¥(hU a380edf8aeb71f8efd3613406ff9413aq¦h]q§(h
|
||||||
|
hhh
hhhhhhhhhhhhhhhhhhh h!h"h#h$h%h&h'h(h)h*h+h,h-h.h/h0h1h2h3h4h5h6h7h8h9h:h;h<h=h>h?h@hAhBhChDhEhFhGhHehI]q¨hK]q©hMU 7f2b203beaf8579d35cec7dd6cd59e81qªhO]q«(hQhRhShThUhVhWhXhYhZh[h\h]h^h_h`hahbhchdhehfhghhhihjhkhlhmhnhohphqhrhshthuhvhwhxhyhzh{h|h}h~hh€h<E282AC>h‚hƒh„h…h†h‡hˆh‰hŠh‹hŒh<C592>hŽh<C5BD>eh<65>Uµg++ -ansi -Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG -DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL -fPIC -c -o tinyxml.os tinyxml.cppq¬h’]qUtinyxml/tinyxml.cppq®ah•]q¯U 8fbf88d5122928d52e45f2299582a984q°aubUtinyxmlparser.cppq±(hoq²}q³(h›Jˆó9Ehœh—ubUtinystr.cppq´(hoqµ}q¶(h›Jˆó9EhœU 0a9fdccb93300c5a9227b1910ae526b5q·ubU tinyxml.hq¸(hoq¹}qº(h¡J ÿ9Eh¢hRubUtinyxml.cppq»(hoq¼}q½(h›JKþ9Ehœh°ubUtinyxmlerror.osq¾(hoq¿}qÀ(hU 6f65267f8663238c23e597a974c35693qÁh]qÂ(hhh
|
||||||
|
hhhhhhh
hhhhhhhh h!h"h#h$h%h&h'h(h)hhhhhh,h-h.h/h0h1h2h*h+h3h4h5h6h7h8h9h:h;h<h=h>h?h@hAhBhChDhEhFhGhHehI]qÃhK]qÄhMU 4aa0234202f972ed28dd7dc18a64299eqÅhO]qÆ(hRhWhQhXhYhZh[hUhShThVhahbhchdhehfhghhhihjhkhlhmhnhohph_h`h\h]h^hshthuhvhwhxhyhqhrhzh{h|h}h~hh€h<E282AC>h‚hƒh„h…h†h‡hˆh‰hŠh‹hŒh<C592>hŽh<C5BD>eh<65>U¿g++ -ansi -Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG -DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL -fPIC -c -o tinyxmlerror.os tinyxmlerror.cppqÇh’]qÈUtinyxml/tinyxmlerror.cppqÉah•]qÊh<C38A>aubU
|
||||||
|
tinystr.osqË(hoqÌ}qÍ(hU 6050f86723f4e371b343884fb65bf913qÎh]qÏ(hhhhh'h(h)hhhhh
hhh*h+hhh!h"h#h$h%h&h/h0h1h2h6h7h8ehI]qÐhK]qÑhMU 7f275df97bbe6da48749f5fd3cf12691qÒhO]qÓ(h[hWhZhUhnhohphVh_h`hShThYh]hqhrh\h^hhhihjhkhlhmhvhwhxhyh}h~heh<65>Uµg++ -ansi -Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG -DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL -fPIC -c -o tinystr.os tinystr.cppqÔh’]qÕUtinyxml/tinystr.cppqÖah•]q×h·aubu.
|
116
tinyxml/tinystr.cpp
Normal file
116
tinyxml/tinystr.cpp
Normal file
|
@ -0,0 +1,116 @@
|
||||||
|
/*
|
||||||
|
www.sourceforge.net/projects/tinyxml
|
||||||
|
Original file by Yves Berquin.
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any
|
||||||
|
damages arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any
|
||||||
|
purpose, including commercial applications, and to alter it and
|
||||||
|
redistribute it freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must
|
||||||
|
not claim that you wrote the original software. If you use this
|
||||||
|
software in a product, an acknowledgment in the product documentation
|
||||||
|
would be appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and
|
||||||
|
must not be misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef TIXML_USE_STL
|
||||||
|
|
||||||
|
#include "tinystr.h"
|
||||||
|
|
||||||
|
// Error value for find primitive
|
||||||
|
const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);
|
||||||
|
|
||||||
|
|
||||||
|
// Null rep.
|
||||||
|
TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, '\0' };
|
||||||
|
|
||||||
|
|
||||||
|
void TiXmlString::reserve (size_type cap)
|
||||||
|
{
|
||||||
|
if (cap > capacity())
|
||||||
|
{
|
||||||
|
TiXmlString tmp;
|
||||||
|
tmp.init(length(), cap);
|
||||||
|
memcpy(tmp.start(), data(), length());
|
||||||
|
swap(tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TiXmlString& TiXmlString::assign(const char* str, size_type len)
|
||||||
|
{
|
||||||
|
size_type cap = capacity();
|
||||||
|
if (len > cap || cap > 3*(len + 8))
|
||||||
|
{
|
||||||
|
TiXmlString tmp;
|
||||||
|
tmp.init(len);
|
||||||
|
memcpy(tmp.start(), str, len);
|
||||||
|
swap(tmp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memmove(start(), str, len);
|
||||||
|
set_size(len);
|
||||||
|
}
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TiXmlString& TiXmlString::append(const char* str, size_type len)
|
||||||
|
{
|
||||||
|
size_type newsize = length() + len;
|
||||||
|
if (newsize > capacity())
|
||||||
|
{
|
||||||
|
reserve (newsize + capacity());
|
||||||
|
}
|
||||||
|
memmove(finish(), str, len);
|
||||||
|
set_size(newsize);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
|
||||||
|
{
|
||||||
|
TiXmlString tmp;
|
||||||
|
tmp.reserve(a.length() + b.length());
|
||||||
|
tmp += a;
|
||||||
|
tmp += b;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
TiXmlString operator + (const TiXmlString & a, const char* b)
|
||||||
|
{
|
||||||
|
TiXmlString tmp;
|
||||||
|
TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
|
||||||
|
tmp.reserve(a.length() + b_len);
|
||||||
|
tmp += a;
|
||||||
|
tmp.append(b, b_len);
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
TiXmlString operator + (const char* a, const TiXmlString & b)
|
||||||
|
{
|
||||||
|
TiXmlString tmp;
|
||||||
|
TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
|
||||||
|
tmp.reserve(a_len + b.length());
|
||||||
|
tmp.append(a, a_len);
|
||||||
|
tmp += b;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // TIXML_USE_STL
|
319
tinyxml/tinystr.h
Normal file
319
tinyxml/tinystr.h
Normal file
|
@ -0,0 +1,319 @@
|
||||||
|
/*
|
||||||
|
www.sourceforge.net/projects/tinyxml
|
||||||
|
Original file by Yves Berquin.
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any
|
||||||
|
damages arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any
|
||||||
|
purpose, including commercial applications, and to alter it and
|
||||||
|
redistribute it freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must
|
||||||
|
not claim that you wrote the original software. If you use this
|
||||||
|
software in a product, an acknowledgment in the product documentation
|
||||||
|
would be appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and
|
||||||
|
must not be misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005.
|
||||||
|
*
|
||||||
|
* - completely rewritten. compact, clean, and fast implementation.
|
||||||
|
* - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems)
|
||||||
|
* - fixed reserve() to work as per specification.
|
||||||
|
* - fixed buggy compares operator==(), operator<(), and operator>()
|
||||||
|
* - fixed operator+=() to take a const ref argument, following spec.
|
||||||
|
* - added "copy" constructor with length, and most compare operators.
|
||||||
|
* - added swap(), clear(), size(), capacity(), operator+().
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef TIXML_USE_STL
|
||||||
|
|
||||||
|
#ifndef TIXML_STRING_INCLUDED
|
||||||
|
#define TIXML_STRING_INCLUDED
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
/* The support for explicit isn't that universal, and it isn't really
|
||||||
|
required - it is used to check that the TiXmlString class isn't incorrectly
|
||||||
|
used. Be nice to old compilers and macro it here:
|
||||||
|
*/
|
||||||
|
#if defined(_MSC_VER) && (_MSC_VER >= 1200 )
|
||||||
|
// Microsoft visual studio, version 6 and higher.
|
||||||
|
#define TIXML_EXPLICIT explicit
|
||||||
|
#elif defined(__GNUC__) && (__GNUC__ >= 3 )
|
||||||
|
// GCC version 3 and higher.s
|
||||||
|
#define TIXML_EXPLICIT explicit
|
||||||
|
#else
|
||||||
|
#define TIXML_EXPLICIT
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
TiXmlString is an emulation of a subset of the std::string template.
|
||||||
|
Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
|
||||||
|
Only the member functions relevant to the TinyXML project have been implemented.
|
||||||
|
The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
|
||||||
|
a string and there's no more room, we allocate a buffer twice as big as we need.
|
||||||
|
*/
|
||||||
|
class TiXmlString
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
// The size type used
|
||||||
|
typedef size_t size_type;
|
||||||
|
|
||||||
|
// Error value for find primitive
|
||||||
|
static const size_type npos; // = -1;
|
||||||
|
|
||||||
|
|
||||||
|
// TiXmlString empty constructor
|
||||||
|
TiXmlString () : rep_(&nullrep_)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// TiXmlString copy constructor
|
||||||
|
TiXmlString ( const TiXmlString & copy) : rep_(0)
|
||||||
|
{
|
||||||
|
init(copy.length());
|
||||||
|
memcpy(start(), copy.data(), length());
|
||||||
|
}
|
||||||
|
|
||||||
|
// TiXmlString constructor, based on a string
|
||||||
|
TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0)
|
||||||
|
{
|
||||||
|
init( static_cast<size_type>( strlen(copy) ));
|
||||||
|
memcpy(start(), copy, length());
|
||||||
|
}
|
||||||
|
|
||||||
|
// TiXmlString constructor, based on a string
|
||||||
|
TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0)
|
||||||
|
{
|
||||||
|
init(len);
|
||||||
|
memcpy(start(), str, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TiXmlString destructor
|
||||||
|
~TiXmlString ()
|
||||||
|
{
|
||||||
|
quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// = operator
|
||||||
|
TiXmlString& operator = (const char * copy)
|
||||||
|
{
|
||||||
|
return assign( copy, (size_type)strlen(copy));
|
||||||
|
}
|
||||||
|
|
||||||
|
// = operator
|
||||||
|
TiXmlString& operator = (const TiXmlString & copy)
|
||||||
|
{
|
||||||
|
return assign(copy.start(), copy.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// += operator. Maps to append
|
||||||
|
TiXmlString& operator += (const char * suffix)
|
||||||
|
{
|
||||||
|
return append(suffix, static_cast<size_type>( strlen(suffix) ));
|
||||||
|
}
|
||||||
|
|
||||||
|
// += operator. Maps to append
|
||||||
|
TiXmlString& operator += (char single)
|
||||||
|
{
|
||||||
|
return append(&single, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// += operator. Maps to append
|
||||||
|
TiXmlString& operator += (const TiXmlString & suffix)
|
||||||
|
{
|
||||||
|
return append(suffix.data(), suffix.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Convert a TiXmlString into a null-terminated char *
|
||||||
|
const char * c_str () const { return rep_->str; }
|
||||||
|
|
||||||
|
// Convert a TiXmlString into a char * (need not be null terminated).
|
||||||
|
const char * data () const { return rep_->str; }
|
||||||
|
|
||||||
|
// Return the length of a TiXmlString
|
||||||
|
size_type length () const { return rep_->size; }
|
||||||
|
|
||||||
|
// Alias for length()
|
||||||
|
size_type size () const { return rep_->size; }
|
||||||
|
|
||||||
|
// Checks if a TiXmlString is empty
|
||||||
|
bool empty () const { return rep_->size == 0; }
|
||||||
|
|
||||||
|
// Return capacity of string
|
||||||
|
size_type capacity () const { return rep_->capacity; }
|
||||||
|
|
||||||
|
|
||||||
|
// single char extraction
|
||||||
|
const char& at (size_type index) const
|
||||||
|
{
|
||||||
|
assert( index < length() );
|
||||||
|
return rep_->str[ index ];
|
||||||
|
}
|
||||||
|
|
||||||
|
// [] operator
|
||||||
|
char& operator [] (size_type index) const
|
||||||
|
{
|
||||||
|
assert( index < length() );
|
||||||
|
return rep_->str[ index ];
|
||||||
|
}
|
||||||
|
|
||||||
|
// find a char in a string. Return TiXmlString::npos if not found
|
||||||
|
size_type find (char lookup) const
|
||||||
|
{
|
||||||
|
return find(lookup, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// find a char in a string from an offset. Return TiXmlString::npos if not found
|
||||||
|
size_type find (char tofind, size_type offset) const
|
||||||
|
{
|
||||||
|
if (offset >= length()) return npos;
|
||||||
|
|
||||||
|
for (const char* p = c_str() + offset; *p != '\0'; ++p)
|
||||||
|
{
|
||||||
|
if (*p == tofind) return static_cast< size_type >( p - c_str() );
|
||||||
|
}
|
||||||
|
return npos;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clear ()
|
||||||
|
{
|
||||||
|
//Lee:
|
||||||
|
//The original was just too strange, though correct:
|
||||||
|
// TiXmlString().swap(*this);
|
||||||
|
//Instead use the quit & re-init:
|
||||||
|
quit();
|
||||||
|
init(0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Function to reserve a big amount of data when we know we'll need it. Be aware that this
|
||||||
|
function DOES NOT clear the content of the TiXmlString if any exists.
|
||||||
|
*/
|
||||||
|
void reserve (size_type cap);
|
||||||
|
|
||||||
|
TiXmlString& assign (const char* str, size_type len);
|
||||||
|
|
||||||
|
TiXmlString& append (const char* str, size_type len);
|
||||||
|
|
||||||
|
void swap (TiXmlString& other)
|
||||||
|
{
|
||||||
|
Rep* r = rep_;
|
||||||
|
rep_ = other.rep_;
|
||||||
|
other.rep_ = r;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
void init(size_type sz) { init(sz, sz); }
|
||||||
|
void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; }
|
||||||
|
char* start() const { return rep_->str; }
|
||||||
|
char* finish() const { return rep_->str + rep_->size; }
|
||||||
|
|
||||||
|
struct Rep
|
||||||
|
{
|
||||||
|
size_type size, capacity;
|
||||||
|
char str[1];
|
||||||
|
};
|
||||||
|
|
||||||
|
void init(size_type sz, size_type cap)
|
||||||
|
{
|
||||||
|
if (cap)
|
||||||
|
{
|
||||||
|
// Lee: the original form:
|
||||||
|
// rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
|
||||||
|
// doesn't work in some cases of new being overloaded. Switching
|
||||||
|
// to the normal allocation, although use an 'int' for systems
|
||||||
|
// that are overly picky about structure alignment.
|
||||||
|
const size_type bytesNeeded = sizeof(Rep) + cap;
|
||||||
|
const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int );
|
||||||
|
rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] );
|
||||||
|
|
||||||
|
rep_->str[ rep_->size = sz ] = '\0';
|
||||||
|
rep_->capacity = cap;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rep_ = &nullrep_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void quit()
|
||||||
|
{
|
||||||
|
if (rep_ != &nullrep_)
|
||||||
|
{
|
||||||
|
// The rep_ is really an array of ints. (see the allocator, above).
|
||||||
|
// Cast it back before delete, so the compiler won't incorrectly call destructors.
|
||||||
|
delete [] ( reinterpret_cast<int*>( rep_ ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Rep * rep_;
|
||||||
|
static Rep nullrep_;
|
||||||
|
|
||||||
|
} ;
|
||||||
|
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
inline bool operator < (const TiXmlString & a, const TiXmlString & b)
|
||||||
|
{
|
||||||
|
return strcmp(a.c_str(), b.c_str()) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); }
|
||||||
|
inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; }
|
||||||
|
inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); }
|
||||||
|
inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); }
|
||||||
|
|
||||||
|
inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; }
|
||||||
|
inline bool operator == (const char* a, const TiXmlString & b) { return b == a; }
|
||||||
|
inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); }
|
||||||
|
inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); }
|
||||||
|
|
||||||
|
TiXmlString operator + (const TiXmlString & a, const TiXmlString & b);
|
||||||
|
TiXmlString operator + (const TiXmlString & a, const char* b);
|
||||||
|
TiXmlString operator + (const char* a, const TiXmlString & b);
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
|
||||||
|
Only the operators that we need for TinyXML have been developped.
|
||||||
|
*/
|
||||||
|
class TiXmlOutStream : public TiXmlString
|
||||||
|
{
|
||||||
|
public :
|
||||||
|
|
||||||
|
// TiXmlOutStream << operator.
|
||||||
|
TiXmlOutStream & operator << (const TiXmlString & in)
|
||||||
|
{
|
||||||
|
*this += in;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TiXmlOutStream << operator.
|
||||||
|
TiXmlOutStream & operator << (const char * in)
|
||||||
|
{
|
||||||
|
*this += in;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
} ;
|
||||||
|
|
||||||
|
#endif // TIXML_STRING_INCLUDED
|
||||||
|
#endif // TIXML_USE_STL
|
1866
tinyxml/tinyxml.cpp
Normal file
1866
tinyxml/tinyxml.cpp
Normal file
File diff suppressed because it is too large
Load diff
1776
tinyxml/tinyxml.h
Normal file
1776
tinyxml/tinyxml.h
Normal file
File diff suppressed because it is too large
Load diff
53
tinyxml/tinyxmlerror.cpp
Normal file
53
tinyxml/tinyxmlerror.cpp
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
/*
|
||||||
|
www.sourceforge.net/projects/tinyxml
|
||||||
|
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
|
||||||
|
warranty. In no event will the authors be held liable for any
|
||||||
|
damages arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any
|
||||||
|
purpose, including commercial applications, and to alter it and
|
||||||
|
redistribute it freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must
|
||||||
|
not claim that you wrote the original software. If you use this
|
||||||
|
software in a product, an acknowledgment in the product documentation
|
||||||
|
would be appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and
|
||||||
|
must not be misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "tinyxml.h"
|
||||||
|
|
||||||
|
// The goal of the seperate error file is to make the first
|
||||||
|
// step towards localization. tinyxml (currently) only supports
|
||||||
|
// english error messages, but the could now be translated.
|
||||||
|
//
|
||||||
|
// It also cleans up the code a bit.
|
||||||
|
//
|
||||||
|
|
||||||
|
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.",
|
||||||
|
"Error null (0) or unexpected EOF found in input stream.",
|
||||||
|
"Error parsing CDATA.",
|
||||||
|
"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
|
||||||
|
};
|
1606
tinyxml/tinyxmlparser.cpp
Normal file
1606
tinyxml/tinyxmlparser.cpp
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue