Update TinyXML
This commit is contained in:
1
src/fileio/xml-parser/.gitattributes
vendored
Normal file
1
src/fileio/xml-parser/.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
||||
* text=auto !eol
|
||||
2
src/fileio/xml-parser/.gitignore
vendored
Normal file
2
src/fileio/xml-parser/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*build*
|
||||
*.user
|
||||
99
src/fileio/xml-parser/CMakeLists.txt
Normal file
99
src/fileio/xml-parser/CMakeLists.txt
Normal file
@@ -0,0 +1,99 @@
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
|
||||
project(ticpp VERSION 2.5.3 LANGUAGES CXX)
|
||||
|
||||
get_property(isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
set(buildTypes "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
|
||||
set(defaultBuildType "Debug")
|
||||
if(NOT isMultiConfig)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
message(STATUS "Setting build type to '${defaultBuildType}' as none was specified.")
|
||||
set(CMAKE_BUILD_TYPE "${defaultBuildType}" CACHE STRING "Choose the type of build." FORCE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${buildTypes}")
|
||||
elseif(NOT CMAKE_BUILD_TYPE IN_LIST buildTypes)
|
||||
message(FATAL_ERROR "Unknown build type: '${CMAKE_BUILD_TYPE}'")
|
||||
endif()
|
||||
endif()
|
||||
unset(defaultBuildType)
|
||||
unset(buildTypes)
|
||||
|
||||
# TODO: This is not the ideal solution to apply these warning flags.
|
||||
# Toolchain files are not really intended for this purpose.
|
||||
# Presets would be a viable solution, but currently, at least on VSCode, this
|
||||
# has the side effect that pretty much everything from generator to build type
|
||||
# to binary directory needs to be specified. The usual control ability of especially
|
||||
# the build type gets lost in preset mode.
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
string(APPEND CMAKE_CXX_FLAGS " /W4")
|
||||
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# This assumes the default Clang frontend and not the MSVC compatible one
|
||||
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wpedantic")
|
||||
else()
|
||||
# This assumes GCC
|
||||
string(APPEND CMAKE_CXX_FLAGS " -Wall -Wextra -Wpedantic")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
elseif(CMAKE_CXX_STANDARD LESS 17 OR CMAKE_CXX_STANDARD GREATER_EQUAL 98)
|
||||
message(FATAL_ERROR "The CMAKE_CXX_STANDARD value needs to be at least 17, current value: ${CMAKE_CXX_STANDARD}")
|
||||
endif()
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
if (NOT DEFINED CMAKE_CXX_EXTENSIONS)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# Disable warnings about standard conformant code that is not conform to Microsoft standards
|
||||
add_compile_definitions(_CRT_SECURE_NO_WARNINGS _SCL_SECURE_NO_WARNINGS)
|
||||
# Without BOM the UTF-8 encoding doesn't get detected so enforce it
|
||||
add_compile_options(/source-charset:utf-8)
|
||||
endif()
|
||||
|
||||
add_library(ticpp_ticpp)
|
||||
add_library(ticpp::ticpp ALIAS ticpp_ticpp)
|
||||
set_target_properties(ticpp_ticpp PROPERTIES
|
||||
OUTPUT_NAME ticpp
|
||||
)
|
||||
|
||||
target_sources(ticpp_ticpp
|
||||
PRIVATE
|
||||
ticpp.cpp
|
||||
ticpp.h
|
||||
ticppapi.h
|
||||
ticpprc.h
|
||||
tinystr.cpp
|
||||
tinystr.h
|
||||
tinyxml.cpp
|
||||
tinyxml.h
|
||||
tinyxmlparser.cpp
|
||||
tinyxmlerror.cpp
|
||||
)
|
||||
|
||||
target_compile_definitions(ticpp_ticpp
|
||||
PUBLIC
|
||||
TIXML_USE_TICPP
|
||||
$<$<BOOL:${BUILD_SHARED_LIBS}>:BUILD_TICPP_DLL>
|
||||
)
|
||||
target_include_directories(ticpp_ticpp
|
||||
INTERFACE
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
|
||||
)
|
||||
|
||||
if(PROJECT_IS_TOP_LEVEL)
|
||||
set(excludeFromAllTag "")
|
||||
else()
|
||||
set(excludeFromAllTag EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
install(TARGETS ticpp_ticpp
|
||||
RUNTIME
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
LIBRARY
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
${excludeFromAllTag}
|
||||
)
|
||||
unset(excludeFromAllTag)
|
||||
21
src/fileio/xml-parser/LICENSE
Normal file
21
src/fileio/xml-parser/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2006 Ryan Pusztai, Ryan Mulder
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
11
src/fileio/xml-parser/README.md
Normal file
11
src/fileio/xml-parser/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# TiCPP
|
||||
|
||||
**TiCPP** is short for the official name TinyXML++. It is a completely new interface to [TinyXML](http://www.grinninglizard.com/tinyxml/) that uses MANY of the C++ strengths.
|
||||
Templates, exceptions, and much better error handling. It is also fully documented in Doxygen. It is really cool because this version lets you interface tiny
|
||||
the exact same way as before or you can choose to use the new `ticpp` classes. All you need to do is define `TIXML_USE_TICPP`.
|
||||
It has been tested in VC 6.0, VC 7.0, VC 7.1, VC 8.0, MinGW gcc 3.4.5, and in Linux GNU gcc 3+.
|
||||
|
||||
Documentation:
|
||||
|
||||
* [Online](http://rawgit.com/wxFormBuilder/ticpp/docs/ticpp.html)
|
||||
* [Download](http://rawgit.com/wxFormBuilder/ticpp/docs/TinyXMLHelp_v2.5.3.chm)
|
||||
@@ -22,7 +22,7 @@ Introduction:
|
||||
Build Steps:
|
||||
1) Download Premake from http://premake.sf.net/download
|
||||
2) Checkout the source for TinyXML++ using Subversion.
|
||||
- svn checkout https://ticpp.googlecode.com/svn/trunk/ ticpp
|
||||
- svn checkout https://github.com/rjpcomputing/ticpp ticpp
|
||||
3) Place the Premake executable in the root directory of TiCPP or somewhere in your
|
||||
path.
|
||||
4) To create the needed build files navigate to the TinyXML++ directory (ticpp)
|
||||
@@ -53,7 +53,8 @@ Build Steps:
|
||||
with gcc or MinGW)
|
||||
|
||||
* Release:
|
||||
make CONFIG=Release
|
||||
make CONFIG=Release (if generated with premake)
|
||||
make config=release (if generated with premake4)
|
||||
|
||||
* Debug:
|
||||
make
|
||||
|
||||
@@ -267,5 +267,3 @@ Changes in version 2.1.5
|
||||
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
|
||||
- Added dll-interface declarations to support using DLLs built via VS200X.
|
||||
|
||||
36
src/fileio/xml-parser/premake.lua
Normal file
36
src/fileio/xml-parser/premake.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
--*****************************************************************************
|
||||
--* Author: RJP Computing <rjpcomputing@gmail.com>
|
||||
--* Copyright (C) 2007 RJP Computing
|
||||
--*
|
||||
--* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
--* this software and associated documentation files (the "Software"), to deal in
|
||||
--* the Software without restriction, including without limitation the rights to
|
||||
--* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
--* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
--* subject to the following conditions:
|
||||
--*
|
||||
--* The above copyright notice and this permission notice shall be included in all
|
||||
--* copies or substantial portions of the Software.
|
||||
--*
|
||||
--* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
--* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
--* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
--* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
--* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
--* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
--*
|
||||
--* NOTES:
|
||||
--* - use the '/' slash for all paths.
|
||||
--*****************************************************************************
|
||||
project.name = "TinyXML++"
|
||||
|
||||
project.bindir = "lib"
|
||||
project.libdir = "lib"
|
||||
|
||||
-- This is for including other Premake scripts.
|
||||
dopackage( "ticpp.lua" )
|
||||
|
||||
-- Add options here.
|
||||
addoption( "dynamic-runtime", "Use the dynamicly loadable version of the runtime." )
|
||||
addoption( "unicode", "Use the Unicode character set" )
|
||||
|
||||
46
src/fileio/xml-parser/premake4.lua
Normal file
46
src/fileio/xml-parser/premake4.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
--*****************************************************************************
|
||||
--* Author: RJP Computing <rjpcomputing@gmail.com>
|
||||
--* Copyright (C) 2009 RJP Computing
|
||||
--*
|
||||
--* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
--* this software and associated documentation files (the "Software"), to deal in
|
||||
--* the Software without restriction, including without limitation the rights to
|
||||
--* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
--* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
--* subject to the following conditions:
|
||||
--*
|
||||
--* The above copyright notice and this permission notice shall be included in all
|
||||
--* copies or substantial portions of the Software.
|
||||
--*
|
||||
--* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
--* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
--* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
--* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
--* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
--* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
--*
|
||||
--* NOTES:
|
||||
--* - use the '/' slash for all paths.
|
||||
--*****************************************************************************
|
||||
solution "TinyXML++"
|
||||
targetdir "lib"
|
||||
implibdir "lib"
|
||||
configurations { "Debug", "Release" }
|
||||
buildoptions { "-std=c++14" }
|
||||
|
||||
-- This is for including other Premake scripts.
|
||||
dofile( "ticpp4.lua" )
|
||||
|
||||
-- Add options here.
|
||||
newoption
|
||||
{
|
||||
trigger = "dynamic-runtime",
|
||||
description = "Use the dynamicly loadable version of the runtime."
|
||||
}
|
||||
|
||||
newoption
|
||||
{
|
||||
trigger = "unicode",
|
||||
description = "Use the Unicode character set"
|
||||
}
|
||||
|
||||
@@ -1,531 +0,0 @@
|
||||
/** @mainpage
|
||||
|
||||
<h1> TinyXML </h1>
|
||||
|
||||
TinyXML is a simple, small, C++ XML parser that can be easily
|
||||
integrated into other programs.
|
||||
|
||||
<h2> What it does. </h2>
|
||||
|
||||
In brief, TinyXML parses an XML document, and builds from that a
|
||||
Document Object Model (DOM) that can be read, modified, and saved.
|
||||
|
||||
XML stands for "eXtensible Markup Language." It allows you to create
|
||||
your own document markups. Where HTML does a very good job of marking
|
||||
documents for browsers, XML allows you to define any kind of document
|
||||
markup, for example a document that describes a "to do" list for an
|
||||
organizer application. XML is a very structured and convenient format.
|
||||
All those random file formats created to store application data can
|
||||
all be replaced with XML. One parser for everything.
|
||||
|
||||
The best place for the complete, correct, and quite frankly hard to
|
||||
read spec is at <a href="http://www.w3.org/TR/2004/REC-xml-20040204/">
|
||||
http://www.w3.org/TR/2004/REC-xml-20040204/</a>. An intro to XML
|
||||
(that I really like) can be found at
|
||||
<a href="http://skew.org/xml/tutorial/">http://skew.org/xml/tutorial</a>.
|
||||
|
||||
There are different ways to access and interact with XML data.
|
||||
TinyXML uses a Document Object Model (DOM), meaning the XML data is parsed
|
||||
into a C++ objects that can be browsed and manipulated, and then
|
||||
written to disk or another output stream. You can also construct an XML document
|
||||
from scratch with C++ objects and write this to disk or another output
|
||||
stream.
|
||||
|
||||
TinyXML is designed to be easy and fast to learn. It is two headers
|
||||
and four cpp files. Simply add these to your project and off you go.
|
||||
There is an example file - xmltest.cpp - to get you started.
|
||||
|
||||
TinyXML is released under the ZLib license,
|
||||
so you can use it in open source or commercial code. The details
|
||||
of the license are at the top of every source file.
|
||||
|
||||
TinyXML attempts to be a flexible parser, but with truly correct and
|
||||
compliant XML output. TinyXML should compile on any reasonably C++
|
||||
compliant system. It does not rely on exceptions or RTTI. It can be
|
||||
compiled with or without STL support. TinyXML fully supports
|
||||
the UTF-8 encoding, and the first 64k character entities.
|
||||
|
||||
|
||||
<h2> What it doesn't do. </h2>
|
||||
|
||||
TinyXML doesn't parse or use DTDs (Document Type Definitions) or XSLs
|
||||
(eXtensible Stylesheet Language.) There are other parsers out there
|
||||
(check out www.sourceforge.org, search for XML) that are much more fully
|
||||
featured. But they are also much bigger, take longer to set up in
|
||||
your project, have a higher learning curve, and often have a more
|
||||
restrictive license. If you are working with browsers or have more
|
||||
complete XML needs, TinyXML is not the parser for you.
|
||||
|
||||
The following DTD syntax will not parse at this time in TinyXML:
|
||||
|
||||
@verbatim
|
||||
<!DOCTYPE Archiv [
|
||||
<!ELEMENT Comment (#PCDATA)>
|
||||
]>
|
||||
@endverbatim
|
||||
|
||||
because TinyXML sees this as a !DOCTYPE node with an illegally
|
||||
embedded !ELEMENT node. This may be addressed in the future.
|
||||
|
||||
<h2> Tutorials. </h2>
|
||||
|
||||
For the impatient, here are some tutorials to get you going. A great way to get started,
|
||||
but it is worth your time to read this (very short) manual completely.
|
||||
|
||||
- @subpage ticppTutorial
|
||||
- @subpage tutorial0
|
||||
|
||||
<h2> Code Status. </h2>
|
||||
|
||||
TinyXML is mature, tested code. It is very stable. If you find
|
||||
bugs, please file a bug report on the sourceforge web site
|
||||
(www.sourceforge.net/projects/tinyxml). We'll get them straightened
|
||||
out as soon as possible.
|
||||
|
||||
There are some areas of improvement; please check sourceforge if you are
|
||||
interested in working on TinyXML.
|
||||
|
||||
<h2> Related Projects </h2>
|
||||
|
||||
TinyXML projects you may find useful! (Descriptions provided by the projects.)
|
||||
|
||||
<ul>
|
||||
<li> <b>TinyXPath</b> (http://tinyxpath.sourceforge.net). TinyXPath is a small footprint
|
||||
XPath syntax decoder, written in C++.</li>
|
||||
<li> <b>@subpage ticpp</b> (http://code.google.com/p/ticpp/). TinyXML++ is a completely new
|
||||
interface to TinyXML that uses MANY of the C++ strengths. Templates,
|
||||
exceptions, and much better error handling.</li>
|
||||
</ul>
|
||||
|
||||
<h2> Features </h2>
|
||||
|
||||
<h3> Using STL </h3>
|
||||
|
||||
TinyXML can be compiled to use or not use STL. When using STL, TinyXML
|
||||
uses the std::string class, and fully supports std::istream, std::ostream,
|
||||
operator<<, and operator>>. Many API methods have both 'const char*' and
|
||||
'const std::string&' forms.
|
||||
|
||||
When STL support is compiled out, no STL files are included whatsoever. All
|
||||
the string classes are implemented by TinyXML itself. API methods
|
||||
all use the 'const char*' form for input.
|
||||
|
||||
Use the compile time #define:
|
||||
|
||||
TIXML_USE_STL
|
||||
|
||||
to compile one version or the other. This can be passed by the compiler,
|
||||
or set as the first line of "tinyxml.h".
|
||||
|
||||
Note: If compiling the test code in Linux, setting the environment
|
||||
variable TINYXML_USE_STL=YES/NO will control STL compilation. In the
|
||||
Windows project file, STL and non STL targets are provided. In your project,
|
||||
It's probably easiest to add the line "#define TIXML_USE_STL" as the first
|
||||
line of tinyxml.h.
|
||||
|
||||
<h3> UTF-8 </h3>
|
||||
|
||||
TinyXML supports UTF-8 allowing to manipulate XML files in any language. TinyXML
|
||||
also supports "legacy mode" - the encoding used before UTF-8 support and
|
||||
probably best described as "extended ascii".
|
||||
|
||||
Normally, TinyXML will try to detect the correct encoding and use it. However,
|
||||
by setting the value of TIXML_DEFAULT_ENCODING in the header file, TinyXML
|
||||
can be forced to always use one encoding.
|
||||
|
||||
TinyXML will assume Legacy Mode until one of the following occurs:
|
||||
<ol>
|
||||
<li> If the non-standard but common "UTF-8 lead bytes" (0xef 0xbb 0xbf)
|
||||
begin the file or data stream, TinyXML will read it as UTF-8. </li>
|
||||
<li> If the declaration tag is read, and it has an encoding="UTF-8", then
|
||||
TinyXML will read it as UTF-8. </li>
|
||||
<li> If the declaration tag is read, and it has no encoding specified, then TinyXML will
|
||||
read it as UTF-8. </li>
|
||||
<li> If the declaration tag is read, and it has an encoding="something else", then TinyXML
|
||||
will read it as Legacy Mode. In legacy mode, TinyXML will work as it did before. It's
|
||||
not clear what that mode does exactly, but old content should keep working.</li>
|
||||
<li> Until one of the above criteria is met, TinyXML runs in Legacy Mode.</li>
|
||||
</ol>
|
||||
|
||||
What happens if the encoding is incorrectly set or detected? TinyXML will try
|
||||
to read and pass through text seen as improperly encoded. You may get some strange results or
|
||||
mangled characters. You may want to force TinyXML to the correct mode.
|
||||
|
||||
You may force TinyXML to Legacy Mode by using LoadFile( TIXML_ENCODING_LEGACY ) or
|
||||
LoadFile( filename, TIXML_ENCODING_LEGACY ). You may force it to use legacy mode all
|
||||
the time by setting TIXML_DEFAULT_ENCODING = TIXML_ENCODING_LEGACY. Likewise, you may
|
||||
force it to TIXML_ENCODING_UTF8 with the same technique.
|
||||
|
||||
For English users, using English XML, UTF-8 is the same as low-ASCII. You
|
||||
don't need to be aware of UTF-8 or change your code in any way. You can think
|
||||
of UTF-8 as a "superset" of ASCII.
|
||||
|
||||
UTF-8 is not a double byte format - but it is a standard encoding of Unicode!
|
||||
TinyXML does not use or directly support wchar, TCHAR, or Microsoft's _UNICODE at this time.
|
||||
It is common to see the term "Unicode" improperly refer to UTF-16, a wide byte encoding
|
||||
of unicode. This is a source of confusion.
|
||||
|
||||
For "high-ascii" languages - everything not English, pretty much - TinyXML can
|
||||
handle all languages, at the same time, as long as the XML is encoded
|
||||
in UTF-8. That can be a little tricky, older programs and operating systems
|
||||
tend to use the "default" or "traditional" code page. Many apps (and almost all
|
||||
modern ones) can output UTF-8, but older or stubborn (or just broken) ones
|
||||
still output text in the default code page.
|
||||
|
||||
For example, Japanese systems traditionally use SHIFT-JIS encoding.
|
||||
Text encoded as SHIFT-JIS can not be read by TinyXML.
|
||||
A good text editor can import SHIFT-JIS and then save as UTF-8.
|
||||
|
||||
The <a href="http://skew.org/xml/tutorial/">Skew.org link</a> does a great
|
||||
job covering the encoding issue.
|
||||
|
||||
The test file "utf8test.xml" is an XML containing English, Spanish, Russian,
|
||||
and Simplified Chinese. (Hopefully they are translated correctly). The file
|
||||
"utf8test.gif" is a screen capture of the XML file, rendered in IE. Note that
|
||||
if you don't have the correct fonts (Simplified Chinese or Russian) on your
|
||||
system, you won't see output that matches the GIF file even if you can parse
|
||||
it correctly. Also note that (at least on my Windows machine) console output
|
||||
is in a Western code page, so that Print() or printf() cannot correctly display
|
||||
the file. This is not a bug in TinyXML - just an OS issue. No data is lost or
|
||||
destroyed by TinyXML. The console just doesn't render UTF-8.
|
||||
|
||||
|
||||
<h3> Entities </h3>
|
||||
TinyXML recognizes the pre-defined "character entities", meaning special
|
||||
characters. Namely:
|
||||
|
||||
@verbatim
|
||||
& &
|
||||
< <
|
||||
> >
|
||||
" "
|
||||
' '
|
||||
@endverbatim
|
||||
|
||||
These are recognized when the XML document is read, and translated to there
|
||||
UTF-8 equivalents. For instance, text with the XML of:
|
||||
|
||||
@verbatim
|
||||
Far & Away
|
||||
@endverbatim
|
||||
|
||||
will have the Value() of "Far & Away" when queried from the TiXmlText object,
|
||||
and will be written back to the XML stream/file as an ampersand. Older versions
|
||||
of TinyXML "preserved" character entities, but the newer versions will translate
|
||||
them into characters.
|
||||
|
||||
Additionally, any character can be specified by its Unicode code point:
|
||||
The syntax " " or " " are both to the non-breaking space characher.
|
||||
|
||||
<h3> Printing </h3>
|
||||
TinyXML can print output in several different ways that all have strengths and limitations.
|
||||
|
||||
- Print( FILE* ). Output to a std-C stream, which includes all C files as well as stdout.
|
||||
- "Pretty prints", but you don't have control over printing options.
|
||||
- The output is streamed directly to the FILE object, so there is no memory overhead
|
||||
in the TinyXML code.
|
||||
- used by Print() and SaveFile()
|
||||
|
||||
- operator<<. Output to a c++ stream.
|
||||
- Integrates with standart C++ iostreams.
|
||||
- Outputs in "network printing" mode without line breaks. Good for network transmission
|
||||
and moving XML between C++ objects, but hard for a human to read.
|
||||
|
||||
- TiXmlPrinter. Output to a std::string or memory buffer.
|
||||
- API is less concise
|
||||
- Future printing options will be put here.
|
||||
- Printing may change slightly in future versions as it is refined and expanded.
|
||||
|
||||
<h3> Streams </h3>
|
||||
With TIXML_USE_STL on TinyXML supports C++ streams (operator <<,>>) streams as well
|
||||
as C (FILE*) streams. There are some differences that you may need to be aware of.
|
||||
|
||||
C style output:
|
||||
- based on FILE*
|
||||
- the Print() and SaveFile() methods
|
||||
|
||||
Generates formatted output, with plenty of white space, intended to be as
|
||||
human-readable as possible. They are very fast, and tolerant of ill formed
|
||||
XML documents. For example, an XML document that contains 2 root elements
|
||||
and 2 declarations, will still print.
|
||||
|
||||
C style input:
|
||||
- based on FILE*
|
||||
- the Parse() and LoadFile() methods
|
||||
|
||||
A fast, tolerant read. Use whenever you don't need the C++ streams.
|
||||
|
||||
C++ style output:
|
||||
- based on std::ostream
|
||||
- operator<<
|
||||
|
||||
Generates condensed output, intended for network transmission rather than
|
||||
readability. Depending on your system's implementation of the ostream class,
|
||||
these may be somewhat slower. (Or may not.) Not tolerant of ill formed XML:
|
||||
a document should contain the correct one root element. Additional root level
|
||||
elements will not be streamed out.
|
||||
|
||||
C++ style input:
|
||||
- based on std::istream
|
||||
- operator>>
|
||||
|
||||
Reads XML from a stream, making it useful for network transmission. The tricky
|
||||
part is knowing when the XML document is complete, since there will almost
|
||||
certainly be other data in the stream. TinyXML will assume the XML data is
|
||||
complete after it reads the root element. Put another way, documents that
|
||||
are ill-constructed with more than one root element will not read correctly.
|
||||
Also note that operator>> is somewhat slower than Parse, due to both
|
||||
implementation of the STL and limitations of TinyXML.
|
||||
|
||||
<h3> White space </h3>
|
||||
The world simply does not agree on whether white space should be kept, or condensed.
|
||||
For example, pretend the '_' is a space, and look at "Hello____world". HTML, and
|
||||
at least some XML parsers, will interpret this as "Hello_world". They condense white
|
||||
space. Some XML parsers do not, and will leave it as "Hello____world". (Remember
|
||||
to keep pretending the _ is a space.) Others suggest that __Hello___world__ should become
|
||||
Hello___world.
|
||||
|
||||
It's an issue that hasn't been resolved to my satisfaction. TinyXML supports the
|
||||
first 2 approaches. Call TiXmlBase::SetCondenseWhiteSpace( bool ) to set the desired behavior.
|
||||
The default is to condense white space.
|
||||
|
||||
If you change the default, you should call TiXmlBase::SetCondenseWhiteSpace( bool )
|
||||
before making any calls to Parse XML data, and I don't recommend changing it after
|
||||
it has been set.
|
||||
|
||||
|
||||
<h3> Handles </h3>
|
||||
|
||||
Where browsing an XML document in a robust way, it is important to check
|
||||
for null returns from method calls. An error safe implementation can
|
||||
generate a lot of code like:
|
||||
|
||||
@verbatim
|
||||
TiXmlElement* root = document.FirstChildElement( "Document" );
|
||||
if ( root )
|
||||
{
|
||||
TiXmlElement* element = root->FirstChildElement( "Element" );
|
||||
if ( element )
|
||||
{
|
||||
TiXmlElement* child = element->FirstChildElement( "Child" );
|
||||
if ( child )
|
||||
{
|
||||
TiXmlElement* child2 = child->NextSiblingElement( "Child" );
|
||||
if ( child2 )
|
||||
{
|
||||
// Finally do something useful.
|
||||
@endverbatim
|
||||
|
||||
Handles have been introduced to clean this up. Using the TiXmlHandle class,
|
||||
the previous code reduces to:
|
||||
|
||||
@verbatim
|
||||
TiXmlHandle docHandle( &document );
|
||||
TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement();
|
||||
if ( child2 )
|
||||
{
|
||||
// do something useful
|
||||
@endverbatim
|
||||
|
||||
Which is much easier to deal with. See TiXmlHandle for more information.
|
||||
|
||||
|
||||
<h3> Row and Column tracking </h3>
|
||||
Being able to track nodes and attributes back to their origin location
|
||||
in source files can be very important for some applications. Additionally,
|
||||
knowing where parsing errors occured in the original source can be very
|
||||
time saving.
|
||||
|
||||
TinyXML can tracks the row and column origin of all nodes and attributes
|
||||
in a text file. The TiXmlBase::Row() and TiXmlBase::Column() methods return
|
||||
the origin of the node in the source text. The correct tabs can be
|
||||
configured in TiXmlDocument::SetTabSize().
|
||||
|
||||
|
||||
<h2> Using and Installing </h2>
|
||||
|
||||
To Compile and Run xmltest:
|
||||
|
||||
A Linux Makefile and a Windows Visual C++ .dsw file is provided.
|
||||
Simply compile and run. It will write the file demotest.xml to your
|
||||
disk and generate output on the screen. It also tests walking the
|
||||
DOM by printing out the number of nodes found using different
|
||||
techniques.
|
||||
|
||||
The Linux makefile is very generic and runs on many systems - it
|
||||
is currently tested on mingw and
|
||||
MacOSX. You do not need to run 'make depend'. The dependecies have been
|
||||
hard coded.
|
||||
|
||||
<h3>Windows project file for VC6</h3>
|
||||
<ul>
|
||||
<li>tinyxml: tinyxml library, non-STL </li>
|
||||
<li>tinyxmlSTL: tinyxml library, STL </li>
|
||||
<li>tinyXmlTest: test app, non-STL </li>
|
||||
<li>tinyXmlTestSTL: test app, STL </li>
|
||||
</ul>
|
||||
|
||||
<h3>Makefile</h3>
|
||||
At the top of the makefile you can set:
|
||||
|
||||
PROFILE, DEBUG, and TINYXML_USE_STL. Details (such that they are) are in
|
||||
the makefile.
|
||||
|
||||
In the tinyxml directory, type "make clean" then "make". The executable
|
||||
file 'xmltest' will be created.
|
||||
|
||||
|
||||
|
||||
<h3>To Use in an Application:</h3>
|
||||
|
||||
Add tinyxml.cpp, tinyxml.h, tinyxmlerror.cpp, tinyxmlparser.cpp, tinystr.cpp, and tinystr.h to your
|
||||
project or make file. That's it! It should compile on any reasonably
|
||||
compliant C++ system. You do not need to enable exceptions or
|
||||
RTTI for TinyXML.
|
||||
|
||||
|
||||
<h2> How TinyXML works. </h2>
|
||||
|
||||
An example is probably the best way to go. Take:
|
||||
@verbatim
|
||||
<?xml version="1.0" standalone=no>
|
||||
<!-- Our to do list data -->
|
||||
<ToDo>
|
||||
<Item priority="1"> Go to the <bold>Toy store!</bold></Item>
|
||||
<Item priority="2"> Do bills</Item>
|
||||
</ToDo>
|
||||
@endverbatim
|
||||
|
||||
Its not much of a To Do list, but it will do. To read this file
|
||||
(say "demo.xml") you would create a document, and parse it in:
|
||||
@verbatim
|
||||
TiXmlDocument doc( "demo.xml" );
|
||||
doc.LoadFile();
|
||||
@endverbatim
|
||||
|
||||
And its ready to go. Now lets look at some lines and how they
|
||||
relate to the DOM.
|
||||
|
||||
@verbatim
|
||||
<?xml version="1.0" standalone=no>
|
||||
@endverbatim
|
||||
|
||||
The first line is a declaration, and gets turned into the
|
||||
TiXmlDeclaration class. It will be the first child of the
|
||||
document node.
|
||||
|
||||
This is the only directive/special tag parsed by by TinyXML.
|
||||
Generally directive tags are stored in TiXmlUnknown so the
|
||||
commands wont be lost when it is saved back to disk.
|
||||
|
||||
@verbatim
|
||||
<!-- Our to do list data -->
|
||||
@endverbatim
|
||||
|
||||
A comment. Will become a TiXmlComment object.
|
||||
|
||||
@verbatim
|
||||
<ToDo>
|
||||
@endverbatim
|
||||
|
||||
The "ToDo" tag defines a TiXmlElement object. This one does not have
|
||||
any attributes, but does contain 2 other elements.
|
||||
|
||||
@verbatim
|
||||
<Item priority="1">
|
||||
@endverbatim
|
||||
|
||||
Creates another TiXmlElement which is a child of the "ToDo" element.
|
||||
This element has 1 attribute, with the name "priority" and the value
|
||||
"1".
|
||||
|
||||
@verbatim
|
||||
Go to the
|
||||
@endverbatim
|
||||
|
||||
A TiXmlText. This is a leaf node and cannot contain other nodes.
|
||||
It is a child of the "Item" TiXmlElement.
|
||||
|
||||
@verbatim
|
||||
<bold>
|
||||
@endverbatim
|
||||
|
||||
|
||||
Another TiXmlElement, this one a child of the "Item" element.
|
||||
|
||||
Etc.
|
||||
|
||||
Looking at the entire object tree, you end up with:
|
||||
@verbatim
|
||||
TiXmlDocument "demo.xml"
|
||||
TiXmlDeclaration "version='1.0'" "standalone=no"
|
||||
TiXmlComment " Our to do list data"
|
||||
TiXmlElement "ToDo"
|
||||
TiXmlElement "Item" Attribtutes: priority = 1
|
||||
TiXmlText "Go to the "
|
||||
TiXmlElement "bold"
|
||||
TiXmlText "Toy store!"
|
||||
TiXmlElement "Item" Attributes: priority=2
|
||||
TiXmlText "Do bills"
|
||||
@endverbatim
|
||||
|
||||
<h2> Documentation </h2>
|
||||
|
||||
The documentation is build with Doxygen, using the 'dox'
|
||||
configuration file.
|
||||
|
||||
<h2> License </h2>
|
||||
|
||||
TinyXML is released under the zlib license:
|
||||
|
||||
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.
|
||||
|
||||
<h2> References </h2>
|
||||
|
||||
The World Wide Web Consortium is the definitive standard body for
|
||||
XML, and there web pages contain huge amounts of information.
|
||||
|
||||
The definitive spec: <a href="http://www.w3.org/TR/2004/REC-xml-20040204/">
|
||||
http://www.w3.org/TR/2004/REC-xml-20040204/</a>
|
||||
|
||||
I also recommend "XML Pocket Reference" by Robert Eckstein and published by
|
||||
OReilly...the book that got the whole thing started.
|
||||
|
||||
<h2> Contributors, Contacts, and a Brief History </h2>
|
||||
|
||||
Thanks very much to everyone who sends suggestions, bugs, ideas, and
|
||||
encouragement. It all helps, and makes this project fun. A special thanks
|
||||
to the contributors on the web pages that keep it lively.
|
||||
|
||||
So many people have sent in bugs and ideas, that rather than list here
|
||||
we try to give credit due in the "changes.txt" file.
|
||||
|
||||
TinyXML was originally written by Lee Thomason. (Often the "I" still
|
||||
in the documentation.) Lee reviews changes and releases new versions,
|
||||
with the help of Yves Berquin, Andrew Ellerton, and the tinyXml community.
|
||||
|
||||
We appreciate your suggestions, and would love to know if you
|
||||
use TinyXML. Hopefully you will enjoy it and find it useful.
|
||||
Please post questions, comments, file bugs, or contact us at:
|
||||
|
||||
www.sourceforge.net/projects/tinyxml
|
||||
|
||||
Lee Thomason, Yves Berquin, Andrew Ellerton
|
||||
*/
|
||||
175
src/fileio/xml-parser/tests/mocks/TicppMock.hh
Normal file
175
src/fileio/xml-parser/tests/mocks/TicppMock.hh
Normal file
@@ -0,0 +1,175 @@
|
||||
#if !defined ( __TINY_XML_MOCK__ )
|
||||
#define __TINY_XML_MOCK__
|
||||
|
||||
namespace ticpp
|
||||
{
|
||||
namespace mock
|
||||
{
|
||||
struct Node;
|
||||
struct Element;
|
||||
struct Declaration;
|
||||
|
||||
struct NodeBase
|
||||
{
|
||||
NodeBase( void )
|
||||
{
|
||||
}
|
||||
MOCK_METHOD0( Clear, void ( void ) );
|
||||
MOCK_METHOD1( SetValue, void( const std::string& ) );
|
||||
MOCK_METHOD1( InsertEndChild, void( const Node& ) );
|
||||
MOCK_METHOD1( LinkEndChild, void( const Node* ) );
|
||||
MOCK_METHOD1( SetText, void ( const double ) );
|
||||
MOCK_METHOD1( SetText, void ( const std::string& ) );
|
||||
MOCK_METHOD1( GetValue, void ( std::string* ) );
|
||||
MOCK_METHOD1( SetIntText, void ( const unsigned int ) );
|
||||
MOCK_METHOD1( RemoveChild, void ( Node* ) );
|
||||
MOCK_CONST_METHOD0( Clone, const Node& ( void ) ); //This is done because unique_ptr's copy constructor is deleted and generates a compiler error inside googlemock.
|
||||
MOCK_CONST_METHOD0( ToElement, Element*( void ) );
|
||||
MOCK_CONST_METHOD0( NoChildren, bool ( void ) );
|
||||
MOCK_CONST_METHOD0( FirstChild, Node*( void ) );
|
||||
MOCK_CONST_METHOD1( FirstChild, Node*( const std::string& ) );
|
||||
MOCK_CONST_METHOD2( FirstChild, Node*( const std::string&, bool ) );
|
||||
MOCK_CONST_METHOD1( IterateChildren, Node*( Node* ) );
|
||||
MOCK_CONST_METHOD2( IterateChildren, Node*( const std::string, Node* ) );
|
||||
MOCK_CONST_METHOD0( FirstChildElement, Element*() );
|
||||
MOCK_CONST_METHOD1( FirstChildElement, Element*( bool ) );
|
||||
MOCK_CONST_METHOD0( Value, std::string( void ) );
|
||||
virtual ~NodeBase( void )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct Node : public StrictMock< NodeBase >
|
||||
{
|
||||
//This is the work around for the Clone method not returning unique_ptr.
|
||||
const Node* release( void ) const
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
Node( void ) : StrictMock< NodeBase >()
|
||||
{
|
||||
}
|
||||
|
||||
Node( const Node& ) : StrictMock< NodeBase >()
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==( const Node& other ) const
|
||||
{
|
||||
return *this == other;
|
||||
}
|
||||
virtual ~Node( void )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct ElementBase : public Node
|
||||
{
|
||||
ElementBase( const std::string& ) : Node()
|
||||
{
|
||||
}
|
||||
MOCK_CONST_METHOD1( GetAttribute, std::string( const std::string& ) );
|
||||
MOCK_CONST_METHOD2( GetAttribute, std::string( std::string, bool ) );
|
||||
MOCK_METHOD2( SetAttribute, void ( const std::string&, const int ) );
|
||||
MOCK_METHOD2( SetAttribute, void ( const std::string&, const std::string& ) );
|
||||
MOCK_CONST_METHOD0( GetText, std::string( void ) );
|
||||
MOCK_CONST_METHOD1( GetText, std::string( bool ) );
|
||||
virtual ~ElementBase( void )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct Element : public StrictMock< ElementBase >
|
||||
{
|
||||
explicit Element( const std::string& name = std::string() ) : StrictMock< ElementBase >( name )
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==( const Element& other ) const
|
||||
{
|
||||
return *this == other;
|
||||
}
|
||||
virtual ~Element( void )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct DocumentBase : public Node
|
||||
{
|
||||
DocumentBase( void ) : Node()
|
||||
{
|
||||
}
|
||||
DocumentBase( const std::string& ) : Node()
|
||||
{
|
||||
}
|
||||
MOCK_METHOD0( SaveFile, void ( void ) );
|
||||
MOCK_METHOD1( SaveFile, void ( const std::string& ) );
|
||||
MOCK_METHOD0( LoadFile, void ( void ) );
|
||||
MOCK_METHOD1( LoadFile, void ( const std::string& ) );
|
||||
MOCK_METHOD1( Parse, void ( const std::string& ) );
|
||||
|
||||
virtual ~DocumentBase( void )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct Document : public StrictMock< DocumentBase >
|
||||
{
|
||||
Document( void ) : StrictMock< DocumentBase >()
|
||||
{
|
||||
}
|
||||
Document( const std::string& name ) : StrictMock< DocumentBase >( name )
|
||||
{
|
||||
}
|
||||
MOCK_CONST_METHOD0( GetDocument, Document*( void ) );
|
||||
virtual ~Document( void )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct DeclarationBase : public Node
|
||||
{
|
||||
DeclarationBase( void ) : Node()
|
||||
{
|
||||
}
|
||||
|
||||
DeclarationBase( const std::string&, const std::string&, const std::string& ) : Node()
|
||||
{
|
||||
}
|
||||
virtual ~DeclarationBase( void )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct Declaration : public StrictMock< DeclarationBase >
|
||||
{
|
||||
Declaration( void ) : StrictMock< DeclarationBase >()
|
||||
{
|
||||
}
|
||||
|
||||
Declaration( const std::string& p1, const std::string& p2, const std::string& p3 ) : StrictMock< DeclarationBase >( p1, p2, p3 )
|
||||
{
|
||||
}
|
||||
virtual ~Declaration( void )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct Comment : public Node
|
||||
{
|
||||
Comment( void )
|
||||
{
|
||||
}
|
||||
virtual ~Comment( void )
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
inline std::ostream& operator << ( std::ostream& os, const Node& )
|
||||
{
|
||||
return( os );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // !defined ( __TINY_XML_MOCK__ )
|
||||
@@ -23,61 +23,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#ifdef TIXML_USE_TICPP
|
||||
|
||||
#include "ticpp.h"
|
||||
#include "ticpprc.h"
|
||||
#include "tinyxml.h"
|
||||
#include <sstream>
|
||||
|
||||
using namespace ticpp;
|
||||
|
||||
// In the following Visitor functions, casting away const should be safe, as the object can only be referred to by a const &
|
||||
bool Visitor::VisitEnter( const TiXmlDocument& doc )
|
||||
{
|
||||
return VisitEnter( Document( const_cast< TiXmlDocument* >( &doc ) ) );
|
||||
}
|
||||
|
||||
bool Visitor::VisitExit( const TiXmlDocument& doc )
|
||||
{
|
||||
return VisitEnter( Document( const_cast< TiXmlDocument* >( &doc ) ) );
|
||||
}
|
||||
|
||||
bool Visitor::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute )
|
||||
{
|
||||
if ( 0 != firstAttribute )
|
||||
{
|
||||
Attribute attribute( const_cast< TiXmlAttribute* >( firstAttribute ) );
|
||||
return VisitEnter( Element( const_cast< TiXmlElement* >( &element ) ), &attribute );
|
||||
}
|
||||
else
|
||||
{
|
||||
return VisitEnter( Element( const_cast< TiXmlElement* >( &element ) ), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
bool Visitor::VisitExit( const TiXmlElement& element )
|
||||
{
|
||||
return VisitExit( Element( const_cast< TiXmlElement* >( &element ) ) );
|
||||
}
|
||||
|
||||
bool Visitor::Visit( const TiXmlDeclaration& declaration )
|
||||
{
|
||||
return Visit( Declaration( const_cast< TiXmlDeclaration* >( &declaration ) ) );
|
||||
}
|
||||
|
||||
bool Visitor::Visit( const TiXmlStylesheetReference& stylesheet )
|
||||
{
|
||||
return Visit( StylesheetReference( const_cast< TiXmlStylesheetReference* >( &stylesheet ) ) );
|
||||
}
|
||||
|
||||
bool Visitor::Visit( const TiXmlText& text )
|
||||
{
|
||||
return Visit( Text( const_cast< TiXmlText* >( &text ) ) );
|
||||
}
|
||||
|
||||
bool Visitor::Visit( const TiXmlComment& comment )
|
||||
{
|
||||
return Visit( Comment( const_cast< TiXmlComment* >( &comment ) ) );
|
||||
}
|
||||
|
||||
Attribute::Attribute()
|
||||
{
|
||||
SetTiXmlPointer( new TiXmlAttribute() );
|
||||
@@ -108,18 +56,6 @@ void Attribute::operator=( const Attribute& copy )
|
||||
this->m_impRC->IncRef();
|
||||
}
|
||||
|
||||
Attribute::Attribute( const Attribute& copy ) : Base()
|
||||
{
|
||||
// Dropping the reference to the old object
|
||||
this->m_impRC->DecRef();
|
||||
|
||||
// Pointing to the new Object
|
||||
SetTiXmlPointer( copy.m_tiXmlPointer );
|
||||
|
||||
// The internal tixml pointer changed in the above line
|
||||
this->m_impRC->IncRef();
|
||||
}
|
||||
|
||||
Attribute::~Attribute()
|
||||
{
|
||||
m_impRC->DecRef();
|
||||
@@ -716,14 +652,14 @@ StylesheetReference* Node::ToStylesheetReference() const
|
||||
return temp;
|
||||
}
|
||||
|
||||
std::auto_ptr< Node > Node::Clone() const
|
||||
std::unique_ptr< Node > Node::Clone() const
|
||||
{
|
||||
TiXmlNode* node = GetTiXmlPointer()->Clone();
|
||||
if ( 0 == node )
|
||||
{
|
||||
TICPPTHROW( "Node could not be cloned" );
|
||||
}
|
||||
std::auto_ptr< Node > temp( NodeFactory( node, false, false ) );
|
||||
std::unique_ptr< Node > temp( NodeFactory( node, false, false ) );
|
||||
|
||||
// Take ownership of the memory from TiXml
|
||||
temp->m_impRC->InitRef();
|
||||
@@ -758,19 +694,17 @@ Comment::Comment( const std::string& comment )
|
||||
|
||||
//*****************************************************************************
|
||||
|
||||
Text::Text(bool cdata)
|
||||
Text::Text()
|
||||
: NodeImp< TiXmlText >( new TiXmlText("") )
|
||||
{
|
||||
m_impRC->InitRef();
|
||||
if(cdata) m_tiXmlPointer->SetCDATA(true);
|
||||
}
|
||||
|
||||
|
||||
Text::Text( const std::string& value, bool cdata )
|
||||
Text::Text( const std::string& value )
|
||||
: NodeImp< TiXmlText >( new TiXmlText( value ) )
|
||||
{
|
||||
m_impRC->InitRef();
|
||||
if(cdata) m_tiXmlPointer->SetCDATA(true);
|
||||
}
|
||||
|
||||
Text::Text( TiXmlText* text )
|
||||
@@ -812,8 +746,7 @@ void Document::LoadFile( TiXmlEncoding encoding )
|
||||
}
|
||||
}
|
||||
|
||||
void Document::SaveFile( void ) const
|
||||
{
|
||||
void Document::SaveFile() const {
|
||||
if ( !m_tiXmlPointer->SaveFile() )
|
||||
{
|
||||
TICPPTHROW( "Couldn't save " << m_tiXmlPointer->Value() );
|
||||
@@ -1095,11 +1028,11 @@ void TiCppRC::DeleteSpawnedWrappers()
|
||||
}
|
||||
m_spawnedWrappers.clear();
|
||||
}
|
||||
|
||||
|
||||
TiCppRC::~TiCppRC()
|
||||
{
|
||||
{
|
||||
DeleteSpawnedWrappers();
|
||||
|
||||
|
||||
// Set pointer held by reference counter to NULL
|
||||
this->m_tiRC->Nullify();
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* - added ticppapi.h include and TICPP_API dll-interface to support building DLL using VS200X
|
||||
*/
|
||||
|
||||
|
||||
#ifndef TIXML_USE_TICPP
|
||||
#define TIXML_USE_TICPP
|
||||
#endif
|
||||
@@ -52,13 +52,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#ifndef TICPP_INCLUDED
|
||||
#define TICPP_INCLUDED
|
||||
|
||||
#include "ticppapi.h"
|
||||
#include "tinyxml.h"
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include <memory>
|
||||
#include <exception>
|
||||
#include <typeinfo>
|
||||
|
||||
/**
|
||||
@subpage ticpp is a TinyXML wrapper that uses a lot more C++ ideals.
|
||||
@@ -113,49 +109,6 @@ namespace ticpp
|
||||
class TICPP_API Comment;
|
||||
class TICPP_API Attribute;
|
||||
|
||||
/** Wrapper around TiXmlVisitor */
|
||||
class TICPP_API Visitor : public TiXmlVisitor
|
||||
{
|
||||
public:
|
||||
// Overload the TiXmlVisitor functions, wrap objects, call ticpp::Visitor functions
|
||||
/// @internal
|
||||
virtual bool VisitEnter( const TiXmlDocument& doc );
|
||||
/// @internal
|
||||
virtual bool VisitExit( const TiXmlDocument& doc );
|
||||
/// @internal
|
||||
virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
|
||||
/// @internal
|
||||
virtual bool VisitExit( const TiXmlElement& element );
|
||||
/// @internal
|
||||
virtual bool Visit( const TiXmlDeclaration& declaration );
|
||||
/// @internal
|
||||
virtual bool Visit( const TiXmlStylesheetReference& stylesheet );
|
||||
/// @internal
|
||||
virtual bool Visit( const TiXmlText& text );
|
||||
/// @internal
|
||||
virtual bool Visit( const TiXmlComment& comment );
|
||||
|
||||
public:
|
||||
/// Visit a document.
|
||||
virtual bool VisitEnter( const Document& /*doc*/ ) { return true; }
|
||||
/// Visit a document.
|
||||
virtual bool VisitExit( const Document& /*doc*/ ) { return true; }
|
||||
|
||||
/// Visit an element.
|
||||
virtual bool VisitEnter( const Element& /*element*/, const Attribute* /*firstAttribute*/ ) { return true; }
|
||||
/// Visit an element.
|
||||
virtual bool VisitExit( const Element& /*element*/ ) { return true; }
|
||||
|
||||
/// Visit a declaration
|
||||
virtual bool Visit( const Declaration& /*declaration*/ ) { return true; }
|
||||
/// Visit a stylesheet reference
|
||||
virtual bool Visit( const StylesheetReference& /*stylesheet*/ ) { return true; }
|
||||
/// Visit a text node
|
||||
virtual bool Visit( const Text& /*text*/ ) { return true; }
|
||||
/// Visit a comment node
|
||||
virtual bool Visit( const Comment& /*comment*/ ) { return true; }
|
||||
};
|
||||
|
||||
/** Wrapper around TiXmlBase */
|
||||
class TICPP_API Base
|
||||
{
|
||||
@@ -263,12 +216,6 @@ namespace ticpp
|
||||
<< "\nLine: " << doc->ErrorRow()
|
||||
<< "\nColumn: " << doc->ErrorCol();
|
||||
}
|
||||
else
|
||||
{
|
||||
full_message << "\nFile: " << (strlen( doc->Value() ) > 0 ? doc->Value() : "<unnamed-file>")
|
||||
<< "\nLine: " << node->Row()
|
||||
<< "\nColumn: " << node->Column();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -422,11 +369,7 @@ namespace ticpp
|
||||
*/
|
||||
void operator=( const Attribute& copy );
|
||||
|
||||
/**
|
||||
@internal
|
||||
Updates the reference count for the old and new pointers.
|
||||
*/
|
||||
Attribute( const Attribute& copy );
|
||||
Attribute( const Attribute& copy ) = delete;
|
||||
|
||||
/*
|
||||
Decrements reference count.
|
||||
@@ -981,13 +924,13 @@ namespace ticpp
|
||||
/**
|
||||
Create an exact duplicate of this node and return it.
|
||||
|
||||
@note Using auto_ptr to manage the memory declared on the heap by TiXmlNode::Clone.
|
||||
@note Using unique_ptr to manage the memory declared on the heap by TiXmlNode::Clone.
|
||||
@code
|
||||
// Now using clone
|
||||
ticpp::Document doc( "C:\\Test.xml" );
|
||||
ticpp::Node* sectionToClone;
|
||||
sectionToClone = doc.FirstChild( "settings" );
|
||||
std::auto_ptr< ticpp::Node > clonedNode = sectionToClone->Clone();
|
||||
std::unique_ptr< ticpp::Node > clonedNode = sectionToClone->Clone();
|
||||
// Now you can use the clone.
|
||||
ticpp::Node* node2 = clonedNode->FirstChildElement()->FirstChild();
|
||||
...
|
||||
@@ -995,7 +938,7 @@ namespace ticpp
|
||||
@endcode
|
||||
@return Pointer the duplicate node.
|
||||
*/
|
||||
std::auto_ptr< Node > Clone() const;
|
||||
std::unique_ptr< Node > Clone() const;
|
||||
|
||||
/**
|
||||
Accept a hierchical visit the nodes in the TinyXML DOM.
|
||||
@@ -1361,7 +1304,7 @@ namespace ticpp
|
||||
/**
|
||||
Constructor.
|
||||
*/
|
||||
explicit Text(bool cdata = false);
|
||||
Text();
|
||||
|
||||
/**
|
||||
Constructor.
|
||||
@@ -1373,7 +1316,7 @@ namespace ticpp
|
||||
Constructor.
|
||||
@overload
|
||||
*/
|
||||
Text( const std::string& value, bool cdata = false );
|
||||
Text( const std::string& value );
|
||||
|
||||
/**
|
||||
Streams value into a string and creates a Text with it.
|
||||
@@ -1385,19 +1328,10 @@ namespace ticpp
|
||||
@see TiXmlText
|
||||
*/
|
||||
template < class T >
|
||||
Text( const T& value, bool cdata = false )
|
||||
Text( const T& value )
|
||||
: NodeImp< TiXmlText >( new TiXmlText( ToString( value ) ) )
|
||||
{
|
||||
m_impRC->InitRef();
|
||||
if(cdata) m_tiXmlPointer->SetCDATA(true);
|
||||
}
|
||||
|
||||
void SetCdata(bool cdata) {
|
||||
m_tiXmlPointer->SetCDATA(cdata);
|
||||
}
|
||||
|
||||
bool isCdata() const {
|
||||
return m_tiXmlPointer->CDATA();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
131
src/fileio/xml-parser/ticpp4.lua
Normal file
131
src/fileio/xml-parser/ticpp4.lua
Normal file
@@ -0,0 +1,131 @@
|
||||
--*****************************************************************************
|
||||
--* Author: RJP Computing <rjpcomputing@gmail.com>
|
||||
--* Date: 01/21/2008
|
||||
--* Version: 1.02
|
||||
--* Copyright (C) 2009 RJP Computing
|
||||
--*
|
||||
--* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
--* this software and associated documentation files (the "Software"), to deal in
|
||||
--* the Software without restriction, including without limitation the rights to
|
||||
--* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
--* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
--* subject to the following conditions:
|
||||
--*
|
||||
--* The above copyright notice and this permission notice shall be included in all
|
||||
--* copies or substantial portions of the Software.
|
||||
--*
|
||||
--* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
--* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
--* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
--* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
--* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
--* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
--*
|
||||
--* NOTES:
|
||||
--* - use the '/' slash for all paths.
|
||||
--*****************************************************************************
|
||||
|
||||
|
||||
--
|
||||
-- Package options
|
||||
--
|
||||
newoption
|
||||
{
|
||||
trigger = "ticpp-shared",
|
||||
description = "Build TinyXML++ as a dll"
|
||||
}
|
||||
|
||||
ticpp = {}
|
||||
|
||||
function ticpp.GetCustomValue( item )
|
||||
local prj = project()
|
||||
for _, block in pairs( prj.blocks ) do
|
||||
if block[item] then
|
||||
return block[item]
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Set the name of your package.
|
||||
project "TiCPP"
|
||||
|
||||
-- Set the files to include/exclude.
|
||||
files { "*.cpp", "*.h" }
|
||||
excludes { "xmltest.cpp" }
|
||||
|
||||
-- Set the defines.
|
||||
defines { "TIXML_USE_TICPP" }
|
||||
|
||||
-- Common setup
|
||||
language "C++"
|
||||
flags { "ExtraWarnings" }
|
||||
|
||||
--
|
||||
-- TinyXML++ dll
|
||||
--
|
||||
if _OPTIONS["ticpp-shared"] then
|
||||
kind "SharedLib"
|
||||
else
|
||||
kind "StaticLib"
|
||||
if not ticpp.GetCustomValue( "targetdir" ) then
|
||||
targetdir( solution().basedir .. "/lib" )
|
||||
end
|
||||
end
|
||||
|
||||
--
|
||||
-- Dynamic Runtime
|
||||
--
|
||||
if not _OPTIONS["dynamic-runtime"] then
|
||||
flags { "StaticRuntime" }
|
||||
end
|
||||
|
||||
--
|
||||
-- Operating Systems specific
|
||||
--
|
||||
if os.is( "windows" ) then
|
||||
defines { "WIN32", "_WINDOWS" }
|
||||
else
|
||||
excludes { "**.rc" } -- Ignore resource files in Linux.
|
||||
buildoptions { "-fPIC" }
|
||||
end
|
||||
|
||||
--
|
||||
-- Unicode
|
||||
--
|
||||
configuration "unicode"
|
||||
flags { "Unicode" }
|
||||
defines { "UNICODE", "_UNICODE" }
|
||||
|
||||
--
|
||||
-- GCC compilers
|
||||
--
|
||||
configuration { "code*", "gmake" }
|
||||
objdir ".obj"
|
||||
buildoptions { "-O0" }
|
||||
|
||||
--
|
||||
-- Visual Studio
|
||||
--
|
||||
configuration "vs*"
|
||||
-- Windows and Visual C++ 2005/2008
|
||||
defines { "_CRT_SECURE_NO_DEPRECATE" }
|
||||
|
||||
configuration( "vs*", "not vs2005" )
|
||||
-- multi-process building
|
||||
flags( "NoMinimalRebuild" )
|
||||
buildoptions( "-MP" )
|
||||
|
||||
--
|
||||
-- Release/Debug
|
||||
--
|
||||
|
||||
-- Set the targets.
|
||||
configuration "Release"
|
||||
targetname ( "ticpp" )
|
||||
defines { "NDEBUG" }
|
||||
flags { "OptimizeSpeed" }
|
||||
configuration "Debug"
|
||||
targetname ( "ticppd" )
|
||||
defines { "DEBUG", "_DEBUG" }
|
||||
flags { "Symbols" }
|
||||
@@ -24,27 +24,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#undef TICPP_API
|
||||
|
||||
#if defined(_WIN32) | defined(WIN32) | defined(WINDOWS) | defined(_WINDOWS)
|
||||
//windows dll defines
|
||||
#include <windows.h>
|
||||
|
||||
#if defined(_WIN32) | defined(WIN32) | defined(WINDOWS) | defined(_WINDOWS)
|
||||
// define BUILD_TICPP_DLL when building TiCPP dll.
|
||||
#ifdef BUILD_TICPP_DLL
|
||||
#define TICPP_API __declspec(dllexport)
|
||||
#endif
|
||||
|
||||
|
||||
// define TICPP_DLL when linking TiCPP dll.
|
||||
#ifdef TICPP_DLL
|
||||
#define TICPP_API __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
|
||||
// Disable dll-interface warning
|
||||
#ifdef TICPP_API
|
||||
#pragma warning( push )
|
||||
#pragma warning( disable : 4251 ) // X needs to have dll-interface to be used by clients of class Y
|
||||
#pragma warning( disable : 4275 ) // X is derived from class Y but only X is exported
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef TICPP_API
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <ios>
|
||||
|
||||
namespace ticpp {
|
||||
class Printer : public Visitor {
|
||||
class Printer : public TiXmlVisitor {
|
||||
Document doc;
|
||||
std::ostream& stream;
|
||||
std::stack<Element*> openElements;
|
||||
@@ -33,7 +33,9 @@ namespace ticpp {
|
||||
openElements.top()->SetAttribute(attrName, boost::lexical_cast<std::string>(attrVal));
|
||||
}
|
||||
template<typename T> void PushText(T textVal, bool cdata = false) {
|
||||
PushNode(new Text(boost::lexical_cast<std::string>(textVal), cdata));
|
||||
TiXmlText* text = new TiXmlText(boost::lexical_cast<std::string>(textVal));
|
||||
text->SetCDATA(cdata);
|
||||
PushNode(new Text(text));
|
||||
}
|
||||
template<typename T> void PushElement(std::string tagName, T elemVal, bool cdata = false) {
|
||||
OpenElement(tagName);
|
||||
|
||||
@@ -23,7 +23,7 @@ distribution.
|
||||
*/
|
||||
|
||||
/*
|
||||
* THIS FILE WAS ALTERED BY Tyge L<EFBFBD>vset, 7. April 2005.
|
||||
* THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ distribution.
|
||||
*/
|
||||
#include "tinyxml.h"
|
||||
|
||||
#include <ctype.h>
|
||||
#include <cctype>
|
||||
|
||||
#ifdef TIXML_USE_STL
|
||||
#include <sstream>
|
||||
@@ -130,9 +130,7 @@ void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase()
|
||||
{
|
||||
TiXmlNode::TiXmlNode(NodeType _type) {
|
||||
parent = 0;
|
||||
type = _type;
|
||||
firstChild = 0;
|
||||
@@ -1604,6 +1602,7 @@ void TiXmlAttributeSet::Add( TiXmlAttribute* addMe )
|
||||
|
||||
void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe )
|
||||
{
|
||||
assert(removeMe);
|
||||
TiXmlAttribute* node;
|
||||
|
||||
for( node = sentinel.next; node != &sentinel; node = node->next )
|
||||
@@ -1685,7 +1684,7 @@ std::istream& operator>> (std::istream & in, TiXmlNode & base)
|
||||
std::ostream& operator<< (std::ostream & out, const TiXmlNode & base)
|
||||
{
|
||||
TiXmlPrinter printer;
|
||||
//printer.SetStreamPrinting();
|
||||
printer.SetStreamPrinting();
|
||||
base.Accept( &printer );
|
||||
out << printer.Str();
|
||||
|
||||
|
||||
@@ -38,11 +38,8 @@ distribution.
|
||||
#endif
|
||||
|
||||
#include "ticppapi.h"
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
|
||||
// Help out windows:
|
||||
#if defined( _DEBUG ) && !defined( DEBUG )
|
||||
|
||||
@@ -22,11 +22,10 @@ must not be misrepresented as being the original software.
|
||||
distribution.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "tinyxml.h"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
//#define DEBUG_PARSER
|
||||
#if defined( DEBUG_PARSER )
|
||||
# if defined( DEBUG ) && defined( _MSC_VER )
|
||||
@@ -104,21 +103,23 @@ void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* leng
|
||||
|
||||
output += *length;
|
||||
|
||||
// Scary scary fall throughs.
|
||||
switch (*length)
|
||||
{
|
||||
case 4:
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
input >>= 6;
|
||||
[[fallthrough]];
|
||||
case 3:
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
input >>= 6;
|
||||
[[fallthrough]];
|
||||
case 2:
|
||||
--output;
|
||||
*output = (char)((input | BYTE_MARK) & BYTE_MASK);
|
||||
input >>= 6;
|
||||
[[fallthrough]];
|
||||
case 1:
|
||||
--output;
|
||||
*output = (char)(input | FIRST_BYTE_MARK[*length]);
|
||||
|
||||
Reference in New Issue
Block a user