Switch to TinyXml2

This commit is contained in:
PKEuS 2013-02-16 10:01:34 -08:00
parent b892d2e14c
commit 167e11b645
15 changed files with 4089 additions and 6156 deletions

View File

@ -357,8 +357,12 @@
<ResourceCompile Include="version.rc" /> <ResourceCompile Include="version.rc" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\externals\tinyxml\tinystr.h" /> <ClInclude Include="..\externals\tinyxml\tinyxml2.h">
<ClInclude Include="..\externals\tinyxml\tinyxml.h" /> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClInclude>
<ClInclude Include="..\lib\config.h" /> <ClInclude Include="..\lib\config.h" />
<ClInclude Include="cmdlineparser.h" /> <ClInclude Include="cmdlineparser.h" />
<ClInclude Include="cppcheckexecutor.h" /> <ClInclude Include="cppcheckexecutor.h" />
@ -372,10 +376,12 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\externals\tinyxml\tinystr.cpp" /> <ClCompile Include="..\externals\tinyxml\tinyxml2.cpp">
<ClCompile Include="..\externals\tinyxml\tinyxml.cpp" /> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ClCompile Include="..\externals\tinyxml\tinyxmlerror.cpp" /> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ClCompile Include="..\externals\tinyxml\tinyxmlparser.cpp" /> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="cmdlineparser.cpp" /> <ClCompile Include="cmdlineparser.cpp" />
<ClCompile Include="cppcheckexecutor.cpp" /> <ClCompile Include="cppcheckexecutor.cpp" />
<ClCompile Include="filelister.cpp" /> <ClCompile Include="filelister.cpp" />

View File

@ -32,10 +32,7 @@
<ClInclude Include="pathmatch.h"> <ClInclude Include="pathmatch.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\externals\tinyxml\tinystr.h"> <ClInclude Include="..\externals\tinyxml\tinyxml2.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\externals\tinyxml\tinyxml.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
@ -58,16 +55,7 @@
<ClCompile Include="cmdlineparser.cpp"> <ClCompile Include="cmdlineparser.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\externals\tinyxml\tinystr.cpp"> <ClCompile Include="..\externals\tinyxml\tinyxml2.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\externals\tinyxml\tinyxml.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\externals\tinyxml\tinyxmlerror.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\externals\tinyxml\tinyxmlparser.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>

View File

