From a02e669a1e835b153ffaa795100b593b95e28703 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Sat, 6 Aug 2022 11:10:32 -0400 Subject: [PATCH] latest from coda-oss --- .../math.linear/include/math/linear/Line2D.h | 7 + .../modules/c++/math.linear/source/Line2D.cpp | 20 + .../coda-oss/modules/c++/std/include/std/bit | 17 +- .../modules/c++/std/include/std/string | 4 +- .../modules/c++/str/include/str/Encoding.h | 1 - .../modules/c++/str/source/EncodedString.cpp | 3 +- .../modules/c++/str/source/Encoding.cpp | 15 +- .../c++/str/unittests/test_base_convert.cpp | 23 +- .../modules/c++/sys/source/sys_filesystem.cpp | 13 +- .../include/xml/lite/ContentHandler.h | 8 +- .../c++/xml.lite/include/xml/lite/Document.h | 71 +- .../c++/xml.lite/include/xml/lite/Element.h | 136 +-- .../include/xml/lite/MinidomHandler.h | 94 +- .../xml.lite/include/xml/lite/MinidomParser.h | 41 +- .../c++/xml.lite/include/xml/lite/QName.h | 30 +- .../xml.lite/include/xml/lite/Serializable.h | 9 +- .../include/xml/lite/UtilitiesXerces.h | 21 +- .../include/xml/lite/ValidatorInterface.h | 31 +- .../include/xml/lite/ValidatorXerces.h | 15 +- .../xml.lite/include/xml/lite/XMLException.h | 17 +- .../include/xml/lite/XMLReaderInterface.h | 1 - .../include/xml/lite/XMLReaderXerces.h | 17 +- .../modules/c++/xml.lite/source/Document.cpp | 41 +- .../modules/c++/xml.lite/source/Element.cpp | 163 +-- .../c++/xml.lite/source/MinidomHandler.cpp | 104 +- .../c++/xml.lite/source/MinidomParser.cpp | 25 +- .../c++/xml.lite/source/NamespaceStack.cpp | 2 +- .../c++/xml.lite/source/UtilitiesXerces.cpp | 7 +- .../xml.lite/source/ValidatorInterface.cpp | 33 - .../c++/xml.lite/source/ValidatorXerces.cpp | 91 +- .../c++/xml.lite/source/XMLReaderXerces.cpp | 84 +- .../xml.lite/unittests/test_xmlattribute.cpp | 5 +- .../xml.lite/unittests/test_xmlelement.cpp | 77 +- .../c++/xml.lite/unittests/test_xmlparser.cpp | 261 ++--- .../xml.lite/source/generated/xml_lite.py | 34 +- .../source/generated/xml_lite_wrap.cxx | 1009 ++--------------- 36 files changed, 632 insertions(+), 1898 deletions(-) diff --git a/externals/coda-oss/modules/c++/math.linear/include/math/linear/Line2D.h b/externals/coda-oss/modules/c++/math.linear/include/math/linear/Line2D.h index 4096ca5d1..bdbf635e1 100644 --- a/externals/coda-oss/modules/c++/math.linear/include/math/linear/Line2D.h +++ b/externals/coda-oss/modules/c++/math.linear/include/math/linear/Line2D.h @@ -57,6 +57,13 @@ class Line2D double distanceToPoint(const Point& P) const; //Return a point that is a distance d from the point P which is on the line Point offsetFromPoint(const Point& P, double distance) const; + // + bool equals(const Line2D& other) const; + + friend bool operator==(const Line2D& lhs, const Line2D& rhs) + { + return lhs.equals(rhs); + } private: Line2DType mType; double mSlope; diff --git a/externals/coda-oss/modules/c++/math.linear/source/Line2D.cpp b/externals/coda-oss/modules/c++/math.linear/source/Line2D.cpp index d311ccb35..3d74a995a 100644 --- a/externals/coda-oss/modules/c++/math.linear/source/Line2D.cpp +++ b/externals/coda-oss/modules/c++/math.linear/source/Line2D.cpp @@ -246,6 +246,26 @@ Line2D::Point Line2D::offsetFromPoint(const Point& P, double distance) const ret.col += distance * std::sin(theta); return ret; } + +bool Line2D::equals(const Line2D& other) const +{ + if (mType == other.mType) + { + if (mType != Line2D::NORMAL) + { + return true; + } + else + { + if ((getSlope() == other.getSlope()) + && (getYIntercept() == other.getYIntercept())) + { + return true; + } + } + } + return false; +} } } diff --git a/externals/coda-oss/modules/c++/std/include/std/bit b/externals/coda-oss/modules/c++/std/include/std/bit index 7ce052c0a..ffe3b7651 100644 --- a/externals/coda-oss/modules/c++/std/include/std/bit +++ b/externals/coda-oss/modules/c++/std/include/std/bit @@ -25,18 +25,17 @@ // Make it (too?) easy for clients to get our various std:: implementations #ifndef CODA_OSS_NO_std_endian #include "coda_oss/CPlusPlus.h" - #if CODA_OSS_cpp17 - // Some C++17 implementations have + #if CODA_OSS_cpp20 + // Some implementations cliam to be C++20 w/o #if __has_include() // __has_include is C++17 - #include - #define CODA_OSS_NO_std_endian 1 // provided by implementation, probably C++20 - #else - #include "coda_oss/bit.h" - #define CODA_OSS_NO_std_endian 0 // no , use our own + #include + #define CODA_OSS_NO_std_endian 1 // provided by implementation, probably C++20 #endif - #else + #endif + // At this point, CODA_OSS_NO_std_endian will be set only if we were able to successfully use (above) + #ifndef CODA_OSS_NO_std_endian #include "coda_oss/bit.h" - #define CODA_OSS_NO_std_endian 0 // < C++17, use our own + #define CODA_OSS_NO_std_endian 0 // <= C++17, use our own #endif #endif diff --git a/externals/coda-oss/modules/c++/std/include/std/string b/externals/coda-oss/modules/c++/std/include/std/string index 4af50dbd0..df11495a6 100644 --- a/externals/coda-oss/modules/c++/std/include/std/string +++ b/externals/coda-oss/modules/c++/std/include/std/string @@ -27,8 +27,8 @@ // Make it (too?) easy for clients to get our various std:: implementations #ifndef CODA_OSS_NO_std_u8string #include "coda_oss/CPlusPlus.h" - #if CODA_OSS_cpp17 - #define CODA_OSS_NO_std_u8string 1 // part of C++17 + #if CODA_OSS_cpp20 + #define CODA_OSS_NO_std_u8string 1 // part of C++20 #else #include "coda_oss/string.h" #define CODA_OSS_NO_std_u8string 0 // use our own diff --git a/externals/coda-oss/modules/c++/str/include/str/Encoding.h b/externals/coda-oss/modules/c++/str/include/str/Encoding.h index 8fcdeb5c4..c063c61d5 100644 --- a/externals/coda-oss/modules/c++/str/include/str/Encoding.h +++ b/externals/coda-oss/modules/c++/str/include/str/Encoding.h @@ -109,7 +109,6 @@ CODA_OSS_API str::W1252string to_w1252string(coda_oss::u8string::const_pointer p namespace details // YOU should use EncodedStringView { void w1252to8(str::W1252string::const_pointer p, size_t sz, std::string&); // encoding is lost -void utf16to8(std::u16string::const_pointer, size_t, std::string&); // encoding is lost void utf8to1252(coda_oss::u8string::const_pointer p, size_t sz, std::string&); // encoding is lost } } diff --git a/externals/coda-oss/modules/c++/str/source/EncodedString.cpp b/externals/coda-oss/modules/c++/str/source/EncodedString.cpp index 1a43d926f..74d5b5d38 100644 --- a/externals/coda-oss/modules/c++/str/source/EncodedString.cpp +++ b/externals/coda-oss/modules/c++/str/source/EncodedString.cpp @@ -20,11 +20,10 @@ * see . * */ +#include "str/EncodedString.h" #include -#include "str/EncodedString.h" - void str::EncodedString::assign(coda_oss::u8string::const_pointer s) { using char_t = std::remove_pointer::type; // avoid copy-paste error diff --git a/externals/coda-oss/modules/c++/str/source/Encoding.cpp b/externals/coda-oss/modules/c++/str/source/Encoding.cpp index 19cb02d9c..958f6b336 100644 --- a/externals/coda-oss/modules/c++/str/source/Encoding.cpp +++ b/externals/coda-oss/modules/c++/str/source/Encoding.cpp @@ -23,6 +23,9 @@ #include #include +#if _WIN32 +#include // _bstr_t +#endif #include #include @@ -171,7 +174,13 @@ void str::details::w1252to8(str::W1252string::const_pointer p, size_t sz, std::s } std::u16string str::to_u16string(str::W1252string::const_pointer p, size_t sz) { - return to_Tstring(p, sz); + auto retval = to_Tstring(p, sz); + #if defined(_WIN32) && (!defined(_NDEBUG) || defined(DEBUG)) + const _bstr_t bstr(str::cast(p)); + const std::wstring wstr(static_cast(bstr)); + assert(retval == str::cast(wstr.c_str())); + #endif + return retval; } str::ui16string str::to_ui16string(str::W1252string::const_pointer p, size_t sz) { @@ -299,10 +308,6 @@ coda_oss::u8string str::to_u8string(std::u16string::const_pointer p, size_t sz) utf8::utf8to16(begin, begin+result.size(), std::back_inserter(utf16line)); */ } -void str::details::utf16to8(std::u16string::const_pointer p, size_t sz, std::string& result) -{ - utf8::utf16to8(p, p + sz, std::back_inserter(result)); -} std::u16string str::to_u16string(coda_oss::u8string::const_pointer p_, size_t sz) { diff --git a/externals/coda-oss/modules/c++/str/unittests/test_base_convert.cpp b/externals/coda-oss/modules/c++/str/unittests/test_base_convert.cpp index ce581c6c6..a5d49c2c0 100644 --- a/externals/coda-oss/modules/c++/str/unittests/test_base_convert.cpp +++ b/externals/coda-oss/modules/c++/str/unittests/test_base_convert.cpp @@ -28,17 +28,14 @@ #include #include +#include #include #include "TestCase.h" -inline static void test_assert_eq(const std::string& testName, const std::u8string& actual, const std::u8string& expected) -{ - TEST_ASSERT_EQ(actual, expected); -} inline static void test_assert_eq(const std::string& testName, const std::u8string& actual, const std::u32string& expected) { - test_assert_eq(testName, actual, str::to_u8string(expected)); + TEST_ASSERT_EQ(actual, str::to_u8string(expected)); } TEST_CASE(testConvert) @@ -106,7 +103,7 @@ TEST_CASE(test_string_to_u8string_ascii) const std::string input { '|', static_cast(ch), '|'}; const auto actual = fromWindows1252(input); const std::u8string expected8{cast8('|'), cast8(ch), cast8('|')}; - test_assert_eq(testName, actual, expected8); + TEST_ASSERT_EQ(actual, expected8); const std::u32string expected{U'|', U(ch), U'|'}; test_assert_eq(testName, actual, expected); } @@ -119,16 +116,16 @@ TEST_CASE(test_string_to_u8string_windows_1252) const std::string input = "|\x80|"; // Windows-1252, "|�|" const auto actual = fromWindows1252(input); const std::u8string expected8{cast8('|'), cast8('\xE2'), cast8('\x82'), cast8('\xAC'), cast8('|')}; // UTF-8, "|�|" - test_assert_eq(testName, actual, expected8); - const std::u32string expected{U"|\U000020AC|"}; // UTF-32, "|�|" + TEST_ASSERT_EQ(actual, expected8); + const std::u32string expected{U"|\u20AC|"}; // UTF-32, "|�|" test_assert_eq(testName, actual, expected); } { const std::string input = "|\x9F|"; // Windows-1252, "|�|" const auto actual = fromWindows1252(input); const std::u8string expected8{cast8('|'), cast8('\xC5'), cast8('\xB8'), cast8('|')}; // UTF-8, "|�|" - test_assert_eq(testName, actual, expected8); - const std::u32string expected{U"|\U00000178|"}; // UTF-32, "|�|" + TEST_ASSERT_EQ(actual, expected8); + const std::u32string expected{U"|\u0178|"}; // UTF-32, "|�|" test_assert_eq(testName, actual, expected); } { @@ -138,8 +135,8 @@ TEST_CASE(test_string_to_u8string_windows_1252) const std::string input{'|', ch, '|'}; const auto actual = fromWindows1252(input); static const std::u8string expected8{cast8('|'), cast8('\xEF'), cast8('\xBF'), cast8('\xBD'), cast8('|')}; // UTF-8, "||" - test_assert_eq(testName, actual, expected8); - const std::u32string expected{U"|\U0000fffd|"}; // UTF-32, "||" + TEST_ASSERT_EQ(actual, expected8); + const std::u32string expected{U"|\ufffd|"}; // UTF-32, "||" test_assert_eq(testName, actual, expected); } } @@ -183,7 +180,7 @@ TEST_CASE(test_string_to_u8string_windows_1252) // are mapped one-by-one. However, we can test that UTF-8 to Windows-1252 // works as that walks through a UTF-8 string which can have 1-, 2-, 3- and 4-bytes // for a single code-point. - const auto w1252 = str::EncodedStringView::details::w1252string(str::EncodedStringView(actual)); + const auto w1252 = str::to_w1252string(actual.data(), actual.size()); TEST_ASSERT(input == w1252); // Can't compare the values with == because TEST_ASSERT_EQ() diff --git a/externals/coda-oss/modules/c++/sys/source/sys_filesystem.cpp b/externals/coda-oss/modules/c++/sys/source/sys_filesystem.cpp index ea2f134c0..95f968896 100644 --- a/externals/coda-oss/modules/c++/sys/source/sys_filesystem.cpp +++ b/externals/coda-oss/modules/c++/sys/source/sys_filesystem.cpp @@ -3,7 +3,6 @@ #include #ifdef _WIN32 #include -#include // _bstr_t #else #include #endif @@ -17,6 +16,7 @@ #include "sys/Path.h" #include "gsl/gsl.h" +#include "str/EncodedString.h" namespace fs = sys::filesystem; @@ -47,9 +47,9 @@ static inline std::string make_what(const char* curfile, const int lineNum, cons fs::path::string_type fs::path::to_native(const std::string& s_) { + #ifdef _WIN32 - const _bstr_t s(s_.c_str()); // convert to wchar_t - return static_cast(s); + return str::EncodedStringView(s_).wstring(); #else return s_; #endif @@ -104,12 +104,7 @@ fs::path::operator string_type() const std::string fs::path::string() const { -#ifdef _WIN32 - const _bstr_t p(c_str()); - return static_cast(p); -#else - return native(); -#endif + return str::EncodedString(p_).native(); } fs::path fs::path::root_path() const diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ContentHandler.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ContentHandler.h index 763a94981..9e03adeae 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ContentHandler.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ContentHandler.h @@ -92,13 +92,7 @@ class ContentHandler * \param length The length of the new data */ virtual void characters(const char *data, int length) = 0; - - virtual bool vcharacters(const void/*XMLCh*/*, size_t /*length*/) // avoid XMLCh, it's specific to Xerces - { return false; /* continue on to existing characters()*/ } /* =0 would break existing code */ - virtual bool call_vcharacters() const // =0 would break existing code - { - return false; // don't call vcharacters(const void*) - } + virtual bool vcharacters(const void/*XMLCh*/*, size_t /*length*/) = 0; // avoid XMLCh, it's specific to Xerces /*! * Receive notification of the beginning of an element. diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Document.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Document.h index 29bb84ea9..f9d75a62b 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Document.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Document.h @@ -38,7 +38,9 @@ #include +#include #include "coda_oss/string.h" +#include "coda_oss/memory.h" #include "xml/lite/Element.h" #include "xml/lite/QName.h" @@ -54,33 +56,45 @@ namespace lite * Use the Document to access the Element nodes contained within. * The DocumentParser will build a tree that you can use. */ -class Document +struct Document final { -public: //! Constructor Document(Element* rootNode = nullptr, bool own = true) : mRootNode(rootNode), mOwnRoot(own) { } + #ifndef SWIG // SWIG doesn't like std::unique_ptr + explicit Document(std::unique_ptr&& rootNode) : // implicitly own=true + Document(rootNode.release(), true /*own*/) + { + } + #endif // SWIG /*! * Destroy the xml tree. This deletes the nodes if they exist * Careful, this may delete your copy if you are not careful */ - virtual ~Document() + ~Document() noexcept(false) { destroy(); } - virtual Document* clone() const + #ifndef SWIG // SWIG doesn't like std::unique_ptr + std::unique_ptr& clone(std::unique_ptr& doc) const { - Document* doc = new Document(); + doc = coda_oss::make_unique(); - Element* cloneRoot = new Element(); + auto cloneRoot = coda_oss::make_unique(); cloneRoot->clone(*mRootNode); - doc->setRootElement(cloneRoot); + doc->setRootElement(std::move(cloneRoot)); return doc; } + Document* clone() const + { + std::unique_ptr doc; + return clone(doc).release(); + } + #endif // SWIG /*! * Factory-type method for creating a new Element @@ -89,22 +103,12 @@ class Document * \param characterData The character data (if any) * \return A new element */ - virtual Element *createElement(const std::string & qname, - const std::string & uri, - std::string characterData = ""); - #ifndef SWIG // SWIG doesn't like unique_ptr or StringEncoding - Element* createElement(const std::string& qname, - const std::string & uri, - const std::string& characterData, StringEncoding) const; - Element* createElement(const std::string& qname, - const std::string& uri, - const coda_oss::u8string& characterData) const; - std::unique_ptr createElement(const xml::lite::QName& qname, const std::string& characterData) const; - std::unique_ptr createElement(const xml::lite::QName& qname, - const std::string& characterData, StringEncoding) const; + Element *createElement(const std::string & qname, const std::string & uri, std::string characterData = ""); + #ifndef SWIG // SWIG doesn't like std::unique_ptr + std::unique_ptr createElement(const xml::lite::QName&, const std::string& characterData) const; + std::unique_ptr createElement(const xml::lite::QName&, const coda_oss::u8string& characterData) const; #endif // SWIG - /*! * Blanket destructor. This thing deletes everything */ @@ -118,13 +122,13 @@ class Document * \param element Element to add * \param underThis Element to add element to */ - virtual void insert(Element * element, Element * underThis); + void insert(Element * element, Element * underThis); /*! * Remove an element from the tree, starting at the root * \param toDelete The node to delete (This DOES do deletion) */ - virtual void remove(Element * toDelete); + void remove(Element * toDelete); /*! * Remove an element from the tree, starting at the second param @@ -133,13 +137,19 @@ class Document * be an optimization depending on the task, so I allow it to remain * public */ - virtual void remove(Element * toDelete, Element * fromHere); + void remove(Element * toDelete, Element * fromHere); /*! * Sets the internal root element * \param element The node to set. */ void setRootElement(Element * element, bool own = true); + #ifndef SWIG // SWIG doesn't like std::unique_ptr + void setRootElement(std::unique_ptr&& element) // implicitly own=true + { + setRootElement(element.release(), true /*own*/); + } + #endif // SWIG /*! * Retrieves the internal root element @@ -151,17 +161,20 @@ class Document mOwnRoot = false; return mRootNode; } - + #ifndef SWIG // SWIG doesn't like std::unique_ptr + std::unique_ptr& getRootElement(std::unique_ptr& rootNode) // implicitly steal=true + { + rootNode.reset(getRootElement(true /*steal*/)); + return rootNode; + } + #endif // SWIG Element *getRootElement() const { return mRootNode; } -protected: - //! Copy constructor +private: Document(const Document&); - - //! Assignment operator Document& operator=(const Document&); //! The root node element diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Element.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Element.h index 657ce12af..96c5c7436 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Element.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Element.h @@ -20,22 +20,23 @@ * */ -#ifndef __XML_LITE_ELEMENT_H__ -#define __XML_LITE_ELEMENT_H__ +#ifndef CODA_OSS_xml_lite_Element_h_INCLUDED_ +#define CODA_OSS_xml_lite_Element_h_INCLUDED_ #pragma once #include #include #include // std::nothrow_t +#include #include #include #include +#include #include "xml/lite/XMLException.h" #include "xml/lite/Attributes.h" #include "xml/lite/QName.h" #include "sys/Conf.h" -#include "coda_oss/optional.h" #include "mem/SharedPtr.h" /*! @@ -59,19 +60,9 @@ namespace lite * This class stores all of the element information about an XML * document. */ -class Element +struct Element final { - Element(const std::string& qname, const std::string& uri, std::nullptr_t) : - mParent(nullptr), mName(uri, qname) - { - } - -public: - //! Default constructor - Element() : - mParent(nullptr) - { - } + Element() = default; /*! * Constructor taking the namespace prefix and the local name @@ -79,37 +70,25 @@ class Element * \param uri The uri of the object * \param characterData The character data (if any) */ - Element(const std::string& qname, const std::string& uri = "", - const std::string& characterData = "") : - Element(qname, uri, nullptr) + explicit Element(const std::string& qname, const std::string& uri = "", const std::string& characterData = "") : + mName(uri, qname) { setCharacterData(characterData); } - #ifndef SWIG // SWIG doesn't like unique_ptr or StringEncoding - Element(const std::string& qname, const std::string& uri, - const std::string& characterData, StringEncoding encoding) : - Element(qname, uri, nullptr) - { - setCharacterData(characterData, encoding); - } - Element(const std::string& qname, const std::string& uri, - const coda_oss::u8string& characterData) : - Element(qname, uri, nullptr) + Element(const xml::lite::QName& qname, const coda_oss::u8string& characterData) : + mName(qname.getName(), qname.getUri().value) { setCharacterData(characterData); } - // StringEncoding is assumed based on the platform: Windows-1252 or UTF-8. + #ifndef SWIG // SWIG doesn't like std::unique_ptr static std::unique_ptr create(const std::string& qname, const std::string& uri = "", const std::string& characterData = ""); - static std::unique_ptr create(const std::string& qname, const xml::lite::Uri& uri, const std::string& characterData = ""); static std::unique_ptr create(const xml::lite::QName&, const std::string& characterData = ""); static std::unique_ptr create(const xml::lite::QName&, const coda_oss::u8string&); - // Encoding of "characterData" is always UTF-8 - static std::unique_ptr createU8(const xml::lite::QName&, const std::string& characterData = ""); #endif // SWIG - + //! Destructor - virtual ~Element() + ~Element() noexcept(false) { destroyChildren(); } @@ -118,14 +97,14 @@ class Element void destroyChildren(); // use clone() to duplicate an Element -#if !(defined(SWIG) || defined(SWIGPYTHON) || defined(HAVE_PYTHON_H)) // SWIG needs these -//private: // encoded as part of the C++ name mangling by some compilers -#endif + #if !(defined(SWIG) || defined(SWIGPYTHON) || defined(HAVE_PYTHON_H)) // SWIG needs these + //private: // encoded as part of the C++ name mangling by some compilers + #endif Element(const Element&); Element& operator=(const Element&); -#if !(defined(SWIG) || defined(SWIGPYTHON) || defined(HAVE_PYTHON_H)) -public: -#endif + #if !(defined(SWIG) || defined(SWIGPYTHON) || defined(HAVE_PYTHON_H)) + public: + #endif Element(Element&&) = default; Element& operator=(Element&&) = default; @@ -290,21 +269,17 @@ class Element * \todo Add format capability */ void print(io::OutputStream& stream) const; - - // This is another slightly goofy routine to maintain backwards compatibility. - // XML documents must be properly (UTF-8, UTF-16 or UTF-32). The legacy - // print() routine (above) can write documents with a Windows-1252 encoding - // as the string is just copied to the output. - // - // The only valid setting for StringEncoding is Utf8; but defaulting that - // could change behavior on Windows. void prettyPrint(io::OutputStream& stream, const std::string& formatter = " ") const; - #ifndef SWIG // SWIG doesn't like unique_ptr or StringEncoding - void print(io::OutputStream& stream, StringEncoding /*=Utf8*/) const; - void prettyPrint(io::OutputStream& stream, StringEncoding /*=Utf8*/, + + // Outputs (presumablly to the console) using the **NATIVE** encoding. + // For most XML processing, **THIS IS WRONG** as output should + // always be UTF-8. However, for displaying XML on the console in Windows, + // the native (Windows-1252) encoding will work better as "special" characters + // will be displayed. + void consoleOutput_(io::OutputStream& stream) const; // be sure OutputStream is the console, not a file + void prettyConsoleOutput_(io::OutputStream& stream, // be sure OutputStream is the console, not a file const std::string& formatter = " ") const; - #endif // SWIG /*! * Determines if a child element exists @@ -329,33 +304,21 @@ class Element * Returns the character data of this element. * \return the charater data */ - std::string getCharacterData() const - { - return mCharacterData; - } - #ifndef SWIG // SWIG doesn't like unique_ptr or StringEncoding - const coda_oss::optional& getEncoding() const - { - return mEncoding; - } - const coda_oss::optional& getCharacterData(std::string& result) const - { - result = getCharacterData(); - return getEncoding(); - } - void getCharacterData(coda_oss::u8string& result) const; - #endif // SWIG + std::string getCharacterData() const; + coda_oss::u8string& getCharacterData(coda_oss::u8string& result) const; /*! * Sets the character data for this element. * \param characters The data to add to this element */ - void setCharacterData(const std::string& characters); - #ifndef SWIG // SWIG doesn't like unique_ptr or StringEncoding - void setCharacterData_(const std::string& characters, const StringEncoding*); - void setCharacterData(const std::string& characters, StringEncoding); - void setCharacterData(const coda_oss::u8string& characters); - #endif // SWIG + void setCharacterData(const std::string&); + void setCharacterData(coda_oss::u8string s) + { + // See Item #41 in "Effective Modern C++" by Scott Meyers. + // std::basic_string is "cheap to move" and "always copied" + // into mCharacterData. + mCharacterData = std::move(s); + } /*! * Sets the local name for this element. @@ -441,7 +404,9 @@ class Element * Adds a child element to this element * \param node the child element to add */ + #ifndef SWIG // SWIG doesn't like std::unique_ptr virtual Element& addChild(std::unique_ptr&& node); + #endif // SWIG #if CODA_OSS_autoptr_is_std // std::auto_ptr removed in C++17 virtual Element& addChild(mem::auto_ptr node); #endif @@ -482,8 +447,7 @@ class Element mParent = parent; } -protected: - +private: void changePrefix(Element* element, const std::string& prefix, const std::string& uri); @@ -492,28 +456,18 @@ class Element const std::string& prefix, const std::string& uri); - void depthPrint(io::OutputStream& stream, int depth, - const std::string& formatter) const; - void depthPrint(io::OutputStream& stream, StringEncoding, int depth, - const std::string& formatter) const; + void depthPrint(io::OutputStream& stream, int depth, const std::string& formatter, bool isConsoleOutput = false) const; - Element* mParent; + Element* mParent = nullptr; //! The children of this element std::vector mChildren; xml::lite::QName mName; //! The attributes for this element xml::lite::Attributes mAttributes; - //! The character data ... - std::string mCharacterData; - - private: - // ... and how that data is encoded - coda_oss::optional mEncoding; - void depthPrint(io::OutputStream& stream, bool utf8, int depth, - const std::string& formatter) const; + coda_oss::u8string mCharacterData; }; -extern Element& add(const xml::lite::QName&, const std::string& value, Element& parent); +Element& add(const xml::lite::QName&, const std::string& value, Element& parent); #ifndef SWIG // The (old) version of SWIG we're using doesn't like certain C++11 features. @@ -614,4 +568,4 @@ inline Element* addNewOptionalElement(const xml::lite::QName& name, const coda_o } } -#endif +#endif // CODA_OSS_xml_lite_Element_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/MinidomHandler.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/MinidomHandler.h index a3b225134..dcf5debb2 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/MinidomHandler.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/MinidomHandler.h @@ -20,8 +20,8 @@ * */ -#ifndef __XML_LITE_MINIDOM_HANDLER_H__ -#define __XML_LITE_MINIDOM_HANDLER_H__ +#ifndef CODA_OSS_xml_lite_MinidomHandler_h_INCLUDED_ +#define CODA_OSS_xml_lite_MinidomHandler_h_INCLUDED_ #pragma once /*! @@ -47,7 +47,11 @@ #include #include +#include "coda_oss/string.h" +#include "coda_oss/memory.h" +#include "str/EncodedString.h" +#include "str/EncodedStringView.h" #include "XMLReader.h" #include "io/StandardStreams.h" #include "Document.h" @@ -68,14 +72,13 @@ namespace lite struct MinidomHandler final : public ContentHandler { //! Constructor. Uses default document - MinidomHandler() : - mDocument(nullptr), mOwnDocument(true), mPreserveCharData(false) + MinidomHandler() { - setDocument(new Document()); + setDocument(coda_oss::make_unique()); } //! Destructor - virtual ~ MinidomHandler() + ~ MinidomHandler() { setDocument(nullptr, true); } @@ -84,22 +87,22 @@ struct MinidomHandler final : public ContentHandler MinidomHandler(MinidomHandler&&) = default; MinidomHandler& operator=(MinidomHandler&&) = default; - virtual void setDocument(Document *newDocument, bool own = true); + void setDocument(Document *newDocument, bool own = true); void setDocument(std::unique_ptr&&); // own = true /** * Retrieves the Document. * @param steal if specified, ownership will be given up (if owned) */ - virtual Document *getDocument(bool steal = false) + Document *getDocument(bool steal = false) { if (steal) mOwnDocument = false; return mDocument; } - void getDocument(std::unique_ptr&); // steal = true + std::unique_ptr& getDocument(std::unique_ptr&); // steal = true - virtual Document *getDocument() const + Document *getDocument() const { return mDocument; } @@ -111,10 +114,8 @@ struct MinidomHandler final : public ContentHandler * \param value The value of the char data * \param length The length of the char data */ - virtual void characters(const char* value, int length) override; - + void characters(const char* value, int length) override; bool vcharacters(const void /*XMLCh*/*, size_t length) override; - bool call_vcharacters() const override; /*! * This method is fired when a new tag is entered. @@ -127,18 +128,10 @@ struct MinidomHandler final : public ContentHandler * \param qname The qname * \param atts The attributes */ - virtual void startElement(const std::string & uri, + void startElement(const std::string & uri, const std::string & localName, const std::string & qname, - const Attributes & atts); - - /*! - * We want to push only the proper amount of bytes - * to the node when we start writing. Here we chew - * up the pieces we take as we are taking them. - * \return The chracter data for the node - */ - virtual std::string adjustCharacterData(); + const Attributes & atts) override; /*! * Handles the actual popping of the node off the node @@ -148,53 +141,42 @@ struct MinidomHandler final : public ContentHandler * \param localName The local name * \param qname The qname */ - virtual void endElement(const std::string & uri, + void endElement(const std::string & uri, const std::string & localName, - const std::string & qname); - - virtual void clear(); + const std::string & qname) override; - /*! - * Trim the white space off the back and front of a string - * \param s String to trim - */ - static void trim(std::string & s); + void clear(); /*! * If set to true, whitespaces will be preserved in the parsed * character data. Otherwise, it will be trimmed. */ - virtual void preserveCharacterData(bool preserve); + void preserveCharacterData(bool preserve); +private: /*! - * If set to true, how std::string values are encoded will be set. - * - * This is a bit goofy to preserve existing behavior: on *ix, - * XML containing non-ASCII data is lost (it turns into - * Windows-1252 on Windows). - * - * When set, there won't be any change on Windows. However, - * on *ix, std::string will be encoding as UTF-8 thus preserving - * the non-ASCII data. + * We want to push only the proper amount of bytes + * to the node when we start writing. Here we chew + * up the pieces we take as we are taking them. + * \return The chracter data for the node + */ + coda_oss::u8string adjustCharacterData(); + + /*! + * Trim the white space off the back and front of a string + * \param s String to trim */ - virtual void storeEncoding(bool value); - bool storeEncoding() const; + static void trim(coda_oss::u8string& s); -protected: - std::string currentCharacterData; + coda_oss::u8string currentCharacterData; std::stack bytesForElement; std::stack nodeStack; - Document *mDocument; - bool mOwnDocument; - bool mPreserveCharData; - - private: - void characters(const char* value, int length, const StringEncoding*); - void call_characters(const std::string&, StringEncoding); - std::shared_ptr mpEncoding; - bool mStoreEncoding = false; + Document* mDocument = nullptr; + bool mOwnDocument = true; + bool mPreserveCharData = false; + void characters(coda_oss::u8string&&); }; } } -#endif +#endif // CODA_OSS_xml_lite_MinidomHandler_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/MinidomParser.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/MinidomParser.h index d25148755..4593d8222 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/MinidomParser.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/MinidomParser.h @@ -20,8 +20,8 @@ * */ -#ifndef __XML_LITE_MINIDOM_PARSER_H__ -#define __XML_LITE_MINIDOM_PARSER_H__ +#ifndef CODA_OSS_xml_lite_MinidomParser_h_INCLUDED_ +#define CODA_OSS_xml_lite_MinidomParser_h_INCLUDED_ #pragma once #include @@ -56,17 +56,15 @@ namespace lite * bloat of the spec. It was inspired by python's xml.dom.minidom * module. */ -struct MinidomParser +struct MinidomParser final { /*! * Constructor. Set our SAX ContentHandler. */ - MinidomParser(bool storeEncoding = false); // see MinidomHandler::storeEncoding() + explicit MinidomParser(bool storeEncoding = true); //! Destructor. - virtual ~MinidomParser() - { - } + ~MinidomParser() = default; MinidomParser(const MinidomParser&) = delete; MinidomParser& operator=(const MinidomParser&) = delete; @@ -79,27 +77,25 @@ struct MinidomParser * \param is This is the input stream to feed the parser * \param size This is the size of the stream to feed the parser */ - virtual void parse(io::InputStream& is, int size = io::InputStream::IS_END); - #ifndef SWIG // SWIG doesn't like unique_ptr or StringEncoding - virtual void parse(io::InputStream& is, StringEncoding, int size = io::InputStream::IS_END); - #endif // SWIG + void parse(io::InputStream& is, int size = io::InputStream::IS_END); + void parse(io::InputStream& is, const void*pInitialEncoding, const void* pFallbackEncoding, + int size = io::InputStream::IS_END); /*! * This clears the MinidomHandler, killing its underlying Document * tree. The Document node is preserved, however -- it must * be explicitly reset to another document to change element type. */ - virtual void clear(); + void clear(); /*! * Return a pointer to the document. Note that its a reference * so you dont get to keep it. * \return Pointer to document. */ - virtual Document *getDocument() const; - - virtual Document *getDocument(bool steal = false); - void getDocument(std::unique_ptr&); // steal = true + Document *getDocument() const; + Document *getDocument(bool steal = false); + std::unique_ptr& getDocument(std::unique_ptr&); // steal = true /*! * Reader accessor @@ -126,20 +122,15 @@ struct MinidomParser * * \param newDocument The new document. */ - virtual void setDocument(Document * newDocument, bool own = true); + void setDocument(Document * newDocument, bool own = true); void setDocument(std::unique_ptr&&); // own = true /*! * @see MinidomHandler::preserveCharacterData */ - virtual void preserveCharacterData(bool preserve); - - /*! - * @see MinidomHandler::storeEncoding - */ - virtual void storeEncoding(bool preserve); + void preserveCharacterData(bool preserve); -protected: +private: MinidomHandler mHandler; XMLReader mReader; }; @@ -154,4 +145,4 @@ inline Document& getDocument(MinidomParser& xmlParser) } } -#endif +#endif // CODA_OSS_xml_lite_MinidomParser_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/QName.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/QName.h index d9304a746..f4b9fbc4f 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/QName.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/QName.h @@ -49,32 +49,6 @@ namespace xml namespace lite { - /*! - * \class StringEncoding - * \brief Specifies how std::string is encoded by MinidomParser. - * - * This is needed because our use of Xerces generates different - * results on Windows/Linux, and changing things might break existing - * code. - * - * On Windows, the UTF-16 strings (internal to Xerces) are converted - * to std::strings with Windows-1252 (more-or-less ISO8859-1) encoding; - * this allows Western European languages to be displayed. On *ix, - * UTF-8 is the norm ... - */ -#ifndef SWIG // SWIG doesn't like unique_ptr or StringEncoding -enum class StringEncoding -{ - Windows1252 // more-or-less ISO5589-1, https://en.wikipedia.org/wiki/Windows-1252 - , Utf8 -}; -constexpr auto PlatformEncoding = sys::Platform == sys::PlatformType::Windows - ? xml::lite::StringEncoding::Windows1252 - : xml::lite::StringEncoding::Utf8; -// Could do the same for std::wstring, but there isn't any code needing it right now. -// Probably better to use std::u16string and std::u32string anyway. -#endif - /*! * \class QName * \brief A Qualified name (includes the namespace stuff) @@ -94,7 +68,7 @@ constexpr auto PlatformEncoding = sys::Platform == sys::PlatformType::Windows struct Uri final // help prevent mixups with std::string { Uri() = default; - Uri(const std::string& v); + explicit Uri(const std::string& v); std::string value; bool empty() const { @@ -144,7 +118,7 @@ class QName final * Constructor taking just the local name (no namespace). * \param lName Just the local name of the object. */ - QName(const std::string& lName) + explicit QName(const std::string& lName) { setName(lName); } diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Serializable.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Serializable.h index c5324ffe4..a1e486447 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Serializable.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/Serializable.h @@ -20,8 +20,8 @@ * */ -#ifndef __XML_LITE_SERIALIZABLE_H__ -#define __XML_LITE_SERIALIZABLE_H__ +#ifndef CODA_OSS_xml_lite_Serializable_h_INCLUDED_ +#define CODA_OSS_xml_lite_Serializable_h_INCLUDED_ #include "io/OutputStream.h" #include "io/InputStream.h" @@ -52,7 +52,7 @@ struct Serializable : public io::Serializable { Serializable() = default; - Serializable(Document* document, bool own = true) + explicit Serializable(Document* document, bool own = true) { setDocument(document, own); } @@ -109,5 +109,4 @@ struct Serializable : public io::Serializable } } -#endif - +#endif // CODA_OSS_xml_lite_Serializable_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/UtilitiesXerces.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/UtilitiesXerces.h index a4e80e2dc..e9df3b4d6 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/UtilitiesXerces.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/UtilitiesXerces.h @@ -20,8 +20,8 @@ * */ -#ifndef __XML_LITE_UTILITIES_XERCES_H__ -#define __XML_LITE_UTILITIES_XERCES_H__ +#ifndef CODA_OSS_xml_lite_UtilitiesXerces_h_INCLUDED_ +#define CODA_OSS_xml_lite_UtilitiesXerces_h_INCLUDED_ #include @@ -400,7 +400,7 @@ struct XercesContentHandler : public XercesContentHandlerInterface_T * Our error handler implementation, then, simply calls the raise, * and warning macros in the factory. */ -struct XercesErrorHandler : public XercesErrorHandlerInterface_T +struct XercesErrorHandler final : public XercesErrorHandlerInterface_T { XercesErrorHandler() = default; XercesErrorHandler(const XercesErrorHandler&) = delete; @@ -413,24 +413,22 @@ struct XercesErrorHandler : public XercesErrorHandlerInterface_T * __warning__(message); * \param exception The exception */ - virtual void warning(const SAXParseException &exception); + void warning(const SAXParseException &exception) override; - virtual void error (const SAXParseException &exception); + void error(const SAXParseException& exception) override; - virtual void fatalError (const SAXParseException &exception); + void fatalError(const SAXParseException& exception) override; // Useless?? - virtual void resetErrors() {} + void resetErrors() override {} }; /*! * \class XercesContext * \brief This class safely creates and destroys Xerces */ -class XercesContext +struct XercesContext final { -public: - //! Constructor XercesContext(); @@ -440,7 +438,6 @@ class XercesContext void destroy(); private: - static std::mutex mMutex; bool mIsDestroyed; }; @@ -449,4 +446,4 @@ class XercesContext #endif -#endif +#endif // CODA_OSS_xml_lite_UtilitiesXerces_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ValidatorInterface.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ValidatorInterface.h index 8eccf673f..c8066b1b1 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ValidatorInterface.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ValidatorInterface.h @@ -54,9 +54,8 @@ namespace lite * \brief This is the information for one * schema validation error. */ -class ValidationInfo +struct ValidationInfo final { -public: ValidationInfo(const std::string& message, const std::string& level, const std::string& file, @@ -130,18 +129,22 @@ class ValidatorInterface * \param xmlID Identifier for this input xml within the error log * \param errors Object for returning errors found (errors are appended) */ - bool validate(io::InputStream& xml, - const std::string& xmlID, - std::vector& errors) const + template + bool vallidateT(io::InputStream& xml, + TStringStream&& oss, + const std::string& xmlID, + std::vector& errors) const { // convert to std::string - io::StringStream oss; xml.streamTo(oss); return validate(oss.stream().str(), xmlID, errors); } - bool validate(io::InputStream& xml, StringEncoding, + bool validate(io::InputStream& xml, const std::string& xmlID, - std::vector& errors) const; + std::vector& errors) const + { + return vallidateT(xml, io::StringStream(), xmlID, errors); + } /*! * Validation against the internal schema pool @@ -154,7 +157,7 @@ class ValidatorInterface std::vector& errors) const { // convert to stream - io::StringStream oss; + io::U8StringStream oss; xml->print(oss); return validate(oss.stream().str(), xmlID, errors); } @@ -168,14 +171,8 @@ class ValidatorInterface virtual bool validate(const std::string& xml, const std::string& xmlID, std::vector& errors) const = 0; - virtual bool validate(const coda_oss::u8string&, const std::string& /*xmlID*/, std::vector&) const // =0 would cause existing code to break - { - return true; // i.e., an error - } - virtual bool validate(const str::W1252string&, const std::string& /*xmlID*/, std::vector&) const // =0 would cause existing code to break - { - return true; // i.e., an error - } + virtual bool validate(const coda_oss::u8string&, const std::string& /*xmlID*/, std::vector&) const = 0; + virtual bool validate(const str::W1252string&, const std::string& /*xmlID*/, std::vector&) const = 0; }; inline std::ostream& operator<< (std::ostream& out, diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ValidatorXerces.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ValidatorXerces.h index 37c0ac9b8..dc2cb3939 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ValidatorXerces.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/ValidatorXerces.h @@ -20,8 +20,8 @@ * */ -#ifndef __XML_LITE_VALIDATOR_XERCES_H__ -#define __XML_LITE_VALIDATOR_XERCES_H__ +#ifndef CODA_OSS_xml_lite_ValidatorXerces_h_INCLUDED_ +#define CODA_OSS_xml_lite_ValidatorXerces_h_INCLUDED_ #include @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -51,7 +52,7 @@ namespace lite typedef xercesc::DOMError ValidationError; -struct ValidationErrorHandler : public xercesc::DOMErrorHandler +struct ValidationErrorHandler final : public xercesc::DOMErrorHandler { ValidationErrorHandler() = default; @@ -61,7 +62,7 @@ struct ValidationErrorHandler : public xercesc::DOMErrorHandler ValidationErrorHandler& operator=(ValidationErrorHandler&&) = delete; //! handle the errors during validation - virtual bool handleError (const ValidationError& err); + bool handleError (const ValidationError& err) override; //! get the raw information const std::vector& getErrorLog() const @@ -99,7 +100,6 @@ struct ValidationErrorHandler : public xercesc::DOMErrorHandler class ValidatorXerces : public ValidatorInterface { XercesContext mCtxt; //! this must be the first member listed - bool mLegacyStringConversion = true; // use exsiting code for XMLCh* conversion public: @@ -138,8 +138,7 @@ class ValidatorXerces : public ValidatorInterface bool validate(const str::W1252string&, const std::string& xmlID, std::vector&) const override; private: - template - bool validate_(const std::basic_string& xml, bool legacyStringConversion, + bool validate_(const coda_oss::u8string& xml, const std::string& xmlID, std::vector& errors) const; @@ -157,4 +156,4 @@ std::ostream& operator<< (std::ostream& out, #endif -#endif +#endif // CODA_OSS_xml_lite_ValidatorXerces_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLException.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLException.h index 685148428..0fdf3af2f 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLException.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLException.h @@ -20,8 +20,8 @@ * */ -#ifndef __XML_LITE_XML_EXCEPTION_H__ -#define __XML_LITE_XML_EXCEPTION_H__ +#ifndef CODA_OSS_xml_lite_XMLException_h_INCLUDED_ +#define CODA_OSS_xml_lite_XMLException_h_INCLUDED_ #include "except/Exception.h" @@ -74,16 +74,15 @@ DECLARE_EXTENDED_EXCEPTION(XMLNotSupported, xml::lite::XMLException) * XML exception while processing documents * */ -class XMLParseException : public XMLException +struct XMLParseException final : public XMLException { -public: /*! * Construct a parse exception * \param message A message as presented by the parser * \param row As reported by the parser * \param column As reported by the parser */ - XMLParseException(const char *message, int row = 0, int column = 0) : + explicit XMLParseException(const char *message, int row = 0, int column = 0) : XMLException(message) { form(row, column); @@ -96,7 +95,7 @@ class XMLParseException : public XMLException * \param column As reported by the parser * \param errNum An error number given by the parser */ - XMLParseException(const std::string & message, int row = 0, int column = 0, + explicit XMLParseException(const std::string & message, int row = 0, int column = 0, int errNum = 0) : XMLException(message) { @@ -133,9 +132,7 @@ class XMLParseException : public XMLException } //! Destructor - virtual ~ XMLParseException() - { - } + virtual ~XMLParseException() = default; private: @@ -160,4 +157,4 @@ class XMLParseException : public XMLException }; } } -#endif +#endif // CODA_OSS_xml_lite_XMLException_h_INCLUDED_ diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLReaderInterface.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLReaderInterface.h index e94dbfc4f..c0540b8cb 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLReaderInterface.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLReaderInterface.h @@ -25,7 +25,6 @@ #include #include "XMLException.h" -#include "Element.h" // StringEncoding namespace xml { diff --git a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLReaderXerces.h b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLReaderXerces.h index 5fc3dc751..beca1fa5c 100644 --- a/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLReaderXerces.h +++ b/externals/coda-oss/modules/c++/xml.lite/include/xml/lite/XMLReaderXerces.h @@ -56,7 +56,7 @@ namespace lite * the Expat C Parser underneath, and wiring it to * generic event calls, via the content handler. */ -class XMLReaderXerces : public XMLReaderInterface +class XMLReaderXerces final : public XMLReaderInterface { XercesContext mCtxt; //! this must be the first member listed std::unique_ptr mNative; @@ -69,10 +69,7 @@ class XMLReaderXerces : public XMLReaderInterface XMLReaderXerces(); //! Destructor. - ~XMLReaderXerces() - { - } - + ~XMLReaderXerces() = default; XMLReaderXerces(const XMLReaderXerces&) = delete; XMLReaderXerces& operator=(const XMLReaderXerces&) = delete; @@ -103,9 +100,8 @@ class XMLReaderXerces : public XMLReaderInterface void parse(io::InputStream& is, int size = io::InputStream::IS_END); void parse(bool storeEncoding, io::InputStream& is, int size = io::InputStream::IS_END); - #ifndef SWIG // SWIG doesn't like unique_ptr or StringEncoding - void parse(bool storeEncoding, io::InputStream& is, StringEncoding, int size = io::InputStream::IS_END); - #endif // SWIG + void parse(io::InputStream& is, const void*pInitialEncoding, const void* pFallbackEncoding, + int size = io::InputStream::IS_END); //! Method to create an xml reader void create(); @@ -115,10 +111,9 @@ class XMLReaderXerces : public XMLReaderInterface std::string getDriverName() const { return "xerces"; } -private: - void parse(bool storeEncoding, io::InputStream& is, const StringEncoding*, int size); - void parse(bool storeEncoding, const std::vector&, const StringEncoding* pEncoding); + static const void* getWindows1252Encoding(); +private: void write(const void*, size_t) override { throw xml::lite::XMLException(Ctxt("I'm not sure how you got here!")); diff --git a/externals/coda-oss/modules/c++/xml.lite/source/Document.cpp b/externals/coda-oss/modules/c++/xml.lite/source/Document.cpp index f4ce03915..20fec58da 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/Document.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/Document.cpp @@ -22,6 +22,8 @@ #include "xml/lite/Document.h" +#include + void xml::lite::Document::setRootElement(Element * element, bool own) { destroy(); @@ -47,60 +49,41 @@ void xml::lite::Document::remove(Element * toDelete) remove(toDelete, mRootNode); } -static -xml::lite::Element * -newElement(const std::string& qname, const std::string& uri) +static std::unique_ptr newElement(const std::string& qname, const std::string& uri) { - auto elem = new xml::lite::Element(); + std::unique_ptr elem(new xml::lite::Element()); elem->setQName(qname); //std::cout << "qname: " << qname << std::endl; elem->setUri(uri); return elem; } -static xml::lite::Element* newElement(const xml::lite::QName& qname) +static std::unique_ptrnewElement(const xml::lite::QName& qname) { return newElement(qname.getName(), qname.getAssociatedUri()); } -xml::lite::Element* xml::lite::Document::createElement(const std::string& qname, - const std::string& uri, + +xml::lite::Element* xml::lite::Document::createElement(const std::string& qname, const std::string& uri, std::string characterData) { auto elem = newElement(qname, uri); elem->setCharacterData(characterData); - return elem; -} -xml::lite::Element* xml::lite::Document::createElement(const std::string& qname, - const std::string& uri, - const std::string& characterData, StringEncoding encoding) const -{ - auto elem = newElement(qname, uri); - elem->setCharacterData(characterData, encoding); - return elem; + return elem.release(); } -xml::lite::Element* xml::lite::Document::createElement(const std::string& qname, - const std::string& uri, +std::unique_ptr xml::lite::Document::createElement(const QName& qname, const coda_oss::u8string& characterData) const { - auto elem = newElement(qname, uri); + auto elem = newElement(qname); elem->setCharacterData(characterData); return elem; } - -std::unique_ptr xml::lite::Document::createElement(const xml::lite::QName& qname, +std::unique_ptr xml::lite::Document::createElement(const QName& qname, const std::string& characterData) const { - std::unique_ptr elem(newElement(qname)); + auto elem = newElement(qname); elem->setCharacterData(characterData); return elem; } -std::unique_ptr xml::lite::Document::createElement(const xml::lite::QName& qname, - const std::string& characterData, StringEncoding encoding) const -{ - std::unique_ptr elem(newElement(qname)); - elem->setCharacterData(characterData, encoding); - return elem; -} void xml::lite::Document::insert(xml::lite::Element * element, xml::lite::Element * underThis) diff --git a/externals/coda-oss/modules/c++/xml.lite/source/Element.cpp b/externals/coda-oss/modules/c++/xml.lite/source/Element.cpp index 5904d86c4..911befe40 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/Element.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/Element.cpp @@ -20,8 +20,11 @@ * */ +#include + #include #include +#include #include "xml/lite/Element.h" #include @@ -30,29 +33,17 @@ #include #include -constexpr auto PlatformEncoding = sys::Platform == sys::PlatformType::Windows - ? xml::lite::StringEncoding::Windows1252 - : xml::lite::StringEncoding::Utf8; - std::unique_ptr xml::lite::Element::create(const std::string& qname, const std::string& uri, const std::string& characterData) { - return coda_oss::make_unique(qname, uri, characterData, PlatformEncoding); -} -std::unique_ptr xml::lite::Element::create(const std::string& qname, const Uri& uri, const std::string& characterData) -{ - return create(qname, uri.value, characterData); + return coda_oss::make_unique(qname, uri, characterData); } std::unique_ptr xml::lite::Element::create(const QName& qname, const std::string& characterData) { - return create(qname.getName(), qname.getUri(), characterData); + return create(qname.getName(), qname.getUri().value, characterData); } std::unique_ptr xml::lite::Element::create(const QName& qname, const coda_oss::u8string& characterData) { - return coda_oss::make_unique(qname.getName(), qname.getUri().value, characterData); -} -std::unique_ptr xml::lite::Element::createU8(const QName& qname, const std::string& characterData) -{ - return create(qname, str::EncodedStringView(characterData).u8string()); + return coda_oss::make_unique(qname, characterData); } xml::lite::Element::Element(const xml::lite::Element& node) @@ -65,11 +56,9 @@ xml::lite::Element& xml::lite::Element::operator=(const xml::lite::Element& node { mName = node.mName; mCharacterData = node.mCharacterData; - mEncoding = node.mEncoding; mAttributes = node.mAttributes; mChildren = node.mChildren; mParent = node.mParent; - mEncoding = node.mEncoding; } return *this; } @@ -245,10 +234,6 @@ void xml::lite::Element::print(io::OutputStream& stream) const { depthPrint(stream, 0, ""); } -void xml::lite::Element::print(io::OutputStream& stream, StringEncoding encoding) const -{ - depthPrint(stream, encoding, 0, ""); -} void xml::lite::Element::prettyPrint(io::OutputStream& stream, const std::string& formatter) const @@ -256,96 +241,50 @@ void xml::lite::Element::prettyPrint(io::OutputStream& stream, depthPrint(stream, 0, formatter); stream.writeln(""); } -void xml::lite::Element::prettyPrint(io::OutputStream& stream, StringEncoding encoding, + +void xml::lite::Element::consoleOutput_(io::OutputStream& stream) const +{ + depthPrint(stream, 0, "", true /*isConsoleOutput*/); +} +void xml::lite::Element::prettyConsoleOutput_(io::OutputStream& stream, const std::string& formatter) const { - depthPrint(stream, encoding, 0, formatter); + depthPrint(stream, 0, formatter, true /*isConsoleOutput*/); stream.writeln(""); } -static xml::lite::StringEncoding getEncoding_(const coda_oss::optional& encoding) -{ - if (encoding.has_value()) - { - if (encoding == xml::lite::StringEncoding::Utf8) { } - else if (encoding == xml::lite::StringEncoding::Windows1252) { } - else - { - throw std::logic_error("Unknown encoding."); - } - return *encoding; - } - // don't know the encoding ... assume a default based on the platform - return PlatformEncoding; +std::string xml::lite::Element::getCharacterData() const +{ + return str::EncodedStringView(mCharacterData).native(); } - -void xml::lite::Element::getCharacterData(coda_oss::u8string& result) const +coda_oss::u8string& xml::lite::Element::getCharacterData(coda_oss::u8string& result) const { - const auto encoding = ::getEncoding_(this->getEncoding()); - - str::EncodedStringView view; - if (encoding == xml::lite::StringEncoding::Utf8) - { - view = str::EncodedStringView(str::c_str(mCharacterData)); - } - else if (encoding == xml::lite::StringEncoding::Windows1252) - { - view = str::EncodedStringView(str::c_str(mCharacterData)); - } - else - { - throw std::logic_error("getCharacterData(): unknown encoding"); - } - - result = view.u8string(); // copy or conversion + result = mCharacterData; + return result; } -static void writeCharacterData(io::OutputStream& stream, - const std::string& characterData, const coda_oss::optional& encoding_) +static void writeCharacterData(io::OutputStream& stream, const std::u8string& characterData, bool isConsoleOutput) { - const auto encoding = getEncoding_(encoding_); - if (encoding == xml::lite::StringEncoding::Windows1252) - { - // need to convert before writing - const str::EncodedStringView view(str::c_str(characterData)); - stream.write(view.u8string()); - } - else if (encoding == xml::lite::StringEncoding::Utf8) + if (!isConsoleOutput) { - // already in UTF-8, no converstion necessary - auto pUtf8 = str::c_str(characterData); - stream.write(pUtf8, characterData.length()); // call UTF-8 overload + stream.write(characterData); // call UTF-8 overload } else { - throw std::logic_error("writeCharacterData(): unknown encoding"); + stream.write(str::EncodedStringView(characterData).native()); // write to the console using the platform native encoding } } -void xml::lite::Element::depthPrint(io::OutputStream& stream, - int depth, - const std::string& formatter) const -{ - // XML must be stored in UTF-8 (or UTF-16/32), in particular, not - // Windows-1252. However, existing code did this, so preserve current behavior. - depthPrint(stream, false /*utf8*/, depth, formatter); -} -void xml::lite::Element::depthPrint(io::OutputStream& stream, StringEncoding encoding, - int depth, - const std::string& formatter) const -{ - if (encoding != StringEncoding::Utf8) - { - throw std::invalid_argument("'encoding' must be UTF-8"); - } - // THIS IS CORRECT, but may break existing code; so it must be explicitly requested. - depthPrint(stream, true /*utf8*/, depth, formatter); -} -void xml::lite::Element::depthPrint(io::OutputStream& stream, bool utf8, - int depth, - const std::string& formatter) const +void xml::lite::Element::depthPrint(io::OutputStream& stream, int depth, const std::string& formatter, bool isConsoleOutput) const { + // XML must be stored in UTF-8 (or UTF-16/32), in particular, not Windows-1252. + // + // Except for a special exception for writing to the console: UTF-8 won't display well on Windows + // and Windows-1252 won't display nicely on Linux. Of course, "console output" is a bit + // iffy since both Windows and Linux support redirection ... so the user could still generate + // a bad XML file. + std::string prefix = ""; for (int i = 0; i < depth; ++i) prefix += formatter; @@ -365,31 +304,21 @@ void xml::lite::Element::depthPrint(io::OutputStream& stream, bool utf8, acc += std::string("\""); } - if (mCharacterData.empty()&& mChildren.empty()) + if (mCharacterData.empty() && mChildren.empty()) { //simple type - just end it here stream.write(acc + "/" + rBrack); } else { - stream.write(acc + rBrack); - if (utf8) - { - // Correct behavior, but may break existing code. - writeCharacterData(stream, mCharacterData, getEncoding()); - } - else - { - // Legacy behavior, will generate incorrect XML output if there are western European - // characters in "mCharacterData". - stream.write(mCharacterData); - } + stream.write(acc + rBrack); + writeCharacterData(stream, mCharacterData, isConsoleOutput); for (unsigned int i = 0; i < mChildren.size(); i++) { if (!formatter.empty()) stream.write("\n"); - mChildren[i]->depthPrint(stream, utf8, depth + 1, formatter); + mChildren[i]->depthPrint(stream, depth + 1, formatter, isConsoleOutput); } if (!mChildren.empty() && !formatter.empty()) @@ -523,29 +452,9 @@ void xml::lite::Element::setNamespaceURI( attr[std::string("xmlns:") + prefix] = uri; } -void xml::lite::Element::setCharacterData_(const std::string& characters, const StringEncoding* pEncoding) -{ - mCharacterData = characters; - if (pEncoding != nullptr) - { - mEncoding = *pEncoding; - } - else - { - mEncoding.reset(); - } -} void xml::lite::Element::setCharacterData(const std::string& characters) { - setCharacterData_(characters, nullptr /*pEncoding*/); -} -void xml::lite::Element::setCharacterData(const std::string& characters, StringEncoding encoding) -{ - setCharacterData_(characters, &encoding); -} -void xml::lite::Element::setCharacterData(const coda_oss::u8string& characters) -{ - setCharacterData(str::c_str(characters), StringEncoding::Utf8); + mCharacterData = str::EncodedStringView(characters).u8string(); } xml::lite::Element& xml::lite::add(const QName& qname, diff --git a/externals/coda-oss/modules/c++/xml.lite/source/MinidomHandler.cpp b/externals/coda-oss/modules/c++/xml.lite/source/MinidomHandler.cpp index 347de87ce..fe33084b7 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/MinidomHandler.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/MinidomHandler.cpp @@ -21,11 +21,14 @@ */ #include +#include +#include #include "str/Manip.h" #include "str/Convert.h" #include "str/Encoding.h" #include "sys/OS.h" +#include "str/EncodedStringView.h" #include "xml/lite/MinidomHandler.h" @@ -43,69 +46,36 @@ void xml::lite::MinidomHandler::setDocument(std::unique_ptr&& newDocum { setDocument(newDocument.release(), true /*own*/); } -void xml::lite::MinidomHandler::getDocument(std::unique_ptr& pDocument) +std::unique_ptr& xml::lite::MinidomHandler::getDocument(std::unique_ptr& pDocument) { pDocument.reset(getDocument(true /*steal*/)); + return pDocument; } void xml::lite::MinidomHandler::clear() { mDocument->destroy(); - currentCharacterData = ""; + currentCharacterData.clear(); assert(bytesForElement.empty()); assert(nodeStack.empty()); } -void xml::lite::MinidomHandler::characters(const char* value, int length, const StringEncoding* pEncoding) +void xml::lite::MinidomHandler::characters(std::u8string&& s) { - if (pEncoding != nullptr) - { - if (mpEncoding != nullptr) - { - // be sure the given encoding matches any encoding already set - if (*pEncoding != *mpEncoding) - { - throw std::invalid_argument("New 'encoding' is different than value already set."); - } - } - else if (storeEncoding()) - { - mpEncoding = std::make_shared(*pEncoding); - } - } - - // Append new data - if (length) - currentCharacterData += std::string(value, length); - // Append number of bytes added to this node's stack value assert(bytesForElement.size()); - bytesForElement.top() += length; -} -void xml::lite::MinidomHandler::characters(const char *value, int length) -{ - const StringEncoding* pEncoding = nullptr; - if ((sys::Platform == sys::PlatformType::Windows) && call_vcharacters()) - { - // If we're still here despite use_char() being "false" then the wide-character - // routine "failed." On Windows, that means the char* value is encoded - // as Windows-1252 (more-or-less ISO8859-1). - static const auto encoding = StringEncoding::Windows1252; - pEncoding = &encoding; - } - characters(value, length, pEncoding); -} + bytesForElement.top() += static_cast(s.length()); -void xml::lite::MinidomHandler::call_characters(const std::string& s, StringEncoding encoding) -{ - const auto length = static_cast(s.length()); - characters(s.c_str(), length, &encoding); + // Append new data + currentCharacterData += std::move(s); } - -bool xml::lite::MinidomHandler::call_vcharacters() const +void xml::lite::MinidomHandler::characters(const char *value, int length) { - // if we're storing the encoding, get wchar_t so that we can convert - return storeEncoding(); + // If we're still here despite use_char() being "false" then the + // wide-character routine "failed." On Windows, that means the char* value + // is encoded as Windows-1252 (more-or-less ISO8859-1). + const str::EncodedString chars(std::string(value, length)); + characters(chars.u8string()); } bool xml::lite::MinidomHandler::vcharacters(const void /*XMLCh*/* chars_, size_t length) @@ -122,29 +92,8 @@ bool xml::lite::MinidomHandler::vcharacters(const void /*XMLCh*/* chars_, size_t static_assert(sizeof(XMLCh) == sizeof(char16_t), "XMLCh should be 16-bits."); auto pChars16 = static_cast(chars_); - std::string chars; - auto platformEncoding = xml::lite::PlatformEncoding; // "conditional expression is constant" - if (platformEncoding == xml::lite::StringEncoding::Utf8) - { - str::details::utf16to8(pChars16, length, chars); - } - else if (platformEncoding == xml::lite::StringEncoding::Windows1252) - { - // On Windows, we want std::string encoded as Windows-1252 so that - // western European characters will be displayed. We can't convert - // to UTF-8 (as above on Linux), because Windows doesn't have good - // support for displaying such strings. Using UTF-16 would be preferred - // on Windows, but all existing code uses std::string instead of std::wstring. - assert(pChars16 != nullptr); // XMLCh == wchar_t == char16_t on Windows - auto pChars = static_cast(chars_); - chars = xml::lite::XercesLocalString(pChars).str(); - } - else - { - throw std::logic_error("Unknown xml::lite::StringEncoding"); - } - - call_characters(chars, platformEncoding); + auto chars = str::EncodedString(std::u16string(pChars16, length)).u8string(); + characters(std::move(chars)); return true; // vcharacters() processed } @@ -164,14 +113,14 @@ void xml::lite::MinidomHandler::startElement(const std::string & uri, } // This function subtracts off the char place from the push -std::string xml::lite::MinidomHandler::adjustCharacterData() +std::u8string xml::lite::MinidomHandler::adjustCharacterData() { // Edit the string with regard to this node's char data // Get rid of what we take on char data accumulator int diff = (int) (currentCharacterData.length()) - bytesForElement.top(); - std::string newCharacterData(currentCharacterData.substr( + auto newCharacterData(currentCharacterData.substr( diff, currentCharacterData.length()) ); @@ -183,7 +132,7 @@ std::string xml::lite::MinidomHandler::adjustCharacterData() return newCharacterData; } -void xml::lite::MinidomHandler::trim(std::string & s) +void xml::lite::MinidomHandler::trim(std::u8string& s) { str::trim(s); } @@ -196,7 +145,7 @@ void xml::lite::MinidomHandler::endElement(const std::string & /*uri*/, xml::lite::Element * current = nodeStack.top(); nodeStack.pop(); - current->setCharacterData_(adjustCharacterData(), mpEncoding.get()); + current->setCharacterData(adjustCharacterData()); // Remove corresponding int on bytes stack bytesForElement.pop(); @@ -221,12 +170,3 @@ void xml::lite::MinidomHandler::preserveCharacterData(bool preserve) mPreserveCharData = preserve; } -void xml::lite::MinidomHandler::storeEncoding(bool value) -{ - mStoreEncoding = value; -} - -bool xml::lite::MinidomHandler::storeEncoding() const -{ - return mStoreEncoding; -} diff --git a/externals/coda-oss/modules/c++/xml.lite/source/MinidomParser.cpp b/externals/coda-oss/modules/c++/xml.lite/source/MinidomParser.cpp index 8082915f6..73a64f3a4 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/MinidomParser.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/MinidomParser.cpp @@ -22,20 +22,24 @@ #include "xml/lite/MinidomParser.h" +#include + xml::lite::MinidomParser::MinidomParser(bool storeEncoding) { + if (!storeEncoding) + { + throw std::invalid_argument("'storeEncoding' is no longer used and must always be 'true'"); + } mReader.setContentHandler(&mHandler); - mHandler.storeEncoding(storeEncoding); } -void xml::lite::MinidomParser::parse(io::InputStream& is, - int size) +void xml::lite::MinidomParser::parse(io::InputStream& is, int size) { - mReader.parse(mHandler.storeEncoding(), is, size); + mReader.parse(is, size); } -void xml::lite::MinidomParser::parse(io::InputStream& is, StringEncoding encoding, int size) +void xml::lite::MinidomParser::parse(io::InputStream& is, const void*pInitialEncoding, const void* pFallbackEncoding, int size) { - mReader.parse(mHandler.storeEncoding(), is, encoding, size); + mReader.parse(is, pInitialEncoding, pFallbackEncoding, size); } void xml::lite::MinidomParser::clear() @@ -52,9 +56,9 @@ xml::lite::Document* xml::lite::MinidomParser::getDocument(bool steal) { return mHandler.getDocument(steal); } -void xml::lite::MinidomParser::getDocument(std::unique_ptr& pDocument) +std::unique_ptr& xml::lite::MinidomParser::getDocument(std::unique_ptr& pDocument) { - mHandler.getDocument(pDocument); + return mHandler.getDocument(pDocument); } void xml::lite::MinidomParser::setDocument(xml::lite::Document* newDocument, bool own) @@ -70,8 +74,3 @@ void xml::lite::MinidomParser::preserveCharacterData(bool preserve) { mHandler.preserveCharacterData(preserve); } - -void xml::lite::MinidomParser::storeEncoding(bool preserve) -{ - mHandler.storeEncoding(preserve); -} \ No newline at end of file diff --git a/externals/coda-oss/modules/c++/xml.lite/source/NamespaceStack.cpp b/externals/coda-oss/modules/c++/xml.lite/source/NamespaceStack.cpp index 7e4f6ef38..4ab047112 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/NamespaceStack.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/NamespaceStack.cpp @@ -54,7 +54,7 @@ void xml::lite::NamespaceStack::getMapping(const std::string& prefix, Uri& resul { if (mMappingStack[i].first == prefix) { - result = mMappingStack[i].second; + result = Uri(mMappingStack[i].second); return; } } diff --git a/externals/coda-oss/modules/c++/xml.lite/source/UtilitiesXerces.cpp b/externals/coda-oss/modules/c++/xml.lite/source/UtilitiesXerces.cpp index 4e2cf942b..ffb0f7fd7 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/UtilitiesXerces.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/UtilitiesXerces.cpp @@ -90,12 +90,9 @@ XercesLocalString& XercesLocalString::operator=(const XercesLocalString& rhs) void XercesContentHandler::characters(const XMLCh* const chars, const XercesSize_T length) { - if (mLiteHandler->call_vcharacters()) + if (mLiteHandler->vcharacters(chars, length)) { - if (mLiteHandler->vcharacters(chars, length)) - { - return; // processed as void* - } + return; // processed as void* } // Either use_wchar_t() is false (default, legacy behavior) or diff --git a/externals/coda-oss/modules/c++/xml.lite/source/ValidatorInterface.cpp b/externals/coda-oss/modules/c++/xml.lite/source/ValidatorInterface.cpp index d8c48895a..d639655cc 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/ValidatorInterface.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/ValidatorInterface.cpp @@ -27,38 +27,5 @@ #include #include -#include -#include -#include -#include - -namespace fs = std::filesystem; - #include -template -bool vallidate_(const xml::lite::ValidatorInterface& validator, - io::InputStream& xml, TStringStream&& oss, - const std::string& xmlID, std::vector& errors) -{ - xml.streamTo(oss); - return validator.validate(oss.stream().str(), xmlID, errors); -} -bool xml::lite::ValidatorInterface::validate( - io::InputStream& xml, StringEncoding encoding, - const std::string& xmlID, - std::vector& errors) const -{ - // convert to the correcrt std::basic_string based on "encoding" - if (encoding == StringEncoding::Utf8) - { - return vallidate_(*this, xml, io::U8StringStream(), xmlID, errors); - } - if (encoding == StringEncoding::Windows1252) - { - return vallidate_(*this, xml, io::W1252StringStream(), xmlID, errors); - } - - // this really shouldn't happen - return validate(xml, xmlID, errors); -} diff --git a/externals/coda-oss/modules/c++/xml.lite/source/ValidatorXerces.cpp b/externals/coda-oss/modules/c++/xml.lite/source/ValidatorXerces.cpp index 9fd7d8ab5..41968be28 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/ValidatorXerces.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/ValidatorXerces.cpp @@ -24,11 +24,14 @@ #include #include #include +#include +#include #include #include #include #include +#include namespace fs = std::filesystem; @@ -92,11 +95,6 @@ ValidatorXerces::ValidatorXerces( bool recursive) : ValidatorXerces(convert(schemaPaths), log, recursive) { - // The string conversion code in validate() doesn't work right on all platforms - // for non-ASCII characters. But changing that to be correct could break - // existing code someplace; thus, it's enabled only if using the new - // fs::path overload, std::string retains existing behavior. - mLegacyStringConversion = false; } ValidatorXerces::ValidatorXerces( const std::vector& schemaPaths, @@ -209,40 +207,16 @@ inline void reset(str::EncodedStringView xmlView, std::unique_ptr; - -template -static void setStringData_(xercesc::DOMLSInputImpl& input, const std::basic_string& xml, std::unique_ptr& pWString) -{ - reset(str::EncodedStringView(xml), pWString); - input.setStringData(pWString->c_str()); -} -static void setStringData(xercesc::DOMLSInputImpl& input, const std::string& xml, bool legacyStringConversion, - std::unique_ptr& pXmlWide, std::unique_ptr& pWString) -{ - if (legacyStringConversion) - { - // This doesn't work right for UTF-8 or Windows-1252 - pXmlWide.reset(new XercesLocalString(xml)); // std::make_unique fails with older compilers - input.setStringData(pXmlWide->toXMLCh()); - } - else - { - setStringData_(input, xml, pWString); - } -} -inline void setStringData(xercesc::DOMLSInputImpl& input, const coda_oss::u8string& xml, bool /*legacyStringConversion*/, - std::unique_ptr&, std::unique_ptr& pWString) -{ - setStringData_(input, xml, pWString); -} -inline void setStringData(xercesc::DOMLSInputImpl& input, const str::W1252string& xml, bool /*legacyStringConversion*/, - std::unique_ptr&, std::unique_ptr& pWString) +static std::unique_ptr setStringData(xercesc::DOMLSInputImpl& input, const std::u8string& xml) { - setStringData_(input, xml, pWString); + // expand to the wide character data for use with xerces + std::unique_ptr retval; + reset(str::EncodedStringView(xml), retval); + input.setStringData(retval->c_str()); + return retval; } -template -bool ValidatorXerces::validate_(const std::basic_string& xml, bool legacyStringConversion, +bool ValidatorXerces::validate_(const std::u8string& xml, const std::string& xmlID, std::vector& errors) const { @@ -260,9 +234,7 @@ bool ValidatorXerces::validate_(const std::basic_string& xml, bool legacy xercesc::XMLPlatformUtils::fgMemoryManager); // expand to the wide character data for use with xerces - std::unique_ptr pXmlWide; - std::unique_ptr pWString; - setStringData(input, xml, legacyStringConversion, pXmlWide, pWString); + auto pWString = setStringData(input, xml); // validate the document mValidator->parse(&input)->release(); @@ -277,23 +249,58 @@ bool ValidatorXerces::validate_(const std::basic_string& xml, bool legacy return (!mErrorHandler->getErrorLog().empty()); } + +static str::EncodedStringView encodeXml(const std::string& xml) +{ + // The XML might contain contain a specific encoding, if it does; + // we want to use it, otherwise we'll corrupt the data. + + // UTF-8 is the normal case, so check it first + const std::regex reUtf8("<\?.*encoding=.*['\"]?.*utf-8.*['\"]?.*\?>", std::regex::icase); + std::cmatch m; + if (std::regex_search(xml.c_str(), m, reUtf8)) + { + return str::EncodedStringView::fromUtf8(xml); + } + + // Maybe this is is poor XML with Windows-1252 encoding :-( + const std::regex reWindows1252("<\?.*encoding=.*['\"]?.*windows-1252.*['\"]?.*\?>", std::regex::icase); + if (std::regex_search(xml.c_str(), m, reWindows1252)) + { + return str::EncodedStringView::fromWindows1252(xml); + } + + // No "... encoding= ..."; let EncodedStringView deal with it + return str::EncodedStringView(xml); +} + bool ValidatorXerces::validate(const std::string& xml, const std::string& xmlID, std::vector& errors) const { - return validate_(xml, mLegacyStringConversion, xmlID, errors); + const auto view = encodeXml(xml); + try + { + return validate(view.u8string(), xmlID, errors); + } + catch (const utf8::invalid_utf8&) { } + + // Can't process as "native" (UTF-8 on Linux, Windows-1252 on Windows). + // Must be Windows-1252 on Linux. + return validate(str::c_str(xml), xmlID, errors); } bool ValidatorXerces::validate(const coda_oss::u8string& xml, const std::string& xmlID, std::vector& errors) const { - return validate_(xml, false /*legacyStringConversion*/, xmlID, errors); + return validate_(xml, xmlID, errors); } bool ValidatorXerces::validate(const str::W1252string& xml, const std::string& xmlID, std::vector& errors) const { - return validate_(xml, false /*legacyStringConversion*/, xmlID, errors); + const str::EncodedStringView xmlView(xml); + return validate(xmlView.u8string(), xmlID, errors); } } diff --git a/externals/coda-oss/modules/c++/xml.lite/source/XMLReaderXerces.cpp b/externals/coda-oss/modules/c++/xml.lite/source/XMLReaderXerces.cpp index 13ec93c03..3ecf8d79f 100644 --- a/externals/coda-oss/modules/c++/xml.lite/source/XMLReaderXerces.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/source/XMLReaderXerces.cpp @@ -34,39 +34,31 @@ xml::lite::XMLReaderXerces::XMLReaderXerces() create(); } -void xml::lite::XMLReaderXerces::parse(bool storeEncoding, - io::InputStream& is, const StringEncoding* pEncoding, int size) +const void* xml::lite::XMLReaderXerces::getWindows1252Encoding() { - io::StringStream oss; - is.streamTo(oss, size); - - const auto available = oss.available(); - if ( available <= 0 ) - { - throw xml::lite::XMLParseException(Ctxt("No stream available")); - } - std::vector buffer(available); - oss.read(buffer.data(), buffer.size()); - parse(storeEncoding, buffer, pEncoding); + return XMLUni::fgWin1252EncodingString; } -void xml::lite::XMLReaderXerces::parse(bool storeEncoding, - const std::vector& buffer, const StringEncoding* pEncoding) + +static void parse(SAX2XMLReader& parser, const std::vector& buffer, const XMLCh* pEncoding) { // Does not take ownership - MemBufInputSource memBuffer((const unsigned char *)buffer.data(), + MemBufInputSource memBuffer((const unsigned char*)buffer.data(), buffer.size(), - XMLReaderXerces::MEM_BUFFER_ID(), + xml::lite::XMLReaderXerces::MEM_BUFFER_ID(), false); - if ((pEncoding != nullptr) && (*pEncoding == StringEncoding::Windows1252)) + if (pEncoding != nullptr) { - // The only other value is StringEncoding::Utf8 which is the default - memBuffer.setEncoding(XMLUni::fgWin1252EncodingString); + memBuffer.setEncoding(pEncoding); } - + parser.parse(memBuffer); +} +static void parse(SAX2XMLReader& parser, const std::vector& buffer, + const XMLCh* pInitialEncoding, const XMLCh* pFallbackEncoding) +{ try { - mNative->parse(memBuffer); + parse(parser, buffer, pInitialEncoding); return; // successful parse } catch (const except::Error& e) @@ -76,41 +68,41 @@ void xml::lite::XMLReaderXerces::parse(bool storeEncoding, { throw; } - // Caller specified an encoding; don't try calling parse() again - if (pEncoding != nullptr) - { - throw; - } - // legacy code, didn't pass storeEncoding=true to MinidomParser - if (!storeEncoding) + + // Trying again will fail, so don't bother + if (pFallbackEncoding == pInitialEncoding) { throw; } } - // If we're here, the initial parse failed and the caller did NOT specify an encoding - // (pEncoding == NULL). Since the default is UTF-8 and that failed, try again - // with Windows-1252. - assert(pEncoding == nullptr); - assert(storeEncoding); - const auto windows1252 = StringEncoding::Windows1252; - parse(true /*storeEncoding*/, buffer, &windows1252); + // Try again using the fallback encoding + parse(parser, buffer, pFallbackEncoding); } -void xml::lite::XMLReaderXerces::parse(io::InputStream& is, int size) -{ - parse(false /*storeEncoding*/, is, size); -} -void xml::lite::XMLReaderXerces::parse(bool storeEncoding, io::InputStream& is, int size) + +void xml::lite::XMLReaderXerces::parse(io::InputStream& is, const void*pInitialEncoding_, const void* pFallbackEncoding_, int size) { - parse(storeEncoding, is, nullptr /*pEncoding*/, size); + io::StringStream oss; + is.streamTo(oss, size); + + const auto available = oss.available(); + if ( available <= 0 ) + { + throw xml::lite::XMLParseException(Ctxt("No stream available")); + } + std::vector buffer(available); + oss.read(buffer.data(), buffer.size()); + + const auto pInitialEncoding = static_cast(pInitialEncoding_); + const auto pFallbackEncoding = static_cast(pFallbackEncoding_); + ::parse(*mNative, buffer, pInitialEncoding, pFallbackEncoding); } -void xml::lite::XMLReaderXerces::parse(bool storeEncoding, - io::InputStream& is, StringEncoding encoding, int size) +void xml::lite::XMLReaderXerces::parse(io::InputStream& is, int size) { - parse(storeEncoding, is, &encoding, size); + // This will try parsing the default (UTF-8) first, then Windows1252 + parse(is, nullptr /*pInitialEncoding*/, getWindows1252Encoding(), size); } - // This function creates the parser void xml::lite::XMLReaderXerces::create() { diff --git a/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlattribute.cpp b/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlattribute.cpp index c96871fc1..d568df3ac 100644 --- a/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlattribute.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlattribute.cpp @@ -27,7 +27,8 @@ #include "xml/lite/MinidomParser.h" -static const std::string uri = "urn:example.com"; +static const std::string strUri = "urn:example.com"; +static const xml::lite::Uri uri(strUri); static const std::string strXml_1_ = R"( @@ -37,7 +38,7 @@ static const std::string strXml_1_ = R"( static const std::string strXml_2_ = R"(" ns:int="314" /> )"; -static const auto strXml = strXml_1_ + uri + strXml_2_; +static const auto strXml = strXml_1_ + strUri + strXml_2_; struct test_MinidomParser final { diff --git a/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlelement.cpp b/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlelement.cpp index 51cc1dae5..ccbdde0a7 100644 --- a/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlelement.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlelement.cpp @@ -20,13 +20,23 @@ * */ -#include - +#include +#include "coda_oss/CPlusPlus.h" #include "io/StringStream.h" #include #include "xml/lite/MinidomParser.h" +// It seems that a macro is better than a utility routine, see https://github.com/tahonermann/char8_t-remediation +// C++20 changed the type of u8 to char8_t* https://en.cppreference.com/w/cpp/language/string_literal +// Not putting this everywhere because (1) well, it's a macro, and (2) it's mostly +// only test code that uses string literals. +#if CODA_OSS_cpp20 +#define U8(s) u8##s +#else +#define U8(s) static_cast(static_cast(s)) +#endif + static const std::string text = "TEXT"; static const std::string strXml1_ = R"( @@ -64,64 +74,6 @@ struct test_MinidomParser final } }; -TEST_CASE(test_CloneCopy_root_encoding) -{ - { - test_MinidomParser xmlParser; - auto& root_ = xmlParser.getRootElement(); - root_.setCharacterData("abc", xml::lite::StringEncoding::Utf8); - const auto& root = root_; - TEST_ASSERT_TRUE(root.getEncoding().has_value()); - - xml::lite::Element copy; - copy.clone(root); - copy.clearChildren(); - TEST_ASSERT_TRUE(copy.getEncoding().has_value()); - copy.setCharacterData("xyz"); - TEST_ASSERT_FALSE(copy.getEncoding().has_value()); - TEST_ASSERT_TRUE(root.getEncoding().has_value()); - - root_.setCharacterData("123"); - TEST_ASSERT_FALSE(root.getEncoding().has_value()); - } - { - test_MinidomParser xmlParser; - auto& root_ = xmlParser.getRootElement(); - root_.setCharacterData("abc", xml::lite::StringEncoding::Utf8); - const auto& root = root_; - - xml::lite::Element copy; - copy.clone(root); - copy.clearChildren(); - TEST_ASSERT_TRUE(copy.getEncoding().has_value()); - copy.setCharacterData("xyz", xml::lite::StringEncoding::Windows1252); - TEST_ASSERT_TRUE(copy.getEncoding().has_value()); - TEST_ASSERT_TRUE(root.getEncoding().has_value()); - TEST_ASSERT(*root.getEncoding() != *copy.getEncoding()); - - root_.setCharacterData("123"); - TEST_ASSERT_FALSE(root.getEncoding().has_value()); - TEST_ASSERT_TRUE(copy.getEncoding().has_value()); - } -} - -TEST_CASE(test_CloneCopy_copy_encoding) -{ - test_MinidomParser xmlParser; - auto& root_ = xmlParser.getRootElement(); - root_.setCharacterData("abc"); - const auto& root = root_; - TEST_ASSERT_FALSE(root.getEncoding().has_value()); - - xml::lite::Element copy; - copy.clone(root); - copy.clearChildren(); - TEST_ASSERT_FALSE(copy.getEncoding().has_value()); - copy.setCharacterData("xyz", xml::lite::StringEncoding::Utf8); - TEST_ASSERT_TRUE(copy.getEncoding().has_value()); - TEST_ASSERT_FALSE(root.getEncoding().has_value()); -} - TEST_CASE(test_getRootElement) { io::StringStream ss; @@ -158,8 +110,6 @@ TEST_CASE(test_getElementsByTagName) const auto characterData = a.getCharacterData(); TEST_ASSERT_EQ(characterData, text); - const auto encoding = a.getEncoding(); - TEST_ASSERT_FALSE(encoding.has_value()); } } @@ -398,9 +348,6 @@ TEST_CASE(test_setValue) int main(int, char**) { - TEST_CHECK(test_CloneCopy_root_encoding); - TEST_CHECK(test_CloneCopy_copy_encoding); - TEST_CHECK(test_getRootElement); TEST_CHECK(test_getElementsByTagName); TEST_CHECK(test_getElementsByTagName_duplicate); diff --git a/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlparser.cpp b/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlparser.cpp index 87226c5ad..adcb4f9f6 100644 --- a/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlparser.cpp +++ b/externals/coda-oss/modules/c++/xml.lite/unittests/test_xmlparser.cpp @@ -29,6 +29,8 @@ #include "str/Convert.h" #include "str/Encoding.h" #include "str/EncodedString.h" +#include "coda_oss/CPlusPlus.h" +#include "sys/OS.h" #include #include "xml/lite/MinidomParser.h" @@ -41,6 +43,7 @@ static inline std::u8string fromUtf8(const std::string& utf8) static const std::string text("TEXT"); static const std::string strXml = "" + text + ""; +static const std::u8string text8 = fromUtf8(text); static const str::EncodedString iso88591Text(str::cast("T\xc9XT")); // ISO8859-1, "T�XT" static const auto iso88591Text1252 = str::EncodedStringView::details::w1252string(iso88591Text.view()); @@ -53,8 +56,7 @@ static const auto pUtf8Text_ = str::c_str(utf8Text8); static const auto strUtf8Xml8 = fromUtf8("") + utf8Text8 + fromUtf8(""); static const std::string strUtf8Xml = str::c_str(strUtf8Xml8); -constexpr auto PlatformEncoding = xml::lite::PlatformEncoding; -static const std::string platfromText_ = PlatformEncoding == xml::lite::StringEncoding::Utf8 ? pUtf8Text_ : pIso88591Text_; +static const std::string platfromText_ = sys::Platform == sys::PlatformType::Windows ? pIso88591Text_ : pUtf8Text_; namespace fs = std::filesystem; @@ -126,26 +128,9 @@ static xml::lite::Element& testXmlUtf8_(xml::lite::MinidomParser& xmlParser) return a; } -TEST_CASE(testXmlUtf8Legacy) -{ - xml::lite::MinidomParser xmlParser; - const auto& a = testXmlUtf8_(xmlParser); - - // This is LEGACY behavior, it is INCORRECT on Linux! - const auto actual = a.getCharacterData(); - #ifdef _WIN32 - TEST_ASSERT_EQ(actual, pIso88591Text_); - #else - TEST_ASSERT_EQ(actual.length(), static_cast(4)); - #endif - - const auto encoding = a.getEncoding(); - TEST_ASSERT_FALSE(encoding.has_value()); -} - TEST_CASE(testXmlUtf8_u8string) { - xml::lite::MinidomParser xmlParser(true /*storeEncoding*/); + xml::lite::MinidomParser xmlParser; const auto& a = testXmlUtf8_(xmlParser); coda_oss::u8string actual; @@ -155,23 +140,12 @@ TEST_CASE(testXmlUtf8_u8string) TEST_CASE(testXmlUtf8) { - xml::lite::MinidomParser xmlParser(true /*storeEncoding*/); + xml::lite::MinidomParser xmlParser; const auto& a = testXmlUtf8_(xmlParser); auto actual = a.getCharacterData(); const auto expected = platfromText_; TEST_ASSERT_EQ(actual, expected); - - std::optional encoding; // avoid compiler warning about possible uninitialized variable - encoding = a.getEncoding(); - TEST_ASSERT_TRUE(encoding.has_value()); - TEST_ASSERT(*encoding == PlatformEncoding); - - // different getCharacterData() API - encoding = a.getCharacterData(actual); - TEST_ASSERT_EQ(actual, expected); - TEST_ASSERT_TRUE(encoding.has_value()); - TEST_ASSERT(*encoding == PlatformEncoding); } TEST_CASE(testXml_setCharacterData) @@ -180,15 +154,6 @@ TEST_CASE(testXml_setCharacterData) auto& a = testXmlUtf8_(xmlParser); a.setCharacterData(utf8Text8); - auto encoding = a.getEncoding(); - TEST_ASSERT_TRUE(encoding.has_value()); - TEST_ASSERT(encoding == xml::lite::StringEncoding::Utf8); - - std::string actual; - encoding = a.getCharacterData(actual); - TEST_ASSERT_TRUE(encoding.has_value()); - TEST_ASSERT(encoding == xml::lite::StringEncoding::Utf8); - TEST_ASSERT_EQ(actual, pUtf8Text_); } static std::string testXmlPrint_(std::string& expected, const std::string& characterData) @@ -210,26 +175,88 @@ TEST_CASE(testXmlPrintSimple) TEST_ASSERT_EQ(actual, expected); } -TEST_CASE(testXmlPrintLegacy) +static std::u8string fromWindows1252(const std::string& s) { - // This is LEGACY behavior, it generates bad XML - std::string expected; - const auto actual = testXmlPrint_(expected, pIso88591Text_); - TEST_ASSERT_EQ(actual, expected); + // s is Windows-1252 on ALL platforms + return str::EncodedStringView::fromWindows1252(s).u8string(); } TEST_CASE(testXmlPrintUtf8) { - xml::lite::MinidomParser xmlParser; - auto& document = getDocument(xmlParser); + const auto expected = std::string("") + pUtf8Text_ + ""; + { + xml::lite::MinidomParser xmlParser; + auto& document = getDocument(xmlParser); - const auto pRootElement = document.createElement(xml::lite::QName(xml::lite::Uri(), "root"), pIso88591Text_, xml::lite::StringEncoding::Windows1252); + const auto s8_w1252 = fromWindows1252(pIso88591Text_); + const auto pRootElement = document.createElement(xml::lite::QName(xml::lite::Uri(), "root"), s8_w1252); - io::StringStream output; - pRootElement->print(output, xml::lite::StringEncoding::Utf8); // write UTF-8 - const auto actual = output.stream().str(); - const auto expected = std::string("") + pUtf8Text_ + ""; - TEST_ASSERT_EQ(actual, expected); + io::StringStream output; + pRootElement->print(output); + const auto actual = output.stream().str(); + TEST_ASSERT_EQ(actual, expected); + } + { + xml::lite::MinidomParser xmlParser; + auto& document = getDocument(xmlParser); + + const auto pRootElement = document.createElement(xml::lite::QName(xml::lite::Uri(), "root"), utf8Text8); + + io::StringStream output; + pRootElement->print(output); + const auto actual = output.stream().str(); + TEST_ASSERT_EQ(actual, expected); + } + { + xml::lite::MinidomParser xmlParser; + auto& document = getDocument(xmlParser); + + const auto pRootElement = document.createElement(xml::lite::QName(xml::lite::Uri(), "root"), platfromText_); + + io::StringStream output; + pRootElement->print(output); + const auto actual = output.stream().str(); + TEST_ASSERT_EQ(actual, expected); + } +} + +TEST_CASE(testXmlConsoleOutput) +{ + const auto expected = "" + platfromText_ + ""; + { + xml::lite::MinidomParser xmlParser; + auto& document = getDocument(xmlParser); + + const auto s8_w1252 = fromWindows1252(pIso88591Text_); + const auto pRootElement = document.createElement(xml::lite::QName(xml::lite::Uri(), "root"), s8_w1252); + + io::StringStream output; + pRootElement->consoleOutput_(output); + const auto actual = output.stream().str(); + TEST_ASSERT_EQ(actual, expected); + } + { + xml::lite::MinidomParser xmlParser; + auto& document = getDocument(xmlParser); + + const auto pRootElement = document.createElement(xml::lite::QName(xml::lite::Uri(), "root"), utf8Text8); + + io::StringStream output; + pRootElement->consoleOutput_(output); + const auto actual = output.stream().str(); + TEST_ASSERT_EQ(actual, expected); + } + { + xml::lite::MinidomParser xmlParser; + auto& document = getDocument(xmlParser); + + const auto pRootElement = document.createElement(xml::lite::QName(xml::lite::Uri(), "root"), platfromText_); + + io::StringStream output; + pRootElement->consoleOutput_(output); + const auto actual = output.stream().str(); + TEST_ASSERT_EQ(actual, expected); + } } TEST_CASE(testXmlParseAndPrintUtf8) @@ -237,18 +264,19 @@ TEST_CASE(testXmlParseAndPrintUtf8) io::StringStream input; input.stream() << strUtf8Xml; - xml::lite::MinidomParser xmlParser(true /*storeEncoding*/); + xml::lite::MinidomParser xmlParser; xmlParser.preserveCharacterData(true); xmlParser.parse(input); const auto pRootElement = getDocument(xmlParser).getRootElement(); io::StringStream output; - pRootElement->print(output, xml::lite::StringEncoding::Utf8); // write UTF-8 + pRootElement->print(output); const auto actual = output.stream().str(); TEST_ASSERT_EQ(actual, strUtf8Xml); } -static void testReadEncodedXmlFile(const std::string& testName, const std::string& xmlFile, bool preserveCharacterData) +static void testReadEncodedXmlFile(const std::string& testName, const std::string& xmlFile, bool preserveCharacterData, + const std::string& platformText, const std::u8string& text8_) { const auto unittests = findRoot() / "modules" / "c++" / "xml.lite" / "unittests"; @@ -260,20 +288,18 @@ static void testReadEncodedXmlFile(const std::string& testName, const std::strin } io::FileInputStream input(path.string()); - xml::lite::MinidomParser xmlParser(true /*storeEncoding*/); + xml::lite::MinidomParser xmlParser; xmlParser.preserveCharacterData(preserveCharacterData); xmlParser.parse(input); const auto& root = getRootElement(getDocument(xmlParser)); const auto& a = root.getElementByTagName("a", true /*recurse*/); auto characterData = a.getCharacterData(); - const auto encoding = a.getEncoding(); - TEST_ASSERT(encoding == PlatformEncoding); - TEST_ASSERT_EQ(characterData, platfromText_); + TEST_ASSERT_EQ(characterData, platformText); std::u8string u8_characterData; a.getCharacterData(u8_characterData); - TEST_ASSERT_EQ(utf8Text8, u8_characterData); + TEST_ASSERT_EQ(text8_, u8_characterData); const auto& textXML = root.getElementByTagName("text", true /*recurse*/); characterData = textXML.getCharacterData(); @@ -292,13 +318,16 @@ static void testReadEncodedXmlFile(const std::string& testName, const std::strin TEST_CASE(testReadEncodedXmlFiles) { // these have "" - testReadEncodedXmlFile(testName, "encoding_utf-8.xml", true /*preserveCharacterData*/); - testReadEncodedXmlFile(testName, "encoding_utf-8.xml", false /*preserveCharacterData*/); - testReadEncodedXmlFile(testName, "encoding_windows-1252.xml", true /*preserveCharacterData*/); - testReadEncodedXmlFile(testName, "encoding_windows-1252.xml", false /*preserveCharacterData*/); + testReadEncodedXmlFile(testName, "encoding_utf-8.xml", true /*preserveCharacterData*/, platfromText_ , utf8Text8); + testReadEncodedXmlFile(testName, "encoding_utf-8.xml", false /*preserveCharacterData*/, platfromText_ , utf8Text8); + testReadEncodedXmlFile(testName, "encoding_windows-1252.xml", true /*preserveCharacterData*/, platfromText_ , utf8Text8); + testReadEncodedXmlFile(testName, "encoding_windows-1252.xml", false /*preserveCharacterData*/, platfromText_ , utf8Text8); + testReadEncodedXmlFile(testName, "ascii_encoding_utf-8.xml", true /*preserveCharacterData*/, text , text8); + testReadEncodedXmlFile(testName, "ascii_encoding_utf-8.xml", false /*preserveCharacterData*/, text , text8); } -static void testReadXmlFile(const std::string& testName, const std::string& xmlFile, bool preserveCharacterData) +static void testReadXmlFile(const std::string& testName, const std::string& xmlFile, bool preserveCharacterData, + const std::string& platformText, const std::u8string& text8_) { const auto unittests = findRoot() / "modules" / "c++" / "xml.lite" / "unittests"; @@ -310,7 +339,7 @@ static void testReadXmlFile(const std::string& testName, const std::string& xmlF } io::FileInputStream input(path.string()); - xml::lite::MinidomParser xmlParser(true /*storeEncoding*/); + xml::lite::MinidomParser xmlParser; xmlParser.preserveCharacterData(preserveCharacterData); xmlParser.parse(input); const auto& root = getRootElement(getDocument(xmlParser)); @@ -320,13 +349,11 @@ static void testReadXmlFile(const std::string& testName, const std::string& xmlF const auto& a = *(aElements[0]); auto characterData = a.getCharacterData(); - const auto encoding = a.getEncoding(); - TEST_ASSERT(encoding == PlatformEncoding); - TEST_ASSERT_EQ(characterData, platfromText_); + TEST_ASSERT_EQ(characterData, platformText); std::u8string u8_characterData; a.getCharacterData(u8_characterData); - TEST_ASSERT_EQ(utf8Text8, u8_characterData); + TEST_ASSERT_EQ(text8_, u8_characterData); const auto& textXML = root.getElementByTagName("text", true /*recurse*/); characterData = textXML.getCharacterData(); @@ -345,10 +372,12 @@ static void testReadXmlFile(const std::string& testName, const std::string& xmlF TEST_CASE(testReadXmlFiles) { // These do NOT have "" - testReadXmlFile(testName, "utf-8.xml", true /*preserveCharacterData*/); - testReadXmlFile(testName, "utf-8.xml", false /*preserveCharacterData*/); - testReadXmlFile(testName, "windows-1252.xml", true /*preserveCharacterData*/); - testReadXmlFile(testName, "windows-1252.xml", false /*preserveCharacterData*/); + testReadXmlFile(testName, "utf-8.xml", true /*preserveCharacterData*/, platfromText_ , utf8Text8); + testReadXmlFile(testName, "utf-8.xml", false /*preserveCharacterData*/, platfromText_ , utf8Text8); + testReadXmlFile(testName, "windows-1252.xml", true /*preserveCharacterData*/, platfromText_ , utf8Text8); + testReadXmlFile(testName, "windows-1252.xml", false /*preserveCharacterData*/, platfromText_ , utf8Text8); + testReadXmlFile(testName, "ascii.xml", true /*preserveCharacterData*/, text , text8); + testReadXmlFile(testName, "ascii.xml", false /*preserveCharacterData*/, text , text8); } static bool find_string(io::FileInputStream& stream, const std::string& s) @@ -389,14 +418,11 @@ TEST_CASE(testReadEmbeddedXml) const auto result = find_string(input, " +static void testValidateXmlFile_(const std::string& testName, const std::string& xmlFile, TStringStream* pStringStream) { const auto unittests = findRoot() / "modules" / "c++" / "xml.lite" / "unittests"; @@ -429,8 +456,8 @@ static void testValidateXmlFile_(const std::string& testName, const std::string& io::FileInputStream fis(path); std::vector errors; - const auto result = (pEncoding == nullptr) ? validator.validate(fis, path.string() /*xmlID*/, errors) : - validator.validate(fis, *pEncoding, path.string() /*xmlID*/, errors); + const auto result = (pStringStream == nullptr) ? validator.validate(fis, path.string() /*xmlID*/, errors) : + validator.vallidateT(fis, *pStringStream, path.string() /*xmlID*/, errors); for (const auto& error : errors) { std::clog << error.toString() << "\n"; @@ -440,11 +467,12 @@ static void testValidateXmlFile_(const std::string& testName, const std::string& } static void testValidateXmlFile(const std::string& testName, const std::string& xmlFile) { - testValidateXmlFile_(testName, xmlFile, nullptr /*pEncoding*/); + testValidateXmlFile_(testName, xmlFile, nullptr /*pStringStream*/); } -static void testValidateXmlFile(const std::string& testName, const std::string& xmlFile, xml::lite::StringEncoding encoding) +template +static void testValidateXmlFile(const std::string& testName, const std::string& xmlFile, TStringStream&& oss) { - testValidateXmlFile_(testName, xmlFile, &encoding); + testValidateXmlFile_(testName, xmlFile, &oss); } TEST_CASE(testValidateXmlFile) { @@ -454,79 +482,32 @@ TEST_CASE(testValidateXmlFile) // legacy validate() API, new string conversion testValidateXmlFile(testName, "utf-8.xml"); testValidateXmlFile(testName, "encoding_utf-8.xml"); + testValidateXmlFile(testName, "encoding_windows-1252.xml"); + testValidateXmlFile(testName, "windows-1252.xml"); // new validate() API - testValidateXmlFile(testName, "utf-8.xml", xml::lite::StringEncoding::Utf8); - testValidateXmlFile(testName, "encoding_utf-8.xml", xml::lite::StringEncoding::Utf8); - testValidateXmlFile(testName, "windows-1252.xml", xml::lite::StringEncoding::Windows1252); - testValidateXmlFile(testName, "encoding_windows-1252.xml", xml::lite::StringEncoding::Windows1252); -} - -static void testValidateXmlFileLegacy(const std::string& testName, const std::string& xmlFile, bool success=true) -{ - const auto unittests = findRoot() / "modules" / "c++" / "xml.lite" / "unittests"; - - const auto xsd = unittests / "doc.xsd"; - if (!exists(xsd)) // running in "externals" of a different project - { - std::clog << "Path does not exist: '" << xsd << "'\n"; - return; - } - const auto path = unittests / xmlFile; - - const std::vector schemaPaths{xsd.parent_path().string()}; // std::string -> legacy behavior - const xml::lite::Validator validator(schemaPaths, nullptr /*log*/); - - io::FileInputStream fis(path); - std::vector errors; - const auto result = validator.validate(fis, path.string() /*xmlID*/, errors); - for (const auto& error : errors) - { - std::clog << error.toString() << "\n"; - } - if (success) - { - TEST_ASSERT_FALSE(result); - TEST_ASSERT_TRUE(errors.empty()); - } - else - { - TEST_ASSERT_TRUE(result); // errors - TEST_ASSERT_FALSE(errors.empty()); - } -} -TEST_CASE(testValidateXmlFileLegacy) -{ - // these two work on all platforms - testValidateXmlFile(testName, "ascii.xml"); - testValidateXmlFile(testName, "ascii_encoding_utf-8.xml"); - - // These are OK on Windows but fail on Linux; this is as-expected with "legacy" string conversion. - constexpr auto success = sys::Platform == sys::PlatformType::Windows ? true : false; - testValidateXmlFileLegacy(testName, "utf-8.xml", success); - testValidateXmlFileLegacy(testName, "encoding_utf-8.xml", success); - testValidateXmlFileLegacy(testName, "windows-1252.xml", success); - testValidateXmlFileLegacy(testName, "encoding_windows-1252.xml", success); + testValidateXmlFile(testName, "utf-8.xml", io::U8StringStream()); + testValidateXmlFile(testName, "encoding_utf-8.xml", io::U8StringStream()); + testValidateXmlFile(testName, "windows-1252.xml", io::W1252StringStream()); + testValidateXmlFile(testName, "encoding_windows-1252.xml", io::W1252StringStream()); } int main(int, char**) { TEST_CHECK(testXmlParseSimple); TEST_CHECK(testXmlPreserveCharacterData); - TEST_CHECK(testXmlUtf8Legacy); TEST_CHECK(testXmlUtf8); TEST_CHECK(testXmlUtf8_u8string); TEST_CHECK(testXml_setCharacterData); TEST_CHECK(testXmlPrintSimple); - TEST_CHECK(testXmlPrintLegacy); TEST_CHECK(testXmlParseAndPrintUtf8); TEST_CHECK(testXmlPrintUtf8); + TEST_CHECK(testXmlConsoleOutput); TEST_CHECK(testReadEncodedXmlFiles); TEST_CHECK(testReadXmlFiles); TEST_CHECK(testReadEmbeddedXml); TEST_CHECK(testValidateXmlFile); - TEST_CHECK(testValidateXmlFileLegacy); } diff --git a/externals/coda-oss/modules/python/xml.lite/source/generated/xml_lite.py b/externals/coda-oss/modules/python/xml.lite/source/generated/xml_lite.py index 8daa62bb3..cc8bd4e77 100644 --- a/externals/coda-oss/modules/python/xml.lite/source/generated/xml_lite.py +++ b/externals/coda-oss/modules/python/xml.lite/source/generated/xml_lite.py @@ -80,16 +80,10 @@ def __init__(self, *args): r""" __init__(Element self) -> Element __init__(Element self, std::string const & qname, std::string const & uri="", std::string const & characterData="") -> Element - __init__(Element self, std::string const & qname, std::string const & uri, std::string const & characterData, xml::lite::StringEncoding encoding) -> Element - __init__(Element self, std::string const & qname, std::string const & uri, coda_oss::u8string const & characterData) -> Element __init__(Element self, Element element) -> Element """ _xml_lite.Element_swiginit(self, _xml_lite.new_Element(*args)) - def clone(self, element: "Element") -> "void": - r"""clone(Element self, Element element)""" - return _xml_lite.Element_clone(self, element) - def attribute(self, s: "std::string const &") -> "std::string &": r"""attribute(Element self, std::string const & s) -> std::string &""" return _xml_lite.Element_attribute(self, s) @@ -137,14 +131,12 @@ def setNamespaceURI(self, prefix: "std::string", uri: "std::string") -> "void": def _print(self, *args) -> "void": r""" _print(Element self, io::OutputStream & stream) - _print(Element self, io::OutputStream & stream, xml::lite::StringEncoding arg3) """ return _xml_lite.Element__print(self, *args) def prettyPrint(self, *args) -> "void": r""" prettyPrint(Element self, io::OutputStream & stream, std::string const & formatter=" ") - prettyPrint(Element self, io::OutputStream & stream, xml::lite::StringEncoding arg3, std::string const & formatter=" ") """ return _xml_lite.Element_prettyPrint(self, *args) @@ -155,27 +147,15 @@ def hasElement(self, *args) -> "bool": """ return _xml_lite.Element_hasElement(self, *args) - def getEncoding(self) -> "coda_oss::optional< xml::lite::StringEncoding > const &": - r"""getEncoding(Element self) -> coda_oss::optional< xml::lite::StringEncoding > const &""" - return _xml_lite.Element_getEncoding(self) - def getCharacterData(self, *args) -> "void": r""" getCharacterData(Element self) -> std::string - getCharacterData(Element self, std::string & result) -> coda_oss::optional< xml::lite::StringEncoding > const - getCharacterData(Element self, coda_oss::u8string & result) """ return _xml_lite.Element_getCharacterData(self, *args) - def setCharacterData_(self, characters: "std::string const &", arg3: "xml::lite::StringEncoding const *") -> "void": - r"""setCharacterData_(Element self, std::string const & characters, xml::lite::StringEncoding const * arg3)""" - return _xml_lite.Element_setCharacterData_(self, characters, arg3) - def setCharacterData(self, *args) -> "void": r""" setCharacterData(Element self, std::string const & characters) - setCharacterData(Element self, std::string const & characters, xml::lite::StringEncoding arg3) - setCharacterData(Element self, coda_oss::u8string const & characters) """ return _xml_lite.Element_setCharacterData(self, *args) @@ -236,15 +216,9 @@ def __init__(self, rootNode: "Element"=None, own: "bool"=True): _xml_lite.Document_swiginit(self, _xml_lite.new_Document(rootNode, own)) __swig_destroy__ = _xml_lite.delete_Document - def clone(self) -> "xml::lite::Document *": - r"""clone(Document self) -> Document""" - return _xml_lite.Document_clone(self) - def createElement(self, *args) -> "xml::lite::Element *": r""" createElement(Document self, std::string const & qname, std::string const & uri, std::string characterData="") -> Element - createElement(Document self, std::string const & qname, std::string const & uri, std::string const & characterData, xml::lite::StringEncoding arg5) -> Element - createElement(Document self, std::string const & qname, std::string const & uri, coda_oss::u8string const & characterData) -> Element """ return _xml_lite.Document_createElement(self, *args) @@ -283,8 +257,8 @@ class MinidomParser(object): thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") __repr__ = _swig_repr - def __init__(self, storeEncoding: "bool"=False): - r"""__init__(MinidomParser self, bool storeEncoding=False) -> MinidomParser""" + def __init__(self, storeEncoding: "bool"=True): + r"""__init__(MinidomParser self, bool storeEncoding=True) -> MinidomParser""" _xml_lite.MinidomParser_swiginit(self, _xml_lite.new_MinidomParser(storeEncoding)) __swig_destroy__ = _xml_lite.delete_MinidomParser @@ -318,10 +292,6 @@ def preserveCharacterData(self, preserve: "bool") -> "void": r"""preserveCharacterData(MinidomParser self, bool preserve)""" return _xml_lite.MinidomParser_preserveCharacterData(self, preserve) - def storeEncoding(self, preserve: "bool") -> "void": - r"""storeEncoding(MinidomParser self, bool preserve)""" - return _xml_lite.MinidomParser_storeEncoding(self, preserve) - # Register MinidomParser in _xml_lite: _xml_lite.MinidomParser_swigregister(MinidomParser) diff --git a/externals/coda-oss/modules/python/xml.lite/source/generated/xml_lite_wrap.cxx b/externals/coda-oss/modules/python/xml.lite/source/generated/xml_lite_wrap.cxx index 6c786cac3..c06a5119e 100644 --- a/externals/coda-oss/modules/python/xml.lite/source/generated/xml_lite_wrap.cxx +++ b/externals/coda-oss/modules/python/xml.lite/source/generated/xml_lite_wrap.cxx @@ -2698,7 +2698,6 @@ SWIGINTERN PyObject *SWIG_PyStaticMethod_New(PyObject *SWIGUNUSEDPARM(self), PyO #define SWIGTYPE_p_std__string swig_types[5] #define SWIGTYPE_p_std__vectorT_xml__lite__Element_p_t swig_types[6] #define SWIGTYPE_p_coda_oss__optionalT_xml__lite__string_encoding_t swig_types[7] -#define SWIGTYPE_p_sys__U8string swig_types[8] #define SWIGTYPE_p_xml__lite__Document swig_types[9] #define SWIGTYPE_p_xml__lite__Element swig_types[10] #define SWIGTYPE_p_xml__lite__MinidomParser swig_types[11] @@ -3114,106 +3113,6 @@ SWIGINTERN PyObject *_wrap_new_Element__SWIG_3(PyObject *SWIGUNUSEDPARM(self), P } -SWIGINTERN PyObject *_wrap_new_Element__SWIG_4(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - std::string *arg1 = 0 ; - std::string *arg2 = 0 ; - std::string *arg3 = 0 ; - xml::lite::StringEncoding arg4 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - int val4 ; - int ecode4 = 0 ; - xml::lite::Element *result = 0 ; - - if ((nobjs < 4) || (nobjs > 4)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Element" "', argument " "1"" of type '" "std::string const &""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Element" "', argument " "1"" of type '" "std::string const &""'"); - } - arg1 = reinterpret_cast< std::string * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Element" "', argument " "2"" of type '" "std::string const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Element" "', argument " "2"" of type '" "std::string const &""'"); - } - arg2 = reinterpret_cast< std::string * >(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_Element" "', argument " "3"" of type '" "std::string const &""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Element" "', argument " "3"" of type '" "std::string const &""'"); - } - arg3 = reinterpret_cast< std::string * >(argp3); - ecode4 = SWIG_AsVal_int(swig_obj[3], &val4); - if (!SWIG_IsOK(ecode4)) { - SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "new_Element" "', argument " "4"" of type '" "xml::lite::StringEncoding""'"); - } - arg4 = static_cast< xml::lite::StringEncoding >(val4); - result = (xml::lite::Element *)new xml::lite::Element((std::string const &)*arg1,(std::string const &)*arg2,(std::string const &)*arg3,arg4); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_xml__lite__Element, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_new_Element__SWIG_5(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - std::string *arg1 = 0 ; - std::string *arg2 = 0 ; - coda_oss::u8string *arg3 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - xml::lite::Element *result = 0 ; - - if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_Element" "', argument " "1"" of type '" "std::string const &""'"); - } - if (!argp1) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Element" "', argument " "1"" of type '" "std::string const &""'"); - } - arg1 = reinterpret_cast< std::string * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_Element" "', argument " "2"" of type '" "std::string const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Element" "', argument " "2"" of type '" "std::string const &""'"); - } - arg2 = reinterpret_cast< std::string * >(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_sys__U8string, 0 | 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "new_Element" "', argument " "3"" of type '" "coda_oss::u8string const &""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_Element" "', argument " "3"" of type '" "coda_oss::u8string const &""'"); - } - arg3 = reinterpret_cast< coda_oss::u8string * >(argp3); - result = (xml::lite::Element *)new xml::lite::Element((std::string const &)*arg1,(std::string const &)*arg2,(coda_oss::u8string const &)*arg3); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_xml__lite__Element, SWIG_POINTER_NEW | 0 ); - return resultobj; -fail: - return NULL; -} - - SWIGINTERN PyObject *_wrap_delete_Element(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; @@ -3258,7 +3157,7 @@ SWIGINTERN PyObject *_wrap_Element_destroyChildren(PyObject *SWIGUNUSEDPARM(self } -SWIGINTERN PyObject *_wrap_new_Element__SWIG_6(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { +SWIGINTERN PyObject *_wrap_new_Element__SWIG_4(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; xml::lite::Element *arg1 = 0 ; void *argp1 = 0 ; @@ -3306,7 +3205,7 @@ SWIGINTERN PyObject *_wrap_new_Element(PyObject *self, PyObject *args) { int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_xml__lite__Element, SWIG_POINTER_NO_NULL | 0); _v = SWIG_CheckState(res); if (_v) { - return _wrap_new_Element__SWIG_6(self, argc, argv); + return _wrap_new_Element__SWIG_4(self, argc, argv); } } if (argc == 2) { @@ -3321,22 +3220,6 @@ SWIGINTERN PyObject *_wrap_new_Element(PyObject *self, PyObject *args) { } } } - if (argc == 3) { - int _v; - int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_sys__U8string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_new_Element__SWIG_5(self, argc, argv); - } - } - } - } if (argc == 3) { int _v; int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); @@ -3353,28 +3236,6 @@ SWIGINTERN PyObject *_wrap_new_Element(PyObject *self, PyObject *args) { } } } - if (argc == 4) { - int _v; - int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_int(argv[3], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_new_Element__SWIG_4(self, argc, argv); - } - } - } - } - } fail: SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'new_Element'.\n" @@ -3383,43 +3244,11 @@ SWIGINTERN PyObject *_wrap_new_Element(PyObject *self, PyObject *args) { " xml::lite::Element::Element(std::string const &,std::string const &,std::string const &)\n" " xml::lite::Element::Element(std::string const &,std::string const &)\n" " xml::lite::Element::Element(std::string const &)\n" - " xml::lite::Element::Element(std::string const &,std::string const &,std::string const &,xml::lite::StringEncoding)\n" - " xml::lite::Element::Element(std::string const &,std::string const &,coda_oss::u8string const &)\n" " xml::lite::Element::Element(xml::lite::Element const &)\n"); return 0; } -SWIGINTERN PyObject *_wrap_Element_clone(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; - xml::lite::Element *arg2 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "Element_clone", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Element_clone" "', argument " "1"" of type '" "xml::lite::Element *""'"); - } - arg1 = reinterpret_cast< xml::lite::Element * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_xml__lite__Element, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Element_clone" "', argument " "2"" of type '" "xml::lite::Element const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Element_clone" "', argument " "2"" of type '" "xml::lite::Element const &""'"); - } - arg2 = reinterpret_cast< xml::lite::Element * >(argp2); - (arg1)->clone((xml::lite::Element const &)*arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} SWIGINTERN PyObject *_wrap_Element_attribute(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { @@ -5258,45 +5087,6 @@ SWIGINTERN PyObject *_wrap_Element__print__SWIG_0(PyObject *SWIGUNUSEDPARM(self) } -SWIGINTERN PyObject *_wrap_Element__print__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; - io::OutputStream *arg2 = 0 ; - xml::lite::StringEncoding arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - - if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Element__print" "', argument " "1"" of type '" "xml::lite::Element const *""'"); - } - arg1 = reinterpret_cast< xml::lite::Element * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_io__OutputStream, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Element__print" "', argument " "2"" of type '" "io::OutputStream &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Element__print" "', argument " "2"" of type '" "io::OutputStream &""'"); - } - arg2 = reinterpret_cast< io::OutputStream * >(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Element__print" "', argument " "3"" of type '" "xml::lite::StringEncoding""'"); - } - arg3 = static_cast< xml::lite::StringEncoding >(val3); - ((xml::lite::Element const *)arg1)->print(*arg2,arg3); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - SWIGINTERN PyObject *_wrap_Element__print(PyObject *self, PyObject *args) { Py_ssize_t argc; PyObject *argv[4] = { @@ -5319,32 +5109,11 @@ SWIGINTERN PyObject *_wrap_Element__print(PyObject *self, PyObject *args) { } } } - if (argc == 3) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Element, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_io__OutputStream, SWIG_POINTER_NO_NULL); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_Element__print__SWIG_1(self, argc, argv); - } - } - } - } fail: SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Element__print'.\n" " Possible C/C++ prototypes are:\n" - " xml::lite::Element::print(io::OutputStream &) const\n" - " xml::lite::Element::print(io::OutputStream &,xml::lite::StringEncoding) const\n"); + " xml::lite::Element::print(io::OutputStream &) const\n"); return 0; } @@ -5422,200 +5191,65 @@ SWIGINTERN PyObject *_wrap_Element_prettyPrint__SWIG_1(PyObject *SWIGUNUSEDPARM( } -SWIGINTERN PyObject *_wrap_Element_prettyPrint__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { +SWIGINTERN PyObject *_wrap_Element_prettyPrint(PyObject *self, PyObject *args) { + Py_ssize_t argc; + PyObject *argv[5] = { + 0 + }; + + if (!(argc = SWIG_Python_UnpackTuple(args, "Element_prettyPrint", 0, 4, argv))) SWIG_fail; + --argc; + if (argc == 2) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Element, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_io__OutputStream, SWIG_POINTER_NO_NULL); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Element_prettyPrint__SWIG_1(self, argc, argv); + } + } + } + if (argc == 3) { + int _v; + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Element, 0); + _v = SWIG_CheckState(res); + if (_v) { + void *vptr = 0; + int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_io__OutputStream, SWIG_POINTER_NO_NULL); + _v = SWIG_CheckState(res); + if (_v) { + int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); + _v = SWIG_CheckState(res); + if (_v) { + return _wrap_Element_prettyPrint__SWIG_0(self, argc, argv); + } + } + } + } + +fail: + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Element_prettyPrint'.\n" + " Possible C/C++ prototypes are:\n" + " xml::lite::Element::prettyPrint(io::OutputStream &,std::string const &) const\n" + " xml::lite::Element::prettyPrint(io::OutputStream &) const\n"); + return 0; +} + + +SWIGINTERN PyObject *_wrap_Element_hasElement__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; - io::OutputStream *arg2 = 0 ; - xml::lite::StringEncoding arg3 ; - std::string *arg4 = 0 ; + std::string *arg2 = 0 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - - if ((nobjs < 4) || (nobjs > 4)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Element_prettyPrint" "', argument " "1"" of type '" "xml::lite::Element const *""'"); - } - arg1 = reinterpret_cast< xml::lite::Element * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_io__OutputStream, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Element_prettyPrint" "', argument " "2"" of type '" "io::OutputStream &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Element_prettyPrint" "', argument " "2"" of type '" "io::OutputStream &""'"); - } - arg2 = reinterpret_cast< io::OutputStream * >(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Element_prettyPrint" "', argument " "3"" of type '" "xml::lite::StringEncoding""'"); - } - arg3 = static_cast< xml::lite::StringEncoding >(val3); - res4 = SWIG_ConvertPtr(swig_obj[3], &argp4, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Element_prettyPrint" "', argument " "4"" of type '" "std::string const &""'"); - } - if (!argp4) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Element_prettyPrint" "', argument " "4"" of type '" "std::string const &""'"); - } - arg4 = reinterpret_cast< std::string * >(argp4); - ((xml::lite::Element const *)arg1)->prettyPrint(*arg2,arg3,(std::string const &)*arg4); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Element_prettyPrint__SWIG_3(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; - io::OutputStream *arg2 = 0 ; - xml::lite::StringEncoding arg3 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - - if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Element_prettyPrint" "', argument " "1"" of type '" "xml::lite::Element const *""'"); - } - arg1 = reinterpret_cast< xml::lite::Element * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_io__OutputStream, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Element_prettyPrint" "', argument " "2"" of type '" "io::OutputStream &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Element_prettyPrint" "', argument " "2"" of type '" "io::OutputStream &""'"); - } - arg2 = reinterpret_cast< io::OutputStream * >(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Element_prettyPrint" "', argument " "3"" of type '" "xml::lite::StringEncoding""'"); - } - arg3 = static_cast< xml::lite::StringEncoding >(val3); - ((xml::lite::Element const *)arg1)->prettyPrint(*arg2,arg3); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Element_prettyPrint(PyObject *self, PyObject *args) { - Py_ssize_t argc; - PyObject *argv[5] = { - 0 - }; - - if (!(argc = SWIG_Python_UnpackTuple(args, "Element_prettyPrint", 0, 4, argv))) SWIG_fail; - --argc; - if (argc == 2) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Element, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_io__OutputStream, SWIG_POINTER_NO_NULL); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_Element_prettyPrint__SWIG_1(self, argc, argv); - } - } - } - if (argc == 3) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Element, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_io__OutputStream, SWIG_POINTER_NO_NULL); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_Element_prettyPrint__SWIG_0(self, argc, argv); - } - } - } - } - if (argc == 3) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Element, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_io__OutputStream, SWIG_POINTER_NO_NULL); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_Element_prettyPrint__SWIG_3(self, argc, argv); - } - } - } - } - if (argc == 4) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Element, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_io__OutputStream, SWIG_POINTER_NO_NULL); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_Element_prettyPrint__SWIG_2(self, argc, argv); - } - } - } - } - } - -fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Element_prettyPrint'.\n" - " Possible C/C++ prototypes are:\n" - " xml::lite::Element::prettyPrint(io::OutputStream &,std::string const &) const\n" - " xml::lite::Element::prettyPrint(io::OutputStream &) const\n" - " xml::lite::Element::prettyPrint(io::OutputStream &,xml::lite::StringEncoding,std::string const &) const\n" - " xml::lite::Element::prettyPrint(io::OutputStream &,xml::lite::StringEncoding) const\n"); - return 0; -} - - -SWIGINTERN PyObject *_wrap_Element_hasElement__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; - std::string *arg2 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - bool result; + bool result; if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Element, 0 | 0 ); @@ -5751,91 +5385,6 @@ SWIGINTERN PyObject *_wrap_Element_getCharacterData__SWIG_0(PyObject *SWIGUNUSED } -SWIGINTERN PyObject *_wrap_Element_getEncoding(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - coda_oss::optional* result = 0; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Element_getEncoding" "', argument " "1"" of type '" "xml::lite::Element const *""'"); - } - arg1 = reinterpret_cast< xml::lite::Element * >(argp1); - result = (coda_oss::optional< xml::lite::StringEncoding > *) &((xml::lite::Element const *)arg1)->getEncoding(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coda_oss__optionalT_xml__lite__string_encoding_t, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Element_getCharacterData__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; - std::string *arg2 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - coda_oss::optional< xml::lite::StringEncoding > *result = 0 ; - - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Element_getCharacterData" "', argument " "1"" of type '" "xml::lite::Element const *""'"); - } - arg1 = reinterpret_cast< xml::lite::Element * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_std__string, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Element_getCharacterData" "', argument " "2"" of type '" "std::string &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Element_getCharacterData" "', argument " "2"" of type '" "std::string &""'"); - } - arg2 = reinterpret_cast< std::string * >(argp2); - result = (coda_oss::optional< xml::lite::StringEncoding > *) &((xml::lite::Element const *)arg1)->getCharacterData(*arg2); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_coda_oss__optionalT_xml__lite__string_encoding_t, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Element_getCharacterData__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; - coda_oss::u8string *arg2 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Element_getCharacterData" "', argument " "1"" of type '" "xml::lite::Element const *""'"); - } - arg1 = reinterpret_cast< xml::lite::Element * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_sys__U8string, 0 ); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Element_getCharacterData" "', argument " "2"" of type '" "coda_oss::u8string &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Element_getCharacterData" "', argument " "2"" of type '" "coda_oss::u8string &""'"); - } - arg2 = reinterpret_cast< coda_oss::u8string * >(argp2); - ((xml::lite::Element const *)arg1)->getCharacterData(*arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - SWIGINTERN PyObject *_wrap_Element_getCharacterData(PyObject *self, PyObject *args) { Py_ssize_t argc; @@ -5852,131 +5401,27 @@ SWIGINTERN PyObject *_wrap_Element_getCharacterData(PyObject *self, PyObject *ar _v = SWIG_CheckState(res); if (_v) { return _wrap_Element_getCharacterData__SWIG_0(self, argc, argv); - } - } - if (argc == 2) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Element, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_Element_getCharacterData__SWIG_1(self, argc, argv); - } - } - } - if (argc == 2) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Element, 0); - _v = SWIG_CheckState(res); - if (_v) { - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[1], &vptr, SWIGTYPE_p_sys__U8string, SWIG_POINTER_NO_NULL); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_Element_getCharacterData__SWIG_2(self, argc, argv); - } - } - } - -fail: - SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Element_getCharacterData'.\n" - " Possible C/C++ prototypes are:\n" - " xml::lite::Element::getCharacterData() const\n" - " xml::lite::Element::getCharacterData(std::string &) const\n" - " xml::lite::Element::getCharacterData(coda_oss::u8string &) const\n"); - return 0; -} - - -SWIGINTERN PyObject *_wrap_Element_setCharacterData_(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; - std::string *arg2 = 0 ; - xml::lite::StringEncoding *arg3 = (xml::lite::StringEncoding *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - PyObject *swig_obj[3] ; - - if (!SWIG_Python_UnpackTuple(args, "Element_setCharacterData_", 3, 3, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Element_setCharacterData_" "', argument " "1"" of type '" "xml::lite::Element *""'"); - } - arg1 = reinterpret_cast< xml::lite::Element * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Element_setCharacterData_" "', argument " "2"" of type '" "std::string const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Element_setCharacterData_" "', argument " "2"" of type '" "std::string const &""'"); - } - arg2 = reinterpret_cast< std::string * >(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3,SWIGTYPE_p_xml__lite__string_encoding, 0 | 0 ); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Element_setCharacterData_" "', argument " "3"" of type '" "xml::lite::StringEncoding const *""'"); - } - arg3 = reinterpret_cast< xml::lite::StringEncoding * >(argp3); - (arg1)->setCharacterData_((std::string const &)*arg2,(xml::lite::StringEncoding const *)arg3); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Element_setCharacterData__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; - std::string *arg2 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Element_setCharacterData" "', argument " "1"" of type '" "xml::lite::Element *""'"); - } - arg1 = reinterpret_cast< xml::lite::Element * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Element_setCharacterData" "', argument " "2"" of type '" "std::string const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Element_setCharacterData" "', argument " "2"" of type '" "std::string const &""'"); - } - arg2 = reinterpret_cast< std::string * >(argp2); - (arg1)->setCharacterData((std::string const &)*arg2); - resultobj = SWIG_Py_Void(); - return resultobj; + } + } + fail: - return NULL; + SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Element_getCharacterData'.\n" + " Possible C/C++ prototypes are:\n" + " xml::lite::Element::getCharacterData() const\n"); + return 0; } -SWIGINTERN PyObject *_wrap_Element_setCharacterData__SWIG_1(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { +SWIGINTERN PyObject *_wrap_Element_setCharacterData__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { PyObject *resultobj = 0; xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; std::string *arg2 = 0 ; - xml::lite::StringEncoding arg3 ; void *argp1 = 0 ; int res1 = 0 ; void *argp2 = 0 ; int res2 = 0 ; - int val3 ; - int ecode3 = 0 ; - if ((nobjs < 3) || (nobjs > 3)) SWIG_fail; + if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Element, 0 | 0 ); if (!SWIG_IsOK(res1)) { SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Element_setCharacterData" "', argument " "1"" of type '" "xml::lite::Element *""'"); @@ -5990,50 +5435,13 @@ SWIGINTERN PyObject *_wrap_Element_setCharacterData__SWIG_1(PyObject *SWIGUNUSED SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Element_setCharacterData" "', argument " "2"" of type '" "std::string const &""'"); } arg2 = reinterpret_cast< std::string * >(argp2); - ecode3 = SWIG_AsVal_int(swig_obj[2], &val3); - if (!SWIG_IsOK(ecode3)) { - SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "Element_setCharacterData" "', argument " "3"" of type '" "xml::lite::StringEncoding""'"); - } - arg3 = static_cast< xml::lite::StringEncoding >(val3); - (arg1)->setCharacterData((std::string const &)*arg2,arg3); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Element_setCharacterData__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - xml::lite::Element *arg1 = (xml::lite::Element *) 0 ; - coda_oss::u8string *arg2 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - - if ((nobjs < 2) || (nobjs > 2)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Element, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Element_setCharacterData" "', argument " "1"" of type '" "xml::lite::Element *""'"); - } - arg1 = reinterpret_cast< xml::lite::Element * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_sys__U8string, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Element_setCharacterData" "', argument " "2"" of type '" "coda_oss::u8string const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Element_setCharacterData" "', argument " "2"" of type '" "coda_oss::u8string const &""'"); - } - arg2 = reinterpret_cast< coda_oss::u8string * >(argp2); - (arg1)->setCharacterData((coda_oss::u8string const &)*arg2); + (arg1)->setCharacterData((std::string const &)*arg2); resultobj = SWIG_Py_Void(); return resultobj; fail: return NULL; } - SWIGINTERN PyObject *_wrap_Element_setCharacterData(PyObject *self, PyObject *args) { Py_ssize_t argc; PyObject *argv[4] = { @@ -6055,45 +5463,11 @@ SWIGINTERN PyObject *_wrap_Element_setCharacterData(PyObject *self, PyObject *ar } } } - if (argc == 2) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Element, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_sys__U8string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_Element_setCharacterData__SWIG_2(self, argc, argv); - } - } - } - if (argc == 3) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Element, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_int(argv[2], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_Element_setCharacterData__SWIG_1(self, argc, argv); - } - } - } - } fail: SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Element_setCharacterData'.\n" " Possible C/C++ prototypes are:\n" - " xml::lite::Element::setCharacterData(std::string const &)\n" - " xml::lite::Element::setCharacterData(std::string const &,xml::lite::StringEncoding)\n" - " xml::lite::Element::setCharacterData(coda_oss::u8string const &)\n"); + " xml::lite::Element::setCharacterData(std::string const &)\n"); return 0; } @@ -6557,27 +5931,6 @@ SWIGINTERN PyObject *_wrap_delete_Document(PyObject *SWIGUNUSEDPARM(self), PyObj } -SWIGINTERN PyObject *_wrap_Document_clone(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - xml::lite::Document *arg1 = (xml::lite::Document *) 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - PyObject *swig_obj[1] ; - xml::lite::Document *result = 0 ; - - if (!args) SWIG_fail; - swig_obj[0] = args; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Document, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Document_clone" "', argument " "1"" of type '" "xml::lite::Document const *""'"); - } - arg1 = reinterpret_cast< xml::lite::Document * >(argp1); - result = (xml::lite::Document *)((xml::lite::Document const *)arg1)->clone(); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_xml__lite__Document, 0 | 0 ); - return resultobj; -fail: - return NULL; -} SWIGINTERN PyObject *_wrap_Document_createElement__SWIG_0(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { @@ -6682,121 +6035,6 @@ SWIGINTERN PyObject *_wrap_Document_createElement__SWIG_1(PyObject *SWIGUNUSEDPA } -SWIGINTERN PyObject *_wrap_Document_createElement__SWIG_2(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - xml::lite::Document *arg1 = (xml::lite::Document *) 0 ; - std::string *arg2 = 0 ; - std::string *arg3 = 0 ; - std::string *arg4 = 0 ; - xml::lite::StringEncoding arg5 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - int val5 ; - int ecode5 = 0 ; - xml::lite::Element *result = 0 ; - - if ((nobjs < 5) || (nobjs > 5)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Document, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Document_createElement" "', argument " "1"" of type '" "xml::lite::Document *""'"); - } - arg1 = reinterpret_cast< xml::lite::Document * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Document_createElement" "', argument " "2"" of type '" "std::string const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Document_createElement" "', argument " "2"" of type '" "std::string const &""'"); - } - arg2 = reinterpret_cast< std::string * >(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Document_createElement" "', argument " "3"" of type '" "std::string const &""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Document_createElement" "', argument " "3"" of type '" "std::string const &""'"); - } - arg3 = reinterpret_cast< std::string * >(argp3); - res4 = SWIG_ConvertPtr(swig_obj[3], &argp4, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Document_createElement" "', argument " "4"" of type '" "std::string const &""'"); - } - if (!argp4) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Document_createElement" "', argument " "4"" of type '" "std::string const &""'"); - } - arg4 = reinterpret_cast< std::string * >(argp4); - ecode5 = SWIG_AsVal_int(swig_obj[4], &val5); - if (!SWIG_IsOK(ecode5)) { - SWIG_exception_fail(SWIG_ArgError(ecode5), "in method '" "Document_createElement" "', argument " "5"" of type '" "xml::lite::StringEncoding""'"); - } - arg5 = static_cast< xml::lite::StringEncoding >(val5); - result = (xml::lite::Element *)(arg1)->createElement((std::string const &)*arg2,(std::string const &)*arg3,(std::string const &)*arg4,arg5); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_xml__lite__Element, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - - -SWIGINTERN PyObject *_wrap_Document_createElement__SWIG_3(PyObject *SWIGUNUSEDPARM(self), Py_ssize_t nobjs, PyObject **swig_obj) { - PyObject *resultobj = 0; - xml::lite::Document *arg1 = (xml::lite::Document *) 0 ; - std::string *arg2 = 0 ; - std::string *arg3 = 0 ; - coda_oss::u8string *arg4 = 0 ; - void *argp1 = 0 ; - int res1 = 0 ; - void *argp2 = 0 ; - int res2 = 0 ; - void *argp3 = 0 ; - int res3 = 0 ; - void *argp4 = 0 ; - int res4 = 0 ; - xml::lite::Element *result = 0 ; - - if ((nobjs < 4) || (nobjs > 4)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__Document, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Document_createElement" "', argument " "1"" of type '" "xml::lite::Document *""'"); - } - arg1 = reinterpret_cast< xml::lite::Document * >(argp1); - res2 = SWIG_ConvertPtr(swig_obj[1], &argp2, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res2)) { - SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Document_createElement" "', argument " "2"" of type '" "std::string const &""'"); - } - if (!argp2) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Document_createElement" "', argument " "2"" of type '" "std::string const &""'"); - } - arg2 = reinterpret_cast< std::string * >(argp2); - res3 = SWIG_ConvertPtr(swig_obj[2], &argp3, SWIGTYPE_p_std__string, 0 | 0); - if (!SWIG_IsOK(res3)) { - SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "Document_createElement" "', argument " "3"" of type '" "std::string const &""'"); - } - if (!argp3) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Document_createElement" "', argument " "3"" of type '" "std::string const &""'"); - } - arg3 = reinterpret_cast< std::string * >(argp3); - res4 = SWIG_ConvertPtr(swig_obj[3], &argp4, SWIGTYPE_p_sys__U8string, 0 | 0); - if (!SWIG_IsOK(res4)) { - SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "Document_createElement" "', argument " "4"" of type '" "coda_oss::u8string const &""'"); - } - if (!argp4) { - SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "Document_createElement" "', argument " "4"" of type '" "coda_oss::u8string const &""'"); - } - arg4 = reinterpret_cast< coda_oss::u8string * >(argp4); - result = (xml::lite::Element *)(arg1)->createElement((std::string const &)*arg2,(std::string const &)*arg3,(coda_oss::u8string const &)*arg4); - resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_xml__lite__Element, 0 | 0 ); - return resultobj; -fail: - return NULL; -} - SWIGINTERN PyObject *_wrap_Document_createElement(PyObject *self, PyObject *args) { Py_ssize_t argc; @@ -6844,62 +6082,12 @@ SWIGINTERN PyObject *_wrap_Document_createElement(PyObject *self, PyObject *args } } } - if (argc == 4) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Document, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_sys__U8string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - return _wrap_Document_createElement__SWIG_3(self, argc, argv); - } - } - } - } - } - if (argc == 5) { - int _v; - void *vptr = 0; - int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_xml__lite__Document, 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_std__string, SWIG_POINTER_NO_NULL | 0); - _v = SWIG_CheckState(res); - if (_v) { - { - int res = SWIG_AsVal_int(argv[4], NULL); - _v = SWIG_CheckState(res); - } - if (_v) { - return _wrap_Document_createElement__SWIG_2(self, argc, argv); - } - } - } - } - } - } fail: SWIG_Python_RaiseOrModifyTypeError("Wrong number or type of arguments for overloaded function 'Document_createElement'.\n" " Possible C/C++ prototypes are:\n" " xml::lite::Document::createElement(std::string const &,std::string const &,std::string)\n" - " xml::lite::Document::createElement(std::string const &,std::string const &)\n" - " xml::lite::Document::createElement(std::string const &,std::string const &,std::string const &,xml::lite::StringEncoding)\n" - " xml::lite::Document::createElement(std::string const &,std::string const &,coda_oss::u8string const &)\n"); + " xml::lite::Document::createElement(std::string const &,std::string const &)\n"); return 0; } @@ -7904,36 +7092,6 @@ SWIGINTERN PyObject *_wrap_MinidomParser_preserveCharacterData(PyObject *SWIGUNU return NULL; } - -SWIGINTERN PyObject *_wrap_MinidomParser_storeEncoding(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { - PyObject *resultobj = 0; - xml::lite::MinidomParser *arg1 = (xml::lite::MinidomParser *) 0 ; - bool arg2 ; - void *argp1 = 0 ; - int res1 = 0 ; - bool val2 ; - int ecode2 = 0 ; - PyObject *swig_obj[2] ; - - if (!SWIG_Python_UnpackTuple(args, "MinidomParser_storeEncoding", 2, 2, swig_obj)) SWIG_fail; - res1 = SWIG_ConvertPtr(swig_obj[0], &argp1,SWIGTYPE_p_xml__lite__MinidomParser, 0 | 0 ); - if (!SWIG_IsOK(res1)) { - SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "MinidomParser_storeEncoding" "', argument " "1"" of type '" "xml::lite::MinidomParser *""'"); - } - arg1 = reinterpret_cast< xml::lite::MinidomParser * >(argp1); - ecode2 = SWIG_AsVal_bool(swig_obj[1], &val2); - if (!SWIG_IsOK(ecode2)) { - SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "MinidomParser_storeEncoding" "', argument " "2"" of type '" "bool""'"); - } - arg2 = static_cast< bool >(val2); - (arg1)->storeEncoding(arg2); - resultobj = SWIG_Py_Void(); - return resultobj; -fail: - return NULL; -} - - SWIGINTERN PyObject *MinidomParser_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *obj; if (!SWIG_Python_UnpackTuple(args, "swigregister", 1, 1, &obj)) return NULL; @@ -7952,11 +7110,8 @@ static PyMethodDef SwigMethods[] = { { "new_Element", _wrap_new_Element, METH_VARARGS, "\n" "Element()\n" "Element(std::string const & qname, std::string const & uri=\"\", std::string const & characterData=\"\")\n" - "Element(std::string const & qname, std::string const & uri, std::string const & characterData, xml::lite::StringEncoding encoding)\n" - "Element(std::string const & qname, std::string const & uri, coda_oss::u8string const & characterData)\n" "new_Element(Element element) -> Element\n" ""}, - { "Element_clone", _wrap_Element_clone, METH_VARARGS, "Element_clone(Element self, Element element)"}, { "Element_attribute", _wrap_Element_attribute, METH_VARARGS, "Element_attribute(Element self, std::string const & s) -> std::string &"}, { "Element_getElementByTagNameNS", _wrap_Element_getElementByTagNameNS, METH_VARARGS, "\n" "Element_getElementByTagNameNS(Element self, std::nothrow_t arg2, std::string const & qname, bool recurse=False) -> Element\n" @@ -7982,27 +7137,19 @@ static PyMethodDef SwigMethods[] = { { "Element_setNamespaceURI", _wrap_Element_setNamespaceURI, METH_VARARGS, "Element_setNamespaceURI(Element self, std::string prefix, std::string uri)"}, { "Element__print", _wrap_Element__print, METH_VARARGS, "\n" "Element__print(Element self, io::OutputStream & stream)\n" - "Element__print(Element self, io::OutputStream & stream, xml::lite::StringEncoding arg3)\n" ""}, { "Element_prettyPrint", _wrap_Element_prettyPrint, METH_VARARGS, "\n" "Element_prettyPrint(Element self, io::OutputStream & stream, std::string const & formatter=\" \")\n" - "Element_prettyPrint(Element self, io::OutputStream & stream, xml::lite::StringEncoding arg3, std::string const & formatter=\" \")\n" ""}, { "Element_hasElement", _wrap_Element_hasElement, METH_VARARGS, "\n" "Element_hasElement(Element self, std::string const & localName) -> bool\n" "Element_hasElement(Element self, std::string const & uri, std::string const & localName) -> bool\n" ""}, - { "Element_getEncoding", _wrap_Element_getEncoding, METH_O, "Element_getEncoding(Element self) -> coda_oss::optional< xml::lite::StringEncoding > const &"}, { "Element_getCharacterData", _wrap_Element_getCharacterData, METH_VARARGS, "\n" "Element_getCharacterData(Element self) -> std::string\n" - "Element_getCharacterData(Element self, std::string & result) -> coda_oss::optional< xml::lite::StringEncoding > const\n" - "Element_getCharacterData(Element self, coda_oss::u8string & result)\n" ""}, - { "Element_setCharacterData_", _wrap_Element_setCharacterData_, METH_VARARGS, "Element_setCharacterData_(Element self, std::string const & characters, xml::lite::StringEncoding const * arg3)"}, { "Element_setCharacterData", _wrap_Element_setCharacterData, METH_VARARGS, "\n" "Element_setCharacterData(Element self, std::string const & characters)\n" - "Element_setCharacterData(Element self, std::string const & characters, xml::lite::StringEncoding arg3)\n" - "Element_setCharacterData(Element self, coda_oss::u8string const & characters)\n" ""}, { "Element_setLocalName", _wrap_Element_setLocalName, METH_VARARGS, "Element_setLocalName(Element self, std::string const & localName)"}, { "Element_getLocalName", _wrap_Element_getLocalName, METH_O, "Element_getLocalName(Element self) -> std::string"}, @@ -8021,11 +7168,8 @@ static PyMethodDef SwigMethods[] = { { "Element_swiginit", Element_swiginit, METH_VARARGS, NULL}, { "new_Document", _wrap_new_Document, METH_VARARGS, "Document(Element rootNode=None, bool own=True)"}, { "delete_Document", _wrap_delete_Document, METH_O, "delete_Document(Document self)"}, - { "Document_clone", _wrap_Document_clone, METH_O, "Document_clone(Document self) -> Document"}, { "Document_createElement", _wrap_Document_createElement, METH_VARARGS, "\n" "Document_createElement(Document self, std::string const & qname, std::string const & uri, std::string characterData=\"\") -> Element\n" - "Document_createElement(Document self, std::string const & qname, std::string const & uri, std::string const & characterData, xml::lite::StringEncoding arg5) -> Element\n" - "Document_createElement(Document self, std::string const & qname, std::string const & uri, coda_oss::u8string const & characterData) -> Element\n" ""}, { "Document_destroy", _wrap_Document_destroy, METH_O, "Document_destroy(Document self)"}, { "Document_insert", _wrap_Document_insert, METH_VARARGS, "Document_insert(Document self, Element element, Element underThis)"}, @@ -8040,7 +7184,7 @@ static PyMethodDef SwigMethods[] = { ""}, { "Document_swigregister", Document_swigregister, METH_O, NULL}, { "Document_swiginit", Document_swiginit, METH_VARARGS, NULL}, - { "new_MinidomParser", _wrap_new_MinidomParser, METH_VARARGS, "MinidomParser(bool storeEncoding=False)"}, + { "new_MinidomParser", _wrap_new_MinidomParser, METH_VARARGS, "MinidomParser(bool storeEncoding=True)"}, { "delete_MinidomParser", _wrap_delete_MinidomParser, METH_O, "delete_MinidomParser(MinidomParser self)"}, { "MinidomParser_parse", _wrap_MinidomParser_parse, METH_VARARGS, "MinidomParser_parse(MinidomParser self, io::InputStream & _is, int size=io::InputStream::IS_END)"}, { "MinidomParser_clear", _wrap_MinidomParser_clear, METH_O, "MinidomParser_clear(MinidomParser self)"}, @@ -8054,7 +7198,6 @@ static PyMethodDef SwigMethods[] = { ""}, { "MinidomParser_setDocument", _wrap_MinidomParser_setDocument, METH_VARARGS, "MinidomParser_setDocument(MinidomParser self, Document newDocument, bool own=True)"}, { "MinidomParser_preserveCharacterData", _wrap_MinidomParser_preserveCharacterData, METH_VARARGS, "MinidomParser_preserveCharacterData(MinidomParser self, bool preserve)"}, - { "MinidomParser_storeEncoding", _wrap_MinidomParser_storeEncoding, METH_VARARGS, "MinidomParser_storeEncoding(MinidomParser self, bool preserve)"}, { "MinidomParser_swigregister", MinidomParser_swigregister, METH_O, NULL}, { "MinidomParser_swiginit", MinidomParser_swiginit, METH_VARARGS, NULL}, { NULL, NULL, 0, NULL } @@ -8074,12 +7217,9 @@ static swig_type_info _swigt__p_io__OutputStream = {"_p_io__OutputStream", "io:: static swig_type_info _swigt__p_std__nothrow_t = {"_p_std__nothrow_t", "std::nothrow_t *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__string = {"_p_std__string", "std::string *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_std__vectorT_xml__lite__Element_p_t = {"_p_std__vectorT_xml__lite__Element_p_t", "std::vector< xml::lite::Element * > *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_coda_oss__optionalT_xml__lite__string_encoding_t = {"_p_coda_oss__optionalT_xml__lite__string_encoding_t", "coda_oss::optional< xml::lite::StringEncoding > *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_sys__U8string = {"_p_sys__U8string", "coda_oss::u8string *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_xml__lite__Document = {"_p_xml__lite__Document", "xml::lite::Document *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_xml__lite__Element = {"_p_xml__lite__Element", "xml::lite::Element *", 0, 0, (void*)0, 0}; static swig_type_info _swigt__p_xml__lite__MinidomParser = {"_p_xml__lite__MinidomParser", "xml::lite::MinidomParser *", 0, 0, (void*)0, 0}; -static swig_type_info _swigt__p_xml__lite__string_encoding = {"_p_xml__lite__string_encoding", "enum xml::lite::StringEncoding *|xml::lite::StringEncoding *", 0, 0, (void*)0, 0}; static swig_type_info *swig_type_initial[] = { &_swigt__p_XMLReader, @@ -8089,12 +7229,9 @@ static swig_type_info *swig_type_initial[] = { &_swigt__p_std__nothrow_t, &_swigt__p_std__string, &_swigt__p_std__vectorT_xml__lite__Element_p_t, - &_swigt__p_coda_oss__optionalT_xml__lite__string_encoding_t, - &_swigt__p_sys__U8string, &_swigt__p_xml__lite__Document, &_swigt__p_xml__lite__Element, &_swigt__p_xml__lite__MinidomParser, - &_swigt__p_xml__lite__string_encoding, }; static swig_cast_info _swigc__p_XMLReader[] = { {&_swigt__p_XMLReader, 0, 0, 0},{0, 0, 0, 0}}; @@ -8104,12 +7241,9 @@ static swig_cast_info _swigc__p_io__OutputStream[] = { {&_swigt__p_io__OutputSt static swig_cast_info _swigc__p_std__nothrow_t[] = { {&_swigt__p_std__nothrow_t, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__string[] = { {&_swigt__p_std__string, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_std__vectorT_xml__lite__Element_p_t[] = { {&_swigt__p_std__vectorT_xml__lite__Element_p_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_coda_oss__optionalT_xml__lite__string_encoding_t[] = { {&_swigt__p_coda_oss__optionalT_xml__lite__string_encoding_t, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_sys__U8string[] = { {&_swigt__p_sys__U8string, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_xml__lite__Document[] = { {&_swigt__p_xml__lite__Document, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_xml__lite__Element[] = { {&_swigt__p_xml__lite__Element, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info _swigc__p_xml__lite__MinidomParser[] = { {&_swigt__p_xml__lite__MinidomParser, 0, 0, 0},{0, 0, 0, 0}}; -static swig_cast_info _swigc__p_xml__lite__string_encoding[] = { {&_swigt__p_xml__lite__string_encoding, 0, 0, 0},{0, 0, 0, 0}}; static swig_cast_info *swig_cast_initial[] = { _swigc__p_XMLReader, @@ -8119,12 +7253,9 @@ static swig_cast_info *swig_cast_initial[] = { _swigc__p_std__nothrow_t, _swigc__p_std__string, _swigc__p_std__vectorT_xml__lite__Element_p_t, - _swigc__p_coda_oss__optionalT_xml__lite__string_encoding_t, - _swigc__p_sys__U8string, _swigc__p_xml__lite__Document, _swigc__p_xml__lite__Element, _swigc__p_xml__lite__MinidomParser, - _swigc__p_xml__lite__string_encoding, }; @@ -8860,8 +7991,6 @@ SWIG_init(void) { SWIG_InstallConstants(d,swig_const_table); - SWIG_Python_SetConstant(d, "string_encoding_windows_1252",SWIG_From_int(static_cast< int >(xml::lite::StringEncoding::Windows1252))); - SWIG_Python_SetConstant(d, "string_encoding_utf_8",SWIG_From_int(static_cast< int >(xml::lite::StringEncoding::Utf8))); #if PY_VERSION_HEX >= 0x03000000 return m; #else