mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
Merge branch 'master' into master
This commit is contained in:
commit
c160db4ef6
|
@ -1,8 +1,8 @@
|
|||
version: '{build}'
|
||||
version: "{build}"
|
||||
os: Visual Studio 2015
|
||||
|
||||
cache:
|
||||
- vcpkg -> .appveyor.yml
|
||||
- vcpkg -> .appveyor.yml
|
||||
|
||||
platform:
|
||||
- x64
|
||||
|
@ -12,15 +12,16 @@ configuration:
|
|||
|
||||
environment:
|
||||
matrix:
|
||||
- STATIC: OFF
|
||||
- STATIC: ON
|
||||
|
||||
- STATIC: OFF
|
||||
- STATIC: ON
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
init: []
|
||||
|
||||
before_build:
|
||||
- git submodule update --init --recursive
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -G "Visual Studio 14 2015" -D CMAKE_GENERATOR_PLATFORM=%platform% -D STATIC=%STATIC% -D SAMPLES=ON -D BENCHMARKS=ON ..
|
||||
|
|
|
@ -25,25 +25,26 @@ jobs:
|
|||
type: string
|
||||
steps:
|
||||
- checkout
|
||||
- run: git submodule update --init --recursive
|
||||
- run: cmake -D XLNT_CXX_LANG=<< parameters.cxx-ver >> -D STATIC=<< parameters.static >> -D BENCHMARKS=<< parameters.benchmarks >> -D SAMPLES=<< parameters.samples >> -D COVERAGE=<< parameters.coverage >> -D CMAKE_BUILD_TYPE=<< parameters.build-type >> .
|
||||
- run: cmake --build . -- -j2
|
||||
- run: ./tests/xlnt.test
|
||||
- when:
|
||||
condition:
|
||||
equal: [ "ON", << parameters.samples >> ]
|
||||
equal: ["ON", << parameters.samples >>]
|
||||
steps:
|
||||
- run: ./samples/sample-decrypt
|
||||
- run: ./samples/sample-img2xlsx ./samples/data/penguin.jpg img.xlsx
|
||||
- run: ./samples/sample-documentation
|
||||
- when:
|
||||
condition:
|
||||
equal: [ "ON", << parameters.benchmarks >> ]
|
||||
equal: ["ON", << parameters.benchmarks >>]
|
||||
steps:
|
||||
- run: ./benchmarks/benchmark-styles
|
||||
- run: ./benchmarks/benchmark-writer
|
||||
- when:
|
||||
condition:
|
||||
equal: [ "ON", << parameters.coverage >> ]
|
||||
equal: ["ON", << parameters.coverage >>]
|
||||
steps:
|
||||
- run: lcov --directory source/CMakeFiles/xlnt.dir --capture --output-file coverage.info --base-directory ../source --no-external --gcov-tool /usr/bin/gcov-6
|
||||
- run: lcov --output-file coverage.info --remove coverage.info source/detail/serialization/miniz.cpp
|
||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -0,0 +1,3 @@
|
|||
[submodule "third-party/libstudxml"]
|
||||
path = third-party/libstudxml
|
||||
url = https://git.codesynthesis.com/libstudxml/libstudxml.git
|
|
@ -32,6 +32,9 @@
|
|||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
#undef min
|
||||
#undef max
|
||||
|
||||
namespace xlnt {
|
||||
namespace detail {
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ set(XLNT_SOURCE_DIR ${XLNT_ROOT_DIR}/source)
|
|||
set(THIRD_PARTY_DIR ${XLNT_ROOT_DIR}/third-party)
|
||||
|
||||
# Include libstudxml library
|
||||
add_subdirectory(${THIRD_PARTY_DIR}/libstudxml
|
||||
add_subdirectory(${THIRD_PARTY_DIR}/libstudxml.build
|
||||
${CMAKE_CURRENT_BINARY_DIR}/third-party/libstudxml)
|
||||
|
||||
if(COVERAGE)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#pragma clang diagnostic ignored "-Wweak-vtables"
|
||||
#pragma clang diagnostic ignored "-Wextra-semi"
|
||||
#pragma clang diagnostic ignored "-Wdeprecated"
|
||||
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant"
|
||||
#include <libstudxml/content.hxx>
|
||||
#include <libstudxml/parser.hxx>
|
||||
#include <libstudxml/qname.hxx>
|
||||
|
|
|
@ -3180,6 +3180,12 @@ rich_text xlsx_consumer::read_rich_text(const xml::qname &parent)
|
|||
run.second.get().underline(font::underline_style::single);
|
||||
}
|
||||
}
|
||||
else if (current_run_property_element == xml::qname(xmlns, "strike"))
|
||||
{
|
||||
run.second.get().strikethrough(parser().attribute_present("val")
|
||||
? is_true(parser().attribute("val"))
|
||||
: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
unexpected_element(current_run_property_element);
|
||||
|
|
|
@ -126,11 +126,10 @@ date date::today()
|
|||
|
||||
int date::weekday() const
|
||||
{
|
||||
#ifndef _MSC_VER
|
||||
std::tm tm{0, 0, 0, day, month - 1, year - 1900, 0, 0, 0, 0, nullptr};
|
||||
#else
|
||||
std::tm tm{0, 0, 0, day, month - 1, year - 1900, 0, 0, 0};
|
||||
#endif
|
||||
std::tm tm{0};
|
||||
tm.tm_mday = day;
|
||||
tm.tm_mon = month - 1;
|
||||
tm.tm_year = year - 1900;
|
||||
std::time_t time = std::mktime(&tm);
|
||||
|
||||
return safe_localtime(time).tm_wday;
|
||||
|
|
BIN
tests/data/excel_test_sheet.xlsx
Normal file
BIN
tests/data/excel_test_sheet.xlsx
Normal file
Binary file not shown.
|
@ -95,6 +95,7 @@ public:
|
|||
register_test(test_Issue445_inline_str_streaming_read);
|
||||
register_test(test_Issue492_stream_empty_row);
|
||||
register_test(test_Issue503_external_link_load);
|
||||
register_test(test_formatting);
|
||||
}
|
||||
|
||||
bool workbook_matches_file(xlnt::workbook &wb, const xlnt::path &file)
|
||||
|
@ -764,6 +765,45 @@ public:
|
|||
auto cell = ws.cell("A1");
|
||||
xlnt_assert_equals(cell.value<std::string>(), std::string("WDG_IC_00000003.aut"));
|
||||
}
|
||||
|
||||
void test_formatting()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
wb.load(path_helper::test_file("excel_test_sheet.xlsx"));
|
||||
auto ws = wb.active_sheet();
|
||||
auto cell = ws.cell("A1");
|
||||
|
||||
xlnt_assert_equals(cell.value<std::string>(), std::string("Bolder Text mixed with normal \ntext first line Bold And Underline"));
|
||||
|
||||
auto rt = cell.value<xlnt::rich_text>();
|
||||
xlnt_assert_equals(rt.runs().size(), 12);
|
||||
|
||||
auto assert_run = [](xlnt::rich_text_run run, std::string text, std::string typeface, xlnt::color color, std::size_t size, bool bold, bool strike, xlnt::font::underline_style underline)
|
||||
{
|
||||
xlnt_assert_equals(run.first, text);
|
||||
xlnt_assert(run.second.is_set());
|
||||
auto font = run.second.get();
|
||||
xlnt_assert_equals(font.name(), typeface);
|
||||
xlnt_assert_equals(font.size(), size);
|
||||
xlnt_assert_equals(font.bold(), bold);
|
||||
xlnt_assert_equals(font.color(), color);
|
||||
xlnt_assert_equals(font.strikethrough(), strike);
|
||||
xlnt_assert_equals(font.underline(), underline);
|
||||
};
|
||||
|
||||
assert_run(rt.runs()[0], "Bolder", "Calibri (Body)", xlnt::theme_color(1), 12, true, false, xlnt::font::underline_style::none);
|
||||
assert_run(rt.runs()[1], " Text ", "Calibri", xlnt::theme_color(1), 12, true, false, xlnt::font::underline_style::none);
|
||||
assert_run(rt.runs()[2], "mixed ", "Calibri", xlnt::color::red(), 12, false, false, xlnt::font::underline_style::none);
|
||||
assert_run(rt.runs()[3], "wit", "Calibri (Body)", xlnt::color::red(), 12, false, false, xlnt::font::underline_style::single);
|
||||
assert_run(rt.runs()[4], "h", "Calibri", xlnt::color::red(), 12, false, false, xlnt::font::underline_style::single);
|
||||
assert_run(rt.runs()[5], " ", "Calibri", xlnt::color::red(), 12, false, false, xlnt::font::underline_style::none);
|
||||
assert_run(rt.runs()[6], "normal", "Calibri (Body)", xlnt::color::red(), 12, false, false, xlnt::font::underline_style::none);
|
||||
assert_run(rt.runs()[7], " ", "Calibri", xlnt::color::red(), 12, false, false, xlnt::font::underline_style::none);
|
||||
assert_run(rt.runs()[8], "\n", "Calibri", xlnt::theme_color(1), 12, false, false, xlnt::font::underline_style::none);
|
||||
assert_run(rt.runs()[9], "text", "Helvetica Neue", xlnt::theme_color(1), 12, false, true, xlnt::font::underline_style::none);
|
||||
assert_run(rt.runs()[10], " first line ", "Calibri", xlnt::theme_color(1), 12, true, false, xlnt::font::underline_style::none);
|
||||
assert_run(rt.runs()[11], "Bold And Underline", "Calibri (Body)", xlnt::theme_color(1), 12, true, false, xlnt::font::underline_style::single);
|
||||
}
|
||||
};
|
||||
|
||||
static serialization_test_suite x;
|
||||
|
|
1
third-party/libstudxml
vendored
Submodule
1
third-party/libstudxml
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit e729667b0f34a39ce4a61339843af4154648667b
|
|
@ -5,8 +5,8 @@ project(libstudxml)
|
|||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
set(LIBSTUDXML_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set(LIBSTUDXML_INCLUDE_DIR ${LIBSTUDXML_ROOT_DIR})
|
||||
set(LIBSTUDXML_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libstudxml)
|
||||
set(LIBSTUDXML_INCLUDE_DIR ${LIBSTUDXML_ROOT_DIR}/../libstudxml)
|
||||
|
||||
if(STATIC_CRT)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/ucm.cmake)
|
31
third-party/libstudxml/LICENSE
vendored
31
third-party/libstudxml/LICENSE
vendored
|
@ -1,31 +0,0 @@
|
|||
Summary: Everything is licensed under the MIT License (text below).
|
||||
|
||||
Code found in the xml/details/expat/ directory is distributed under
|
||||
the MIT License (see the xml/details/expat/LICENSE file for copyright
|
||||
information).
|
||||
|
||||
Code found in the xml/details/genx/ directory is distributed under
|
||||
the MIT License (see the xml/details/genx/LICENSE file for copyright
|
||||
information).
|
||||
|
||||
The rest is Copyright (c) 2013-2019 Code Synthesis Tools CC and is
|
||||
distributed under the MIT License:
|
||||
|
||||
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.
|
82
third-party/libstudxml/libstudxml/buildfile
vendored
82
third-party/libstudxml/libstudxml/buildfile
vendored
|
@ -1,82 +0,0 @@
|
|||
# file : libstudxml/buildfile
|
||||
# copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
# license : MIT; see accompanying LICENSE file
|
||||
|
||||
lib{studxml}: {hxx ixx txx cxx}{** -version} {hxx}{version} \
|
||||
details/{h}{config*}
|
||||
|
||||
# Expat. Note that we treat a whole bunch of its sources as files since they
|
||||
# are private and #include's (including .c file).
|
||||
#
|
||||
lib{studxml}: details/expat/{ \
|
||||
h{expat expat_external} \
|
||||
c{xmlparse xmlrole xmltok} \
|
||||
file{ascii.h asciitab.h config.h iasciitab.h internal.h latin1tab.h nametab.h \
|
||||
utf8tab.h xmlrole.h xmltok.h xmltok_impl.h xmltok_impl.c xmltok_ns.c} \
|
||||
doc{LICENSE README} \
|
||||
}
|
||||
|
||||
details/expat/doc{README}@./: install = false
|
||||
details/expat/doc{LICENSE}@./: install = doc/EXPAT-LICENSE
|
||||
|
||||
# Genx.
|
||||
#
|
||||
lib{studxml}: details/genx/{h{*} c{*} doc{LICENSE README}}
|
||||
|
||||
# Include the generated version header into the distribution (so that we don't
|
||||
# pick up an installed one) and don't remove it when cleaning in src (so that
|
||||
# clean results in a state identical to distributed).
|
||||
#
|
||||
hxx{version}: in{version} $src_root/manifest
|
||||
hxx{version}:
|
||||
{
|
||||
dist = true
|
||||
clean = ($src_root != $out_root)
|
||||
}
|
||||
|
||||
# Build options.
|
||||
#
|
||||
if ($c.class == 'gcc')
|
||||
{
|
||||
# Disable warnings that pop up with -Wextra (e.g, -fimplicit-fallthrough)
|
||||
# in C implementation details.
|
||||
#
|
||||
details/expat/ c.coptions += -Wno-extra
|
||||
details/genx/ c.coptions += -Wno-extra
|
||||
}
|
||||
|
||||
# We are a mixed C/C++ library, though C is implementation-only, kind of: we
|
||||
# need headers but not symbols.
|
||||
#
|
||||
cc.poptions =+ "-I$out_root" "-I$src_root"
|
||||
|
||||
obja{*}: cc.poptions += -DLIBSTUDXML_STATIC_BUILD
|
||||
objs{*}: cc.poptions += -DLIBSTUDXML_SHARED_BUILD
|
||||
|
||||
# Export options.
|
||||
#
|
||||
lib{studxml}: cc.export.poptions = "-I$out_root" "-I$src_root"
|
||||
|
||||
liba{studxml}: cc.export.poptions += -DLIBSTUDXML_STATIC
|
||||
libs{studxml}: cc.export.poptions += -DLIBSTUDXML_SHARED
|
||||
|
||||
# For pre-releases use the complete version to make sure they cannot be used
|
||||
# in place of another pre-release or the final version. See the version module
|
||||
# for details on the version.* variable values.
|
||||
#
|
||||
if $version.pre_release
|
||||
lib{studxml}: bin.lib.version = @"-$version.project_id"
|
||||
else
|
||||
lib{studxml}: bin.lib.version = @"-$version.major.$version.minor"
|
||||
|
||||
# Install into the libstudxml/ subdirectory of, say, /usr/include/
|
||||
# recreating subdirectories.
|
||||
#
|
||||
{h hxx ixx txx}{*}:
|
||||
{
|
||||
install = include/libstudxml/
|
||||
install.subdirs = true
|
||||
}
|
||||
|
||||
details/genx/doc{README}@./: install = false
|
||||
details/genx/doc{LICENSE}@./: install = doc/GENX-LICENSE
|
35
third-party/libstudxml/libstudxml/content.hxx
vendored
35
third-party/libstudxml/libstudxml/content.hxx
vendored
|
@ -1,35 +0,0 @@
|
|||
// file : libstudxml/content.hxx -*- C++ -*-
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#ifndef LIBSTUDXML_CONTENT_HXX
|
||||
#define LIBSTUDXML_CONTENT_HXX
|
||||
|
||||
#include <libstudxml/details/pre.hxx>
|
||||
|
||||
namespace xml
|
||||
{
|
||||
// XML content model. C++11 enum class emulated for C++98.
|
||||
//
|
||||
struct content
|
||||
{
|
||||
enum value
|
||||
{
|
||||
// element characters whitespaces notes
|
||||
empty, // no no ignored
|
||||
simple, // no yes preserved content accumulated
|
||||
complex, // yes no ignored
|
||||
mixed // yes yes preserved
|
||||
};
|
||||
|
||||
content (value v): v_ (v) {};
|
||||
operator value () const {return v_;}
|
||||
|
||||
private:
|
||||
value v_;
|
||||
};
|
||||
}
|
||||
|
||||
#include <libstudxml/details/post.hxx>
|
||||
|
||||
#endif // LIBSTUDXML_CONTENT_HXX
|
|
@ -1,15 +0,0 @@
|
|||
/* file : libstudxml/details/config-vc.h
|
||||
* copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
* license : MIT; see accompanying LICENSE file
|
||||
*/
|
||||
|
||||
/* Configuration file for Windows/VC++ for the build2 build. */
|
||||
|
||||
#ifndef LIBSTUDXML_DETAILS_CONFIG_VC_H
|
||||
#define LIBSTUDXML_DETAILS_CONFIG_VC_H
|
||||
|
||||
// Always little-endian, at least on i686 and x86_64.
|
||||
//
|
||||
#define LIBSTUDXML_BYTEORDER 1234
|
||||
|
||||
#endif /* LIBSTUDXML_DETAILS_CONFIG_VC_H */
|
|
@ -1,40 +0,0 @@
|
|||
/* file : libstudxml/details/build2/config.h
|
||||
* copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
* license : MIT; see accompanying LICENSE file
|
||||
*/
|
||||
|
||||
/* Static configuration file for the build2 build. */
|
||||
|
||||
#ifndef LIBSTUDXML_DETAILS_CONFIG_H
|
||||
#define LIBSTUDXML_DETAILS_CONFIG_H
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
# include <sys/endian.h> /* BYTE_ORDER */
|
||||
#else
|
||||
# if defined(_WIN32)
|
||||
# ifndef BYTE_ORDER
|
||||
# define BIG_ENDIAN 4321
|
||||
# define LITTLE_ENDIAN 1234
|
||||
# define BYTE_ORDER LITTLE_ENDIAN
|
||||
# endif
|
||||
# else
|
||||
# include <sys/param.h> /* BYTE_ORDER/__BYTE_ORDER */
|
||||
# ifndef BYTE_ORDER
|
||||
# ifdef __BYTE_ORDER
|
||||
# define BYTE_ORDER __BYTE_ORDER
|
||||
# define BIG_ENDIAN __BIG_ENDIAN
|
||||
# define LITTLE_ENDIAN __LITTLE_ENDIAN
|
||||
# else
|
||||
# error no BYTE_ORDER/__BYTE_ORDER define
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
# define LIBSTUDXML_BYTEORDER 4321
|
||||
#else
|
||||
# define LIBSTUDXML_BYTEORDER 1234
|
||||
#endif
|
||||
|
||||
#endif /* LIBSTUDXML_DETAILS_CONFIG_H */
|
|
@ -1,40 +0,0 @@
|
|||
// file : libstudxml/details/config.hxx
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#ifndef LIBSTUDXML_DETAILS_CONFIG_HXX
|
||||
#define LIBSTUDXML_DETAILS_CONFIG_HXX
|
||||
|
||||
// C++11 support.
|
||||
//
|
||||
#ifdef _MSC_VER
|
||||
# if _MSC_VER >= 1900
|
||||
# define STUDXML_CXX11_NOEXCEPT
|
||||
# endif
|
||||
#else
|
||||
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
|
||||
# ifdef __clang__ // Pretends to be a really old __GNUC__ on some platforms.
|
||||
# define STUDXML_CXX11_NOEXCEPT
|
||||
# elif defined(__GNUC__)
|
||||
# if (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4
|
||||
# define STUDXML_CXX11_NOEXCEPT
|
||||
# endif
|
||||
# else
|
||||
# define STUDXML_CXX11_NOEXCEPT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef STUDXML_CXX11_NOEXCEPT
|
||||
# define STUDXML_NOTHROW_NOEXCEPT noexcept
|
||||
#else
|
||||
# define STUDXML_NOTHROW_NOEXCEPT throw()
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <libstudxml/details/config-vc.h>
|
||||
#else
|
||||
# include <libstudxml/details/config.h>
|
||||
#endif
|
||||
|
||||
#endif // LIBSTUDXML_DETAILS_CONFIG_HXX
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
and Clark Cooper
|
||||
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
|
||||
|
||||
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.
|
|
@ -1,2 +0,0 @@
|
|||
This directory contains the Expat XML parser library for internal
|
||||
use by libstudxml.
|
|
@ -1,92 +0,0 @@
|
|||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#define ASCII_A 0x41
|
||||
#define ASCII_B 0x42
|
||||
#define ASCII_C 0x43
|
||||
#define ASCII_D 0x44
|
||||
#define ASCII_E 0x45
|
||||
#define ASCII_F 0x46
|
||||
#define ASCII_G 0x47
|
||||
#define ASCII_H 0x48
|
||||
#define ASCII_I 0x49
|
||||
#define ASCII_J 0x4A
|
||||
#define ASCII_K 0x4B
|
||||
#define ASCII_L 0x4C
|
||||
#define ASCII_M 0x4D
|
||||
#define ASCII_N 0x4E
|
||||
#define ASCII_O 0x4F
|
||||
#define ASCII_P 0x50
|
||||
#define ASCII_Q 0x51
|
||||
#define ASCII_R 0x52
|
||||
#define ASCII_S 0x53
|
||||
#define ASCII_T 0x54
|
||||
#define ASCII_U 0x55
|
||||
#define ASCII_V 0x56
|
||||
#define ASCII_W 0x57
|
||||
#define ASCII_X 0x58
|
||||
#define ASCII_Y 0x59
|
||||
#define ASCII_Z 0x5A
|
||||
|
||||
#define ASCII_a 0x61
|
||||
#define ASCII_b 0x62
|
||||
#define ASCII_c 0x63
|
||||
#define ASCII_d 0x64
|
||||
#define ASCII_e 0x65
|
||||
#define ASCII_f 0x66
|
||||
#define ASCII_g 0x67
|
||||
#define ASCII_h 0x68
|
||||
#define ASCII_i 0x69
|
||||
#define ASCII_j 0x6A
|
||||
#define ASCII_k 0x6B
|
||||
#define ASCII_l 0x6C
|
||||
#define ASCII_m 0x6D
|
||||
#define ASCII_n 0x6E
|
||||
#define ASCII_o 0x6F
|
||||
#define ASCII_p 0x70
|
||||
#define ASCII_q 0x71
|
||||
#define ASCII_r 0x72
|
||||
#define ASCII_s 0x73
|
||||
#define ASCII_t 0x74
|
||||
#define ASCII_u 0x75
|
||||
#define ASCII_v 0x76
|
||||
#define ASCII_w 0x77
|
||||
#define ASCII_x 0x78
|
||||
#define ASCII_y 0x79
|
||||
#define ASCII_z 0x7A
|
||||
|
||||
#define ASCII_0 0x30
|
||||
#define ASCII_1 0x31
|
||||
#define ASCII_2 0x32
|
||||
#define ASCII_3 0x33
|
||||
#define ASCII_4 0x34
|
||||
#define ASCII_5 0x35
|
||||
#define ASCII_6 0x36
|
||||
#define ASCII_7 0x37
|
||||
#define ASCII_8 0x38
|
||||
#define ASCII_9 0x39
|
||||
|
||||
#define ASCII_TAB 0x09
|
||||
#define ASCII_SPACE 0x20
|
||||
#define ASCII_EXCL 0x21
|
||||
#define ASCII_QUOT 0x22
|
||||
#define ASCII_AMP 0x26
|
||||
#define ASCII_APOS 0x27
|
||||
#define ASCII_MINUS 0x2D
|
||||
#define ASCII_PERIOD 0x2E
|
||||
#define ASCII_COLON 0x3A
|
||||
#define ASCII_SEMI 0x3B
|
||||
#define ASCII_LT 0x3C
|
||||
#define ASCII_EQUALS 0x3D
|
||||
#define ASCII_GT 0x3E
|
||||
#define ASCII_LSQB 0x5B
|
||||
#define ASCII_RSQB 0x5D
|
||||
#define ASCII_UNDERSCORE 0x5F
|
||||
#define ASCII_LPAREN 0x28
|
||||
#define ASCII_RPAREN 0x29
|
||||
#define ASCII_FF 0x0C
|
||||
#define ASCII_SLASH 0x2F
|
||||
#define ASCII_HASH 0x23
|
||||
#define ASCII_PIPE 0x7C
|
||||
#define ASCII_COMMA 0x2C
|
|
@ -1,36 +0,0 @@
|
|||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_CR, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
|
@ -1,35 +0,0 @@
|
|||
#ifndef EXPAT_CONFIG_H
|
||||
#define EXPAT_CONFIG_H
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# include <libstudxml/details/config-vc.h>
|
||||
#else
|
||||
# include <libstudxml/details/config.h>
|
||||
#endif
|
||||
|
||||
#define BYTEORDER LIBSTUDXML_BYTEORDER
|
||||
|
||||
#define XML_NS 1
|
||||
#define XML_DTD 1
|
||||
#define XML_CONTEXT_BYTES 1024
|
||||
|
||||
#define UNUSED(x) (void)x;
|
||||
|
||||
#ifdef _WIN32
|
||||
/* Windows
|
||||
*
|
||||
*/
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
|
||||
#define HAVE_MEMMOVE 1
|
||||
|
||||
#else
|
||||
/* POSIX
|
||||
*
|
||||
*/
|
||||
#define HAVE_MEMMOVE 1
|
||||
#endif
|
||||
|
||||
#endif /* EXPAT_CONFIG_H */
|
1047
third-party/libstudxml/libstudxml/details/expat/expat.h
vendored
1047
third-party/libstudxml/libstudxml/details/expat/expat.h
vendored
File diff suppressed because it is too large
Load Diff
|
@ -1,119 +0,0 @@
|
|||
/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef Expat_External_INCLUDED
|
||||
#define Expat_External_INCLUDED 1
|
||||
|
||||
/* Link to Expat API statically */
|
||||
|
||||
#define XML_STATIC 1
|
||||
|
||||
/* External API definitions */
|
||||
|
||||
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
|
||||
#define XML_USE_MSC_EXTENSIONS 1
|
||||
#endif
|
||||
|
||||
/* Expat tries very hard to make the API boundary very specifically
|
||||
defined. There are two macros defined to control this boundary;
|
||||
each of these can be defined before including this header to
|
||||
achieve some different behavior, but doing so it not recommended or
|
||||
tested frequently.
|
||||
|
||||
XMLCALL - The calling convention to use for all calls across the
|
||||
"library boundary." This will default to cdecl, and
|
||||
try really hard to tell the compiler that's what we
|
||||
want.
|
||||
|
||||
XMLIMPORT - Whatever magic is needed to note that a function is
|
||||
to be imported from a dynamically loaded library
|
||||
(.dll, .so, or .sl, depending on your platform).
|
||||
|
||||
The XMLCALL macro was added in Expat 1.95.7. The only one which is
|
||||
expected to be directly useful in client code is XMLCALL.
|
||||
|
||||
Note that on at least some Unix versions, the Expat library must be
|
||||
compiled with the cdecl calling convention as the default since
|
||||
system headers may assume the cdecl convention.
|
||||
*/
|
||||
#ifndef XMLCALL
|
||||
#if defined(_MSC_VER)
|
||||
#define XMLCALL __cdecl
|
||||
#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
|
||||
#define XMLCALL __attribute__((cdecl))
|
||||
#else
|
||||
/* For any platform which uses this definition and supports more than
|
||||
one calling convention, we need to extend this definition to
|
||||
declare the convention used on that platform, if it's possible to
|
||||
do so.
|
||||
|
||||
If this is the case for your platform, please file a bug report
|
||||
with information on how to identify your platform via the C
|
||||
pre-processor and how to specify the same calling convention as the
|
||||
platform's malloc() implementation.
|
||||
*/
|
||||
#define XMLCALL
|
||||
#endif
|
||||
#endif /* not defined XMLCALL */
|
||||
|
||||
|
||||
#if !defined(XML_STATIC) && !defined(XMLIMPORT)
|
||||
#ifndef XML_BUILDING_EXPAT
|
||||
/* using Expat from an application */
|
||||
|
||||
#ifdef XML_USE_MSC_EXTENSIONS
|
||||
#define XMLIMPORT __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#endif /* not defined XML_STATIC */
|
||||
|
||||
|
||||
/* If we didn't define it above, define it away: */
|
||||
#ifndef XMLIMPORT
|
||||
#define XMLIMPORT
|
||||
#endif
|
||||
|
||||
|
||||
#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
#define XML_UNICODE
|
||||
#endif
|
||||
|
||||
#ifdef XML_UNICODE /* Information is UTF-16 encoded. */
|
||||
#ifdef XML_UNICODE_WCHAR_T
|
||||
typedef wchar_t XML_Char;
|
||||
typedef wchar_t XML_LChar;
|
||||
#else
|
||||
typedef unsigned short XML_Char;
|
||||
typedef char XML_LChar;
|
||||
#endif /* XML_UNICODE_WCHAR_T */
|
||||
#else /* Information is UTF-8 encoded. */
|
||||
typedef char XML_Char;
|
||||
typedef char XML_LChar;
|
||||
#endif /* XML_UNICODE */
|
||||
|
||||
#ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
|
||||
#if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
|
||||
typedef __int64 XML_Index;
|
||||
typedef unsigned __int64 XML_Size;
|
||||
#else
|
||||
typedef long long XML_Index;
|
||||
typedef unsigned long long XML_Size;
|
||||
#endif
|
||||
#else
|
||||
typedef long XML_Index;
|
||||
typedef unsigned long XML_Size;
|
||||
#endif /* XML_LARGE_SIZE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not Expat_External_INCLUDED */
|
|
@ -1,37 +0,0 @@
|
|||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */
|
||||
/* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x04 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x08 */ BT_NONXML, BT_S, BT_LF, BT_NONXML,
|
||||
/* 0x0C */ BT_NONXML, BT_S, BT_NONXML, BT_NONXML,
|
||||
/* 0x10 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x14 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x18 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x1C */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0x20 */ BT_S, BT_EXCL, BT_QUOT, BT_NUM,
|
||||
/* 0x24 */ BT_OTHER, BT_PERCNT, BT_AMP, BT_APOS,
|
||||
/* 0x28 */ BT_LPAR, BT_RPAR, BT_AST, BT_PLUS,
|
||||
/* 0x2C */ BT_COMMA, BT_MINUS, BT_NAME, BT_SOL,
|
||||
/* 0x30 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x34 */ BT_DIGIT, BT_DIGIT, BT_DIGIT, BT_DIGIT,
|
||||
/* 0x38 */ BT_DIGIT, BT_DIGIT, BT_COLON, BT_SEMI,
|
||||
/* 0x3C */ BT_LT, BT_EQUALS, BT_GT, BT_QUEST,
|
||||
/* 0x40 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x44 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x48 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x4C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x50 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x54 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x58 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_LSQB,
|
||||
/* 0x5C */ BT_OTHER, BT_RSQB, BT_OTHER, BT_NMSTRT,
|
||||
/* 0x60 */ BT_OTHER, BT_HEX, BT_HEX, BT_HEX,
|
||||
/* 0x64 */ BT_HEX, BT_HEX, BT_HEX, BT_NMSTRT,
|
||||
/* 0x68 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x6C */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x70 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x74 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0x78 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0x7C */ BT_VERBAR, BT_OTHER, BT_OTHER, BT_OTHER,
|
|
@ -1,73 +0,0 @@
|
|||
/* internal.h
|
||||
|
||||
Internal definitions used by Expat. This is not needed to compile
|
||||
client code.
|
||||
|
||||
The following calling convention macros are defined for frequently
|
||||
called functions:
|
||||
|
||||
FASTCALL - Used for those internal functions that have a simple
|
||||
body and a low number of arguments and local variables.
|
||||
|
||||
PTRCALL - Used for functions called though function pointers.
|
||||
|
||||
PTRFASTCALL - Like PTRCALL, but for low number of arguments.
|
||||
|
||||
inline - Used for selected internal functions for which inlining
|
||||
may improve performance on some platforms.
|
||||
|
||||
Note: Use of these macros is based on judgement, not hard rules,
|
||||
and therefore subject to change.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__)
|
||||
/* We'll use this version by default only where we know it helps.
|
||||
|
||||
regparm() generates warnings on Solaris boxes. See SF bug #692878.
|
||||
|
||||
Instability reported with egcs on a RedHat Linux 7.3.
|
||||
Let's comment out:
|
||||
#define FASTCALL __attribute__((stdcall, regparm(3)))
|
||||
and let's try this:
|
||||
*/
|
||||
#define FASTCALL __attribute__((regparm(3)))
|
||||
#define PTRFASTCALL __attribute__((regparm(3)))
|
||||
#endif
|
||||
|
||||
/* Using __fastcall seems to have an unexpected negative effect under
|
||||
MS VC++, especially for function pointers, so we won't use it for
|
||||
now on that platform. It may be reconsidered for a future release
|
||||
if it can be made more effective.
|
||||
Likely reason: __fastcall on Windows is like stdcall, therefore
|
||||
the compiler cannot perform stack optimizations for call clusters.
|
||||
*/
|
||||
|
||||
/* Make sure all of these are defined if they aren't already. */
|
||||
|
||||
#ifndef FASTCALL
|
||||
#define FASTCALL
|
||||
#endif
|
||||
|
||||
#ifndef PTRCALL
|
||||
#define PTRCALL
|
||||
#endif
|
||||
|
||||
#ifndef PTRFASTCALL
|
||||
#define PTRFASTCALL
|
||||
#endif
|
||||
|
||||
#ifndef XML_MIN_SIZE
|
||||
#if !defined(__cplusplus) && !defined(inline)
|
||||
#ifdef __GNUC__
|
||||
#define inline __inline
|
||||
#endif /* __GNUC__ */
|
||||
#endif
|
||||
#endif /* XML_MIN_SIZE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define inline inline
|
||||
#else
|
||||
#ifndef inline
|
||||
#define inline
|
||||
#endif
|
||||
#endif
|
|
@ -1,36 +0,0 @@
|
|||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x84 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x88 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x8C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x90 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x94 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x98 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0x9C */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA4 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xA8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xAC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB0 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xB4 */ BT_OTHER, BT_NMSTRT, BT_OTHER, BT_NAME,
|
||||
/* 0xB8 */ BT_OTHER, BT_OTHER, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xBC */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER,
|
||||
/* 0xC0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xC8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xCC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xD4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xD8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xDC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xE8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xEC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF0 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xF4 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_OTHER,
|
||||
/* 0xF8 */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
||||
/* 0xFC */ BT_NMSTRT, BT_NMSTRT, BT_NMSTRT, BT_NMSTRT,
|
|
@ -1,150 +0,0 @@
|
|||
static const unsigned namingBitmap[] = {
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0x00000000, 0x04000000, 0x87FFFFFE, 0x07FFFFFE,
|
||||
0x00000000, 0x00000000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0xFFFFFFFF, 0x7FF3FFFF, 0xFFFFFDFE, 0x7FFFFFFF,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFE00F, 0xFC31FFFF,
|
||||
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00000003, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFD740, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF0003, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0x0000007F, 0x00000000, 0xFFFF0000, 0x000707FF,
|
||||
0x00000000, 0x07FFFFFE, 0x000007FE, 0xFFFE0000,
|
||||
0xFFFFFFFF, 0x7CFFFFFF, 0x002F7FFF, 0x00000060,
|
||||
0xFFFFFFE0, 0x23FFFFFF, 0xFF000000, 0x00000003,
|
||||
0xFFF99FE0, 0x03C5FDFF, 0xB0000000, 0x00030003,
|
||||
0xFFF987E0, 0x036DFDFF, 0x5E000000, 0x001C0000,
|
||||
0xFFFBAFE0, 0x23EDFDFF, 0x00000000, 0x00000001,
|
||||
0xFFF99FE0, 0x23CDFDFF, 0xB0000000, 0x00000003,
|
||||
0xD63DC7E0, 0x03BFC718, 0x00000000, 0x00000000,
|
||||
0xFFFDDFE0, 0x03EFFDFF, 0x00000000, 0x00000003,
|
||||
0xFFFDDFE0, 0x03EFFDFF, 0x40000000, 0x00000003,
|
||||
0xFFFDDFE0, 0x03FFFDFF, 0x00000000, 0x00000003,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFE, 0x000D7FFF, 0x0000003F, 0x00000000,
|
||||
0xFEF02596, 0x200D6CAE, 0x0000001F, 0x00000000,
|
||||
0x00000000, 0x00000000, 0xFFFFFEFF, 0x000003FF,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0xFFFFFFFF, 0xFFFF003F, 0x007FFFFF,
|
||||
0x0007DAED, 0x50000000, 0x82315001, 0x002C62AB,
|
||||
0x40000000, 0xF580C900, 0x00000007, 0x02010800,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0x0FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x03FFFFFF,
|
||||
0x3F3FFFFF, 0xFFFFFFFF, 0xAAFF3F3F, 0x3FFFFFFF,
|
||||
0xFFFFFFFF, 0x5FDFFFFF, 0x0FCF1FDC, 0x1FDC1FFF,
|
||||
0x00000000, 0x00004C40, 0x00000000, 0x00000000,
|
||||
0x00000007, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000080, 0x000003FE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||
0x001FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x07FFFFFF,
|
||||
0xFFFFFFE0, 0x00001FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x0000003F, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0x0000000F, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x07FF6000, 0x87FFFFFE, 0x07FFFFFE,
|
||||
0x00000000, 0x00800000, 0xFF7FFFFF, 0xFF7FFFFF,
|
||||
0x00FFFFFF, 0x00000000, 0xFFFF0000, 0xFFFFFFFF,
|
||||
0xFFFFFFFF, 0xF80001FF, 0x00030003, 0x00000000,
|
||||
0xFFFFFFFF, 0xFFFFFFFF, 0x0000003F, 0x00000003,
|
||||
0xFFFFD7C0, 0xFFFFFFFB, 0x547F7FFF, 0x000FFFFD,
|
||||
0xFFFFDFFE, 0xFFFFFFFF, 0xDFFEFFFF, 0xFFFFFFFF,
|
||||
0xFFFF007B, 0xFFFFFFFF, 0xFFFF199F, 0x033FCFFF,
|
||||
0x00000000, 0xFFFE0000, 0x027FFFFF, 0xFFFFFFFE,
|
||||
0xFFFE007F, 0xBBFFFFFB, 0xFFFF0016, 0x000707FF,
|
||||
0x00000000, 0x07FFFFFE, 0x0007FFFF, 0xFFFF03FF,
|
||||
0xFFFFFFFF, 0x7CFFFFFF, 0xFFEF7FFF, 0x03FF3DFF,
|
||||
0xFFFFFFEE, 0xF3FFFFFF, 0xFF1E3FFF, 0x0000FFCF,
|
||||
0xFFF99FEE, 0xD3C5FDFF, 0xB080399F, 0x0003FFCF,
|
||||
0xFFF987E4, 0xD36DFDFF, 0x5E003987, 0x001FFFC0,
|
||||
0xFFFBAFEE, 0xF3EDFDFF, 0x00003BBF, 0x0000FFC1,
|
||||
0xFFF99FEE, 0xF3CDFDFF, 0xB0C0398F, 0x0000FFC3,
|
||||
0xD63DC7EC, 0xC3BFC718, 0x00803DC7, 0x0000FF80,
|
||||
0xFFFDDFEE, 0xC3EFFDFF, 0x00603DDF, 0x0000FFC3,
|
||||
0xFFFDDFEC, 0xC3EFFDFF, 0x40603DDF, 0x0000FFC3,
|
||||
0xFFFDDFEC, 0xC3FFFDFF, 0x00803DCF, 0x0000FFC3,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0xFFFFFFFE, 0x07FF7FFF, 0x03FF7FFF, 0x00000000,
|
||||
0xFEF02596, 0x3BFF6CAE, 0x03FF3F5F, 0x00000000,
|
||||
0x03000000, 0xC2A003FF, 0xFFFFFEFF, 0xFFFE03FF,
|
||||
0xFEBF0FDF, 0x02FE3FFF, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||
0x00000000, 0x00000000, 0x1FFF0000, 0x00000002,
|
||||
0x000000A0, 0x003EFFFE, 0xFFFFFFFE, 0xFFFFFFFF,
|
||||
0x661FFFFF, 0xFFFFFFFE, 0xFFFFFFFF, 0x77FFFFFF,
|
||||
};
|
||||
static const unsigned char nmstrtPages[] = {
|
||||
0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x00,
|
||||
0x00, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
|
||||
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||
0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x15, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
||||
static const unsigned char namePages[] = {
|
||||
0x19, 0x03, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x00,
|
||||
0x00, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25,
|
||||
0x10, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x13,
|
||||
0x26, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x27, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x17,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
||||
0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x18,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
};
|
|
@ -1,37 +0,0 @@
|
|||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
|
||||
/* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x88 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x8C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x90 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x94 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x98 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0x9C */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xA8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xAC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB0 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB4 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xB8 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xBC */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL,
|
||||
/* 0xC0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xC8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xCC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD0 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD4 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xD8 */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xDC */ BT_LEAD2, BT_LEAD2, BT_LEAD2, BT_LEAD2,
|
||||
/* 0xE0 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE4 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xE8 */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xEC */ BT_LEAD3, BT_LEAD3, BT_LEAD3, BT_LEAD3,
|
||||
/* 0xF0 */ BT_LEAD4, BT_LEAD4, BT_LEAD4, BT_LEAD4,
|
||||
/* 0xF4 */ BT_LEAD4, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xF8 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML,
|
||||
/* 0xFC */ BT_NONXML, BT_NONXML, BT_MALFORM, BT_MALFORM,
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,114 +0,0 @@
|
|||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef XmlRole_INCLUDED
|
||||
#define XmlRole_INCLUDED 1
|
||||
|
||||
#ifdef __VMS
|
||||
/* 0 1 2 3 0 1 2 3
|
||||
1234567890123456789012345678901 1234567890123456789012345678901 */
|
||||
#define XmlPrologStateInitExternalEntity XmlPrologStateInitExternalEnt
|
||||
#endif
|
||||
|
||||
#include <libstudxml/details/expat/xmltok.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
XML_ROLE_ERROR = -1,
|
||||
XML_ROLE_NONE = 0,
|
||||
XML_ROLE_XML_DECL,
|
||||
XML_ROLE_INSTANCE_START,
|
||||
XML_ROLE_DOCTYPE_NONE,
|
||||
XML_ROLE_DOCTYPE_NAME,
|
||||
XML_ROLE_DOCTYPE_SYSTEM_ID,
|
||||
XML_ROLE_DOCTYPE_PUBLIC_ID,
|
||||
XML_ROLE_DOCTYPE_INTERNAL_SUBSET,
|
||||
XML_ROLE_DOCTYPE_CLOSE,
|
||||
XML_ROLE_GENERAL_ENTITY_NAME,
|
||||
XML_ROLE_PARAM_ENTITY_NAME,
|
||||
XML_ROLE_ENTITY_NONE,
|
||||
XML_ROLE_ENTITY_VALUE,
|
||||
XML_ROLE_ENTITY_SYSTEM_ID,
|
||||
XML_ROLE_ENTITY_PUBLIC_ID,
|
||||
XML_ROLE_ENTITY_COMPLETE,
|
||||
XML_ROLE_ENTITY_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_NONE,
|
||||
XML_ROLE_NOTATION_NAME,
|
||||
XML_ROLE_NOTATION_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_NO_SYSTEM_ID,
|
||||
XML_ROLE_NOTATION_PUBLIC_ID,
|
||||
XML_ROLE_ATTRIBUTE_NAME,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_CDATA,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ID,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREF,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_IDREFS,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITY,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_ENTITIES,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN,
|
||||
XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS,
|
||||
XML_ROLE_ATTRIBUTE_ENUM_VALUE,
|
||||
XML_ROLE_ATTRIBUTE_NOTATION_VALUE,
|
||||
XML_ROLE_ATTLIST_NONE,
|
||||
XML_ROLE_ATTLIST_ELEMENT_NAME,
|
||||
XML_ROLE_IMPLIED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_REQUIRED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_DEFAULT_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_FIXED_ATTRIBUTE_VALUE,
|
||||
XML_ROLE_ELEMENT_NONE,
|
||||
XML_ROLE_ELEMENT_NAME,
|
||||
XML_ROLE_CONTENT_ANY,
|
||||
XML_ROLE_CONTENT_EMPTY,
|
||||
XML_ROLE_CONTENT_PCDATA,
|
||||
XML_ROLE_GROUP_OPEN,
|
||||
XML_ROLE_GROUP_CLOSE,
|
||||
XML_ROLE_GROUP_CLOSE_REP,
|
||||
XML_ROLE_GROUP_CLOSE_OPT,
|
||||
XML_ROLE_GROUP_CLOSE_PLUS,
|
||||
XML_ROLE_GROUP_CHOICE,
|
||||
XML_ROLE_GROUP_SEQUENCE,
|
||||
XML_ROLE_CONTENT_ELEMENT,
|
||||
XML_ROLE_CONTENT_ELEMENT_REP,
|
||||
XML_ROLE_CONTENT_ELEMENT_OPT,
|
||||
XML_ROLE_CONTENT_ELEMENT_PLUS,
|
||||
XML_ROLE_PI,
|
||||
XML_ROLE_COMMENT,
|
||||
#ifdef XML_DTD
|
||||
XML_ROLE_TEXT_DECL,
|
||||
XML_ROLE_IGNORE_SECT,
|
||||
XML_ROLE_INNER_PARAM_ENTITY_REF,
|
||||
#endif /* XML_DTD */
|
||||
XML_ROLE_PARAM_ENTITY_REF
|
||||
};
|
||||
|
||||
typedef struct prolog_state {
|
||||
int (PTRCALL *handler) (struct prolog_state *state,
|
||||
int tok,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const ENCODING *enc);
|
||||
unsigned level;
|
||||
int role_none;
|
||||
#ifdef XML_DTD
|
||||
unsigned includeLevel;
|
||||
int documentEntity;
|
||||
int inEntityValue;
|
||||
#endif /* XML_DTD */
|
||||
} PROLOG_STATE;
|
||||
|
||||
void XmlPrologStateInit(PROLOG_STATE *);
|
||||
#ifdef XML_DTD
|
||||
void XmlPrologStateInitExternalEntity(PROLOG_STATE *);
|
||||
#endif /* XML_DTD */
|
||||
|
||||
#define XmlTokenRole(state, tok, ptr, end, enc) \
|
||||
(((state)->handler)(state, tok, ptr, end, enc))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not XmlRole_INCLUDED */
|
1681
third-party/libstudxml/libstudxml/details/expat/xmltok.c
vendored
1681
third-party/libstudxml/libstudxml/details/expat/xmltok.c
vendored
File diff suppressed because it is too large
Load Diff
|
@ -1,316 +0,0 @@
|
|||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
#ifndef XmlTok_INCLUDED
|
||||
#define XmlTok_INCLUDED 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* The following token may be returned by XmlContentTok */
|
||||
#define XML_TOK_TRAILING_RSQB -5 /* ] or ]] at the end of the scan; might be
|
||||
start of illegal ]]> sequence */
|
||||
/* The following tokens may be returned by both XmlPrologTok and
|
||||
XmlContentTok.
|
||||
*/
|
||||
#define XML_TOK_NONE -4 /* The string to be scanned is empty */
|
||||
#define XML_TOK_TRAILING_CR -3 /* A CR at the end of the scan;
|
||||
might be part of CRLF sequence */
|
||||
#define XML_TOK_PARTIAL_CHAR -2 /* only part of a multibyte sequence */
|
||||
#define XML_TOK_PARTIAL -1 /* only part of a token */
|
||||
#define XML_TOK_INVALID 0
|
||||
|
||||
/* The following tokens are returned by XmlContentTok; some are also
|
||||
returned by XmlAttributeValueTok, XmlEntityTok, XmlCdataSectionTok.
|
||||
*/
|
||||
#define XML_TOK_START_TAG_WITH_ATTS 1
|
||||
#define XML_TOK_START_TAG_NO_ATTS 2
|
||||
#define XML_TOK_EMPTY_ELEMENT_WITH_ATTS 3 /* empty element tag <e/> */
|
||||
#define XML_TOK_EMPTY_ELEMENT_NO_ATTS 4
|
||||
#define XML_TOK_END_TAG 5
|
||||
#define XML_TOK_DATA_CHARS 6
|
||||
#define XML_TOK_DATA_NEWLINE 7
|
||||
#define XML_TOK_CDATA_SECT_OPEN 8
|
||||
#define XML_TOK_ENTITY_REF 9
|
||||
#define XML_TOK_CHAR_REF 10 /* numeric character reference */
|
||||
|
||||
/* The following tokens may be returned by both XmlPrologTok and
|
||||
XmlContentTok.
|
||||
*/
|
||||
#define XML_TOK_PI 11 /* processing instruction */
|
||||
#define XML_TOK_XML_DECL 12 /* XML decl or text decl */
|
||||
#define XML_TOK_COMMENT 13
|
||||
#define XML_TOK_BOM 14 /* Byte order mark */
|
||||
|
||||
/* The following tokens are returned only by XmlPrologTok */
|
||||
#define XML_TOK_PROLOG_S 15
|
||||
#define XML_TOK_DECL_OPEN 16 /* <!foo */
|
||||
#define XML_TOK_DECL_CLOSE 17 /* > */
|
||||
#define XML_TOK_NAME 18
|
||||
#define XML_TOK_NMTOKEN 19
|
||||
#define XML_TOK_POUND_NAME 20 /* #name */
|
||||
#define XML_TOK_OR 21 /* | */
|
||||
#define XML_TOK_PERCENT 22
|
||||
#define XML_TOK_OPEN_PAREN 23
|
||||
#define XML_TOK_CLOSE_PAREN 24
|
||||
#define XML_TOK_OPEN_BRACKET 25
|
||||
#define XML_TOK_CLOSE_BRACKET 26
|
||||
#define XML_TOK_LITERAL 27
|
||||
#define XML_TOK_PARAM_ENTITY_REF 28
|
||||
#define XML_TOK_INSTANCE_START 29
|
||||
|
||||
/* The following occur only in element type declarations */
|
||||
#define XML_TOK_NAME_QUESTION 30 /* name? */
|
||||
#define XML_TOK_NAME_ASTERISK 31 /* name* */
|
||||
#define XML_TOK_NAME_PLUS 32 /* name+ */
|
||||
#define XML_TOK_COND_SECT_OPEN 33 /* <![ */
|
||||
#define XML_TOK_COND_SECT_CLOSE 34 /* ]]> */
|
||||
#define XML_TOK_CLOSE_PAREN_QUESTION 35 /* )? */
|
||||
#define XML_TOK_CLOSE_PAREN_ASTERISK 36 /* )* */
|
||||
#define XML_TOK_CLOSE_PAREN_PLUS 37 /* )+ */
|
||||
#define XML_TOK_COMMA 38
|
||||
|
||||
/* The following token is returned only by XmlAttributeValueTok */
|
||||
#define XML_TOK_ATTRIBUTE_VALUE_S 39
|
||||
|
||||
/* The following token is returned only by XmlCdataSectionTok */
|
||||
#define XML_TOK_CDATA_SECT_CLOSE 40
|
||||
|
||||
/* With namespace processing this is returned by XmlPrologTok for a
|
||||
name with a colon.
|
||||
*/
|
||||
#define XML_TOK_PREFIXED_NAME 41
|
||||
|
||||
#ifdef XML_DTD
|
||||
#define XML_TOK_IGNORE_SECT 42
|
||||
#endif /* XML_DTD */
|
||||
|
||||
#ifdef XML_DTD
|
||||
#define XML_N_STATES 4
|
||||
#else /* not XML_DTD */
|
||||
#define XML_N_STATES 3
|
||||
#endif /* not XML_DTD */
|
||||
|
||||
#define XML_PROLOG_STATE 0
|
||||
#define XML_CONTENT_STATE 1
|
||||
#define XML_CDATA_SECTION_STATE 2
|
||||
#ifdef XML_DTD
|
||||
#define XML_IGNORE_SECTION_STATE 3
|
||||
#endif /* XML_DTD */
|
||||
|
||||
#define XML_N_LITERAL_TYPES 2
|
||||
#define XML_ATTRIBUTE_VALUE_LITERAL 0
|
||||
#define XML_ENTITY_VALUE_LITERAL 1
|
||||
|
||||
/* The size of the buffer passed to XmlUtf8Encode must be at least this. */
|
||||
#define XML_UTF8_ENCODE_MAX 4
|
||||
/* The size of the buffer passed to XmlUtf16Encode must be at least this. */
|
||||
#define XML_UTF16_ENCODE_MAX 2
|
||||
|
||||
typedef struct position {
|
||||
/* first line and first column are 0 not 1 */
|
||||
XML_Size lineNumber;
|
||||
XML_Size columnNumber;
|
||||
} POSITION;
|
||||
|
||||
typedef struct {
|
||||
const char *name;
|
||||
const char *valuePtr;
|
||||
const char *valueEnd;
|
||||
char normalized;
|
||||
} ATTRIBUTE;
|
||||
|
||||
struct encoding;
|
||||
typedef struct encoding ENCODING;
|
||||
|
||||
typedef int (PTRCALL *SCANNER)(const ENCODING *,
|
||||
const char *,
|
||||
const char *,
|
||||
const char **);
|
||||
|
||||
struct encoding {
|
||||
SCANNER scanners[XML_N_STATES];
|
||||
SCANNER literalScanners[XML_N_LITERAL_TYPES];
|
||||
int (PTRCALL *sameName)(const ENCODING *,
|
||||
const char *,
|
||||
const char *);
|
||||
int (PTRCALL *nameMatchesAscii)(const ENCODING *,
|
||||
const char *,
|
||||
const char *,
|
||||
const char *);
|
||||
int (PTRFASTCALL *nameLength)(const ENCODING *, const char *);
|
||||
const char *(PTRFASTCALL *skipS)(const ENCODING *, const char *);
|
||||
int (PTRCALL *getAtts)(const ENCODING *enc,
|
||||
const char *ptr,
|
||||
int attsMax,
|
||||
ATTRIBUTE *atts);
|
||||
int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
|
||||
int (PTRCALL *predefinedEntityName)(const ENCODING *,
|
||||
const char *,
|
||||
const char *);
|
||||
void (PTRCALL *updatePosition)(const ENCODING *,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
POSITION *);
|
||||
int (PTRCALL *isPublicId)(const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr);
|
||||
void (PTRCALL *utf8Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
char **toP,
|
||||
const char *toLim);
|
||||
void (PTRCALL *utf16Convert)(const ENCODING *enc,
|
||||
const char **fromP,
|
||||
const char *fromLim,
|
||||
unsigned short **toP,
|
||||
const unsigned short *toLim);
|
||||
int minBytesPerChar;
|
||||
char isUtf8;
|
||||
char isUtf16;
|
||||
};
|
||||
|
||||
/* Scan the string starting at ptr until the end of the next complete
|
||||
token, but do not scan past eptr. Return an integer giving the
|
||||
type of token.
|
||||
|
||||
Return XML_TOK_NONE when ptr == eptr; nextTokPtr will not be set.
|
||||
|
||||
Return XML_TOK_PARTIAL when the string does not contain a complete
|
||||
token; nextTokPtr will not be set.
|
||||
|
||||
Return XML_TOK_INVALID when the string does not start a valid
|
||||
token; nextTokPtr will be set to point to the character which made
|
||||
the token invalid.
|
||||
|
||||
Otherwise the string starts with a valid token; nextTokPtr will be
|
||||
set to point to the character following the end of that token.
|
||||
|
||||
Each data character counts as a single token, but adjacent data
|
||||
characters may be returned together. Similarly for characters in
|
||||
the prolog outside literals, comments and processing instructions.
|
||||
*/
|
||||
|
||||
|
||||
#define XmlTok(enc, state, ptr, end, nextTokPtr) \
|
||||
(((enc)->scanners[state])(enc, ptr, end, nextTokPtr))
|
||||
|
||||
#define XmlPrologTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_PROLOG_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlContentTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_CONTENT_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlCdataSectionTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_CDATA_SECTION_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#ifdef XML_DTD
|
||||
|
||||
#define XmlIgnoreSectionTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlTok(enc, XML_IGNORE_SECTION_STATE, ptr, end, nextTokPtr)
|
||||
|
||||
#endif /* XML_DTD */
|
||||
|
||||
/* This is used for performing a 2nd-level tokenization on the content
|
||||
of a literal that has already been returned by XmlTok.
|
||||
*/
|
||||
#define XmlLiteralTok(enc, literalType, ptr, end, nextTokPtr) \
|
||||
(((enc)->literalScanners[literalType])(enc, ptr, end, nextTokPtr))
|
||||
|
||||
#define XmlAttributeValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ATTRIBUTE_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \
|
||||
XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr)
|
||||
|
||||
#define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2))
|
||||
|
||||
#define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \
|
||||
(((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2))
|
||||
|
||||
#define XmlNameLength(enc, ptr) \
|
||||
(((enc)->nameLength)(enc, ptr))
|
||||
|
||||
#define XmlSkipS(enc, ptr) \
|
||||
(((enc)->skipS)(enc, ptr))
|
||||
|
||||
#define XmlGetAttributes(enc, ptr, attsMax, atts) \
|
||||
(((enc)->getAtts)(enc, ptr, attsMax, atts))
|
||||
|
||||
#define XmlCharRefNumber(enc, ptr) \
|
||||
(((enc)->charRefNumber)(enc, ptr))
|
||||
|
||||
#define XmlPredefinedEntityName(enc, ptr, end) \
|
||||
(((enc)->predefinedEntityName)(enc, ptr, end))
|
||||
|
||||
#define XmlUpdatePosition(enc, ptr, end, pos) \
|
||||
(((enc)->updatePosition)(enc, ptr, end, pos))
|
||||
|
||||
#define XmlIsPublicId(enc, ptr, end, badPtr) \
|
||||
(((enc)->isPublicId)(enc, ptr, end, badPtr))
|
||||
|
||||
#define XmlUtf8Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf8Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
#define XmlUtf16Convert(enc, fromP, fromLim, toP, toLim) \
|
||||
(((enc)->utf16Convert)(enc, fromP, fromLim, toP, toLim))
|
||||
|
||||
typedef struct {
|
||||
ENCODING initEnc;
|
||||
const ENCODING **encPtr;
|
||||
} INIT_ENCODING;
|
||||
|
||||
int XmlParseXmlDecl(int isGeneralTextEntity,
|
||||
const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr,
|
||||
const char **versionPtr,
|
||||
const char **versionEndPtr,
|
||||
const char **encodingNamePtr,
|
||||
const ENCODING **namedEncodingPtr,
|
||||
int *standalonePtr);
|
||||
|
||||
int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||
const ENCODING *XmlGetUtf8InternalEncoding(void);
|
||||
const ENCODING *XmlGetUtf16InternalEncoding(void);
|
||||
int FASTCALL XmlUtf8Encode(int charNumber, char *buf);
|
||||
int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf);
|
||||
int XmlSizeOfUnknownEncoding(void);
|
||||
|
||||
|
||||
typedef int (XMLCALL *CONVERTER) (void *userData, const char *p);
|
||||
|
||||
ENCODING *
|
||||
XmlInitUnknownEncoding(void *mem,
|
||||
int *table,
|
||||
CONVERTER convert,
|
||||
void *userData);
|
||||
|
||||
int XmlParseXmlDeclNS(int isGeneralTextEntity,
|
||||
const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr,
|
||||
const char **versionPtr,
|
||||
const char **versionEndPtr,
|
||||
const char **encodingNamePtr,
|
||||
const ENCODING **namedEncodingPtr,
|
||||
int *standalonePtr);
|
||||
|
||||
int XmlInitEncodingNS(INIT_ENCODING *, const ENCODING **, const char *name);
|
||||
const ENCODING *XmlGetUtf8InternalEncodingNS(void);
|
||||
const ENCODING *XmlGetUtf16InternalEncodingNS(void);
|
||||
ENCODING *
|
||||
XmlInitUnknownEncodingNS(void *mem,
|
||||
int *table,
|
||||
CONVERTER convert,
|
||||
void *userData);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* not XmlTok_INCLUDED */
|
File diff suppressed because it is too large
Load Diff
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
enum {
|
||||
BT_NONXML,
|
||||
BT_MALFORM,
|
||||
BT_LT,
|
||||
BT_AMP,
|
||||
BT_RSQB,
|
||||
BT_LEAD2,
|
||||
BT_LEAD3,
|
||||
BT_LEAD4,
|
||||
BT_TRAIL,
|
||||
BT_CR,
|
||||
BT_LF,
|
||||
BT_GT,
|
||||
BT_QUOT,
|
||||
BT_APOS,
|
||||
BT_EQUALS,
|
||||
BT_QUEST,
|
||||
BT_EXCL,
|
||||
BT_SOL,
|
||||
BT_SEMI,
|
||||
BT_NUM,
|
||||
BT_LSQB,
|
||||
BT_S,
|
||||
BT_NMSTRT,
|
||||
BT_COLON,
|
||||
BT_HEX,
|
||||
BT_DIGIT,
|
||||
BT_NAME,
|
||||
BT_MINUS,
|
||||
BT_OTHER, /* known not to be a name or name start character */
|
||||
BT_NONASCII, /* might be a name or name start character */
|
||||
BT_PERCNT,
|
||||
BT_LPAR,
|
||||
BT_RPAR,
|
||||
BT_AST,
|
||||
BT_PLUS,
|
||||
BT_COMMA,
|
||||
BT_VERBAR
|
||||
};
|
||||
|
||||
#include <stddef.h>
|
|
@ -1,115 +0,0 @@
|
|||
/* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd
|
||||
See the file COPYING for copying permission.
|
||||
*/
|
||||
|
||||
/* This file is included! */
|
||||
#ifdef XML_TOK_NS_C
|
||||
|
||||
const ENCODING *
|
||||
NS(XmlGetUtf8InternalEncoding)(void)
|
||||
{
|
||||
return &ns(internal_utf8_encoding).enc;
|
||||
}
|
||||
|
||||
const ENCODING *
|
||||
NS(XmlGetUtf16InternalEncoding)(void)
|
||||
{
|
||||
#if BYTEORDER == 1234
|
||||
return &ns(internal_little2_encoding).enc;
|
||||
#elif BYTEORDER == 4321
|
||||
return &ns(internal_big2_encoding).enc;
|
||||
#else
|
||||
const short n = 1;
|
||||
return (*(const char *)&n
|
||||
? &ns(internal_little2_encoding).enc
|
||||
: &ns(internal_big2_encoding).enc);
|
||||
#endif
|
||||
}
|
||||
|
||||
static const ENCODING * const NS(encodings)[] = {
|
||||
&ns(latin1_encoding).enc,
|
||||
&ns(ascii_encoding).enc,
|
||||
&ns(utf8_encoding).enc,
|
||||
&ns(big2_encoding).enc,
|
||||
&ns(big2_encoding).enc,
|
||||
&ns(little2_encoding).enc,
|
||||
&ns(utf8_encoding).enc /* NO_ENC */
|
||||
};
|
||||
|
||||
static int PTRCALL
|
||||
NS(initScanProlog)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr)
|
||||
{
|
||||
return initScan(NS(encodings), (const INIT_ENCODING *)enc,
|
||||
XML_PROLOG_STATE, ptr, end, nextTokPtr);
|
||||
}
|
||||
|
||||
static int PTRCALL
|
||||
NS(initScanContent)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr)
|
||||
{
|
||||
return initScan(NS(encodings), (const INIT_ENCODING *)enc,
|
||||
XML_CONTENT_STATE, ptr, end, nextTokPtr);
|
||||
}
|
||||
|
||||
int
|
||||
NS(XmlInitEncoding)(INIT_ENCODING *p, const ENCODING **encPtr,
|
||||
const char *name)
|
||||
{
|
||||
int i = getEncodingIndex(name);
|
||||
if (i == UNKNOWN_ENC)
|
||||
return 0;
|
||||
SET_INIT_ENC_INDEX(p, i);
|
||||
p->initEnc.scanners[XML_PROLOG_STATE] = NS(initScanProlog);
|
||||
p->initEnc.scanners[XML_CONTENT_STATE] = NS(initScanContent);
|
||||
p->initEnc.updatePosition = initUpdatePosition;
|
||||
p->encPtr = encPtr;
|
||||
*encPtr = &(p->initEnc);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static const ENCODING *
|
||||
NS(findEncoding)(const ENCODING *enc, const char *ptr, const char *end)
|
||||
{
|
||||
#define ENCODING_MAX 128
|
||||
char buf[ENCODING_MAX];
|
||||
char *p = buf;
|
||||
int i;
|
||||
XmlUtf8Convert(enc, &ptr, end, &p, p + ENCODING_MAX - 1);
|
||||
if (ptr != end)
|
||||
return 0;
|
||||
*p = 0;
|
||||
if (streqci(buf, KW_UTF_16) && enc->minBytesPerChar == 2)
|
||||
return enc;
|
||||
i = getEncodingIndex(buf);
|
||||
if (i == UNKNOWN_ENC)
|
||||
return 0;
|
||||
return NS(encodings)[i];
|
||||
}
|
||||
|
||||
int
|
||||
NS(XmlParseXmlDecl)(int isGeneralTextEntity,
|
||||
const ENCODING *enc,
|
||||
const char *ptr,
|
||||
const char *end,
|
||||
const char **badPtr,
|
||||
const char **versionPtr,
|
||||
const char **versionEndPtr,
|
||||
const char **encodingName,
|
||||
const ENCODING **encoding,
|
||||
int *standalone)
|
||||
{
|
||||
return doParseXmlDecl(NS(findEncoding),
|
||||
isGeneralTextEntity,
|
||||
enc,
|
||||
ptr,
|
||||
end,
|
||||
badPtr,
|
||||
versionPtr,
|
||||
versionEndPtr,
|
||||
encodingName,
|
||||
encoding,
|
||||
standalone);
|
||||
}
|
||||
|
||||
#endif /* XML_TOK_NS_C */
|
|
@ -1,41 +0,0 @@
|
|||
// file : libstudxml/details/export.hxx
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#ifndef LIBSTUDXML_DETAILS_EXPORT_HXX
|
||||
#define LIBSTUDXML_DETAILS_EXPORT_HXX
|
||||
|
||||
// Normally we don't export class templates (but do complete specializations),
|
||||
// inline functions, and classes with only inline member functions. Exporting
|
||||
// classes that inherit from non-exported/imported bases (e.g., std::string)
|
||||
// will end up badly. The only known workarounds are to not inherit or to not
|
||||
// export. Also, MinGW GCC doesn't like seeing non-exported function being
|
||||
// used before their inline definition. The workaround is to reorder code. In
|
||||
// the end it's all trial and error.
|
||||
|
||||
#if defined(LIBSTUDXML_STATIC) // Using static.
|
||||
# define LIBSTUDXML_EXPORT
|
||||
#elif defined(LIBSTUDXML_STATIC_BUILD) // Building static.
|
||||
# define LIBSTUDXML_EXPORT
|
||||
#elif defined(LIBSTUDXML_SHARED) // Using shared.
|
||||
# ifdef _WIN32
|
||||
# define LIBSTUDXML_EXPORT __declspec(dllimport)
|
||||
# else
|
||||
# define LIBSTUDXML_EXPORT
|
||||
# endif
|
||||
#elif defined(LIBSTUDXML_SHARED_BUILD) // Building shared.
|
||||
# ifdef _WIN32
|
||||
# define LIBSTUDXML_EXPORT __declspec(dllexport)
|
||||
# else
|
||||
# define LIBSTUDXML_EXPORT
|
||||
# endif
|
||||
#else
|
||||
// If none of the above macros are defined, then we assume we are being used
|
||||
// by some third-party build system that cannot/doesn't signal the library
|
||||
// type. Note that this fallback works for both static and shared but in case
|
||||
// of shared will be sub-optimal compared to having dllimport.
|
||||
//
|
||||
# define LIBSTUDXML_EXPORT // Using static or shared.
|
||||
#endif
|
||||
|
||||
#endif // LIBSTUDXML_DETAILS_EXPORT_HXX
|
|
@ -1,22 +0,0 @@
|
|||
Copyright (c) 2007-2019 Code Synthesis Tools CC.
|
||||
Copyright (c) Tim Bray and Sun Microsystems, 2004.
|
||||
|
||||
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.
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
This directory contains a customized version of the Genx XML generator
|
||||
library for internal use by libstudxml.
|
|
@ -1,394 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007-2019 Code Synthesis Tools CC.
|
||||
* Copyright (c) 2004 by Tim Bray and Sun Microsystems.
|
||||
*
|
||||
* For copying permission, see the accompanying COPYING file.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Construct character-properties tables for genx.
|
||||
* Quite likely there's a better way.
|
||||
* This version is generated semi-automatically from the source code of the
|
||||
* XML specification via emacs global replace and keyboard macros
|
||||
*/
|
||||
#include <libstudxml/details/genx/genx.h>
|
||||
|
||||
static void charProp(char * p, int c, int prop)
|
||||
{
|
||||
p[c] |= prop;
|
||||
}
|
||||
|
||||
static void rangeProp(char * p, size_t start, size_t end, int prop)
|
||||
{
|
||||
size_t i;
|
||||
for (i = start; i <= end; i++)
|
||||
p[i] |= prop;
|
||||
}
|
||||
|
||||
void genxSetCharProps(char * p)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < GENX_CHAR_TABLE_SIZE; i++)
|
||||
p[i] = 0;
|
||||
|
||||
/* per XML 1.0 */
|
||||
charProp(p, 0x9, GENX_XML_CHAR);
|
||||
charProp(p, 0xa, GENX_XML_CHAR);
|
||||
charProp(p, 0xd, GENX_XML_CHAR);
|
||||
rangeProp(p, 0x20, 0xff, GENX_XML_CHAR);
|
||||
|
||||
#if GENX_CHAR_TABLE_SIZE == 0x10000
|
||||
rangeProp(p, 0x0100, 0xd7ff, GENX_XML_CHAR);
|
||||
rangeProp(p, 0xe000, 0xfffd, GENX_XML_CHAR);
|
||||
#endif
|
||||
|
||||
/* Letter ::= BaseChar | Ideographic */
|
||||
rangeProp(p, 0x0041, 0x005A, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0061, 0x007A, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x00C0, 0x00D6, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x00D8, 0x00F6, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x00F8, 0x00FF, GENX_LETTER|GENX_NAMECHAR);
|
||||
|
||||
#if GENX_CHAR_TABLE_SIZE == 0x10000
|
||||
|
||||
rangeProp(p, 0x0100, 0x0131, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0134, 0x013E, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0141, 0x0148, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x014A, 0x017E, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0180, 0x01C3, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x01CD, 0x01F0, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x01F4, 0x01F5, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x01FA, 0x0217, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0250, 0x02A8, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x02BB, 0x02C1, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0386, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0388, 0x038A, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x038C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x038E, 0x03A1, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x03A3, 0x03CE, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x03D0, 0x03D6, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x03DA, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x03DC, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x03DE, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x03E0, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x03E2, 0x03F3, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0401, 0x040C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x040E, 0x044F, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0451, 0x045C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x045E, 0x0481, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0490, 0x04C4, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x04C7, 0x04C8, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x04CB, 0x04CC, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x04D0, 0x04EB, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x04EE, 0x04F5, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x04F8, 0x04F9, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0531, 0x0556, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0559, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0561, 0x0586, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x05D0, 0x05EA, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x05F0, 0x05F2, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0621, 0x063A, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0641, 0x064A, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0671, 0x06B7, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x06BA, 0x06BE, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x06C0, 0x06CE, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x06D0, 0x06D3, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x06D5, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x06E5, 0x06E6, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0905, 0x0939, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x093D, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0958, 0x0961, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0985, 0x098C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x098F, 0x0990, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0993, 0x09A8, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x09AA, 0x09B0, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x09B2, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x09B6, 0x09B9, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x09DC, 0x09DD, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x09DF, 0x09E1, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x09F0, 0x09F1, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A05, 0x0A0A, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A0F, 0x0A10, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A13, 0x0A28, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A2A, 0x0A30, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A32, 0x0A33, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A35, 0x0A36, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A38, 0x0A39, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A59, 0x0A5C, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0A5E, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A72, 0x0A74, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A85, 0x0A8B, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0A8D, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A8F, 0x0A91, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A93, 0x0AA8, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0AAA, 0x0AB0, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0AB2, 0x0AB3, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0AB5, 0x0AB9, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0ABD, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0AE0, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B05, 0x0B0C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B0F, 0x0B10, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B13, 0x0B28, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B2A, 0x0B30, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B32, 0x0B33, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B36, 0x0B39, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0B3D, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B5C, 0x0B5D, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B5F, 0x0B61, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B85, 0x0B8A, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B8E, 0x0B90, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B92, 0x0B95, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B99, 0x0B9A, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0B9C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B9E, 0x0B9F, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0BA3, 0x0BA4, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0BA8, 0x0BAA, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0BAE, 0x0BB5, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0BB7, 0x0BB9, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C05, 0x0C0C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C0E, 0x0C10, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C12, 0x0C28, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C2A, 0x0C33, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C35, 0x0C39, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C60, 0x0C61, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C85, 0x0C8C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C8E, 0x0C90, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C92, 0x0CA8, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0CAA, 0x0CB3, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0CB5, 0x0CB9, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0CDE, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0CE0, 0x0CE1, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0D05, 0x0D0C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0D0E, 0x0D10, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0D12, 0x0D28, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0D2A, 0x0D39, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0D60, 0x0D61, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0E01, 0x0E2E, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0E30, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0E32, 0x0E33, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0E40, 0x0E45, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0E81, 0x0E82, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0E84, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0E87, 0x0E88, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0E8A, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0E8D, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0E94, 0x0E97, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0E99, 0x0E9F, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0EA1, 0x0EA3, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0EA5, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0EA7, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0EAA, 0x0EAB, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0EAD, 0x0EAE, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0EB0, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0EB2, 0x0EB3, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0EBD, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0EC0, 0x0EC4, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0F40, 0x0F47, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0F49, 0x0F69, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x10A0, 0x10C5, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x10D0, 0x10F6, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1100, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1102, 0x1103, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1105, 0x1107, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1109, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x110B, 0x110C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x110E, 0x1112, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x113C, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x113E, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1140, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x114C, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x114E, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1150, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1154, 0x1155, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1159, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x115F, 0x1161, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1163, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1165, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1167, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1169, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x116D, 0x116E, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1172, 0x1173, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1175, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x119E, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x11A8, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x11AB, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x11AE, 0x11AF, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x11B7, 0x11B8, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x11BA, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x11BC, 0x11C2, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x11EB, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x11F0, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x11F9, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1E00, 0x1E9B, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1EA0, 0x1EF9, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1F00, 0x1F15, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1F18, 0x1F1D, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1F20, 0x1F45, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1F48, 0x1F4D, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1F50, 0x1F57, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1F59, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1F5B, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1F5D, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1F5F, 0x1F7D, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1F80, 0x1FB4, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1FB6, 0x1FBC, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x1FBE, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1FC2, 0x1FC4, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1FC6, 0x1FCC, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1FD0, 0x1FD3, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1FD6, 0x1FDB, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1FE0, 0x1FEC, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1FF2, 0x1FF4, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x1FF6, 0x1FFC, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x2126, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x212A, 0x212B, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x212E, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x2180, 0x2182, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x3041, 0x3094, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x30A1, 0x30FA, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x3105, 0x312C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0xAC00, 0xD7A3, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x4E00, 0x9FA5, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x3007, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x3021, 0x3029, GENX_LETTER|GENX_NAMECHAR);
|
||||
|
||||
#endif /* GENX_CHAR_TABLE_SIZE == 0x10000 */
|
||||
|
||||
/*
|
||||
* NameChar ::=
|
||||
* Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
|
||||
*/
|
||||
|
||||
charProp(p, '.', GENX_NAMECHAR);
|
||||
charProp(p, '-', GENX_NAMECHAR);
|
||||
charProp(p, '_', GENX_NAMECHAR);
|
||||
|
||||
rangeProp(p, 0x0030, 0x0039, GENX_NAMECHAR);
|
||||
charProp(p, 0x00B7, GENX_LETTER|GENX_NAMECHAR);
|
||||
|
||||
#if GENX_CHAR_TABLE_SIZE == 0x10000
|
||||
|
||||
rangeProp(p, 0x0660, 0x0669, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x06F0, 0x06F9, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0966, 0x096F, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x09E6, 0x09EF, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A66, 0x0A6F, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0AE6, 0x0AEF, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B66, 0x0B6F, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0BE7, 0x0BEF, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C66, 0x0C6F, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0CE6, 0x0CEF, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0D66, 0x0D6F, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0E50, 0x0E59, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0ED0, 0x0ED9, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0F20, 0x0F29, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0300, 0x0345, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0360, 0x0361, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0483, 0x0486, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0591, 0x05A1, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x05A3, 0x05B9, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x05BB, 0x05BD, GENX_NAMECHAR);
|
||||
charProp(p, 0x05BF, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x05C1, 0x05C2, GENX_NAMECHAR);
|
||||
charProp(p, 0x05C4, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x064B, 0x0652, GENX_NAMECHAR);
|
||||
charProp(p, 0x0670, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x06D6, 0x06DC, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x06DD, 0x06DF, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x06E0, 0x06E4, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x06E7, 0x06E8, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x06EA, 0x06ED, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0901, 0x0903, GENX_NAMECHAR);
|
||||
charProp(p, 0x093C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x093E, 0x094C, GENX_NAMECHAR);
|
||||
charProp(p, 0x094D, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0951, 0x0954, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0962, 0x0963, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0981, 0x0983, GENX_NAMECHAR);
|
||||
charProp(p, 0x09BC, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x09BE, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x09BF, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x09C0, 0x09C4, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x09C7, 0x09C8, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x09CB, 0x09CD, GENX_NAMECHAR);
|
||||
charProp(p, 0x09D7, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x09E2, 0x09E3, GENX_NAMECHAR);
|
||||
charProp(p, 0x0A02, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0A3C, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0A3E, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0A3F, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A40, 0x0A42, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A47, 0x0A48, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A4B, 0x0A4D, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A70, 0x0A71, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0A81, 0x0A83, GENX_NAMECHAR);
|
||||
charProp(p, 0x0ABC, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0ABE, 0x0AC5, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0AC7, 0x0AC9, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0ACB, 0x0ACD, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B01, 0x0B03, GENX_NAMECHAR);
|
||||
charProp(p, 0x0B3C, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B3E, 0x0B43, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B47, 0x0B48, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B4B, 0x0B4D, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B56, 0x0B57, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0B82, 0x0B83, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0BBE, 0x0BC2, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0BC6, 0x0BC8, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0BCA, 0x0BCD, GENX_NAMECHAR);
|
||||
charProp(p, 0x0BD7, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C01, 0x0C03, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C3E, 0x0C44, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C46, 0x0C48, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C4A, 0x0C4D, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C55, 0x0C56, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0C82, 0x0C83, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0CBE, 0x0CC4, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0CC6, 0x0CC8, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0CCA, 0x0CCD, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0CD5, 0x0CD6, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0D02, 0x0D03, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0D3E, 0x0D43, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0D46, 0x0D48, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0D4A, 0x0D4D, GENX_NAMECHAR);
|
||||
charProp(p, 0x0D57, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0E31, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0E34, 0x0E3A, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0E47, 0x0E4E, GENX_NAMECHAR);
|
||||
charProp(p, 0x0EB1, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0EB4, 0x0EB9, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0EBB, 0x0EBC, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0EC8, 0x0ECD, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0F18, 0x0F19, GENX_NAMECHAR);
|
||||
charProp(p, 0x0F35, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0F37, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0F39, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0F3E, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0F3F, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0F71, 0x0F84, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0F86, 0x0F8B, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0F90, 0x0F95, GENX_NAMECHAR);
|
||||
charProp(p, 0x0F97, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0F99, 0x0FAD, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x0FB1, 0x0FB7, GENX_NAMECHAR);
|
||||
charProp(p, 0x0FB9, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x20D0, 0x20DC, GENX_NAMECHAR);
|
||||
charProp(p, 0x20E1, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x302A, 0x302F, GENX_NAMECHAR);
|
||||
charProp(p, 0x3099, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x309A, GENX_LETTER|GENX_NAMECHAR);
|
||||
|
||||
charProp(p, 0x02D0, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x02D1, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0387, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0640, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0E46, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x0EC6, GENX_LETTER|GENX_NAMECHAR);
|
||||
charProp(p, 0x3005, GENX_LETTER|GENX_NAMECHAR);
|
||||
rangeProp(p, 0x3031, 0x3035, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x309D, 0x309E, GENX_NAMECHAR);
|
||||
rangeProp(p, 0x30FC, 0x30FE, GENX_NAMECHAR);
|
||||
|
||||
#endif /* GENX_CHAR_TABLE_SIZE == 0x10000 */
|
||||
}
|
2502
third-party/libstudxml/libstudxml/details/genx/genx.c
vendored
2502
third-party/libstudxml/libstudxml/details/genx/genx.c
vendored
File diff suppressed because it is too large
Load Diff
|
@ -1,390 +0,0 @@
|
|||
/*
|
||||
* genx - C-callable library for generating XML documents
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2007-2019 Code Synthesis Tools CC.
|
||||
* Copyright (c) 2004 by Tim Bray and Sun Microsystems.
|
||||
*
|
||||
* For copying permission, see the accompanying COPYING file.
|
||||
*/
|
||||
|
||||
#ifndef GENX_H
|
||||
#define GENX_H
|
||||
|
||||
#include <stddef.h> /* size_t */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Note on error handling: genx routines mostly return
|
||||
* GENX_SUCCESS (guaranteed to be zero) in normal circumstances, one of
|
||||
* these other GENX_ values on a memory allocation or I/O failure or if the
|
||||
* call would result in non-well-formed output.
|
||||
* You can associate an error message with one of these codes explicitly
|
||||
* or with the most recent error using genxGetErrorMessage() and
|
||||
* genxLastErrorMessage(); see below.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GENX_SUCCESS = 0,
|
||||
GENX_BAD_UTF8,
|
||||
GENX_NON_XML_CHARACTER,
|
||||
GENX_BAD_NAME,
|
||||
GENX_ALLOC_FAILED,
|
||||
GENX_BAD_NAMESPACE_NAME,
|
||||
GENX_INTERNAL_ERROR,
|
||||
GENX_DUPLICATE_PREFIX,
|
||||
GENX_SEQUENCE_ERROR,
|
||||
GENX_NO_START_TAG,
|
||||
GENX_IO_ERROR,
|
||||
GENX_MISSING_VALUE,
|
||||
GENX_MALFORMED_COMMENT,
|
||||
GENX_XML_PI_TARGET,
|
||||
GENX_MALFORMED_PI,
|
||||
GENX_DUPLICATE_ATTRIBUTE,
|
||||
GENX_ATTRIBUTE_IN_DEFAULT_NAMESPACE,
|
||||
GENX_DUPLICATE_NAMESPACE,
|
||||
GENX_BAD_DEFAULT_DECLARATION
|
||||
} genxStatus;
|
||||
|
||||
/* character types */
|
||||
#define GENX_XML_CHAR 1
|
||||
#define GENX_LETTER 2
|
||||
#define GENX_NAMECHAR 4
|
||||
|
||||
/* The size of the character table. Valid values are 0x100 (first 255
|
||||
chars are checked) and 0x10000 (all chars are checked). */
|
||||
#ifndef GENX_CHAR_TABLE_SIZE
|
||||
# define GENX_CHAR_TABLE_SIZE 0x100
|
||||
#endif
|
||||
|
||||
/* a UTF-8 string */
|
||||
typedef unsigned char * utf8;
|
||||
typedef const unsigned char * constUtf8;
|
||||
|
||||
/*
|
||||
* genx's own types
|
||||
*/
|
||||
typedef struct genxWriter_rec * genxWriter;
|
||||
typedef struct genxNamespace_rec * genxNamespace;
|
||||
typedef struct genxElement_rec * genxElement;
|
||||
typedef struct genxAttribute_rec * genxAttribute;
|
||||
|
||||
typedef void * (*genxAlloc) (void * userData, size_t bytes);
|
||||
typedef void (*genxDealloc) (void * userData, void* data);
|
||||
|
||||
/*
|
||||
* Constructors, set/get
|
||||
*/
|
||||
|
||||
/*
|
||||
* Create a new writer. For generating multiple XML documents, it's most
|
||||
* efficient to re-use the same genx object. However, you can only write
|
||||
* one document at a time with a writer.
|
||||
* Returns NULL if it fails, which can only be due to an allocation failure.
|
||||
*/
|
||||
genxWriter genxNew(genxAlloc alloc, genxDealloc dealloc, void * userData);
|
||||
|
||||
/*
|
||||
* Reset the writer object back into usable state after an error or
|
||||
* interruption.
|
||||
*/
|
||||
genxStatus genxReset (genxWriter w);
|
||||
|
||||
/*
|
||||
* Dispose of a writer, freeing all associated memory
|
||||
*/
|
||||
void genxDispose(genxWriter w);
|
||||
|
||||
/*
|
||||
* Set/get
|
||||
*/
|
||||
|
||||
/*
|
||||
* The userdata pointer will be passed to memory-allocation
|
||||
* and I/O callbacks. If not set, genx will pass NULL
|
||||
*/
|
||||
void genxSetUserData(genxWriter w, void * userData);
|
||||
void * genxGetUserData(genxWriter w);
|
||||
|
||||
/*
|
||||
* Set/get pretty-printing. If indentation is set to 0, then no pretty-
|
||||
* printing is performed.
|
||||
*/
|
||||
genxStatus genxSetPrettyPrint(genxWriter w, int indentation);
|
||||
int genxGetPrettyPrint(genxWriter w);
|
||||
|
||||
/*
|
||||
* Suspend/resume pretty-printing. Pretty-printing can be suspended
|
||||
* only inside an element and, unless explicitly resumed, it will
|
||||
* remain suspended until the end of that element. You should only
|
||||
* explicitly resume pretty-printing at the element nesting level
|
||||
* of suspension. If pretty-printing is already suspended at an
|
||||
* outer nesting level, then subsequent calls to suspend/resume
|
||||
* are ignored. The PrettyPrintSuspended() function can be used
|
||||
* to check if pretty-printing is currently suspended. If it is
|
||||
* not, then this function returns 0. Otherwise, it returns the
|
||||
* level at which pretty-printing was suspended, with root element
|
||||
* being level 1.
|
||||
*/
|
||||
genxStatus genxSuspendPrettyPrint(genxWriter w);
|
||||
genxStatus genxResumePrettyPrint(genxWriter w);
|
||||
int genxPrettyPrintSuspended(genxWriter w);
|
||||
|
||||
|
||||
/*
|
||||
* Set/get canonicalization. If true, then output explicit closing
|
||||
* tags and sort attributes. Default is false.
|
||||
*/
|
||||
genxStatus genxSetCanonical(genxWriter w, int flag);
|
||||
int genxGetCanonical(genxWriter w);
|
||||
|
||||
/*
|
||||
* User-provided memory allocator, if desired. For example, if you were
|
||||
* in an Apache module, you could arrange for genx to use ap_palloc by
|
||||
* making the pool accessible via the userData call.
|
||||
* The "dealloc" is to be used to free memory allocated with "alloc". If
|
||||
* alloc is provided but dealloc is NULL, genx will not attempt to free
|
||||
* the memory; this would be appropriate in an Apache context.
|
||||
* If "alloc" is not provided, genx routines use malloc() to allocate memory
|
||||
*/
|
||||
void genxSetAlloc(genxWriter w, genxAlloc alloc);
|
||||
void genxSetDealloc(genxWriter w, genxDealloc dealloc);
|
||||
genxAlloc genxGetAlloc(genxWriter w);
|
||||
genxDealloc genxGetDealloc(genxWriter w);
|
||||
|
||||
/*
|
||||
* Get the prefix associated with a namespace
|
||||
*/
|
||||
utf8 genxGetNamespacePrefix(genxNamespace ns);
|
||||
|
||||
/*
|
||||
* Declaration functions
|
||||
*/
|
||||
|
||||
/*
|
||||
* Declare a namespace. The provided prefix is the default but can be
|
||||
* overridden by genxAddNamespace. If no default prefiix is provided,
|
||||
* genx will generate one of the form g-%d.
|
||||
* On error, returns NULL and signals via statusp
|
||||
*/
|
||||
genxNamespace genxDeclareNamespace(genxWriter w,
|
||||
constUtf8 uri, constUtf8 prefix,
|
||||
genxStatus * statusP);
|
||||
|
||||
/*
|
||||
* Declare an element
|
||||
* If something failed, returns NULL and sets the status code via statusP
|
||||
*/
|
||||
genxElement genxDeclareElement(genxWriter w,
|
||||
genxNamespace ns, constUtf8 name,
|
||||
genxStatus * statusP);
|
||||
|
||||
/*
|
||||
* Declare an attribute
|
||||
*/
|
||||
genxAttribute genxDeclareAttribute(genxWriter w,
|
||||
genxNamespace ns,
|
||||
constUtf8 name, genxStatus * statusP);
|
||||
|
||||
/*
|
||||
* Writing XML
|
||||
*/
|
||||
|
||||
/*
|
||||
* Caller-provided I/O package.
|
||||
* First form is for a null-terminated string.
|
||||
* for second, if you have s="abcdef" and want to send "abc", you'd call
|
||||
* sendBounded(userData, s, s + 3)
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
genxStatus (* send)(void * userData, constUtf8 s);
|
||||
genxStatus (* sendBounded)(void * userData, constUtf8 start, constUtf8 end);
|
||||
genxStatus (* flush)(void * userData);
|
||||
} genxSender;
|
||||
|
||||
genxStatus genxStartDocSender(genxWriter w, genxSender * sender);
|
||||
|
||||
/*
|
||||
* End a document. Calls "flush".
|
||||
*/
|
||||
genxStatus genxEndDocument(genxWriter w);
|
||||
|
||||
/*
|
||||
* Write XML declaration. If encoding or standalone are NULL, then those
|
||||
* attributes are omitted.
|
||||
*/
|
||||
genxStatus genxXmlDeclaration(genxWriter w,
|
||||
constUtf8 version,
|
||||
constUtf8 encoding,
|
||||
constUtf8 standalone);
|
||||
/*
|
||||
* Write DOCTYPE declaration. If public_id is not NULL, then this is
|
||||
* a PUBLIC DOCTYPE declaration, otherwise, if system_id is not NULL,
|
||||
* then this is a SYSTEM DOCTYPE. If both are NULL, then a DOCTYPE
|
||||
* that only contains the root element and, if not NULL, internal
|
||||
* subset is written.
|
||||
*/
|
||||
genxStatus genxDoctypeDeclaration(genxWriter w,
|
||||
constUtf8 root_element,
|
||||
constUtf8 public_id,
|
||||
constUtf8 system_id,
|
||||
constUtf8 internal_subset);
|
||||
|
||||
/*
|
||||
* Write a comment
|
||||
*/
|
||||
genxStatus genxComment(genxWriter w, constUtf8 text);
|
||||
|
||||
/*
|
||||
* Write a PI
|
||||
*/
|
||||
genxStatus genxPI(genxWriter w, constUtf8 target, constUtf8 text);
|
||||
|
||||
/*
|
||||
* Start an element
|
||||
*/
|
||||
genxStatus genxStartElementLiteral(genxWriter w,
|
||||
constUtf8 xmlns, constUtf8 name);
|
||||
|
||||
/*
|
||||
* Start a predeclared element
|
||||
* - element must have been declared
|
||||
*/
|
||||
genxStatus genxStartElement(genxElement e);
|
||||
|
||||
/*
|
||||
* Get current element. The returned values are valid until this
|
||||
* element ceases to be current (i.e., EndElement() is called).
|
||||
* If the element is unqualified, then xmlns is set to NULL.
|
||||
*/
|
||||
genxStatus genxGetCurrentElement (genxWriter w,
|
||||
constUtf8* xmlns, constUtf8* name);
|
||||
|
||||
/*
|
||||
* Write an attribute
|
||||
*/
|
||||
genxStatus genxAddAttributeLiteral(genxWriter w, constUtf8 xmlns,
|
||||
constUtf8 name, constUtf8 value);
|
||||
|
||||
/*
|
||||
* Write a predeclared attribute
|
||||
*/
|
||||
genxStatus genxAddAttribute(genxAttribute a, constUtf8 value);
|
||||
|
||||
/*
|
||||
* Start an attribute
|
||||
*/
|
||||
genxStatus genxStartAttributeLiteral(genxWriter w,
|
||||
constUtf8 xmlns, constUtf8 name);
|
||||
|
||||
/*
|
||||
* Start a predeclared attribute
|
||||
*/
|
||||
genxStatus genxStartAttribute(genxAttribute a);
|
||||
|
||||
/*
|
||||
* Get current attribute. The returned values are valid until this
|
||||
* attribute ceases to be current (i.e., EndAttribute() is called).
|
||||
* If the attribute is unqualified, then xmlns is set to NULL.
|
||||
*/
|
||||
genxStatus genxGetCurrentAttribute (genxWriter w,
|
||||
constUtf8* xmlns, constUtf8* name);
|
||||
|
||||
/*
|
||||
* End an attribute
|
||||
*/
|
||||
genxStatus genxEndAttribute(genxWriter w);
|
||||
|
||||
/*
|
||||
* add a namespace declaration
|
||||
*/
|
||||
genxStatus genxAddNamespaceLiteral(genxWriter w,
|
||||
constUtf8 uri, constUtf8 prefix);
|
||||
|
||||
/*
|
||||
* add a predefined namespace declaration
|
||||
*/
|
||||
genxStatus genxAddNamespace(genxNamespace ns, constUtf8 prefix);
|
||||
|
||||
/*
|
||||
* Clear default namespace declaration
|
||||
*/
|
||||
genxStatus genxUnsetDefaultNamespace(genxWriter w);
|
||||
|
||||
/*
|
||||
* Write an end tag
|
||||
*/
|
||||
genxStatus genxEndElement(genxWriter w);
|
||||
|
||||
/*
|
||||
* Write some text
|
||||
* You can't write any text outside the root element, except with
|
||||
* genxComment and genxPI.
|
||||
*/
|
||||
genxStatus genxAddText(genxWriter w, constUtf8 start);
|
||||
genxStatus genxAddCountedText(genxWriter w, constUtf8 start, size_t byteCount);
|
||||
genxStatus genxAddBoundedText(genxWriter w, constUtf8 start, constUtf8 end);
|
||||
|
||||
/*
|
||||
* Write one character. The integer value is the Unicode character
|
||||
* value, as usually expressed in U+XXXX notation.
|
||||
*/
|
||||
genxStatus genxAddCharacter(genxWriter w, int c);
|
||||
|
||||
/*
|
||||
* Utility routines
|
||||
*/
|
||||
|
||||
/*
|
||||
* Return the Unicode character encoded by the UTF-8 pointed-to by the
|
||||
* argument, and advance the argument past the encoding of the character.
|
||||
* Returns -1 if the UTF-8 is malformed, in which case advances the
|
||||
* argument to point at the first byte past the point past the malformed
|
||||
* ones.
|
||||
*/
|
||||
int genxNextUnicodeChar(constUtf8 * sp);
|
||||
|
||||
/*
|
||||
* Scan a buffer allegedly full of UTF-8 encoded XML characters; return
|
||||
* one of GENX_SUCCESS, GENX_BAD_UTF8, or GENX_NON_XML_CHARACTER
|
||||
*/
|
||||
genxStatus genxCheckText(genxWriter w, constUtf8 s);
|
||||
|
||||
/*
|
||||
* return character status, the OR of GENX_XML_CHAR,
|
||||
* GENX_LETTER, and GENX_NAMECHAR
|
||||
*/
|
||||
int genxCharClass(genxWriter w, int c);
|
||||
|
||||
/*
|
||||
* Silently wipe any non-XML characters out of a chunk of text.
|
||||
* If you call this on a string before you pass it addText or
|
||||
* addAttribute, you will never get an error from genx unless
|
||||
* (a) there's a bug in your software, e.g. a malformed element name, or
|
||||
* (b) there's a memory allocation or I/O error
|
||||
* The output can never be longer than the input.
|
||||
* Returns true if any changes were made.
|
||||
*/
|
||||
int genxScrubText(genxWriter w, constUtf8 in, utf8 out);
|
||||
|
||||
/*
|
||||
* return error messages
|
||||
*/
|
||||
char * genxGetErrorMessage(genxWriter w, genxStatus status);
|
||||
char * genxLastErrorMessage(genxWriter w);
|
||||
|
||||
/*
|
||||
* return version
|
||||
*/
|
||||
char * genxGetVersion();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* GENX_H */
|
|
@ -1,7 +0,0 @@
|
|||
// file : libstudxml/details/post.hxx
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning (pop)
|
||||
#endif
|
|
@ -1,21 +0,0 @@
|
|||
// file : libstudxml/details/pre.hxx
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#ifdef _MSC_VER
|
||||
// Push warning state.
|
||||
//
|
||||
# pragma warning (push, 3)
|
||||
|
||||
// Disabled warnings.
|
||||
//
|
||||
# pragma warning (disable:4251) // needs to have DLL-interface
|
||||
# pragma warning (disable:4290) // exception specification ignored
|
||||
# pragma warning (disable:4355) // passing 'this' to a member
|
||||
# pragma warning (disable:4800) // forcing value to bool
|
||||
|
||||
// Elevated warnings.
|
||||
//
|
||||
# pragma warning (2:4239) // standard doesn't allow this conversion
|
||||
|
||||
#endif
|
19
third-party/libstudxml/libstudxml/exception.hxx
vendored
19
third-party/libstudxml/libstudxml/exception.hxx
vendored
|
@ -1,19 +0,0 @@
|
|||
// file : libstudxml/exception.hxx -*- C++ -*-
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#ifndef LIBSTUDXML_EXCEPTION_HXX
|
||||
#define LIBSTUDXML_EXCEPTION_HXX
|
||||
|
||||
#include <libstudxml/details/pre.hxx>
|
||||
|
||||
#include <exception>
|
||||
|
||||
namespace xml
|
||||
{
|
||||
class exception: public std::exception {};
|
||||
}
|
||||
|
||||
#include <libstudxml/details/post.hxx>
|
||||
|
||||
#endif // LIBSTUDXML_EXCEPTION_HXX
|
22
third-party/libstudxml/libstudxml/forward.hxx
vendored
22
third-party/libstudxml/libstudxml/forward.hxx
vendored
|
@ -1,22 +0,0 @@
|
|||
// file : libstudxml/forward.hxx -*- C++ -*-
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#ifndef LIBSTUDXML_FORWARD_HXX
|
||||
#define LIBSTUDXML_FORWARD_HXX
|
||||
|
||||
#include <libstudxml/details/pre.hxx>
|
||||
|
||||
#include <libstudxml/version.hxx>
|
||||
|
||||
namespace xml
|
||||
{
|
||||
class qname;
|
||||
class parser;
|
||||
class serializer;
|
||||
class exception;
|
||||
}
|
||||
|
||||
#include <libstudxml/details/post.hxx>
|
||||
|
||||
#endif // LIBSTUDXML_FORWARD_HXX
|
937
third-party/libstudxml/libstudxml/parser.cxx
vendored
937
third-party/libstudxml/libstudxml/parser.cxx
vendored
|
@ -1,937 +0,0 @@
|
|||
// file : libstudxml/parser.cxx
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#include <new> // std::bad_alloc
|
||||
#include <cassert>
|
||||
#include <cstring> // std::strchr
|
||||
#include <istream>
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
#include <libstudxml/parser.hxx>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace xml
|
||||
{
|
||||
// parsing
|
||||
//
|
||||
void parsing::
|
||||
init ()
|
||||
{
|
||||
ostringstream os;
|
||||
if (!name_.empty ())
|
||||
os << name_ << ':';
|
||||
os << line_ << ':' << column_ << ": error: " << description_;
|
||||
what_ = os.str ();
|
||||
}
|
||||
|
||||
// parser::event_type
|
||||
//
|
||||
static const char* parser_event_str[] =
|
||||
{
|
||||
"start element",
|
||||
"end element",
|
||||
"start attribute",
|
||||
"end attribute",
|
||||
"characters",
|
||||
"start namespace declaration",
|
||||
"end namespace declaration",
|
||||
"end of file"
|
||||
};
|
||||
|
||||
ostream&
|
||||
operator<< (ostream& os, parser::event_type e)
|
||||
{
|
||||
return os << parser_event_str[e];
|
||||
}
|
||||
|
||||
// parser
|
||||
//
|
||||
parser::
|
||||
~parser ()
|
||||
{
|
||||
if (p_ != 0)
|
||||
XML_ParserFree (p_);
|
||||
}
|
||||
|
||||
void parser::
|
||||
init ()
|
||||
{
|
||||
depth_ = 0;
|
||||
state_ = state_next;
|
||||
event_ = eof;
|
||||
queue_ = eof;
|
||||
|
||||
pqname_ = &qname_;
|
||||
pvalue_ = &value_;
|
||||
|
||||
line_ = 0;
|
||||
column_ = 0;
|
||||
|
||||
attr_i_ = 0;
|
||||
start_ns_i_ = 0;
|
||||
end_ns_i_ = 0;
|
||||
|
||||
if ((feature_ & receive_attributes_map) != 0 &&
|
||||
(feature_ & receive_attributes_event) != 0)
|
||||
feature_ &= ~receive_attributes_map;
|
||||
|
||||
// Allocate the parser. Make sure nothing else can throw after
|
||||
// this call since otherwise we will leak it.
|
||||
//
|
||||
p_ = XML_ParserCreateNS (0, XML_Char (' '));
|
||||
|
||||
if (p_ == 0)
|
||||
throw bad_alloc ();
|
||||
|
||||
// Get prefixes in addition to namespaces and local names.
|
||||
//
|
||||
XML_SetReturnNSTriplet (p_, true);
|
||||
|
||||
// Set handlers.
|
||||
//
|
||||
XML_SetUserData(p_, this);
|
||||
|
||||
if ((feature_ & receive_elements) != 0)
|
||||
{
|
||||
XML_SetStartElementHandler (p_, &start_element_);
|
||||
XML_SetEndElementHandler (p_, &end_element_);
|
||||
}
|
||||
|
||||
if ((feature_ & receive_characters) != 0)
|
||||
XML_SetCharacterDataHandler (p_, &characters_);
|
||||
|
||||
if ((feature_ & receive_namespace_decls) != 0)
|
||||
XML_SetNamespaceDeclHandler (p_,
|
||||
&start_namespace_decl_,
|
||||
&end_namespace_decl_);
|
||||
}
|
||||
|
||||
void parser::
|
||||
handle_error ()
|
||||
{
|
||||
XML_Error e (XML_GetErrorCode (p_));
|
||||
|
||||
if (e == XML_ERROR_ABORTED)
|
||||
{
|
||||
// For now we only abort the parser in the characters_() and
|
||||
// start_element_() handlers.
|
||||
//
|
||||
switch (content ())
|
||||
{
|
||||
case content_type::empty:
|
||||
throw parsing (*this, "characters in empty content");
|
||||
case content_type::simple:
|
||||
throw parsing (*this, "element in simple content");
|
||||
case content_type::complex:
|
||||
throw parsing (*this, "characters in complex content");
|
||||
default:
|
||||
assert (false);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw parsing (iname_,
|
||||
XML_GetCurrentLineNumber (p_),
|
||||
XML_GetCurrentColumnNumber (p_),
|
||||
XML_ErrorString (e));
|
||||
}
|
||||
|
||||
struct stream_exception_controller
|
||||
{
|
||||
~stream_exception_controller ()
|
||||
{
|
||||
istream::iostate s = is_.rdstate ();
|
||||
s &= ~istream::failbit;
|
||||
|
||||
// If our error state (sans failbit) intersects with the
|
||||
// exception state then that means we have an active
|
||||
// exception and changing error/exception state will
|
||||
// cause another to be thrown.
|
||||
//
|
||||
if (!(old_state_ & s))
|
||||
{
|
||||
// Clear failbit if it was caused by eof.
|
||||
//
|
||||
if (is_.fail () && is_.eof ())
|
||||
is_.clear (s);
|
||||
|
||||
is_.exceptions (old_state_);
|
||||
}
|
||||
}
|
||||
|
||||
stream_exception_controller (istream& is)
|
||||
: is_ (is), old_state_ (is_.exceptions ())
|
||||
{
|
||||
is_.exceptions (old_state_ & ~istream::failbit);
|
||||
}
|
||||
|
||||
private:
|
||||
stream_exception_controller (const stream_exception_controller&);
|
||||
|
||||
stream_exception_controller&
|
||||
operator= (const stream_exception_controller&);
|
||||
|
||||
private:
|
||||
istream& is_;
|
||||
istream::iostate old_state_;
|
||||
};
|
||||
|
||||
parser::event_type parser::
|
||||
next ()
|
||||
{
|
||||
if (state_ == state_next)
|
||||
return next_ (false);
|
||||
else
|
||||
{
|
||||
// If we previously peeked at start/end_element, then adjust
|
||||
// state accordingly.
|
||||
//
|
||||
switch (event_)
|
||||
{
|
||||
case end_element:
|
||||
{
|
||||
if (!element_state_.empty () &&
|
||||
element_state_.back ().depth == depth_)
|
||||
pop_element ();
|
||||
|
||||
depth_--;
|
||||
break;
|
||||
}
|
||||
case start_element:
|
||||
{
|
||||
depth_++;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
state_ = state_next;
|
||||
return event_;
|
||||
}
|
||||
}
|
||||
|
||||
const string& parser::
|
||||
attribute (const qname_type& qn) const
|
||||
{
|
||||
if (const element_entry* e = get_element ())
|
||||
{
|
||||
attribute_map_type::const_iterator i (e->attr_map_.find (qn));
|
||||
|
||||
if (i != e->attr_map_.end ())
|
||||
{
|
||||
if (!i->second.handled)
|
||||
{
|
||||
i->second.handled = true;
|
||||
e->attr_unhandled_--;
|
||||
}
|
||||
return i->second.value;
|
||||
}
|
||||
}
|
||||
|
||||
throw parsing (*this, "attribute '" + qn.string () + "' expected");
|
||||
}
|
||||
|
||||
string parser::
|
||||
attribute (const qname_type& qn, const string& dv) const
|
||||
{
|
||||
if (const element_entry* e = get_element ())
|
||||
{
|
||||
attribute_map_type::const_iterator i (e->attr_map_.find (qn));
|
||||
|
||||
if (i != e->attr_map_.end ())
|
||||
{
|
||||
if (!i->second.handled)
|
||||
{
|
||||
i->second.handled = true;
|
||||
e->attr_unhandled_--;
|
||||
}
|
||||
return i->second.value;
|
||||
}
|
||||
}
|
||||
|
||||
return dv;
|
||||
}
|
||||
|
||||
bool parser::
|
||||
attribute_present (const qname_type& qn) const
|
||||
{
|
||||
if (const element_entry* e = get_element ())
|
||||
{
|
||||
attribute_map_type::const_iterator i (e->attr_map_.find (qn));
|
||||
|
||||
if (i != e->attr_map_.end ())
|
||||
{
|
||||
if (!i->second.handled)
|
||||
{
|
||||
i->second.handled = true;
|
||||
e->attr_unhandled_--;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void parser::
|
||||
next_expect (event_type e)
|
||||
{
|
||||
if (next () != e)
|
||||
throw parsing (*this, string (parser_event_str[e]) + " expected");
|
||||
}
|
||||
|
||||
void parser::
|
||||
next_expect (event_type e, const string& ns, const string& n)
|
||||
{
|
||||
if (next () != e || namespace_ () != ns || name () != n)
|
||||
throw parsing (*this,
|
||||
string (parser_event_str[e]) + " '" +
|
||||
qname_type (ns, n).string () + "' expected");
|
||||
}
|
||||
|
||||
string parser::
|
||||
element ()
|
||||
{
|
||||
content (content_type::simple);
|
||||
string r;
|
||||
|
||||
// The content of the element can be empty in which case there
|
||||
// will be no characters event.
|
||||
//
|
||||
event_type e (next ());
|
||||
if (e == characters)
|
||||
{
|
||||
r.swap (value ());
|
||||
e = next ();
|
||||
}
|
||||
|
||||
// We cannot really get anything other than end_element since
|
||||
// the simple content validation won't allow it.
|
||||
//
|
||||
assert (e == end_element);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
string parser::
|
||||
element (const qname_type& qn, const string& dv)
|
||||
{
|
||||
if (peek () == start_element && qname () == qn)
|
||||
{
|
||||
next ();
|
||||
return element ();
|
||||
}
|
||||
|
||||
return dv;
|
||||
}
|
||||
|
||||
const parser::element_entry* parser::
|
||||
get_element_ () const
|
||||
{
|
||||
// The start_element_() Expat handler may have already provisioned
|
||||
// an entry in the element stack. In this case, we need to get the
|
||||
// one before it, if any.
|
||||
//
|
||||
const element_entry* r (0);
|
||||
element_state::size_type n (element_state_.size () - 1);
|
||||
|
||||
if (element_state_[n].depth == depth_)
|
||||
r = &element_state_[n];
|
||||
else if (n != 0 && element_state_[n].depth > depth_)
|
||||
{
|
||||
n--;
|
||||
if (element_state_[n].depth == depth_)
|
||||
r = &element_state_[n];
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
void parser::
|
||||
pop_element ()
|
||||
{
|
||||
// Make sure there are no unhandled attributes left.
|
||||
//
|
||||
const element_entry& e (element_state_.back ());
|
||||
if (e.attr_unhandled_ != 0)
|
||||
{
|
||||
// Find the first unhandled attribute and report it.
|
||||
//
|
||||
for (attribute_map_type::const_iterator i (e.attr_map_.begin ());
|
||||
i != e.attr_map_.end (); ++i)
|
||||
{
|
||||
if (!i->second.handled)
|
||||
throw parsing (
|
||||
*this, "unexpected attribute '" + i->first.string () + "'");
|
||||
}
|
||||
assert (false);
|
||||
}
|
||||
|
||||
element_state_.pop_back ();
|
||||
}
|
||||
|
||||
parser::event_type parser::
|
||||
next_ (bool peek)
|
||||
{
|
||||
event_type e (next_body ());
|
||||
|
||||
// Content-specific processing. Note that we handle characters in the
|
||||
// characters_() Expat handler for two reasons. Firstly, it is faster
|
||||
// to ignore the whitespaces at the source. Secondly, this allows us
|
||||
// to distinguish between element and attribute characters. We can
|
||||
// move this processing to the handler because the characters event
|
||||
// is never queued.
|
||||
//
|
||||
switch (e)
|
||||
{
|
||||
case end_element:
|
||||
{
|
||||
// If this is a peek, then avoid popping the stack just yet.
|
||||
// This way, the attribute map will still be valid until we
|
||||
// call next().
|
||||
//
|
||||
if (!peek)
|
||||
{
|
||||
if (!element_state_.empty () &&
|
||||
element_state_.back ().depth == depth_)
|
||||
pop_element ();
|
||||
|
||||
depth_--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case start_element:
|
||||
{
|
||||
if (const element_entry* e = get_element ())
|
||||
{
|
||||
switch (e->content)
|
||||
{
|
||||
case content_type::empty:
|
||||
throw parsing (*this, "element in empty content");
|
||||
case content_type::simple:
|
||||
throw parsing (*this, "element in simple content");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If this is a peek, then delay adjusting the depth.
|
||||
//
|
||||
if (!peek)
|
||||
depth_++;
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return e;
|
||||
}
|
||||
|
||||
parser::event_type parser::
|
||||
next_body ()
|
||||
{
|
||||
// See if we have any start namespace declarations we need to return.
|
||||
//
|
||||
if (start_ns_i_ < start_ns_.size ())
|
||||
{
|
||||
// Based on the previous event determine what's the next one must be.
|
||||
//
|
||||
switch (event_)
|
||||
{
|
||||
case start_namespace_decl:
|
||||
{
|
||||
if (++start_ns_i_ == start_ns_.size ())
|
||||
{
|
||||
start_ns_i_ = 0;
|
||||
start_ns_.clear ();
|
||||
pqname_ = &qname_;
|
||||
break; // No more declarations.
|
||||
}
|
||||
}
|
||||
// Fall through.
|
||||
case start_element:
|
||||
{
|
||||
event_ = start_namespace_decl;
|
||||
pqname_ = &start_ns_[start_ns_i_];
|
||||
return event_;
|
||||
}
|
||||
default:
|
||||
{
|
||||
assert (false);
|
||||
return event_ = eof;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See if we have any attributes we need to return as events.
|
||||
//
|
||||
if (attr_i_ < attr_.size ())
|
||||
{
|
||||
// Based on the previous event determine what's the next one must be.
|
||||
//
|
||||
switch (event_)
|
||||
{
|
||||
case start_attribute:
|
||||
{
|
||||
event_ = characters;
|
||||
pvalue_ = &attr_[attr_i_].value;
|
||||
return event_;
|
||||
}
|
||||
case characters:
|
||||
{
|
||||
event_ = end_attribute; // Name is already set.
|
||||
return event_;
|
||||
}
|
||||
case end_attribute:
|
||||
{
|
||||
if (++attr_i_ == attr_.size ())
|
||||
{
|
||||
attr_i_ = 0;
|
||||
attr_.clear ();
|
||||
pqname_ = &qname_;
|
||||
pvalue_ = &value_;
|
||||
break; // No more attributes.
|
||||
}
|
||||
}
|
||||
// Fall through.
|
||||
case start_element:
|
||||
case start_namespace_decl:
|
||||
{
|
||||
event_ = start_attribute;
|
||||
pqname_ = &attr_[attr_i_].qname;
|
||||
return event_;
|
||||
}
|
||||
default:
|
||||
{
|
||||
assert (false);
|
||||
return event_ = eof;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See if we have any end namespace declarations we need to return.
|
||||
//
|
||||
if (end_ns_i_ < end_ns_.size ())
|
||||
{
|
||||
// Based on the previous event determine what's the next one must be.
|
||||
//
|
||||
switch (event_)
|
||||
{
|
||||
case end_namespace_decl:
|
||||
{
|
||||
if (++end_ns_i_ == end_ns_.size ())
|
||||
{
|
||||
end_ns_i_ = 0;
|
||||
end_ns_.clear ();
|
||||
pqname_ = &qname_;
|
||||
break; // No more declarations.
|
||||
}
|
||||
}
|
||||
// Fall through.
|
||||
default:
|
||||
{
|
||||
// The end namespace declaration comes before the end element which
|
||||
// means it can follow pretty much any other event.
|
||||
//
|
||||
event_ = end_namespace_decl;
|
||||
pqname_ = &end_ns_[end_ns_i_];
|
||||
return event_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check the queue.
|
||||
//
|
||||
if (queue_ != eof)
|
||||
{
|
||||
event_ = queue_;
|
||||
queue_ = eof;
|
||||
|
||||
line_ = XML_GetCurrentLineNumber (p_);
|
||||
column_ = XML_GetCurrentColumnNumber (p_);
|
||||
|
||||
return event_;
|
||||
}
|
||||
|
||||
// Reset the character accumulation flag.
|
||||
//
|
||||
accumulate_ = false;
|
||||
|
||||
XML_ParsingStatus ps;
|
||||
XML_GetParsingStatus (p_, &ps);
|
||||
|
||||
switch (ps.parsing)
|
||||
{
|
||||
case XML_INITIALIZED:
|
||||
{
|
||||
// As if we finished the previous chunk.
|
||||
break;
|
||||
}
|
||||
case XML_PARSING:
|
||||
{
|
||||
assert (false);
|
||||
return event_ = eof;
|
||||
}
|
||||
case XML_FINISHED:
|
||||
{
|
||||
return event_ = eof;
|
||||
}
|
||||
case XML_SUSPENDED:
|
||||
{
|
||||
switch (XML_ResumeParser (p_))
|
||||
{
|
||||
case XML_STATUS_SUSPENDED:
|
||||
{
|
||||
// If the parser is again in the suspended state, then
|
||||
// that means we have the next event.
|
||||
//
|
||||
return event_;
|
||||
}
|
||||
case XML_STATUS_OK:
|
||||
{
|
||||
// Otherwise, we need to get and parse the next chunk of data
|
||||
// unless this was the last chunk, in which case this is eof.
|
||||
//
|
||||
if (ps.finalBuffer)
|
||||
return event_ = eof;
|
||||
|
||||
break;
|
||||
}
|
||||
case XML_STATUS_ERROR:
|
||||
handle_error ();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get and parse the next chunk of data until we get the next event
|
||||
// or reach eof.
|
||||
//
|
||||
if (!accumulate_)
|
||||
event_ = eof;
|
||||
|
||||
XML_Status s;
|
||||
do
|
||||
{
|
||||
if (size_ != 0)
|
||||
{
|
||||
s = XML_Parse (p_,
|
||||
static_cast <const char*> (data_.buf),
|
||||
static_cast <int> (size_),
|
||||
true);
|
||||
|
||||
if (s == XML_STATUS_ERROR)
|
||||
handle_error ();
|
||||
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
const size_t cap (4096);
|
||||
|
||||
char* b (static_cast<char*> (XML_GetBuffer (p_, cap)));
|
||||
if (b == 0)
|
||||
throw bad_alloc ();
|
||||
|
||||
// Temporarily unset the exception failbit. Also clear the fail bit
|
||||
// when we reset the old state if it was caused by eof.
|
||||
//
|
||||
istream& is (*data_.is);
|
||||
{
|
||||
stream_exception_controller sec (is);
|
||||
is.read (b, static_cast<streamsize> (cap));
|
||||
}
|
||||
|
||||
// If the caller hasn't configured the stream to use exceptions,
|
||||
// then use the parsing exception to report an error.
|
||||
//
|
||||
if (is.bad () || (is.fail () && !is.eof ()))
|
||||
throw parsing (*this, "io failure");
|
||||
|
||||
bool eof (is.eof ());
|
||||
|
||||
s = XML_ParseBuffer (p_, static_cast<int> (is.gcount ()), eof);
|
||||
|
||||
if (s == XML_STATUS_ERROR)
|
||||
handle_error ();
|
||||
|
||||
if (eof)
|
||||
break;
|
||||
}
|
||||
} while (s != XML_STATUS_SUSPENDED);
|
||||
|
||||
return event_;
|
||||
}
|
||||
|
||||
static void
|
||||
split_name (const XML_Char* s, qname& qn)
|
||||
{
|
||||
string& ns (qn.namespace_ ());
|
||||
string& name (qn.name ());
|
||||
string& prefix (qn.prefix ());
|
||||
|
||||
const char* p (strchr (s, ' '));
|
||||
|
||||
if (p == 0)
|
||||
{
|
||||
ns.clear ();
|
||||
name = s;
|
||||
prefix.clear ();
|
||||
}
|
||||
else
|
||||
{
|
||||
ns.assign (s, 0, p - s);
|
||||
|
||||
s = p + 1;
|
||||
p = strchr (s, ' ');
|
||||
|
||||
if (p == 0)
|
||||
{
|
||||
name = s;
|
||||
prefix.clear ();
|
||||
}
|
||||
else
|
||||
{
|
||||
name.assign (s, 0, p - s);
|
||||
prefix = p + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void XMLCALL parser::
|
||||
start_element_ (void* v, const XML_Char* name, const XML_Char** atts)
|
||||
{
|
||||
parser& p (*static_cast<parser*> (v));
|
||||
|
||||
XML_ParsingStatus ps;
|
||||
XML_GetParsingStatus (p.p_, &ps);
|
||||
|
||||
// Expat has a (mis)-feature of a possibily calling handlers even
|
||||
// after the non-resumable XML_StopParser call.
|
||||
//
|
||||
if (ps.parsing == XML_FINISHED)
|
||||
return;
|
||||
|
||||
// Cannot be a followup event.
|
||||
//
|
||||
assert (ps.parsing == XML_PARSING);
|
||||
|
||||
// When accumulating characters in simple content, we expect to
|
||||
// see more characters or end element. Seeing start element is
|
||||
// possible but means violation of the content model.
|
||||
//
|
||||
if (p.accumulate_)
|
||||
{
|
||||
// It would have been easier to throw the exception directly,
|
||||
// however, the Expat code is most likely not exception safe.
|
||||
//
|
||||
p.line_ = XML_GetCurrentLineNumber (p.p_);
|
||||
p.column_ = XML_GetCurrentColumnNumber (p.p_);
|
||||
XML_StopParser (p.p_, false);
|
||||
return;
|
||||
}
|
||||
|
||||
p.event_ = start_element;
|
||||
split_name (name, p.qname_);
|
||||
|
||||
p.line_ = XML_GetCurrentLineNumber (p.p_);
|
||||
p.column_ = XML_GetCurrentColumnNumber (p.p_);
|
||||
|
||||
// Handle attributes.
|
||||
//
|
||||
if (*atts != 0)
|
||||
{
|
||||
bool am ((p.feature_ & receive_attributes_map) != 0);
|
||||
bool ae ((p.feature_ & receive_attributes_event) != 0);
|
||||
|
||||
// Provision an entry for this element.
|
||||
//
|
||||
element_entry* pe (0);
|
||||
if (am)
|
||||
{
|
||||
p.element_state_.push_back (element_entry (p.depth_ + 1));
|
||||
pe = &p.element_state_.back ();
|
||||
}
|
||||
|
||||
if (am || ae)
|
||||
{
|
||||
for (; *atts != 0; atts += 2)
|
||||
{
|
||||
if (am)
|
||||
{
|
||||
qname_type qn;
|
||||
split_name (*atts, qn);
|
||||
attribute_map_type::value_type v (qn, attribute_value_type ());
|
||||
v.second.value = *(atts + 1);
|
||||
v.second.handled = false;
|
||||
pe->attr_map_.insert (v);
|
||||
}
|
||||
else
|
||||
{
|
||||
p.attr_.push_back (attribute_type ());
|
||||
split_name (*atts, p.attr_.back ().qname);
|
||||
p.attr_.back ().value = *(atts + 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (am)
|
||||
pe->attr_unhandled_ = pe->attr_map_.size ();
|
||||
}
|
||||
}
|
||||
|
||||
XML_StopParser (p.p_, true);
|
||||
}
|
||||
|
||||
void XMLCALL parser::
|
||||
end_element_ (void* v, const XML_Char* name)
|
||||
{
|
||||
parser& p (*static_cast<parser*> (v));
|
||||
|
||||
XML_ParsingStatus ps;
|
||||
XML_GetParsingStatus (p.p_, &ps);
|
||||
|
||||
// Expat has a (mis)-feature of a possibily calling handlers even
|
||||
// after the non-resumable XML_StopParser call.
|
||||
//
|
||||
if (ps.parsing == XML_FINISHED)
|
||||
return;
|
||||
|
||||
// This can be a followup event for empty elements (<foo/>). In this
|
||||
// case the element name is already set.
|
||||
//
|
||||
if (ps.parsing != XML_PARSING)
|
||||
p.queue_ = end_element;
|
||||
else
|
||||
{
|
||||
split_name (name, p.qname_);
|
||||
|
||||
// If we are accumulating characters, then queue this event.
|
||||
//
|
||||
if (p.accumulate_)
|
||||
p.queue_ = end_element;
|
||||
else
|
||||
{
|
||||
p.event_ = end_element;
|
||||
|
||||
p.line_ = XML_GetCurrentLineNumber (p.p_);
|
||||
p.column_ = XML_GetCurrentColumnNumber (p.p_);
|
||||
}
|
||||
|
||||
XML_StopParser (p.p_, true);
|
||||
}
|
||||
}
|
||||
|
||||
void XMLCALL parser::
|
||||
characters_ (void* v, const XML_Char* s, int n)
|
||||
{
|
||||
parser& p (*static_cast<parser*> (v));
|
||||
|
||||
XML_ParsingStatus ps;
|
||||
XML_GetParsingStatus (p.p_, &ps);
|
||||
|
||||
// Expat has a (mis)-feature of a possibily calling handlers even
|
||||
// after the non-resumable XML_StopParser call.
|
||||
//
|
||||
if (ps.parsing == XML_FINISHED)
|
||||
return;
|
||||
|
||||
content_type cont (p.content ());
|
||||
|
||||
// If this is empty or complex content, see if these are whitespaces.
|
||||
//
|
||||
switch (cont)
|
||||
{
|
||||
case content_type::empty:
|
||||
case content_type::complex:
|
||||
{
|
||||
for (int i (0); i != n; ++i)
|
||||
{
|
||||
char c (s[i]);
|
||||
if (c == 0x20 || c == 0x0A || c == 0x0D || c == 0x09)
|
||||
continue;
|
||||
|
||||
// It would have been easier to throw the exception directly,
|
||||
// however, the Expat code is most likely not exception safe.
|
||||
//
|
||||
p.line_ = XML_GetCurrentLineNumber (p.p_);
|
||||
p.column_ = XML_GetCurrentColumnNumber (p.p_);
|
||||
XML_StopParser (p.p_, false);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Append the characters if we are accumulating. This can also be a
|
||||
// followup event for another character event. In this case also
|
||||
// append the data.
|
||||
//
|
||||
if (p.accumulate_ || ps.parsing != XML_PARSING)
|
||||
{
|
||||
assert (p.event_ == characters);
|
||||
p.value_.append (s, n);
|
||||
}
|
||||
else
|
||||
{
|
||||
p.event_ = characters;
|
||||
p.value_.assign (s, n);
|
||||
|
||||
p.line_ = XML_GetCurrentLineNumber (p.p_);
|
||||
p.column_ = XML_GetCurrentColumnNumber (p.p_);
|
||||
|
||||
// In simple content we need to accumulate all the characters
|
||||
// into a single event. To do this we will let the parser run
|
||||
// until we reach the end of the element.
|
||||
//
|
||||
if (cont == content_type::simple)
|
||||
p.accumulate_ = true;
|
||||
else
|
||||
XML_StopParser (p.p_, true);
|
||||
}
|
||||
}
|
||||
|
||||
void XMLCALL parser::
|
||||
start_namespace_decl_ (void* v, const XML_Char* prefix, const XML_Char* ns)
|
||||
{
|
||||
parser& p (*static_cast<parser*> (v));
|
||||
|
||||
XML_ParsingStatus ps;
|
||||
XML_GetParsingStatus (p.p_, &ps);
|
||||
|
||||
// Expat has a (mis)-feature of a possibily calling handlers even
|
||||
// after the non-resumable XML_StopParser call.
|
||||
//
|
||||
if (ps.parsing == XML_FINISHED)
|
||||
return;
|
||||
|
||||
p.start_ns_.push_back (qname_type ());
|
||||
p.start_ns_.back ().prefix () = (prefix != 0 ? prefix : "");
|
||||
p.start_ns_.back ().namespace_ () = (ns != 0 ? ns : "");
|
||||
}
|
||||
|
||||
void XMLCALL parser::
|
||||
end_namespace_decl_ (void* v, const XML_Char* prefix)
|
||||
{
|
||||
parser& p (*static_cast<parser*> (v));
|
||||
|
||||
XML_ParsingStatus ps;
|
||||
XML_GetParsingStatus (p.p_, &ps);
|
||||
|
||||
// Expat has a (mis)-feature of a possibily calling handlers even
|
||||
// after the non-resumable XML_StopParser call.
|
||||
//
|
||||
if (ps.parsing == XML_FINISHED)
|
||||
return;
|
||||
|
||||
p.end_ns_.push_back (qname_type ());
|
||||
p.end_ns_.back ().prefix () = (prefix != 0 ? prefix : "");
|
||||
}
|
||||
}
|
472
third-party/libstudxml/libstudxml/parser.hxx
vendored
472
third-party/libstudxml/libstudxml/parser.hxx
vendored
|
@ -1,472 +0,0 @@
|
|||
// file : libstudxml/parser.hxx -*- C++ -*-
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#ifndef LIBSTUDXML_PARSER_HXX
|
||||
#define LIBSTUDXML_PARSER_HXX
|
||||
|
||||
#include <libstudxml/details/pre.hxx>
|
||||
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
#include <cstddef> // std::size_t
|
||||
|
||||
#include <libstudxml/details/config.hxx> // STUDXML_NOTHROW_NOEXCEPT,
|
||||
// LIBSTUDXML_EXTERNAL_EXPAT
|
||||
|
||||
#ifndef LIBSTUDXML_EXTERNAL_EXPAT
|
||||
# include <libstudxml/details/expat/expat.h>
|
||||
#else
|
||||
# include <expat.h>
|
||||
#endif
|
||||
|
||||
// We only support UTF-8 Expat.
|
||||
//
|
||||
#ifdef XML_UNICODE
|
||||
# error UTF-16 expat (XML_UNICODE defined) is not supported
|
||||
#endif
|
||||
|
||||
#include <libstudxml/forward.hxx>
|
||||
#include <libstudxml/qname.hxx>
|
||||
#include <libstudxml/content.hxx>
|
||||
#include <libstudxml/exception.hxx>
|
||||
|
||||
#include <libstudxml/details/export.hxx>
|
||||
|
||||
namespace xml
|
||||
{
|
||||
class parsing: public exception
|
||||
{
|
||||
public:
|
||||
virtual
|
||||
~parsing () STUDXML_NOTHROW_NOEXCEPT {}
|
||||
|
||||
parsing (const std::string& name,
|
||||
unsigned long long line,
|
||||
unsigned long long column,
|
||||
const std::string& description);
|
||||
|
||||
parsing (const parser& p, const std::string& description);
|
||||
|
||||
const std::string&
|
||||
name () const {return name_;}
|
||||
|
||||
unsigned long long
|
||||
line () const {return line_;}
|
||||
|
||||
unsigned long long
|
||||
column () const {return column_;}
|
||||
|
||||
const std::string&
|
||||
description () const {return description_;}
|
||||
|
||||
virtual const char*
|
||||
what () const STUDXML_NOTHROW_NOEXCEPT {return what_.c_str ();}
|
||||
|
||||
private:
|
||||
LIBSTUDXML_EXPORT void
|
||||
init ();
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
unsigned long long line_;
|
||||
unsigned long long column_;
|
||||
std::string description_;
|
||||
std::string what_;
|
||||
};
|
||||
|
||||
class LIBSTUDXML_EXPORT parser
|
||||
{
|
||||
public:
|
||||
typedef xml::qname qname_type;
|
||||
typedef xml::content content_type;
|
||||
|
||||
typedef unsigned short feature_type;
|
||||
|
||||
// If both receive_attributes_event and receive_attributes_map are
|
||||
// specified, then receive_attributes_event is assumed.
|
||||
//
|
||||
static const feature_type receive_elements = 0x0001;
|
||||
static const feature_type receive_characters = 0x0002;
|
||||
static const feature_type receive_attributes_map = 0x0004;
|
||||
static const feature_type receive_attributes_event = 0x0008;
|
||||
static const feature_type receive_namespace_decls = 0x0010;
|
||||
|
||||
static const feature_type receive_default = receive_elements |
|
||||
receive_characters |
|
||||
receive_attributes_map;
|
||||
|
||||
// Parse std::istream. Input name is used in diagnostics to identify
|
||||
// the document being parsed.
|
||||
//
|
||||
// If stream exceptions are enabled then std::ios_base::failure
|
||||
// exception is used to report io errors (badbit and failbit).
|
||||
// Otherwise, those are reported as the parsing exception.
|
||||
//
|
||||
parser (std::istream&,
|
||||
const std::string& input_name,
|
||||
feature_type = receive_default);
|
||||
|
||||
// Parse memory buffer that contains the whole document. Input name
|
||||
// is used in diagnostics to identify the document being parsed.
|
||||
//
|
||||
parser (const void* data,
|
||||
std::size_t size,
|
||||
const std::string& input_name,
|
||||
feature_type = receive_default);
|
||||
|
||||
const std::string&
|
||||
input_name () const {return iname_;}
|
||||
|
||||
~parser ();
|
||||
|
||||
private:
|
||||
parser (const parser&);
|
||||
parser& operator= (const parser&);
|
||||
|
||||
// Parsing events.
|
||||
//
|
||||
public:
|
||||
enum event_type
|
||||
{
|
||||
// If adding new events, also update the stream insertion operator.
|
||||
//
|
||||
start_element,
|
||||
end_element,
|
||||
start_attribute,
|
||||
end_attribute,
|
||||
characters,
|
||||
start_namespace_decl,
|
||||
end_namespace_decl,
|
||||
eof
|
||||
};
|
||||
|
||||
event_type
|
||||
next ();
|
||||
|
||||
// Get the next event and make sure that it's what's expected. If it
|
||||
// is not, then throw an appropriate parsing exception.
|
||||
//
|
||||
void
|
||||
next_expect (event_type);
|
||||
|
||||
void
|
||||
next_expect (event_type, const std::string& name);
|
||||
|
||||
void
|
||||
next_expect (event_type, const qname_type& qname);
|
||||
|
||||
void
|
||||
next_expect (event_type, const std::string& ns, const std::string& name);
|
||||
|
||||
event_type
|
||||
peek ();
|
||||
|
||||
// Return the even that was last returned by the call to next() or
|
||||
// peek().
|
||||
//
|
||||
event_type
|
||||
event () {return event_;}
|
||||
|
||||
// Event data.
|
||||
//
|
||||
public:
|
||||
const qname_type& qname () const {return *pqname_;}
|
||||
|
||||
const std::string& namespace_ () const {return pqname_->namespace_ ();}
|
||||
const std::string& name () const {return pqname_->name ();}
|
||||
const std::string& prefix () const {return pqname_->prefix ();}
|
||||
|
||||
std::string& value () {return *pvalue_;}
|
||||
const std::string& value () const {return *pvalue_;}
|
||||
template <typename T> T value () const;
|
||||
|
||||
unsigned long long line () const {return line_;}
|
||||
unsigned long long column () const {return column_;}
|
||||
|
||||
// Attribute map lookup. If attribute is not found, then the version
|
||||
// without the default value throws an appropriate parsing exception
|
||||
// while the version with the default value returns that value.
|
||||
//
|
||||
// Note also that there is no attribute(ns,name) version since it
|
||||
// would conflict with attribute(name,dv) (qualified attributes
|
||||
// are not very common).
|
||||
//
|
||||
// Attribute map is valid throughout at the "element level" until
|
||||
// end_element and not just during start_element. As a special case,
|
||||
// the map is still valid after peek() that returned end_element until
|
||||
// this end_element event is retrieved with next().
|
||||
//
|
||||
const std::string&
|
||||
attribute (const std::string& name) const;
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
attribute (const std::string& name) const;
|
||||
|
||||
std::string
|
||||
attribute (const std::string& name,
|
||||
const std::string& default_value) const;
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
attribute (const std::string& name, const T& default_value) const;
|
||||
|
||||
const std::string&
|
||||
attribute (const qname_type& qname) const;
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
attribute (const qname_type& qname) const;
|
||||
|
||||
std::string
|
||||
attribute (const qname_type& qname,
|
||||
const std::string& default_value) const;
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
attribute (const qname_type& qname, const T& default_value) const;
|
||||
|
||||
bool
|
||||
attribute_present (const std::string& name) const;
|
||||
|
||||
bool
|
||||
attribute_present (const qname_type& qname) const;
|
||||
|
||||
// Low-level attribute map access. Note that this API assumes
|
||||
// all attributes are handled.
|
||||
//
|
||||
struct attribute_value_type
|
||||
{
|
||||
std::string value;
|
||||
mutable bool handled;
|
||||
};
|
||||
|
||||
typedef std::map<qname_type, attribute_value_type> attribute_map_type;
|
||||
|
||||
const attribute_map_type&
|
||||
attribute_map () const;
|
||||
|
||||
// Optional content processing.
|
||||
//
|
||||
public:
|
||||
// Note that you cannot get/set content while peeking.
|
||||
//
|
||||
void
|
||||
content (content_type);
|
||||
|
||||
content_type
|
||||
content () const;
|
||||
|
||||
// Versions that also set the content. Event type must be start_element.
|
||||
//
|
||||
void
|
||||
next_expect (event_type, const std::string& name, content_type);
|
||||
|
||||
void
|
||||
next_expect (event_type, const qname_type& qname, content_type);
|
||||
|
||||
void
|
||||
next_expect (event_type,
|
||||
const std::string& ns, const std::string& name,
|
||||
content_type);
|
||||
|
||||
// Helpers for parsing elements with simple content. The first two
|
||||
// functions assume that start_element has already been parsed. The
|
||||
// rest parse the complete element, from start to end.
|
||||
//
|
||||
// Note also that as with attribute(), there is no (namespace,name)
|
||||
// overload since it would conflicts with (namespace,default_value).
|
||||
//
|
||||
public:
|
||||
std::string
|
||||
element ();
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
element ();
|
||||
|
||||
std::string
|
||||
element (const std::string& name);
|
||||
|
||||
std::string
|
||||
element (const qname_type& qname);
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
element (const std::string& name);
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
element (const qname_type& qname);
|
||||
|
||||
std::string
|
||||
element (const std::string& name, const std::string& default_value);
|
||||
|
||||
std::string
|
||||
element (const qname_type& qname, const std::string& default_value);
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
element (const std::string& name, const T& default_value);
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
element (const qname_type& qname, const T& default_value);
|
||||
|
||||
// C++11 range-based for support. Generally, the iterator interface
|
||||
// doesn't make much sense for the parser so for now we have an
|
||||
// implementation that is just enough to the range-based for.
|
||||
//
|
||||
public:
|
||||
struct iterator
|
||||
{
|
||||
typedef event_type value_type;
|
||||
|
||||
iterator (parser* p = nullptr, event_type e = eof): p_ (p), e_ (e) {}
|
||||
value_type operator* () const {return e_;}
|
||||
iterator& operator++ () {e_ = p_->next (); return *this;}
|
||||
|
||||
// Comparison only makes sense when comparing to end (eof).
|
||||
//
|
||||
bool operator== (iterator y) const {return e_ == eof && y.e_ == eof;}
|
||||
bool operator!= (iterator y) const {return !(*this == y);}
|
||||
|
||||
private:
|
||||
parser* p_;
|
||||
event_type e_;
|
||||
};
|
||||
|
||||
iterator begin () {return iterator (this, next ());}
|
||||
iterator end () {return iterator (this, eof);}
|
||||
|
||||
private:
|
||||
static void XMLCALL
|
||||
start_element_ (void*, const XML_Char*, const XML_Char**);
|
||||
|
||||
static void XMLCALL
|
||||
end_element_ (void*, const XML_Char*);
|
||||
|
||||
static void XMLCALL
|
||||
characters_ (void*, const XML_Char*, int);
|
||||
|
||||
static void XMLCALL
|
||||
start_namespace_decl_ (void*, const XML_Char*, const XML_Char*);
|
||||
|
||||
static void XMLCALL
|
||||
end_namespace_decl_ (void*, const XML_Char*);
|
||||
|
||||
private:
|
||||
void
|
||||
init ();
|
||||
|
||||
event_type
|
||||
next_ (bool peek);
|
||||
|
||||
event_type
|
||||
next_body ();
|
||||
|
||||
void
|
||||
handle_error ();
|
||||
|
||||
private:
|
||||
// If size_ is 0, then data is std::istream. Otherwise, it is a buffer.
|
||||
//
|
||||
union
|
||||
{
|
||||
std::istream* is;
|
||||
const void* buf;
|
||||
} data_;
|
||||
|
||||
std::size_t size_;
|
||||
|
||||
const std::string iname_;
|
||||
feature_type feature_;
|
||||
|
||||
XML_Parser p_;
|
||||
std::size_t depth_;
|
||||
bool accumulate_; // Whether we are accumulating character content.
|
||||
enum {state_next, state_peek} state_;
|
||||
event_type event_;
|
||||
event_type queue_;
|
||||
|
||||
qname_type qname_;
|
||||
std::string value_;
|
||||
|
||||
// These are used to avoid copying when we are handling attributes
|
||||
// and namespace decls.
|
||||
//
|
||||
const qname_type* pqname_;
|
||||
std::string* pvalue_;
|
||||
|
||||
unsigned long long line_;
|
||||
unsigned long long column_;
|
||||
|
||||
// Attributes as events.
|
||||
//
|
||||
struct attribute_type
|
||||
{
|
||||
qname_type qname;
|
||||
std::string value;
|
||||
};
|
||||
|
||||
typedef std::vector<attribute_type> attributes;
|
||||
|
||||
attributes attr_;
|
||||
attributes::size_type attr_i_; // Index of the current attribute.
|
||||
|
||||
// Namespace declarations.
|
||||
//
|
||||
typedef std::vector<qname_type> namespace_decls;
|
||||
|
||||
namespace_decls start_ns_;
|
||||
namespace_decls::size_type start_ns_i_; // Index of the current decl.
|
||||
|
||||
namespace_decls end_ns_;
|
||||
namespace_decls::size_type end_ns_i_; // Index of the current decl.
|
||||
|
||||
// Element state consisting of the content model and attribute map.
|
||||
//
|
||||
struct element_entry
|
||||
{
|
||||
element_entry (std::size_t d, content_type c = content_type::mixed)
|
||||
: depth (d), content (c), attr_unhandled_ (0) {}
|
||||
|
||||
std::size_t depth;
|
||||
content_type content;
|
||||
attribute_map_type attr_map_;
|
||||
mutable attribute_map_type::size_type attr_unhandled_;
|
||||
};
|
||||
|
||||
typedef std::vector<element_entry> element_state;
|
||||
std::vector<element_entry> element_state_;
|
||||
|
||||
// Empty attribute map to return when an element has no attributes.
|
||||
//
|
||||
const attribute_map_type empty_attr_map_;
|
||||
|
||||
// Return the element entry corresponding to the current depth, if
|
||||
// exists, and NULL otherwise.
|
||||
//
|
||||
const element_entry*
|
||||
get_element () const;
|
||||
|
||||
const element_entry*
|
||||
get_element_ () const;
|
||||
|
||||
void
|
||||
pop_element ();
|
||||
};
|
||||
|
||||
LIBSTUDXML_EXPORT std::ostream&
|
||||
operator<< (std::ostream&, parser::event_type);
|
||||
}
|
||||
|
||||
#include <libstudxml/parser.ixx>
|
||||
#include <libstudxml/parser.txx>
|
||||
|
||||
#include <libstudxml/details/post.hxx>
|
||||
|
||||
#endif // LIBSTUDXML_PARSER_HXX
|
240
third-party/libstudxml/libstudxml/parser.ixx
vendored
240
third-party/libstudxml/libstudxml/parser.ixx
vendored
|
@ -1,240 +0,0 @@
|
|||
// file : libstudxml/parser.ixx
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include <libstudxml/value-traits.hxx>
|
||||
|
||||
namespace xml
|
||||
{
|
||||
// parsing
|
||||
//
|
||||
inline parsing::
|
||||
parsing (const std::string& n,
|
||||
unsigned long long l,
|
||||
unsigned long long c,
|
||||
const std::string& d)
|
||||
: name_ (n), line_ (l), column_ (c), description_ (d)
|
||||
{
|
||||
init ();
|
||||
}
|
||||
|
||||
inline parsing::
|
||||
parsing (const parser& p, const std::string& d)
|
||||
: name_ (p.input_name ()),
|
||||
line_ (p.line ()),
|
||||
column_ (p.column ()),
|
||||
description_ (d)
|
||||
{
|
||||
init ();
|
||||
}
|
||||
|
||||
// parser
|
||||
//
|
||||
inline parser::
|
||||
parser (std::istream& is, const std::string& iname, feature_type f)
|
||||
: size_ (0), iname_ (iname), feature_ (f)
|
||||
{
|
||||
data_.is = &is;
|
||||
init ();
|
||||
}
|
||||
|
||||
inline parser::
|
||||
parser (const void* data,
|
||||
std::size_t size,
|
||||
const std::string& iname,
|
||||
feature_type f)
|
||||
: size_ (size), iname_ (iname), feature_ (f)
|
||||
{
|
||||
assert (data != nullptr && size != 0);
|
||||
|
||||
data_.buf = data;
|
||||
init ();
|
||||
}
|
||||
|
||||
inline parser::event_type parser::
|
||||
peek ()
|
||||
{
|
||||
if (state_ == state_peek)
|
||||
return event_;
|
||||
else
|
||||
{
|
||||
event_type e (next_ (true));
|
||||
state_ = state_peek; // Set it after the call to next_().
|
||||
return e;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T parser::
|
||||
value () const
|
||||
{
|
||||
return value_traits<T>::parse (value (), *this);
|
||||
}
|
||||
|
||||
inline const parser::element_entry* parser::
|
||||
get_element () const
|
||||
{
|
||||
return element_state_.empty () ? nullptr : get_element_ ();
|
||||
}
|
||||
|
||||
inline const std::string& parser::
|
||||
attribute (const std::string& n) const
|
||||
{
|
||||
return attribute (qname_type (n));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T parser::
|
||||
attribute (const std::string& n) const
|
||||
{
|
||||
return attribute<T> (qname_type (n));
|
||||
}
|
||||
|
||||
inline std::string parser::
|
||||
attribute (const std::string& n, const std::string& dv) const
|
||||
{
|
||||
return attribute (qname_type (n), dv);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T parser::
|
||||
attribute (const std::string& n, const T& dv) const
|
||||
{
|
||||
return attribute<T> (qname_type (n), dv);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T parser::
|
||||
attribute (const qname_type& qn) const
|
||||
{
|
||||
return value_traits<T>::parse (attribute (qn), *this);
|
||||
}
|
||||
|
||||
inline bool parser::
|
||||
attribute_present (const std::string& n) const
|
||||
{
|
||||
return attribute_present (qname_type (n));
|
||||
}
|
||||
|
||||
inline const parser::attribute_map_type& parser::
|
||||
attribute_map () const
|
||||
{
|
||||
if (const element_entry* e = get_element ())
|
||||
{
|
||||
e->attr_unhandled_ = 0; // Assume all handled.
|
||||
return e->attr_map_;
|
||||
}
|
||||
|
||||
return empty_attr_map_;
|
||||
}
|
||||
|
||||
inline void parser::
|
||||
next_expect (event_type e, const qname_type& qn)
|
||||
{
|
||||
next_expect (e, qn.namespace_ (), qn.name ());
|
||||
}
|
||||
|
||||
inline void parser::
|
||||
next_expect (event_type e, const std::string& n)
|
||||
{
|
||||
next_expect (e, std::string (), n);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T parser::
|
||||
element ()
|
||||
{
|
||||
return value_traits<T>::parse (element (), *this);
|
||||
}
|
||||
|
||||
inline std::string parser::
|
||||
element (const std::string& n)
|
||||
{
|
||||
next_expect (start_element, n);
|
||||
return element ();
|
||||
}
|
||||
|
||||
inline std::string parser::
|
||||
element (const qname_type& qn)
|
||||
{
|
||||
next_expect (start_element, qn);
|
||||
return element ();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T parser::
|
||||
element (const std::string& n)
|
||||
{
|
||||
return value_traits<T>::parse (element (n), *this);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T parser::
|
||||
element (const qname_type& qn)
|
||||
{
|
||||
return value_traits<T>::parse (element (qn), *this);
|
||||
}
|
||||
|
||||
inline std::string parser::
|
||||
element (const std::string& n, const std::string& dv)
|
||||
{
|
||||
return element (qname_type (n), dv);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline T parser::
|
||||
element (const std::string& n, const T& dv)
|
||||
{
|
||||
return element<T> (qname_type (n), dv);
|
||||
}
|
||||
|
||||
inline void parser::
|
||||
content (content_type c)
|
||||
{
|
||||
assert (state_ == state_next);
|
||||
|
||||
if (!element_state_.empty () && element_state_.back ().depth == depth_)
|
||||
element_state_.back ().content = c;
|
||||
else
|
||||
element_state_.push_back (element_entry (depth_, c));
|
||||
}
|
||||
|
||||
inline parser::content_type parser::
|
||||
content () const
|
||||
{
|
||||
assert (state_ == state_next);
|
||||
|
||||
return
|
||||
!element_state_.empty () && element_state_.back ().depth == depth_
|
||||
? element_state_.back ().content
|
||||
: content_type (content_type::mixed);
|
||||
}
|
||||
|
||||
inline void parser::
|
||||
next_expect (event_type e, const qname_type& qn, content_type c)
|
||||
{
|
||||
assert (e == start_element);
|
||||
next_expect (e, qn);
|
||||
content (c);
|
||||
}
|
||||
|
||||
inline void parser::
|
||||
next_expect (event_type e, const std::string& n, content_type c)
|
||||
{
|
||||
assert (e == start_element);
|
||||
next_expect (e, std::string (), n);
|
||||
content (c);
|
||||
}
|
||||
|
||||
inline void parser::
|
||||
next_expect (event_type e,
|
||||
const std::string& ns, const std::string& n,
|
||||
content_type c)
|
||||
{
|
||||
assert (e == start_element);
|
||||
next_expect (e, ns, n);
|
||||
content (c);
|
||||
}
|
||||
}
|
43
third-party/libstudxml/libstudxml/parser.txx
vendored
43
third-party/libstudxml/libstudxml/parser.txx
vendored
|
@ -1,43 +0,0 @@
|
|||
// file : libstudxml/parser.txx
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#include <libstudxml/value-traits.hxx>
|
||||
|
||||
namespace xml
|
||||
{
|
||||
template <typename T>
|
||||
T parser::
|
||||
attribute (const qname_type& qn, const T& dv) const
|
||||
{
|
||||
if (const element_entry* e = get_element ())
|
||||
{
|
||||
attribute_map_type::const_iterator i (e->attr_map_.find (qn));
|
||||
|
||||
if (i != e->attr_map_.end ())
|
||||
{
|
||||
if (!i->second.handled)
|
||||
{
|
||||
i->second.handled = true;
|
||||
e->attr_unhandled_--;
|
||||
}
|
||||
return value_traits<T>::parse (i->second.value, *this);
|
||||
}
|
||||
}
|
||||
|
||||
return dv;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T parser::
|
||||
element (const qname_type& qn, const T& dv)
|
||||
{
|
||||
if (peek () == start_element && qname () == qn)
|
||||
{
|
||||
next ();
|
||||
return element<T> ();
|
||||
}
|
||||
|
||||
return dv;
|
||||
}
|
||||
}
|
32
third-party/libstudxml/libstudxml/qname.cxx
vendored
32
third-party/libstudxml/libstudxml/qname.cxx
vendored
|
@ -1,32 +0,0 @@
|
|||
// file : libstudxml/qname.cxx
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#include <ostream>
|
||||
|
||||
#include <libstudxml/qname.hxx>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace xml
|
||||
{
|
||||
string qname::
|
||||
string () const
|
||||
{
|
||||
std::string r;
|
||||
if (!ns_.empty ())
|
||||
{
|
||||
r += ns_;
|
||||
r += '#';
|
||||
}
|
||||
|
||||
r += name_;
|
||||
return r;
|
||||
}
|
||||
|
||||
ostream&
|
||||
operator<< (ostream& os, const qname& qn)
|
||||
{
|
||||
return os << qn.string ();
|
||||
}
|
||||
}
|
86
third-party/libstudxml/libstudxml/qname.hxx
vendored
86
third-party/libstudxml/libstudxml/qname.hxx
vendored
|
@ -1,86 +0,0 @@
|
|||
// file : libstudxml/qname.hxx -*- C++ -*-
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#ifndef LIBSTUDXML_QNAME_HXX
|
||||
#define LIBSTUDXML_QNAME_HXX
|
||||
|
||||
#include <libstudxml/details/pre.hxx>
|
||||
|
||||
#include <string>
|
||||
#include <iosfwd>
|
||||
|
||||
#include <libstudxml/forward.hxx>
|
||||
|
||||
#include <libstudxml/details/export.hxx>
|
||||
|
||||
namespace xml
|
||||
{
|
||||
// Note that the optional prefix is just a "syntactic sugar". In
|
||||
// particular, it is ignored by the comparison operators and the
|
||||
// std::ostream insertion operator.
|
||||
//
|
||||
class LIBSTUDXML_EXPORT qname
|
||||
{
|
||||
public:
|
||||
qname () {}
|
||||
qname (const std::string& name): name_ (name) {}
|
||||
qname (const std::string& ns, const std::string& name)
|
||||
: ns_ (ns), name_ (name) {}
|
||||
qname (const std::string& ns,
|
||||
const std::string& name,
|
||||
const std::string& prefix)
|
||||
: ns_ (ns), name_ (name), prefix_ (prefix) {}
|
||||
|
||||
const std::string& namespace_ () const {return ns_;}
|
||||
const std::string& name () const {return name_;}
|
||||
const std::string& prefix () const {return prefix_;}
|
||||
|
||||
std::string& namespace_ () {return ns_;}
|
||||
std::string& name () {return name_;}
|
||||
std::string& prefix () {return prefix_;}
|
||||
|
||||
bool
|
||||
empty () const {return name_.empty () && ns_.empty ();}
|
||||
|
||||
// String representation in the [<namespace>#]<name> form.
|
||||
//
|
||||
std::string
|
||||
string () const;
|
||||
|
||||
// Note that comparison operators ignore prefixes.
|
||||
//
|
||||
public:
|
||||
friend bool
|
||||
operator< (const qname& x, const qname& y)
|
||||
{
|
||||
return x.ns_ < y.ns_ || (x.ns_ == y.ns_ && x.name_ < y.name_);
|
||||
}
|
||||
|
||||
friend bool
|
||||
operator== (const qname& x, const qname& y)
|
||||
{
|
||||
return x.ns_ == y.ns_ && x.name_ == y.name_;
|
||||
}
|
||||
|
||||
friend bool
|
||||
operator!= (const qname& x, const qname& y)
|
||||
{
|
||||
return !(x == y);
|
||||
}
|
||||
|
||||
private:
|
||||
std::string ns_;
|
||||
std::string name_;
|
||||
std::string prefix_;
|
||||
};
|
||||
|
||||
// Print the string representation ([<namespace>#]<name>).
|
||||
//
|
||||
LIBSTUDXML_EXPORT std::ostream&
|
||||
operator<< (std::ostream&, const qname&);
|
||||
}
|
||||
|
||||
#include <libstudxml/details/post.hxx>
|
||||
|
||||
#endif // LIBSTUDXML_QNAME_HXX
|
325
third-party/libstudxml/libstudxml/serializer.cxx
vendored
325
third-party/libstudxml/libstudxml/serializer.cxx
vendored
|
@ -1,325 +0,0 @@
|
|||
// file : libstudxml/serializer.cxx
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#include <new> // std::bad_alloc
|
||||
#include <cstring> // std::strlen
|
||||
|
||||
#include <libstudxml/serializer.hxx>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace xml
|
||||
{
|
||||
// serialization
|
||||
//
|
||||
void serialization::
|
||||
init ()
|
||||
{
|
||||
if (!name_.empty ())
|
||||
{
|
||||
what_ += name_;
|
||||
what_ += ": ";
|
||||
}
|
||||
|
||||
what_ += "error: ";
|
||||
what_ += description_;
|
||||
}
|
||||
|
||||
// serializer
|
||||
//
|
||||
extern "C" genxStatus
|
||||
genx_write (void* p, constUtf8 us)
|
||||
{
|
||||
// It would have been easier to throw the exception directly,
|
||||
// however, the Genx code is most likely not exception safe.
|
||||
//
|
||||
ostream* os (static_cast<ostream*> (p));
|
||||
const char* s (reinterpret_cast<const char*> (us));
|
||||
os->write (s, static_cast<streamsize> (strlen (s)));
|
||||
return os->good () ? GENX_SUCCESS : GENX_IO_ERROR;
|
||||
}
|
||||
|
||||
extern "C" genxStatus
|
||||
genx_write_bound (void* p, constUtf8 start, constUtf8 end)
|
||||
{
|
||||
ostream* os (static_cast<ostream*> (p));
|
||||
const char* s (reinterpret_cast<const char*> (start));
|
||||
streamsize n (static_cast<streamsize> (end - start));
|
||||
os->write (s, n);
|
||||
return os->good () ? GENX_SUCCESS : GENX_IO_ERROR;
|
||||
}
|
||||
|
||||
extern "C" genxStatus
|
||||
genx_flush (void* p)
|
||||
{
|
||||
ostream* os (static_cast<ostream*> (p));
|
||||
os->flush ();
|
||||
return os->good () ? GENX_SUCCESS : GENX_IO_ERROR;
|
||||
}
|
||||
|
||||
serializer::
|
||||
~serializer ()
|
||||
{
|
||||
if (s_ != 0)
|
||||
genxDispose (s_);
|
||||
}
|
||||
|
||||
serializer::
|
||||
serializer (ostream& os, const string& oname, unsigned short ind)
|
||||
: os_ (os), os_state_ (os.exceptions ()), oname_ (oname), depth_ (0)
|
||||
{
|
||||
// Temporarily disable exceptions on the stream.
|
||||
//
|
||||
os_.exceptions (ostream::goodbit);
|
||||
|
||||
// Allocate the serializer. Make sure nothing else can throw after
|
||||
// this call since otherwise we will leak it.
|
||||
//
|
||||
s_ = genxNew (0, 0, 0);
|
||||
|
||||
if (s_ == 0)
|
||||
throw bad_alloc ();
|
||||
|
||||
genxSetUserData (s_, &os_);
|
||||
|
||||
if (ind != 0)
|
||||
genxSetPrettyPrint (s_, ind);
|
||||
|
||||
sender_.send = &genx_write;
|
||||
sender_.sendBounded = &genx_write_bound;
|
||||
sender_.flush = &genx_flush;
|
||||
|
||||
if (genxStatus e = genxStartDocSender (s_, &sender_))
|
||||
{
|
||||
string m (genxGetErrorMessage (s_, e));
|
||||
genxDispose (s_);
|
||||
throw serialization (oname, m);
|
||||
}
|
||||
}
|
||||
|
||||
void serializer::
|
||||
handle_error (genxStatus e) const
|
||||
{
|
||||
switch (e)
|
||||
{
|
||||
case GENX_ALLOC_FAILED:
|
||||
throw bad_alloc ();
|
||||
case GENX_IO_ERROR:
|
||||
// Restoring the original exception state should trigger the
|
||||
// exception. If it doesn't (e.g., because the user didn't
|
||||
// configure the stream to throw), then fall back to the
|
||||
// serialiation exception.
|
||||
//
|
||||
os_.exceptions (os_state_);
|
||||
// Fall through.
|
||||
default:
|
||||
throw serialization (oname_, genxGetErrorMessage (s_, e));
|
||||
}
|
||||
}
|
||||
|
||||
void serializer::
|
||||
start_element (const string& ns, const string& name)
|
||||
{
|
||||
if (genxStatus e = genxStartElementLiteral (
|
||||
s_,
|
||||
reinterpret_cast<constUtf8> (ns.empty () ? 0 : ns.c_str ()),
|
||||
reinterpret_cast<constUtf8> (name.c_str ())))
|
||||
handle_error (e);
|
||||
|
||||
depth_++;
|
||||
}
|
||||
|
||||
void serializer::
|
||||
end_element ()
|
||||
{
|
||||
if (genxStatus e = genxEndElement (s_))
|
||||
handle_error (e);
|
||||
|
||||
// Call EndDocument() if we are past the root element.
|
||||
//
|
||||
if (--depth_ == 0)
|
||||
{
|
||||
if (genxStatus e = genxEndDocument (s_))
|
||||
handle_error (e);
|
||||
|
||||
// Also restore the original exception state on the stream.
|
||||
//
|
||||
os_.exceptions (os_state_);
|
||||
}
|
||||
}
|
||||
|
||||
void serializer::
|
||||
end_element (const string& ns, const string& name)
|
||||
{
|
||||
constUtf8 cns, cn;
|
||||
genxStatus e;
|
||||
if ((e = genxGetCurrentElement (s_, &cns, &cn)) ||
|
||||
reinterpret_cast<const char*> (cn) != name ||
|
||||
(cns == 0 ? !ns.empty () : reinterpret_cast<const char*> (cns) != ns))
|
||||
{
|
||||
handle_error (e != GENX_SUCCESS ? e : GENX_SEQUENCE_ERROR);
|
||||
}
|
||||
|
||||
end_element ();
|
||||
}
|
||||
|
||||
void serializer::
|
||||
element (const string& ns, const string& n, const string& v)
|
||||
{
|
||||
start_element (ns, n);
|
||||
element (v);
|
||||
}
|
||||
|
||||
void serializer::
|
||||
start_attribute (const string& ns, const string& name)
|
||||
{
|
||||
if (genxStatus e = genxStartAttributeLiteral (
|
||||
s_,
|
||||
reinterpret_cast<constUtf8> (ns.empty () ? 0 : ns.c_str ()),
|
||||
reinterpret_cast<constUtf8> (name.c_str ())))
|
||||
handle_error (e);
|
||||
}
|
||||
|
||||
void serializer::
|
||||
end_attribute ()
|
||||
{
|
||||
if (genxStatus e = genxEndAttribute (s_))
|
||||
handle_error (e);
|
||||
}
|
||||
|
||||
void serializer::
|
||||
end_attribute (const string& ns, const string& name)
|
||||
{
|
||||
constUtf8 cns, cn;
|
||||
genxStatus e;
|
||||
if ((e = genxGetCurrentAttribute (s_, &cns, &cn)) ||
|
||||
reinterpret_cast<const char*> (cn) != name ||
|
||||
(cns == 0 ? !ns.empty () : reinterpret_cast<const char*> (cns) != ns))
|
||||
{
|
||||
handle_error (e != GENX_SUCCESS ? e : GENX_SEQUENCE_ERROR);
|
||||
}
|
||||
|
||||
end_attribute ();
|
||||
}
|
||||
|
||||
void serializer::
|
||||
attribute (const string& ns,
|
||||
const string& name,
|
||||
const string& value)
|
||||
{
|
||||
if (genxStatus e = genxAddAttributeLiteral (
|
||||
s_,
|
||||
reinterpret_cast<constUtf8> (ns.empty () ? 0 : ns.c_str ()),
|
||||
reinterpret_cast<constUtf8> (name.c_str ()),
|
||||
reinterpret_cast<constUtf8> (value.c_str ())))
|
||||
handle_error (e);
|
||||
}
|
||||
|
||||
void serializer::
|
||||
characters (const string& value)
|
||||
{
|
||||
if (genxStatus e = genxAddCountedText (
|
||||
s_,
|
||||
reinterpret_cast<constUtf8> (value.c_str ()), value.size ()))
|
||||
handle_error (e);
|
||||
}
|
||||
|
||||
void serializer::
|
||||
namespace_decl (const string& ns, const string& p)
|
||||
{
|
||||
if (genxStatus e = ns.empty () && p.empty ()
|
||||
? genxUnsetDefaultNamespace (s_)
|
||||
: genxAddNamespaceLiteral (
|
||||
s_,
|
||||
reinterpret_cast<constUtf8> (ns.c_str ()),
|
||||
reinterpret_cast<constUtf8> (p.c_str ())))
|
||||
handle_error (e);
|
||||
}
|
||||
|
||||
void serializer::
|
||||
xml_decl (const string& ver, const string& enc, const string& stl)
|
||||
{
|
||||
if (genxStatus e = genxXmlDeclaration (
|
||||
s_,
|
||||
reinterpret_cast<constUtf8> (ver.c_str ()),
|
||||
(enc.empty () ? 0 : reinterpret_cast<constUtf8> (enc.c_str ())),
|
||||
(stl.empty () ? 0 : reinterpret_cast<constUtf8> (stl.c_str ()))))
|
||||
handle_error (e);
|
||||
}
|
||||
|
||||
void serializer::
|
||||
doctype_decl (const string& re,
|
||||
const string& pi,
|
||||
const string& si,
|
||||
const string& is)
|
||||
{
|
||||
if (genxStatus e = genxDoctypeDeclaration (
|
||||
s_,
|
||||
reinterpret_cast<constUtf8> (re.c_str ()),
|
||||
(pi.empty () ? 0 : reinterpret_cast<constUtf8> (pi.c_str ())),
|
||||
(si.empty () ? 0 : reinterpret_cast<constUtf8> (si.c_str ())),
|
||||
(is.empty () ? 0 : reinterpret_cast<constUtf8> (is.c_str ()))))
|
||||
handle_error (e);
|
||||
}
|
||||
|
||||
bool serializer::
|
||||
lookup_namespace_prefix (const string& ns, string& p) const
|
||||
{
|
||||
// Currently Genx will create a namespace mapping if one doesn't
|
||||
// already exist.
|
||||
//
|
||||
genxStatus e;
|
||||
genxNamespace gns (
|
||||
genxDeclareNamespace (
|
||||
s_, reinterpret_cast<constUtf8> (ns.c_str ()), 0, &e));
|
||||
|
||||
if (e != GENX_SUCCESS)
|
||||
handle_error (e);
|
||||
|
||||
p = reinterpret_cast<const char*> (genxGetNamespacePrefix (gns));
|
||||
return true;
|
||||
}
|
||||
|
||||
qname serializer::
|
||||
current_element () const
|
||||
{
|
||||
constUtf8 ns, n;
|
||||
if (genxStatus e = genxGetCurrentElement (s_, &ns, &n))
|
||||
handle_error (e);
|
||||
|
||||
return qname (ns != 0 ? reinterpret_cast<const char*> (ns) : "",
|
||||
reinterpret_cast<const char*> (n));
|
||||
}
|
||||
|
||||
qname serializer::
|
||||
current_attribute () const
|
||||
{
|
||||
constUtf8 ns, n;
|
||||
if (genxStatus e = genxGetCurrentAttribute (s_, &ns, &n))
|
||||
handle_error (e);
|
||||
|
||||
return qname (ns != 0 ? reinterpret_cast<const char*> (ns) : "",
|
||||
reinterpret_cast<const char*> (n));
|
||||
}
|
||||
|
||||
void serializer::
|
||||
suspend_indentation ()
|
||||
{
|
||||
if (genxStatus e = genxSuspendPrettyPrint (s_))
|
||||
handle_error (e);
|
||||
}
|
||||
|
||||
void serializer::
|
||||
resume_indentation ()
|
||||
{
|
||||
if (genxStatus e = genxResumePrettyPrint (s_))
|
||||
handle_error (e);
|
||||
}
|
||||
|
||||
size_t serializer::
|
||||
indentation_suspended () const
|
||||
{
|
||||
return static_cast<size_t> (genxPrettyPrintSuspended (s_));
|
||||
}
|
||||
}
|
307
third-party/libstudxml/libstudxml/serializer.hxx
vendored
307
third-party/libstudxml/libstudxml/serializer.hxx
vendored
|
@ -1,307 +0,0 @@
|
|||
// file : libstudxml/serializer.hxx -*- C++ -*-
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#ifndef LIBSTUDXML_SERIALIZER_HXX
|
||||
#define LIBSTUDXML_SERIALIZER_HXX
|
||||
|
||||
#include <libstudxml/details/pre.hxx>
|
||||
|
||||
#include <string>
|
||||
#include <ostream>
|
||||
#include <cstddef> // std::size_t
|
||||
|
||||
#include <libstudxml/details/genx/genx.h>
|
||||
|
||||
#include <libstudxml/forward.hxx>
|
||||
#include <libstudxml/qname.hxx>
|
||||
#include <libstudxml/exception.hxx>
|
||||
|
||||
#include <libstudxml/details/config.hxx> // STUDXML_NOTHROW_NOEXCEPT
|
||||
#include <libstudxml/details/export.hxx>
|
||||
|
||||
namespace xml
|
||||
{
|
||||
class serialization: public exception
|
||||
{
|
||||
public:
|
||||
virtual
|
||||
~serialization () STUDXML_NOTHROW_NOEXCEPT {}
|
||||
|
||||
serialization (const std::string& name, const std::string& description);
|
||||
serialization (const serializer& s, const std::string& description);
|
||||
|
||||
const std::string&
|
||||
name () const {return name_;}
|
||||
|
||||
const std::string&
|
||||
description () const {return description_;}
|
||||
|
||||
virtual const char*
|
||||
what () const STUDXML_NOTHROW_NOEXCEPT {return what_.c_str ();}
|
||||
|
||||
private:
|
||||
LIBSTUDXML_EXPORT void
|
||||
init ();
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
std::string description_;
|
||||
std::string what_;
|
||||
};
|
||||
|
||||
class LIBSTUDXML_EXPORT serializer
|
||||
{
|
||||
public:
|
||||
typedef xml::qname qname_type;
|
||||
|
||||
// Serialize to std::ostream. Output name is used in diagnostics to
|
||||
// identify the document being serialized. The indentation argument
|
||||
// specifies the number of indentation spaces that should be used for
|
||||
// pretty-printing. If 0 is passed, no pretty-printing is performed.
|
||||
//
|
||||
// If stream exceptions are enabled then std::ios_base::failure
|
||||
// exception is used to report io errors (badbit and failbit).
|
||||
// Otherwise, those are reported as the serialization exception.
|
||||
//
|
||||
serializer (std::ostream&,
|
||||
const std::string& output_name,
|
||||
unsigned short indentation = 2);
|
||||
|
||||
const std::string&
|
||||
output_name () const {return oname_;}
|
||||
|
||||
~serializer ();
|
||||
|
||||
private:
|
||||
serializer (const serializer&);
|
||||
serializer& operator= (const serializer&);
|
||||
|
||||
// Serialization functions.
|
||||
//
|
||||
public:
|
||||
|
||||
// Elements.
|
||||
//
|
||||
void
|
||||
start_element (const qname_type& qname);
|
||||
|
||||
void
|
||||
start_element (const std::string& name);
|
||||
|
||||
void
|
||||
start_element (const std::string& ns, const std::string& name);
|
||||
|
||||
void
|
||||
end_element ();
|
||||
|
||||
// "Checked" end element. That is, it checks that the element
|
||||
// you think you are ending matches the current one.
|
||||
//
|
||||
void
|
||||
end_element (const qname_type& qname);
|
||||
|
||||
void
|
||||
end_element (const std::string& name);
|
||||
|
||||
void
|
||||
end_element (const std::string& ns, const std::string& name);
|
||||
|
||||
|
||||
// Helpers for serializing elements with simple content. The first two
|
||||
// functions assume that start_element() has already been called. The
|
||||
// other two serialize the complete element, from start to end.
|
||||
//
|
||||
void
|
||||
element (const std::string& value);
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
element (const T& value);
|
||||
|
||||
void
|
||||
element (const std::string& name, const std::string& value);
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
element (const std::string& name, const T& value);
|
||||
|
||||
void
|
||||
element (const qname_type& qname, const std::string& value);
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
element (const qname_type& qname, const T& value);
|
||||
|
||||
void
|
||||
element (const std::string& namespace_,
|
||||
const std::string& name,
|
||||
const std::string& value);
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
element (const std::string& namespace_,
|
||||
const std::string& name,
|
||||
const T& value);
|
||||
|
||||
// Attributes.
|
||||
//
|
||||
void
|
||||
start_attribute (const qname_type& qname);
|
||||
|
||||
void
|
||||
start_attribute (const std::string& name);
|
||||
|
||||
void
|
||||
start_attribute (const std::string& ns, const std::string& name);
|
||||
|
||||
void
|
||||
end_attribute ();
|
||||
|
||||
// "Checked" end attribute. That is, it checks that the attribute
|
||||
// you think you are ending matches the current one.
|
||||
//
|
||||
void
|
||||
end_attribute (const qname_type& qname);
|
||||
|
||||
void
|
||||
end_attribute (const std::string& name);
|
||||
|
||||
void
|
||||
end_attribute (const std::string& ns, const std::string& name);
|
||||
|
||||
|
||||
void
|
||||
attribute (const qname_type& qname, const std::string& value);
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
attribute (const qname_type& qname, const T& value);
|
||||
|
||||
void
|
||||
attribute (const std::string& name, const std::string& value);
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
attribute (const std::string& name, const T& value);
|
||||
|
||||
void
|
||||
attribute (const std::string& ns,
|
||||
const std::string& name,
|
||||
const std::string& value);
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
attribute (const std::string& ns,
|
||||
const std::string& name,
|
||||
const T& value);
|
||||
|
||||
// Characters.
|
||||
//
|
||||
void
|
||||
characters (const std::string& value);
|
||||
|
||||
template <typename T>
|
||||
void
|
||||
characters (const T& value);
|
||||
|
||||
// Namespaces declaration. If prefix is empty, then the default
|
||||
// namespace is declared. If both prefix and namespace are empty,
|
||||
// then the default namespace declaration is cleared (xmlns="").
|
||||
//
|
||||
// This function should be called after start_element().
|
||||
//
|
||||
void
|
||||
namespace_decl (const std::string& ns, const std::string& prefix);
|
||||
|
||||
// XML declaration. If encoding or standalone are not specified,
|
||||
// then these attributes are omitted from the output.
|
||||
//
|
||||
void
|
||||
xml_decl (const std::string& version = "1.0",
|
||||
const std::string& encoding = "UTF-8",
|
||||
const std::string& standalone = "");
|
||||
|
||||
// DOCTYPE declaration. If encoding or standalone are not specified,
|
||||
// then these attributes are omitted from the output.
|
||||
//
|
||||
void
|
||||
doctype_decl (const std::string& root_element,
|
||||
const std::string& public_id = "",
|
||||
const std::string& system_id = "",
|
||||
const std::string& internal_subset = "");
|
||||
|
||||
// Utility functions.
|
||||
//
|
||||
public:
|
||||
// Return true if there is a mapping. In this case, prefix contains
|
||||
// the mapped prefix.
|
||||
//
|
||||
bool
|
||||
lookup_namespace_prefix (const std::string& ns, std::string& prefix) const;
|
||||
|
||||
// Return the current element, that is, the latest element for which
|
||||
// start_element() but not end_element() have been called.
|
||||
//
|
||||
qname
|
||||
current_element () const;
|
||||
|
||||
// Return the current attribute, that is, the latest attribute for
|
||||
// which start_attribute() but not end_attribute() have been called.
|
||||
//
|
||||
qname
|
||||
current_attribute () const;
|
||||
|
||||
// Suspend/resume indentation.
|
||||
//
|
||||
public:
|
||||
|
||||
// Indentation can be suspended only inside an element and, unless
|
||||
// explicitly resumed, it will remain suspended until the end of
|
||||
// that element. You should only explicitly resume indentation at
|
||||
// the element nesting level of suspension. If indentation is already
|
||||
// suspended at an outer nesting level, then subsequent calls to
|
||||
// suspend/resume are ignored. The indentation_suspended() function
|
||||
// can be used to check if indentation is currently suspended. If it
|
||||
// is not, then this function returns 0. Otherwise, it returns the
|
||||
// level at which pretty-printing was suspended, with root element
|
||||
// being level 1.
|
||||
//
|
||||
void
|
||||
suspend_indentation ();
|
||||
|
||||
void
|
||||
resume_indentation ();
|
||||
|
||||
std::size_t
|
||||
indentation_suspended () const;
|
||||
|
||||
private:
|
||||
void
|
||||
handle_error (genxStatus) const;
|
||||
|
||||
private:
|
||||
std::ostream& os_;
|
||||
std::ostream::iostate os_state_; // Original exception state.
|
||||
const std::string oname_;
|
||||
|
||||
genxWriter s_;
|
||||
genxSender sender_;
|
||||
std::size_t depth_;
|
||||
};
|
||||
|
||||
// Stream-like interface for serializer. If the passed argument is
|
||||
// callable with the serializer as its argument, then this function
|
||||
// (object) is called with the passed serializer. Otherwise, the
|
||||
// argument is passed to the serializer's characters() function.
|
||||
//
|
||||
template <typename T>
|
||||
serializer&
|
||||
operator<< (serializer&, const T& value);
|
||||
}
|
||||
|
||||
#include <libstudxml/serializer.ixx>
|
||||
|
||||
#include <libstudxml/details/post.hxx>
|
||||
|
||||
#endif // LIBSTUDXML_SERIALIZER_HXX
|
219
third-party/libstudxml/libstudxml/serializer.ixx
vendored
219
third-party/libstudxml/libstudxml/serializer.ixx
vendored
|
@ -1,219 +0,0 @@
|
|||
// file : libstudxml/serializer.ixx
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#include <libstudxml/value-traits.hxx>
|
||||
|
||||
namespace xml
|
||||
{
|
||||
// serialization
|
||||
//
|
||||
inline serialization::
|
||||
serialization (const std::string& name, const std::string& d)
|
||||
: name_ (name), description_ (d)
|
||||
{
|
||||
init ();
|
||||
}
|
||||
|
||||
inline serialization::
|
||||
serialization (const serializer& s, const std::string& d)
|
||||
: name_ (s.output_name ()), description_ (d)
|
||||
{
|
||||
init ();
|
||||
}
|
||||
|
||||
// serializer
|
||||
//
|
||||
inline void serializer::
|
||||
start_element (const qname_type& qname)
|
||||
{
|
||||
start_element (qname.namespace_ (), qname.name ());
|
||||
}
|
||||
|
||||
inline void serializer::
|
||||
start_element (const std::string& name)
|
||||
{
|
||||
start_element (std::string (), name);
|
||||
}
|
||||
|
||||
inline void serializer::
|
||||
end_element (const qname_type& qname)
|
||||
{
|
||||
end_element (qname.namespace_ (), qname.name ());
|
||||
}
|
||||
|
||||
inline void serializer::
|
||||
end_element (const std::string& name)
|
||||
{
|
||||
end_element (std::string (), name);
|
||||
}
|
||||
|
||||
inline void serializer::
|
||||
element (const std::string& v)
|
||||
{
|
||||
if (!v.empty ())
|
||||
characters (v);
|
||||
|
||||
end_element ();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void serializer::
|
||||
element (const T& v)
|
||||
{
|
||||
element (value_traits<T>::serialize (v, *this));
|
||||
}
|
||||
|
||||
inline void serializer::
|
||||
element (const std::string& n, const std::string& v)
|
||||
{
|
||||
element (std::string (), n, v);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void serializer::
|
||||
element (const std::string& n, const T& v)
|
||||
{
|
||||
element (n, value_traits<T>::serialize (v, *this));
|
||||
}
|
||||
|
||||
inline void serializer::
|
||||
element (const qname_type& qn, const std::string& v)
|
||||
{
|
||||
element (qn.namespace_ (), qn.name (), v);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void serializer::
|
||||
element (const qname_type& qn, const T& v)
|
||||
{
|
||||
element (qn, value_traits<T>::serialize (v, *this));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void serializer::
|
||||
element (const std::string& ns, const std::string& n, const T& v)
|
||||
{
|
||||
element (ns, n, value_traits<T>::serialize (v, *this));
|
||||
}
|
||||
|
||||
inline void serializer::
|
||||
start_attribute (const qname_type& qname)
|
||||
{
|
||||
start_attribute (qname.namespace_ (), qname.name ());
|
||||
}
|
||||
|
||||
inline void serializer::
|
||||
start_attribute (const std::string& name)
|
||||
{
|
||||
start_attribute (std::string (), name);
|
||||
}
|
||||
|
||||
inline void serializer::
|
||||
end_attribute (const qname_type& qname)
|
||||
{
|
||||
end_attribute (qname.namespace_ (), qname.name ());
|
||||
}
|
||||
|
||||
inline void serializer::
|
||||
end_attribute (const std::string& name)
|
||||
{
|
||||
end_attribute (std::string (), name);
|
||||
}
|
||||
|
||||
inline void serializer::
|
||||
attribute (const qname_type& qname, const std::string& value)
|
||||
{
|
||||
attribute (qname.namespace_ (), qname.name (), value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void serializer::
|
||||
attribute (const qname_type& qname, const T& value)
|
||||
{
|
||||
attribute (qname, value_traits<T>::serialize (value, *this));
|
||||
}
|
||||
|
||||
inline void serializer::
|
||||
attribute (const std::string& name, const std::string& value)
|
||||
{
|
||||
attribute (std::string (), name, value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void serializer::
|
||||
attribute (const std::string& name, const T& value)
|
||||
{
|
||||
attribute (name, value_traits<T>::serialize (value, *this));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void serializer::
|
||||
attribute (const std::string& ns, const std::string& name, const T& value)
|
||||
{
|
||||
attribute (ns, name, value_traits<T>::serialize (value, *this));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline void serializer::
|
||||
characters (const T& value)
|
||||
{
|
||||
characters (value_traits<T>::serialize (value, *this));
|
||||
}
|
||||
|
||||
// operator<<
|
||||
//
|
||||
|
||||
inline serializer&
|
||||
operator<< (serializer& s, void (*func) (serializer&))
|
||||
{
|
||||
func (s);
|
||||
return s;
|
||||
}
|
||||
|
||||
namespace details
|
||||
{
|
||||
// Detect whether T is callable with argument A.
|
||||
//
|
||||
template <typename T, typename A>
|
||||
struct is_callable
|
||||
{
|
||||
typedef char no[1];
|
||||
typedef char yes[2];
|
||||
template <typename X> static X declval ();
|
||||
|
||||
template <int> struct check;
|
||||
|
||||
template <typename>
|
||||
static no& test (...);
|
||||
|
||||
template <typename X>
|
||||
static yes& test (check<sizeof (declval<X> () (declval<A> ()), 0)>*);
|
||||
|
||||
static const bool value = sizeof (test<T> (0)) == sizeof (yes);
|
||||
};
|
||||
|
||||
template <typename T, bool = is_callable<const T&, serializer&>::value>
|
||||
struct inserter;
|
||||
|
||||
template <typename T>
|
||||
struct inserter<T, true>
|
||||
{
|
||||
static void insert (serializer& s, const T& f) {f (s);}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct inserter<T, false>
|
||||
{
|
||||
static void insert (serializer& s, const T& v) {s.characters (v);}
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
inline serializer&
|
||||
operator<< (serializer& s, const T& value)
|
||||
{
|
||||
details::inserter<T>::insert (s, value);
|
||||
return s;
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
// file : libstudxml/value-traits.cxx
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#include <libstudxml/parser.hxx>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace xml
|
||||
{
|
||||
bool default_value_traits<bool>::
|
||||
parse (string s, const parser& p)
|
||||
{
|
||||
if (s == "true" || s == "1" || s == "True" || s == "TRUE")
|
||||
return true;
|
||||
else if (s == "false" || s == "0" || s == "False" || s == "FALSE")
|
||||
return false;
|
||||
else
|
||||
throw parsing (p, "invalid bool value '" + s + "'");
|
||||
}
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
// file : libstudxml/value-traits.hxx -*- C++ -*-
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#ifndef LIBSTUDXML_VALUE_TRAITS_HXX
|
||||
#define LIBSTUDXML_VALUE_TRAITS_HXX
|
||||
|
||||
#include <libstudxml/details/pre.hxx>
|
||||
|
||||
#include <string>
|
||||
#include <cstddef> // std::size_t
|
||||
|
||||
#include <libstudxml/forward.hxx>
|
||||
|
||||
#include <libstudxml/details/export.hxx>
|
||||
|
||||
namespace xml
|
||||
{
|
||||
template <typename T>
|
||||
struct default_value_traits
|
||||
{
|
||||
static T
|
||||
parse (std::string, const parser&);
|
||||
|
||||
static std::string
|
||||
serialize (const T&, const serializer&);
|
||||
};
|
||||
|
||||
template <>
|
||||
struct LIBSTUDXML_EXPORT default_value_traits<bool>
|
||||
{
|
||||
static bool
|
||||
parse (std::string, const parser&);
|
||||
|
||||
static std::string
|
||||
serialize (bool v, const serializer&)
|
||||
{
|
||||
return v ? "true" : "false";
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct default_value_traits<std::string>
|
||||
{
|
||||
static std::string
|
||||
parse (std::string s, const parser&)
|
||||
{
|
||||
return s;
|
||||
}
|
||||
|
||||
static std::string
|
||||
serialize (const std::string& v, const serializer&)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct value_traits: default_value_traits<T> {};
|
||||
|
||||
template <typename T, std::size_t N>
|
||||
struct value_traits<T[N]>: default_value_traits<const T*> {};
|
||||
}
|
||||
|
||||
#include <libstudxml/value-traits.txx>
|
||||
|
||||
#include <libstudxml/details/post.hxx>
|
||||
|
||||
#endif // LIBSTUDXML_VALUE_TRAITS_HXX
|
|
@ -1,32 +0,0 @@
|
|||
// file : libstudxml/value-traits.txx
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include <libstudxml/parser.hxx>
|
||||
#include <libstudxml/serializer.hxx>
|
||||
|
||||
namespace xml
|
||||
{
|
||||
template <typename T>
|
||||
T default_value_traits<T>::
|
||||
parse (std::string s, const parser& p)
|
||||
{
|
||||
T r;
|
||||
std::istringstream is (s);
|
||||
if (!(is >> r && is.eof ()) )
|
||||
throw parsing (p, "invalid value '" + s + "'");
|
||||
return r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::string default_value_traits<T>::
|
||||
serialize (const T& v, const serializer& s)
|
||||
{
|
||||
std::ostringstream os;
|
||||
if (!(os << v))
|
||||
throw serialization (s, "invalid value");
|
||||
return os.str ();
|
||||
}
|
||||
}
|
39
third-party/libstudxml/libstudxml/version.hxx.in
vendored
39
third-party/libstudxml/libstudxml/version.hxx.in
vendored
|
@ -1,39 +0,0 @@
|
|||
// file : libstudxml/version.hxx.in -*- C++ -*-
|
||||
// copyright : Copyright (c) 2013-2019 Code Synthesis Tools CC
|
||||
// license : MIT; see accompanying LICENSE file
|
||||
|
||||
#ifndef LIBSTUDXML_VERSION // Note: using the version macro itself.
|
||||
|
||||
// The numeric version format is AAAAABBBBBCCCCCDDDE where:
|
||||
//
|
||||
// AAAAA - major version number
|
||||
// BBBBB - minor version number
|
||||
// CCCCC - bugfix version number
|
||||
// DDD - alpha / beta (DDD + 500) version number
|
||||
// E - final (0) / snapshot (1)
|
||||
//
|
||||
// When DDDE is not 0, 1 is subtracted from AAAAABBBBBCCCCC. For example:
|
||||
//
|
||||
// Version AAAAABBBBBCCCCCDDDE
|
||||
//
|
||||
// 0.1.0 0000000001000000000
|
||||
// 0.1.2 0000000001000020000
|
||||
// 1.2.3 0000100002000030000
|
||||
// 2.2.0-a.1 0000200001999990010
|
||||
// 3.0.0-b.2 0000299999999995020
|
||||
// 2.2.0-a.1.z 0000200001999990011
|
||||
//
|
||||
#define LIBSTUDXML_VERSION $libstudxml.version.project_number$ULL
|
||||
#define LIBSTUDXML_VERSION_STR "$libstudxml.version.project$"
|
||||
#define LIBSTUDXML_VERSION_ID "$libstudxml.version.project_id$"
|
||||
|
||||
#define LIBSTUDXML_VERSION_MAJOR $libstudxml.version.major$
|
||||
#define LIBSTUDXML_VERSION_MINOR $libstudxml.version.minor$
|
||||
#define LIBSTUDXML_VERSION_PATCH $libstudxml.version.patch$
|
||||
|
||||
#define LIBSTUDXML_PRE_RELEASE $libstudxml.version.pre_release$
|
||||
|
||||
#define LIBSTUDXML_SNAPSHOT $libstudxml.version.snapshot_sn$ULL
|
||||
#define LIBSTUDXML_SNAPSHOT_ID "$libstudxml.version.snapshot_id$"
|
||||
|
||||
#endif // LIBSTUDXML_VERSION
|
1
third-party/libstudxml/version
vendored
1
third-party/libstudxml/version
vendored
|
@ -1 +0,0 @@
|
|||
1.1.0-b.8
|
Loading…
Reference in New Issue
Block a user