@ -32,7 +32,7 @@
#ifdef HAVE_RULES #ifdef HAVE_RULES
// xml is used in rules // xml is used in rules
#include <tinyxml.h> #include <tinyxml2.h>
#endif #endif
static void AddFilesToList(const std::string& FileList, std::vector<std::string>& PathNames) static void AddFilesToList(const std::string& FileList, std::vector<std::string>& PathNames)
@ -587,28 +587,28 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
// Rule file // Rule file
else if (std::strncmp(argv[i], "--rule-file=", 12) == 0) { else if (std::strncmp(argv[i], "--rule-file=", 12) == 0) {
TiXmlDocument doc; tinyxml2::XMLDocument doc;
if (doc.LoadFile(12+argv[i])) { if (doc.LoadFile(12+argv[i]) == tinyxml2::XML_NO_ERROR) {
TiXmlElement *node = doc.FirstChildElement(); tinyxml2::XMLElement *node = doc.FirstChildElement();
for (; node && node->ValueStr() == "rule"; node = node->NextSiblingElement()) { for (; node && strcmp(node->Value(), "rule") == 0; node = node->NextSiblingElement()) {
Settings::Rule rule; Settings::Rule rule;
TiXmlElement *pattern = node->FirstChildElement("pattern"); tinyxml2::XMLElement *pattern = node->FirstChildElement("pattern");
if (pattern) { if (pattern) {
rule.pattern = pattern->GetText(); rule.pattern = pattern->GetText();
} }
TiXmlElement *message = node->FirstChildElement("message"); tinyxml2::XMLElement *message = node->FirstChildElement("message");
if (message) { if (message) {
TiXmlElement *severity = message->FirstChildElement("severity"); tinyxml2::XMLElement *severity = message->FirstChildElement("severity");
if (severity) if (severity)
rule.severity = severity->GetText(); rule.severity = severity->GetText();
TiXmlElement *id = message->FirstChildElement("id"); tinyxml2::XMLElement *id = message->FirstChildElement("id");
if (id) if (id)
rule.id = id->GetText(); rule.id = id->GetText();
TiXmlElement *summary = message->FirstChildElement("summary"); tinyxml2::XMLElement *summary = message->FirstChildElement("summary");
if (summary) if (summary)
rule.summary = summary->GetText(); rule.summary = summary->GetText();
} }

View File

@ -1,299 +0,0 @@
Changes in version 1.0.1:
- Fixed comment tags which were outputing as '<?--' instead of
the correct '<!--'.
- Implemented the Next and Prev methods of the TiXmlAttribute class.
- Renamed 'LastAttribtute' to 'LastAttribute'
- Fixed bad pointer to 'isspace' that could occur while parsing text.
- Errors finding beginning and end of tags no longer throw it into an
infinite loop. (Hopefully.)
Changes in version 1.0.2
- Minor documentation fixes.
Changes in version 1.0.3
- After nodes are added to a document, they return a pointer
to the new node instead of a bool for success.
- Elements can be constructed with a value, which is the
element name. Every element must have a value or it will be
invalid, but the code changes to enforce this are not fully
in place.
Changes in version 1.1.0
- Added the TiXmlAttributeSet class to pull the attributes into
a seperate container.
- Moved the doubly liked list out of XmlBase. Now XmlBase only
requires the Print() function and defines some utility functions.
- Moved errors into a seperate file. (With the idea of internationalization
to the other latin-1 languages.)
- Added the "NodeType"
- Fixed white space parsing in text to conform with the standard.
Basically, all white space becomes just one space.
- Added the TiXmlDeclaration class to read xml declarations.
Changes in version 1.2.0
- Removed the factory. The factory was not really in the spirit
of small and simple, confused the code, and was of limited value.
- Added FirstChildElement and NextSiblingElement, because they
are such common functions.
- Re-wrote the example to test and demonstrate more functionality.
Changes in version 1.2.1
- Fixed a bug where comments couldn't be inside elements.
- Loading now clears out existing XML rather than appending.
- Added the "Clear" method on a node to delete all its children.
Changes in version 1.2.2
- Fixed TiXmlAttribute::Previous actually returning "next." Thanks
to Rickard Troedsson for the bug fix.
Changes in version 1.2.3
- Added the TIXML prefix to the error strings to resolve conflicts
with #defines in OS headers. Thanks to Steve Lhomme.
- Fixed a delete buf that should be a delete [] buf.
Thanks to Ephi Sinowitz.
Changes in version 1.2.4
- ReplaceChild() was almost guarenteed to fail. Should be fixed,
thanks to Joe Smith. Joe also pointed out that the Print() functions
should take stream references: I agree, and would like to overload
the Print() method to take either format, but I don't want to do
this in a dot release.
- Some compilers seem to need an extra <ctype.h> include. Thanks
to Steve Lhomme for that.
Changes in version 2.0.0 BETA
- Made the ToXXX() casts safe if 'this' is null.
When "LoadFile" is called with a filename, the value will correctly get set.
Thanks to Brian Yoder.
- Fixed bug where isalpha() and isalnum() would get called with a negative value for
high ascii numbers. Thanks to Alesky Aksenov.
- Fixed some errors codes that were not getting set.
- Made methods "const" that were not.
- Added a switch to enable or disable the ignoring of white space. ( TiXmlDocument::SetIgnoreWhiteSpace() )
- Greater standardization and code re-use in the parser.
- Added a stream out operator.
- Added a stream in operator.
- Entity support, of predefined entites. &#x entities are untouched by input or output.
- Improved text out formatting.
- Fixed ReplaceChild bug, thanks to Tao Chen.
Changes in version 2.0.1
- Fixed hanging on loading a 0 length file. Thanks to Jeff Scozzafava.
- Fixed crashing on InsertBeforeChild and InsertAfterChild. Also possibility of bad links being
created by same function. Thanks to Frank De prins.
- Added missing licence text. Thanks to Lars Willemsens.
- Added <ctype.h> include, at the suggestion of Steve Walters.
Changes in version 2.1.0
- Yves Berquin brings us the STL switch. The forum on SourceForge, and various emails to
me, have long debated all out STL vs. no STL at all. And now you can have it both ways.
TinyXml will compile either way.
Changes in version 2.1.1
- Compilation warnings.
Changes in version 2.1.2
- Uneeded code is not compiled in the STL case.
- Changed headers so that STL can be turned on or off in tinyxml.h
Changes in version 2.1.3
- Fixed non-const reference in API; now uses a pointer.
- Copy constructor of TiXmlString not checking for assignment to self.
- Nimrod Cohen found a truly evil bug in the STL implementation that occurs
when a string is converted to a c_str and then assigned to self. Search for
STL_STRING_BUG for a full description. I'm asserting this is a Microsoft STL
bug, since &string and string.c_str() should never be the same. Nevertheless,
the code works around it.
- Urivan Saaib pointed out a compiler conflict, where the C headers define
the isblank macro, which was wiping out the TiXmlString::isblank() method.
The method was unused and has been removed.
Changes in version 2.1.4
- Reworked the entity code. Entities were not correctly surving round trip input and output.
Will now automatically create entities for high ascii in output.
Changes in version 2.1.5
- Bug fix by kylotan : infinite loop on some input (tinyxmlparser.cpp rev 1.27)
- Contributed by Ivica Aracic (bytelord) : 1 new VC++ project to compile versions as static libraries (tinyxml_lib.dsp),
and an example usage in xmltest.dsp
(Patch request ID 678605)
- A suggestion by Ronald Fenner Jr (dormlock) to add #include <istream> and <ostream> for Apple's Project Builder
(Patch request ID 697642)
- A patch from ohommes that allows to parse correctly dots in element names and attribute names
(Patch request 602600 and kylotan 701728)
- A patch from hermitgeek ( James ) and wasteland for improper error reporting
- Reviewed by Lee, with the following changes:
- Got sick of fighting the STL/non-STL thing in the windows build. Broke
them out as seperate projects.
- I have too long not included the dsw. Added.
- TinyXmlText had a protected Print. Odd.
- Made LinkEndChild public, with docs and appropriate warnings.
- Updated the docs.
2.2.0
- Fixed an uninitialized pointer in the TiXmlAttributes
- Fixed STL compilation problem in MinGW (and gcc 3?) - thanks Brian Yoder for finding this one
- Fixed a syntax error in TiXmlDeclaration - thanks Brian Yoder
- Fletcher Dunn proposed and submitted new error handling that tracked the row and column. Lee
modified it to not have performance impact.
- General cleanup suggestions from Fletcher Dunn.
- In error handling, general errors will no longer clear the error state of specific ones.
- Fix error in documentation : comments starting with "<?--" instead of "<!--" (thanks ion_pulse)
- Added the TiXmlHandle. An easy, safe way to browse XML DOMs with less code.
- Added QueryAttribute calls which have better error messaging. (Proposed by Fletcher Dunn)
- Nodes and attributes can now print themselves to strings. (Yves suggestion)
- Fixed bug where entities with one character would confuse parser. (Thanks Roman)
2.2.1
- Additional testing (no more bugs found to be fixed in this release)
- Significant performance improvement to the cursor code.
2.3.0
- User Data are now defined in TiXmlBase instead of TiXmlNode
- Character Entities are now UCS-2
- Character Entities can be decimal or hexadecimal
- UTF-8 conversion.
- Fixed many, many bugs.
2.3.1
- Fixed bug in handling nulls embedded in the input.
- Make UTF-8 parser tolerant of bad text encoding.
- Added encoding detection.
- Many fixes and input from John-Philip Leonard Johansson (JP) and Ellers,
including UTF-8 feedback, bug reports, and patches. Thanks!
- Added version # constants - a suggestion from JP and Ellers.
- [ 979180 ] Missing ; in entity reference, fix from Rob Laveaux.
- Copy constructors and assignment have been a long time coming. Thanks to
Fokke and JP.
2.3.2
- Made the IsAlpha and IsAlphaNum much more tolerant of non-UTF-8 encodings. Thanks
Volker Boerchers for finding the issue.
- Ran the program though the magnificent Valgrind - http://valgrind.kde.org - to check
for memory errors. Fixed some minor issues.
2.3.3
- Fixed crash when test program was run from incorrect directory.
- Fixed bug 1070717 - empty document not returned correctly - thanks Katsuhisa Yuasa.
- Bug 1079301 resolved - deprecated stdlib calls. Thanks Adrian Boeing.
- Bug 1035218 fixed - documentation errors. Xunji Luo
- Other bug fixes have accumulated and been fixed on the way as well; my apologies to
authors not credited!
- Big fix / addition is to correctly return const values. TinyXml could basically
remove const in a method like this: TiXmlElement* Foo() const, where the returned element
was a pointer to internal data. That is now: const TiXmlElement* Foo() const and
TiXmlElement* Foo().
2.3.4
- Fixed additional const errors, thanks Kent Gibson.
- Correctly re-enable warnings after tinyxml header. Thanks Cory Nelson.
- Variety of type cleanup and warning fixes. Thanks Warren Stevens.
- Cleaned up unneeded constructor calls in TinyString - thanks to Geoff Carlton and
the discussion group on sourceforge.
2.4.0
- Improved string class, thanks Tyge Lovset (whose name gets mangled in English - sorry)
- Type cast compiler warning, thanks Rob van den Bogaard
- Added GetText() convenience function. Thanks Ilya Parniuk & Andrew Ellers for input.
- Many thanks to marlonism for finding an infinite loop in bad xml.
- A patch to cleanup warnings from Robert Gebis.
- Added ValueStr() to get the value of a node as a string.
- TiXmlText can now parse and output as CDATA
- Additional string improvement from James (z2895)
- Removed extraneous 'const', thanks David Aldrich
- First pass at switching to the "safe" stdlib functions. Many people have suggested and
pushed on this, but Warren Stevens put together the first proposal.
- TinyXml now will do EOL normalization before parsing, consistent with the W3C XML spec.
- Documents loaded with the UTF-8 BOM will now save with the UTF-8 BOM. Good suggestion
from 'instructor_'
- Ellers submitted his very popular tutorials, which have been added to the distribution.
2.4.1
- Fixed CDATA output formatting
- Fixed memory allocators in TinyString to work with overloaded new/delete
2.4.2
- solosnake pointed out that TIXML_LOG causes problems on an XBOX. The definition in the header
was superflous and was moved inside of DEBUG_PARSING
2.4.3
- Fixed a test bug that caused a crash in 'xmltest'. TinyXML was fine, but it isn't good
to ship with a broken test suite.
- Started converting some functions to not cast between std::string and const char*
quite as often.
- Added FILE* versions of the document loads - good suggestion from Wade Brainerd
- Empty documents might not always return the errors they should. [1398915] Thanks to igor v.
- Added some asserts for multiply adding a node, regardng bug [1391937] suggested by Paco Arjonilla.
2.4.4
- Bug find thanks to andre-gross found a memory leak that occured when a document failed to load.
- Bug find (and good analysis) by VirtualJim who found a case where attribute parsing
should be throwing an error and wasn't.
- Steve Hyatt suggested the QueryValueAttribute method, which is now implemented.
- DavidA identified a chunk of dead code.
- Andrew Baxter sent in some compiler warnings that were good clean up points.
2.5
- Added the Visit() API. Many thanks to both Andrew Ellerton and John-Philip for all their
work, code, suggestion, and just general pushing that it should be done.
- Removed existing streaming code and use TiXmlPrinter instead.
- [ tinyxml-Bugs-1527079 ] Compile error in tinystr.cpp fixed, thanks to Paul Suggs
- [ tinyxml-Bugs-1522890 ] SaveFile has no error checks fixed, thanks to Ivan Dobrokotov
- Ivan Dobrokotov also reported redundant memory allocation in the Attribute() method, which
upon investigation was a mess. The attribute should now be fixed for both const char* and
std::string, and the return types match the input parameters.
- Feature [ 1511105 ] Make TiXmlComment constructor accept a string / char*, implemented.
Thanks to Karl Itschen for the feedback.
- [ 1480108 ] Stream parsing fails when CDATA contains tags was found by Tobias Grimm, who also
submitted a test case and patch. A significant bug in CDATA streaming (operator>>) has now
been fixed.
2.5.2
- Lieven, and others, pointed out a missing const-cast that upset the Open Watcom compiler.
Should now be fixed.
- ErrorRow and ErrorCol should have been const, and weren't. Fixed thanks to Dmitry Polutov.
2.5.3
- zloe_zlo identified a missing string specialization for QueryValueAttribute() [ 1695429 ]. Worked
on this bug, but not sure how to fix it in a safe, cross-compiler way.
- increased warning level to 4 and turned on detect 64 bit portability issues for VC2005.
May address [ 1677737 ] VS2005: /Wp64 warnings
- grosheck identified several problems with the Document copy. Many thanks for [ 1660367 ]
- Nice catch, and suggested fix, be Gilad Novik on the Printer dropping entities.
"[ 1600650 ] Bug when printing xml text" is now fixed.
- A subtle fix from Nicos Gollan in the tinystring initializer:
[ 1581449 ] Fix initialiser of TiXmlString::nullrep_
- Great catch, although there isn't a submitter for the bug. [ 1475201 ] TinyXML parses entities in comments.
Comments should not, in fact, parse entities. Fixed the code path and added tests.
- We were not catching all the returns from ftell. Thanks to Bernard for catching that.
2.5.4
- A TiXMLDocument can't be a sub-node. Block this from happening in the 'replace'. Thanks Noam.
- [ 1714831 ] TiXmlBase::location is not copied by copy-ctors, fix reported and suggested by Nicola Civran.
- Fixed possible memory overrun in the comment reading code - thanks gcarlton77
2.5.5
- Alex van der Wal spotted incorrect types (lf) being used in print and scan. robertnestor pointed out some problems with the simple solution. Types updated.
- Johannes Hillert pointed out some bug typos.
- Christian Mueller identified inconsistent error handling with Attributes.
- olivier barthelemy also reported a problem with double truncation, also related to the %lf issue.
- zaelsius came up with a great (and simple) suggestion to fix QueryValueAttribute truncating strings.
- added some null pointer checks suggested by hansenk
- Sami Väisänen found a (rare) buffer overrun that could occur in parsing.
- vi tri filed a bug that led to a refactoring of the attribute setting mess (as well as adding a missing SetDoubleAttribute() )
- removed TIXML_ERROR_OUT_OF_MEMORY. TinyXML does not systematically address OOO, and the notion it does is misleading.
- vanneto, keithmarshall, others all reported the warning from IsWhiteSpace() usage. Cleaned this up - many thanks to everyone who reported this one.
- tibur found a bug in end tag parsing
2.6.2
- Switched over to VC 2010
- Fixed up all the build issues arising from that. (Lots of latent build problems.)
- Removed the old, now unmaintained and likely not working, build files.
- Fixed some static analysis issues reported by orbitcowboy from cppcheck.
- Bayard 95 sent in analysis from a different analyzer - fixes applied from that as well.
- Tim Kosse sent a patch fixing an infinite loop.
- Ma Anguo identified a doc issue.
- Eddie Cohen identified a missing qualifier resulting in a compilation error on some systems.
- Fixed a line ending bug. (What year is this? Can we all agree on a format for text files? Please? ...oh well.)

View File

@ -1,111 +0,0 @@
/*
www.sourceforge.net/projects/tinyxml
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.
*/
#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

View File

@ -1,305 +0,0 @@
/*
www.sourceforge.net/projects/tinyxml
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.
*/
#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();
}
TiXmlString& operator = (const char * copy)
{
return assign( copy, (size_type)strlen(copy));
}
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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,2 @@
HEADERS += $${BASEPATH}tinystr.h \ HEADERS += $${BASEPATH}tinyxml2.h
$${BASEPATH}tinyxml.h SOURCES += $${BASEPATH}tinyxml2.cpp
SOURCES += $${BASEPATH}tinystr.cpp \
$${BASEPATH}tinyxml.cpp \
$${BASEPATH}tinyxmlerror.cpp \
$${BASEPATH}tinyxmlparser.cpp

2095
externals/tinyxml/tinyxml2.cpp vendored Normal file

File diff suppressed because it is too large Load Diff

1968
externals/tinyxml/tinyxml2.h vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,52 +0,0 @@
/*
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[ TiXmlBase::TIXML_ERROR_STRING_COUNT ] =
{
"No error",
"Error",
"Failed to open file",
"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.",
};

File diff suppressed because it is too large Load Diff

View File

@ -29,10 +29,6 @@
<ClCompile Include="..\cli\filelister.cpp" /> <ClCompile Include="..\cli\filelister.cpp" />
<ClCompile Include="..\cli\pathmatch.cpp" /> <ClCompile Include="..\cli\pathmatch.cpp" />
<ClCompile Include="..\cli\threadexecutor.cpp" /> <ClCompile Include="..\cli\threadexecutor.cpp" />
<ClCompile Include="..\externals\tinyxml\tinystr.cpp" />
<ClCompile Include="..\externals\tinyxml\tinyxml.cpp" />
<ClCompile Include="..\externals\tinyxml\tinyxmlerror.cpp" />
<ClCompile Include="..\externals\tinyxml\tinyxmlparser.cpp" />
<ClCompile Include="options.cpp" /> <ClCompile Include="options.cpp" />
<ClCompile Include="test64bit.cpp" /> <ClCompile Include="test64bit.cpp" />
<ClCompile Include="testassignif.cpp" /> <ClCompile Include="testassignif.cpp" />
@ -83,8 +79,6 @@
<ClInclude Include="..\cli\filelister.h" /> <ClInclude Include="..\cli\filelister.h" />
<ClInclude Include="..\cli\pathmatch.h" /> <ClInclude Include="..\cli\pathmatch.h" />
<ClInclude Include="..\cli\threadexecutor.h" /> <ClInclude Include="..\cli\threadexecutor.h" />
<ClInclude Include="..\externals\tinyxml\tinystr.h" />
<ClInclude Include="..\externals\tinyxml\tinyxml.h" />
<ClInclude Include="..\lib\config.h" /> <ClInclude Include="..\lib\config.h" />
<ClInclude Include="options.h" /> <ClInclude Include="options.h" />
<ClInclude Include="redirect.h" /> <ClInclude Include="redirect.h" />

View File

@ -148,18 +148,6 @@
<ClCompile Include="..\cli\cmdlineparser.cpp"> <ClCompile Include="..\cli\cmdlineparser.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\externals\tinyxml\tinystr.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\externals\tinyxml\tinyxml.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\externals\tinyxml\tinyxmlerror.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\externals\tinyxml\tinyxmlparser.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="testio.cpp"> <ClCompile Include="testio.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
@ -204,12 +192,6 @@
<ClInclude Include="..\cli\cmdlineparser.h"> <ClInclude Include="..\cli\cmdlineparser.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\externals\tinyxml\tinystr.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\externals\tinyxml\tinyxml.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\lib\config.h"> <ClInclude Include="..\lib\config.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>