From 2da7d1ea4502c5054fe966291c830482048a13c2 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 14 Sep 2015 13:16:40 +0200 Subject: [PATCH 001/240] Prepare for an ABI/API-breaking release * .gitignore: 2.6 -> *. * NEWS: Note that the next release will break ABI. * README: 2.6 -> 3.0 * configure.ac: Version 2.90.0, 2.6 -> 3.0, reset LIBXMLXX_SO_VERSION to 0:0:0. * docs/manual/libxml++_without_code.xml: 2.6 -> 3.0 * libxml++/libxml++.h: 2.6 -> 3.0 * libxml++-2.6.pc.in: Rename to libxml++.pc.in. * libxml++.pc.in: Rename from libxml++-2.6.pc.in. Bug #754673. The libxml++-2-40 branch is intended for future 2.40.x releases with the libxml++-2.6 ABI. --- .gitignore | 6 +++--- NEWS | 10 ++++++++-- README | 12 ++++++------ configure.ac | 16 ++++++++++------ docs/manual/libxml++_without_code.xml | 8 ++++---- libxml++-2.6.pc.in => libxml++.pc.in | 0 libxml++/libxml++.h | 8 +++++--- 7 files changed, 36 insertions(+), 24 deletions(-) rename libxml++-2.6.pc.in => libxml++.pc.in (100%) diff --git a/.gitignore b/.gitignore index 2c27b84f..e6428597 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,7 @@ stamp-h? /config.status /configure /configure.lineno -/libxml++-2.6.pc +/libxml++-*.pc /libxml++-*.tar.* /libtool @@ -39,8 +39,8 @@ stamp-h? /docs/reference/Doxyfile /docs/reference/doxygen.log /docs/reference/html/ -/docs/reference/libxml++-2.6.devhelp2 -/docs/reference/libxml++-2.6.tag +/docs/reference/libxml++-*.devhelp2 +/docs/reference/libxml++-*.tag # examples /examples/dom_build/dom_build diff --git a/NEWS b/NEWS index 3f03781a..cee70a16 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,14 @@ +2.90.0 (unstable): + +* Renamed ABI from libxml++-2.6 to libxml++-3.0. + This requires applications to change their pkg-config check to libxml++-3.0 + when they wish to use libxml++ 2.9x or 3.x instead of libxml++ 2.x. + 2.39.2 (unstable): * SaxParser: Fix “double free or corruption” if a std::exception is thrown by a handler method. - (Daniel Trebbien, Kjell Ahlstedt) + (Daniel Trebbien, Kjell Ahlstedt) Bug #753570 * Replace some (deprecated in C++11) std::auto_ptr by std::unique_ptr. There are still some auto_ptrs in header files bug replacing them would break ABI. @@ -17,7 +23,7 @@ * Fix the build with C++11 compilers, such as MS Visual C++ 2013 - Implicit conversions from streams to bool are no longer allowed.) - (Mikhail Titov) + (Mikhail Titov) Bug #748658 * Build: Disable deprecated API in dependencies if --enable-warnings=fatal (Kjell Ahlstedt) * Build: Require libxml2 2.7.7 or later diff --git a/README b/README index 7474a6aa..cb4ff964 100644 --- a/README +++ b/README @@ -1,14 +1,15 @@ libxml++ ------------- -This library provides a C++ interface to XML files. It uses libxml 2 to access -the XML files, and in order to configure libxml++ you must have both libxml and +This library provides a C++ interface to XML files. It uses libxml2 to access +the XML files, and in order to configure libxml++ you must have both libxml2 and pkg-config installed. To get the latest version of libxml++, see http://libxmlplusplus.sourceforge.net/ -To contact the developers, send e-mail to the mailing list. We welcome patches, -but it helps to discuss them first. +To contact the developers, send e-mail to the mailing list at +http://mail.gnome.org/mailman/listinfo/libxmlplusplus-list +We welcome patches, but it helps to discuss them first. Read the file 'INSTALL' for instructions to compile and install the library. @@ -16,6 +17,5 @@ See the examples directory for example code. Use pkg-config to discover the necessary include and linker arguments. For instance, - pkg-config libxml++-2.6 --cflags --libs + pkg-config libxml++-3.0 --cflags --libs Ideally you would use PKG_CHECK_MODULES in your configure.ac file. -See http://www.openismus.com for generic help with that. diff --git a/configure.ac b/configure.ac index 6fce8806..673198b6 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,6 @@ -AC_INIT([libxml++], [2.39.2], +## This file is part of libxml++. + +AC_INIT([libxml++], [2.90.0], [https://bugzilla.gnome.org/enter_bug.cgi?product=libxml%2B%2B], [libxml++], [http://libxmlplusplus.sourceforge.net/]) AC_PREREQ([2.59]) @@ -14,15 +16,17 @@ AM_MAINTAINER_MODE([disable]) AC_ARG_VAR([ACLOCAL_FLAGS], [aclocal flags, e.g. -I ]) MM_PREREQ([0.9.8]) -MM_INIT_MODULE([libxml++-2.6]) +MM_INIT_MODULE([libxml++-3.0]) -# Copy the mm-common .pl scripts into docs/, -# and use them from there, +# Tell mm-common-prepare to copy the mm-common .pl scripts +# and some other files into docs/, and use them from there, # so we can dist them to avoid a tarball-build dependency. MM_CONFIG_DOCTOOL_DIR([docs]) +# libxml++ does not use libtool's versioning system. +# Let LIBXMLXX_SO_VERSION remain equal to 0:0:0. # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -AC_SUBST([LIBXMLXX_SO_VERSION], [2:7:0]) +AC_SUBST([LIBXMLXX_SO_VERSION], [0:0:0]) AC_PROG_CXX MM_AX_CXX_COMPILE_STDCXX_11([noext],[mandatory]) @@ -66,7 +70,7 @@ AC_CONFIG_FILES([Makefile docs/Makefile docs/reference/Doxyfile MSVC_Net2010/libxml++/libxml++.rc - libxml++-2.6.pc]) + ${LIBXMLXX_MODULE_NAME}.pc:libxml++.pc.in]) # Copy the generated configuration headers into the MSVC project directories. AC_CONFIG_COMMANDS([MSVC_Net2010/libxml++/libxml++config.h], diff --git a/docs/manual/libxml++_without_code.xml b/docs/manual/libxml++_without_code.xml index bba9147c..1648f9fa 100644 --- a/docs/manual/libxml++_without_code.xml +++ b/docs/manual/libxml++_without_code.xml @@ -44,10 +44,10 @@ url="http://www.gnome.org">GNOME project, of which libxml++ is a part.libxml++ is packaged by major Linux and *BSD distributions and can be installed from source on Linux and Windows, using any modern compiler, such as g++, SUN Forte, or MSVC++. For instance, to install libxml++ and its documentation on debian, use apt-get or synaptic like so: - # apt-get install libxml++2.6-dev libxml++2.6-doc + # apt-get install libxml++3.0-dev libxml++3.0-doc - To check that you have the libxml++ development packages installed, and that your environment is working properly, try pkg-config libxml++-2.6 --modversion. + To check that you have the libxml++ development packages installed, and that your environment is working properly, try pkg-config libxml++-3.0 --modversion. Links for downloading and more documentation can be found at libxmlplusplus.sourceforge.net. libxml++ is licensed under the LGPL, which allows its use via dynamic linking in both open source and closed-source software. The underlying libxml2 library uses the even more generous MIT licence. @@ -64,11 +64,11 @@ url="http://libxmlplusplus.sourceforge.net">libxmlplusplus.sourceforge.net Compilation and Linking To use libxml++ in your application, you must tell the compiler where to find the include headers and where to find the libxml++ library. libxml++ provides a pkg-config .pc file to make this easy. For instance, the following command will provide the necessary compiler options: - pkg-config libxml++-2.6 --cflags --libs + pkg-config libxml++-3.0 --cflags --libs When using autoconf and automake, this is even easier with the PKG_CHECK_MODULES macro in your configure.ac file. For instance: - PKG_CHECK_MODULES(SOMEAPP, libxml++-2.6 >= 2.38.0) + PKG_CHECK_MODULES(SOMEAPP, libxml++-3.0 >= 3.0.0) AC_SUBST(SOMEAPP_CFLAGS) AC_SUBST(SOMEAPP_LIBS) diff --git a/libxml++-2.6.pc.in b/libxml++.pc.in similarity index 100% rename from libxml++-2.6.pc.in rename to libxml++.pc.in diff --git a/libxml++/libxml++.h b/libxml++/libxml++.h index 1338b48c..8aafb5c3 100644 --- a/libxml++/libxml++.h +++ b/libxml++/libxml++.h @@ -14,7 +14,7 @@ * libxml++ is a C++ wrapper for the libxml2 XML parser and builder library. It presents a * simple C++-like API that can achieve common tasks with less code. * - * See also the libxml++ Tutorial and the libxml++ website. + * See also the libxml++ Tutorial and the libxml++ website. * * @section features Features * @@ -33,12 +33,14 @@ * * If your source file is @c program.cc, you can compile it with: * @code - * g++ program.cc -o program `pkg-config --cflags --libs libxml++-2.6` + * g++ program.cc -o program `pkg-config --cflags --libs libxml++-3.0` * @endcode + * If your version of g++ is not C++11-compliant be default, + * add the @c -std=c++11 or @c -std=c++0x option. * * Alternatively, if using autoconf, use the following in @c configure.ac: * @code - * PKG_CHECK_MODULES([LIBXMLXX], [libxml++-2.6]) + * PKG_CHECK_MODULES([LIBXMLXX], [libxml++-3.0]) * @endcode * Then use the generated @c LIBXMLXX_CFLAGS and @c LIBXMLXX_LIBS variables in * the project @c Makefile.am files. For example: From 8c3b88c5cd013ee9cc83f28f99e38821df99e177 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 17 Sep 2015 09:43:37 +0200 Subject: [PATCH 002/240] Node::get_children(): Propagate const qualifier to children * libxml++/nodes/node.[h|cc]: Add const_NodeList. The const version of get_children() returns const_NodeList instead of const NodeList. * examples/dom_parser/main.cc: Remove unused variable. Bug #338907. --- examples/dom_parser/main.cc | 4 --- libxml++/nodes/node.cc | 56 ++++++++++++++++++++----------------- libxml++/nodes/node.h | 3 +- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/examples/dom_parser/main.cc b/examples/dom_parser/main.cc index 8e9371eb..c81e3d6c 100644 --- a/examples/dom_parser/main.cc +++ b/examples/dom_parser/main.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* main.cc * * Copyright (C) 2002 The libxml++ development team @@ -105,7 +103,6 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) if(!nodeContent) { //Recurse through child nodes: - auto list = node->get_children(); for(const auto& child : node->get_children()) { print_node(child, indentation + 2); //recursive @@ -190,4 +187,3 @@ int main(int argc, char* argv[]) return EXIT_SUCCESS; } - diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index cd3263e7..5042a390 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -26,6 +26,33 @@ namespace // anonymous { +xmlpp::Node* _convert_node(xmlNode* node) +{ + xmlpp::Node* res = nullptr; + if (node) + { + xmlpp::Node::create_wrapper(node); + res = static_cast(node->_private); + } + return res; +} + +// Common part of const and non-const get_children() +template +Tlist get_children_common(const Glib::ustring& name, xmlNode* child) +{ + Tlist children; + + while (child) + { + if (name.empty() || name == (const char*)child->name) + children.push_back(_convert_node(child)); + + child = child->next; + } + return children; +} + // Common part of xmlpp::Node::eval_to_[boolean|number|string] xmlXPathObject* eval_common(const Glib::ustring& xpath, const xmlpp::Node::PrefixNsMap* namespaces, @@ -182,17 +209,6 @@ Node* Node::get_previous_sibling() return static_cast(cobj()->prev->_private); } -static Node* _convert_node(xmlNode* node) -{ - Node* res = nullptr; - if(node) - { - Node::create_wrapper(node); - res = static_cast(node->_private); - } - return res; -} - Node* Node::get_first_child(const Glib::ustring& name) { auto child = impl_->children; @@ -216,24 +232,12 @@ const Node* Node::get_first_child(const Glib::ustring& name) const Node::NodeList Node::get_children(const Glib::ustring& name) { - auto child = impl_->children; - if(!child) - return NodeList(); - - NodeList children; - do - { - if(name.empty() || name == (const char*)child->name) - children.push_back(_convert_node(child)); - } - while((child = child->next)); - - return children; + return get_children_common(name, impl_->children); } -const Node::NodeList Node::get_children(const Glib::ustring& name) const +Node::const_NodeList Node::get_children(const Glib::ustring& name) const { - return const_cast(this)->get_children(name); + return get_children_common(name, impl_->children); } Element* Node::add_child(const Glib::ustring& name, diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index 74d0f0e0..825a1033 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -54,6 +54,7 @@ class Node : public NonCopyable { public: typedef std::list NodeList; + typedef std::list const_NodeList; /** @throws xmlpp::internal_error If @a node is 0. */ @@ -150,7 +151,7 @@ class Node : public NonCopyable * @param name The names of the child nodes to get. If you do not specify a name, then the list will contain all nodes, regardless of their names. * @returns The list of child nodes. */ - const NodeList get_children(const Glib::ustring& name = Glib::ustring()) const; + const_NodeList get_children(const Glib::ustring& name = Glib::ustring()) const; /** Add a child element to this node. * This node must be an element node. From f940edf2829d8d53284c42a35b8a46bf3a5a1e7f Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 17 Sep 2015 10:26:32 +0200 Subject: [PATCH 003/240] Node::find(): Propagate const qualifier to found nodes * libxml++/nodes/node.[h|cc]: Add const_NodeSet. Add non-const versions of find() and let the const versions return const_NodeSet. * examples/dom_xpath/main.cc: Add some const. Bug #338907. --- examples/dom_xpath/main.cc | 10 +-- libxml++/nodes/node.cc | 162 +++++++++++++++++++------------------ libxml++/nodes/node.h | 22 ++++- 3 files changed, 109 insertions(+), 85 deletions(-) diff --git a/examples/dom_xpath/main.cc b/examples/dom_xpath/main.cc index 96bf6638..8000df87 100644 --- a/examples/dom_xpath/main.cc +++ b/examples/dom_xpath/main.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* main.cc * * Copyright (C) 2002 The libxml++ development team @@ -59,19 +57,19 @@ bool xpath_test(const xmlpp::Node* node, const Glib::ustring& xpath) { std::cout << " " << child->get_path(); - auto attribute = dynamic_cast(child); + auto attribute = dynamic_cast(child); if (attribute) std::cout << ", value=\"" << attribute->get_value() << "\""; - auto content_node = dynamic_cast(child); + auto content_node = dynamic_cast(child); if (content_node) std::cout << ", content=\"" << content_node->get_content() << "\""; - auto entity_reference = dynamic_cast(child); + auto entity_reference = dynamic_cast(child); if (entity_reference) std::cout << ", text=\"" << entity_reference->get_original_text() << "\""; - auto element = dynamic_cast(child); + auto element = dynamic_cast(child); if (element) { auto text_node = element->get_child_text(); diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index 5042a390..2b494ecb 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -53,6 +53,81 @@ Tlist get_children_common(const Glib::ustring& name, xmlNode* child) return children; } +// Common part of all overloaded xmlpp::Node::find() methods. +template +Tvector find_common(const Glib::ustring& xpath, + const xmlpp::Node::PrefixNsMap* namespaces, xmlNode* node) +{ + auto ctxt = xmlXPathNewContext(node->doc); + if (!ctxt) + throw xmlpp::internal_error("Could not create XPath context for " + xpath); + ctxt->node = node; + + if (namespaces) + { + for (xmlpp::Node::PrefixNsMap::const_iterator it = namespaces->begin(); + it != namespaces->end(); ++it) + xmlXPathRegisterNs(ctxt, + reinterpret_cast(it->first.c_str()), + reinterpret_cast(it->second.c_str())); + } + + auto result = xmlXPathEval((const xmlChar*)xpath.c_str(), ctxt); + + if (!result) + { + xmlXPathFreeContext(ctxt); + + throw xmlpp::exception("Invalid XPath: " + xpath); + } + + if (result->type != XPATH_NODESET) + { + xmlXPathFreeObject(result); + xmlXPathFreeContext(ctxt); + + throw xmlpp::internal_error("Only nodeset result types are supported."); + } + + auto nodeset = result->nodesetval; + Tvector nodes; + if (nodeset && !xmlXPathNodeSetIsEmpty(nodeset)) + { + const int count = xmlXPathNodeSetGetLength(nodeset); + nodes.reserve(count); + for (int i = 0; i != count; ++i) + { + auto cnode = xmlXPathNodeSetItem(nodeset, i); + if (!cnode) + { + std::cerr << "Node::find(): The xmlNode was null." << std::endl; + continue; + } + + if (cnode->type == XML_NAMESPACE_DECL) + { + //In this case we would cast it to a xmlNs*, + //but this C++ method only returns Nodes. + std::cerr << "Node::find(): Ignoring an xmlNs object." << std::endl; + continue; + } + + //TODO: Check for other cnode->type values? + + nodes.push_back(_convert_node(cnode)); + } + } + else + { + // return empty set + } + + xmlXPathFreeObject(result); + xmlXPathFreeContext(ctxt); + + return nodes; +} + // Common part of xmlpp::Node::eval_to_[boolean|number|string] xmlXPathObject* eval_common(const Glib::ustring& xpath, const xmlpp::Node::PrefixNsMap* namespaces, @@ -451,91 +526,24 @@ Glib::ustring Node::get_path() const return retn; } -static NodeSet find_impl(xmlXPathContext* ctxt, const Glib::ustring& xpath) +NodeSet Node::find(const Glib::ustring& xpath) { - auto result = xmlXPathEval((const xmlChar*)xpath.c_str(), ctxt); - - if(!result) - { - xmlXPathFreeContext(ctxt); - - throw exception("Invalid XPath: " + xpath); - } - - if(result->type != XPATH_NODESET) - { - xmlXPathFreeObject(result); - xmlXPathFreeContext(ctxt); - - throw internal_error("Only nodeset result types are supported."); - } - - auto nodeset = result->nodesetval; - NodeSet nodes; - if( nodeset && !xmlXPathNodeSetIsEmpty(nodeset)) - { - const int count = xmlXPathNodeSetGetLength(nodeset); - nodes.reserve(count); - for (int i = 0; i != count; ++i) - { - auto cnode = xmlXPathNodeSetItem(nodeset, i); - if(!cnode) - { - std::cerr << "Node::find_impl: The xmlNode was null." << std::endl; - continue; - } - - if(cnode->type == XML_NAMESPACE_DECL) - { - //In this case we would cast it to a xmlNs*, - //but this C++ method only returns Nodes. - std::cerr << "Node::find_impl: ignoring an xmlNs object." << std::endl; - continue; - } - - //TODO: Check for other cnode->type values? - - Node::create_wrapper(cnode); - auto cppNode = static_cast(cnode->_private); - nodes.push_back(cppNode); - } - } - else - { - // return empty set - } - - xmlXPathFreeObject(result); - xmlXPathFreeContext(ctxt); - - return nodes; + return find_common(xpath, 0, impl_); } -NodeSet Node::find(const Glib::ustring& xpath) const +const_NodeSet Node::find(const Glib::ustring& xpath) const { - auto ctxt = xmlXPathNewContext(impl_->doc); - if (!ctxt) - throw internal_error("Could not create XPath context for " + xpath); - ctxt->node = impl_; - - return find_impl(ctxt, xpath); + return find_common(xpath, 0, impl_); } -NodeSet Node::find(const Glib::ustring& xpath, - const PrefixNsMap& namespaces) const +NodeSet Node::find(const Glib::ustring& xpath, const PrefixNsMap& namespaces) { - auto ctxt = xmlXPathNewContext(impl_->doc); - if (!ctxt) - throw internal_error("Could not create XPath context for " + xpath); - ctxt->node = impl_; - - for (PrefixNsMap::const_iterator it=namespaces.begin(); - it != namespaces.end(); it++) - xmlXPathRegisterNs(ctxt, - reinterpret_cast(it->first.c_str()), - reinterpret_cast(it->second.c_str())); + return find_common(xpath, &namespaces, impl_); +} - return find_impl(ctxt, xpath); +const_NodeSet Node::find(const Glib::ustring& xpath, const PrefixNsMap& namespaces) const +{ + return find_common(xpath, &namespaces, impl_); } bool Node::eval_to_boolean(const Glib::ustring& xpath, XPathResultType* result_type) const diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index 825a1033..fe701527 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -29,6 +29,7 @@ class Attribute; class Node; typedef std::vector NodeSet; +typedef std::vector const_NodeSet; // xmlpp::XPathResultType is similar to xmlXPathObjectType in libxml2. /** An XPath expression is evaluated to yield a result, which @@ -282,7 +283,15 @@ class Node : public NonCopyable * @throws xmlpp::exception If the XPath expression cannot be evaluated. * @throws xmlpp::internal_error If the result type is not nodeset. */ - NodeSet find(const Glib::ustring& xpath) const; + NodeSet find(const Glib::ustring& xpath); + + /** Find nodes from an XPath expression. + * @param xpath The XPath of the nodes. + * @returns The resulting const_NodeSet. + * @throws xmlpp::exception If the XPath expression cannot be evaluated. + * @throws xmlpp::internal_error If the result type is not nodeset. + */ + const_NodeSet find(const Glib::ustring& xpath) const; /** A map of namespace prefixes to namespace URIs. */ @@ -295,7 +304,16 @@ class Node : public NonCopyable * @throws xmlpp::exception If the XPath expression cannot be evaluated. * @throws xmlpp::internal_error If the result type is not nodeset. */ - NodeSet find(const Glib::ustring& xpath, const PrefixNsMap& namespaces) const; + NodeSet find(const Glib::ustring& xpath, const PrefixNsMap& namespaces); + + /** Find nodes from an XPath expression. + * @param xpath The XPath of the nodes. + * @param namespaces A map of namespace prefixes to namespace URIs to be used while finding. + * @returns The resulting const_NodeSet. + * @throws xmlpp::exception If the XPath expression cannot be evaluated. + * @throws xmlpp::internal_error If the result type is not nodeset. + */ + const_NodeSet find(const Glib::ustring& xpath, const PrefixNsMap& namespaces) const; /** Evaluate an XPath expression. * @param xpath The XPath expression. From 5a2ed1d8e21caa5dab9dcbd655ddfe0f047419f2 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 17 Sep 2015 11:01:59 +0200 Subject: [PATCH 004/240] Element::get_attributes(): Propagate const qualifier to attributes * libxml++/nodes/element.[h|cc]: Add const_AttributeList. The const version of get_attributes() returns const_AttributeList instead of const AttributeList. * examples/dom_parser/main.cc: * examples/dom_xinclude/main.cc: Use "for(const auto&". Bug #338907. --- examples/dom_parser/main.cc | 4 +--- examples/dom_xinclude/main.cc | 4 +--- libxml++/nodes/element.cc | 13 +++++++++---- libxml++/nodes/element.h | 3 ++- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/examples/dom_parser/main.cc b/examples/dom_parser/main.cc index c81e3d6c..26b46d81 100644 --- a/examples/dom_parser/main.cc +++ b/examples/dom_parser/main.cc @@ -75,10 +75,8 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) std::cout << indent << " line = " << node->get_line() << std::endl; //Print attributes: - const auto attributes = nodeElement->get_attributes(); - for(xmlpp::Element::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter) + for (const auto& attribute : nodeElement->get_attributes()) { - const auto attribute = *iter; const auto namespace_prefix = attribute->get_namespace_prefix(); std::cout << indent << " Attribute "; diff --git a/examples/dom_xinclude/main.cc b/examples/dom_xinclude/main.cc index 00312874..71e538c4 100644 --- a/examples/dom_xinclude/main.cc +++ b/examples/dom_xinclude/main.cc @@ -71,10 +71,8 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) std::cout << indent << " Element line = " << node->get_line() << std::endl; //Print attributes: - const auto attributes = nodeElement->get_attributes(); - for (xmlpp::Element::AttributeList::const_iterator iter = attributes.begin(); iter != attributes.end(); ++iter) + for (const auto& attribute : nodeElement->get_attributes()) { - const auto attribute = *iter; const auto namespace_prefix = attribute->get_namespace_prefix(); std::cout << indent << " Attribute "; diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc index a2a4f550..63e47d18 100644 --- a/libxml++/nodes/element.cc +++ b/libxml++/nodes/element.cc @@ -23,18 +23,23 @@ Element::~Element() Element::AttributeList Element::get_attributes() { AttributeList attributes; - for(auto attr = cobj()->properties; attr; attr = attr->next) + for (auto attr = cobj()->properties; attr; attr = attr->next) { Node::create_wrapper(reinterpret_cast(attr)); attributes.push_back(reinterpret_cast(attr->_private)); } - return attributes; } -const Element::AttributeList Element::get_attributes() const +Element::const_AttributeList Element::get_attributes() const { - return const_cast(this)->get_attributes(); + const_AttributeList attributes; + for (auto attr = cobj()->properties; attr; attr = attr->next) + { + Node::create_wrapper(reinterpret_cast(attr)); + attributes.push_back(reinterpret_cast(attr->_private)); + } + return attributes; } Attribute* Element::get_attribute(const Glib::ustring& name, diff --git a/libxml++/nodes/element.h b/libxml++/nodes/element.h index 1cad9bd7..fe23aee2 100644 --- a/libxml++/nodes/element.h +++ b/libxml++/nodes/element.h @@ -27,6 +27,7 @@ class Element : public Node ~Element() override; typedef std::list AttributeList; + typedef std::list const_AttributeList; /** Add a namespace declaration to this node which will apply to this node and all children. * @@ -53,7 +54,7 @@ class Element : public Node /** Obtain the list of explicitly set attributes for this element. * @returns The list of explicitly set attributes. */ - const AttributeList get_attributes() const; + const_AttributeList get_attributes() const; //TODO: There should be a const and non-const version. //See the patch at https://bugzilla.gnome.org/show_bug.cgi?id=632524 From a640bf9548ccb67d59cc168fd651145169e55414 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 17 Sep 2015 11:15:52 +0200 Subject: [PATCH 005/240] Replace xmlpp::NodeSet by xmlpp::Node::NodeSet * libxml++/nodes/node.[h|cc]: Declare the NodeSet and const_NodeSet typedefs inside class Node. That's consistent with how Node::NodeList, Node::PrefixNsMap and Element::AttributeList are declared. --- libxml++/nodes/node.cc | 8 ++++---- libxml++/nodes/node.h | 7 +++---- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index 2b494ecb..d9ba465e 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -526,22 +526,22 @@ Glib::ustring Node::get_path() const return retn; } -NodeSet Node::find(const Glib::ustring& xpath) +Node::NodeSet Node::find(const Glib::ustring& xpath) { return find_common(xpath, 0, impl_); } -const_NodeSet Node::find(const Glib::ustring& xpath) const +Node::const_NodeSet Node::find(const Glib::ustring& xpath) const { return find_common(xpath, 0, impl_); } -NodeSet Node::find(const Glib::ustring& xpath, const PrefixNsMap& namespaces) +Node::NodeSet Node::find(const Glib::ustring& xpath, const PrefixNsMap& namespaces) { return find_common(xpath, &namespaces, impl_); } -const_NodeSet Node::find(const Glib::ustring& xpath, const PrefixNsMap& namespaces) const +Node::const_NodeSet Node::find(const Glib::ustring& xpath, const PrefixNsMap& namespaces) const { return find_common(xpath, &namespaces, impl_); } diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index fe701527..f5b6e55d 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -27,10 +27,6 @@ class TextNode; class Element; class Attribute; -class Node; -typedef std::vector NodeSet; -typedef std::vector const_NodeSet; - // xmlpp::XPathResultType is similar to xmlXPathObjectType in libxml2. /** An XPath expression is evaluated to yield a result, which * has one of the following four basic types: @@ -57,6 +53,9 @@ class Node : public NonCopyable typedef std::list NodeList; typedef std::list const_NodeList; + typedef std::vector NodeSet; + typedef std::vector const_NodeSet; + /** @throws xmlpp::internal_error If @a node is 0. */ explicit Node(_xmlNode* node); From 9c4a8ab554ac76323aae77d07f46a520c5165328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Aksel=20R=C3=B8ysland?= Date: Thu, 17 Sep 2015 13:19:06 +0200 Subject: [PATCH 006/240] Document::get_root_node(): Propagate const qualifier to root Element * libxml++/document.[h|cc]: Let the const version of get_root_node() return a const Element*. Add a non-const version. * examples/sax_parser_build_dom/main.cc: * examples/sax_parser_build_dom/svgdocument.[h|cc]: Add some const. Bug #632522. --- examples/sax_parser_build_dom/main.cc | 5 +---- examples/sax_parser_build_dom/svgdocument.cc | 6 ++---- examples/sax_parser_build_dom/svgdocument.h | 4 +--- libxml++/document.cc | 7 ++++++- libxml++/document.h | 10 +++++++--- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/examples/sax_parser_build_dom/main.cc b/examples/sax_parser_build_dom/main.cc index 92e2c9de..132b51d5 100644 --- a/examples/sax_parser_build_dom/main.cc +++ b/examples/sax_parser_build_dom/main.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* main.cc * * By Dan Dennedy @@ -65,7 +63,7 @@ main(int argc, char* argv[]) auto nl = element->find("//path[@style != '']"); if(!nl.empty()) { - auto path = dynamic_cast(nl[0]); + auto path = dynamic_cast(nl[0]); std::cout << "style of first path node with a style = \"" << path->get_style() << "\"" << std::endl; } } @@ -77,4 +75,3 @@ main(int argc, char* argv[]) return EXIT_SUCCESS; } - diff --git a/examples/sax_parser_build_dom/svgdocument.cc b/examples/sax_parser_build_dom/svgdocument.cc index db4aceb4..b9190536 100644 --- a/examples/sax_parser_build_dom/svgdocument.cc +++ b/examples/sax_parser_build_dom/svgdocument.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* svgdocument.cc * * By Dan Dennedy @@ -25,9 +23,9 @@ namespace SVG { -SVG::Element* Document::get_root() const +const SVG::Element* Document::get_root() const { - return dynamic_cast(get_root_node()); // RTTI + return dynamic_cast(get_root_node()); // RTTI } } //namespace SVG diff --git a/examples/sax_parser_build_dom/svgdocument.h b/examples/sax_parser_build_dom/svgdocument.h index 324d8995..6261b6ad 100644 --- a/examples/sax_parser_build_dom/svgdocument.h +++ b/examples/sax_parser_build_dom/svgdocument.h @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* svgdocument.h * * By Dan Dennedy @@ -32,7 +30,7 @@ namespace SVG { class Document : public xmlpp::Document { public: - SVG::Element* get_root() const; + const SVG::Element* get_root() const; // TODO: add custom document methods }; diff --git a/libxml++/document.cc b/libxml++/document.cc index e4f5c1c5..c3ced5c7 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -223,7 +223,7 @@ void Document::set_internal_subset(const Glib::ustring& name, dtd->_private = new Dtd(dtd); } -Element* Document::get_root_node() const +Element* Document::get_root_node() { auto root = xmlDocGetRootElement(impl_); if(root == nullptr) @@ -235,6 +235,11 @@ Element* Document::get_root_node() const } } +const Element* Document::get_root_node() const +{ + return const_cast(this)->get_root_node(); +} + Element* Document::create_root_node(const Glib::ustring& name, const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) diff --git a/libxml++/document.h b/libxml++/document.h index eaede6cf..a70a566c 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -95,13 +95,17 @@ class Document : NonCopyable const Glib::ustring& external_id, const Glib::ustring& system_id); - //TODO: There should be a const and non-const version. - //See the patch here: https://bugzilla.gnome.org/show_bug.cgi?id=632522 /** Return the root node. * This function does @b not create a default root node if it doesn't exist. * @return A pointer to the root node if it exists, 0 otherwise. */ - Element* get_root_node() const; + Element* get_root_node(); + + /** Return the root node. + * This function does @b not create a default root node if it doesn't exist. + * @return A pointer to the root node if it exists, 0 otherwise. + */ + const Element* get_root_node() const; /** Create the root element node. * If the document already contains a root element node, it is replaced, and From c21bc5df99560b6f3029e51b54e176b7aa5a3fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Knut=20Aksel=20R=C3=B8ysland?= Date: Thu, 17 Sep 2015 13:34:11 +0200 Subject: [PATCH 007/240] Element::get_attribute(): Propagate const qualifier to Attribute * libxml++/nodes/element.[h|cc]: Let the const version of get_attribute() return a const Attribute*. Add a non-const version. Bug #632524. --- libxml++/nodes/element.cc | 8 +++++++- libxml++/nodes/element.h | 15 ++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc index 63e47d18..ea97f6b3 100644 --- a/libxml++/nodes/element.cc +++ b/libxml++/nodes/element.cc @@ -43,7 +43,7 @@ Element::const_AttributeList Element::get_attributes() const } Attribute* Element::get_attribute(const Glib::ustring& name, - const Glib::ustring& ns_prefix) const + const Glib::ustring& ns_prefix) { // An empty ns_prefix means "use no namespace". // The default namespace never applies to an attribute. @@ -70,6 +70,12 @@ Attribute* Element::get_attribute(const Glib::ustring& name, return 0; } +const Attribute* Element::get_attribute(const Glib::ustring& name, + const Glib::ustring& ns_prefix) const +{ + return const_cast(this)->get_attribute(name, ns_prefix); +} + Glib::ustring Element::get_attribute_value(const Glib::ustring& name, const Glib::ustring& ns_prefix) const { const auto attr = get_attribute(name, ns_prefix); diff --git a/libxml++/nodes/element.h b/libxml++/nodes/element.h index fe23aee2..5bb1aa38 100644 --- a/libxml++/nodes/element.h +++ b/libxml++/nodes/element.h @@ -56,8 +56,6 @@ class Element : public Node */ const_AttributeList get_attributes() const; - //TODO: There should be a const and non-const version. - //See the patch at https://bugzilla.gnome.org/show_bug.cgi?id=632524 /** Get the attribute with this name, and optionally with this namespace. * @param name The name of the attribute that will be retrieved. * @param ns_prefix Namespace prefix. @@ -67,7 +65,18 @@ class Element : public Node * of an attribute with a default value. */ Attribute* get_attribute(const Glib::ustring& name, - const Glib::ustring& ns_prefix = Glib::ustring()) const; + const Glib::ustring& ns_prefix = Glib::ustring()); + + /** Get the attribute with this name, and optionally with this namespace. + * @param name The name of the attribute that will be retrieved. + * @param ns_prefix Namespace prefix. + * @return The attribute, or 0 if no suitable Attribute was found. + * Is either an AttributeNode*, pointing to an explicitly set + * attribute, or an AttributeDeclaration*, pointing to the declaration + * of an attribute with a default value. + */ + const Attribute* get_attribute(const Glib::ustring& name, + const Glib::ustring& ns_prefix = Glib::ustring()) const; /** Get the value of the attribute with this name, and optionally with this namespace. * For finer control, you might use get_attribute() and use the methods of the Attribute class. From 14e97f7b1c7e6cd10c39a3ef5607e02a057c29c8 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 17 Sep 2015 15:19:32 +0200 Subject: [PATCH 008/240] Replace remaining auto_ptr by unique_ptr Replace the deprecated std::auto_ptr by std::unique_ptr in header files. Bug #753123. --- libxml++/parsers/saxparser.h | 2 +- libxml++/parsers/textreader.h | 2 +- libxml++/relaxngschema.h | 4 ++-- libxml++/validators/relaxngvalidator.h | 4 ++-- libxml++/validators/schemavalidatorbase.h | 1 - libxml++/validators/xsdvalidator.h | 4 ++-- libxml++/xsdschema.h | 4 ++-- 7 files changed, 10 insertions(+), 11 deletions(-) diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index 6b3405a3..3ed8e1e3 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -216,7 +216,7 @@ class SaxParser : public Parser //TODO: Remove the virtual when we can break ABI? virtual void parse(); - std::auto_ptr<_xmlSAXHandler> sax_handler_; + std::unique_ptr<_xmlSAXHandler> sax_handler_; // A separate xmlpp::Document that is just used for entity resolution, // and never seen in the API: diff --git a/libxml++/parsers/textreader.h b/libxml++/parsers/textreader.h index 5901894d..9acd6cda 100644 --- a/libxml++/parsers/textreader.h +++ b/libxml++/parsers/textreader.h @@ -257,7 +257,7 @@ class TextReader: NonCopyable void * locator); void check_for_exceptions() const; - std::auto_ptr propertyreader; + std::unique_ptr propertyreader; _xmlTextReader* impl_; int severity_; Glib::ustring error_; diff --git a/libxml++/relaxngschema.h b/libxml++/relaxngschema.h index 8df7089b..ffe2eaa4 100644 --- a/libxml++/relaxngschema.h +++ b/libxml++/relaxngschema.h @@ -23,7 +23,7 @@ #include #include -#include // std::auto_ptr +#include // std::unique_ptr #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { @@ -105,7 +105,7 @@ class RelaxNGSchema : public SchemaBase private: struct Impl; - std::auto_ptr pimpl_; + std::unique_ptr pimpl_; }; } // namespace xmlpp diff --git a/libxml++/validators/relaxngvalidator.h b/libxml++/validators/relaxngvalidator.h index f9138a3a..1f86222f 100644 --- a/libxml++/validators/relaxngvalidator.h +++ b/libxml++/validators/relaxngvalidator.h @@ -22,7 +22,7 @@ #define __LIBXMLPP_VALIDATOR_RELAXNGVALIDATOR_H #include -#include // std::auto_ptr +#include // std::unique_ptr namespace Glib { @@ -156,7 +156,7 @@ class RelaxNGValidator : public SchemaValidatorBase private: struct Impl; - std::auto_ptr pimpl_; + std::unique_ptr pimpl_; }; } // namespace xmlpp diff --git a/libxml++/validators/schemavalidatorbase.h b/libxml++/validators/schemavalidatorbase.h index 02b63a7e..85299fd0 100644 --- a/libxml++/validators/schemavalidatorbase.h +++ b/libxml++/validators/schemavalidatorbase.h @@ -20,7 +20,6 @@ #define __LIBXMLPP_VALIDATOR_SCHEMAVALIDATORBASE_H #include -#include // std::auto_ptr namespace Glib { diff --git a/libxml++/validators/xsdvalidator.h b/libxml++/validators/xsdvalidator.h index 2f14cb09..bf65ecd8 100644 --- a/libxml++/validators/xsdvalidator.h +++ b/libxml++/validators/xsdvalidator.h @@ -20,7 +20,7 @@ #define __LIBXMLPP_VALIDATOR_XSDVALIDATOR_H #include -#include // std::auto_ptr +#include // std::unique_ptr namespace Glib { @@ -146,7 +146,7 @@ class XsdValidator : public SchemaValidatorBase private: struct Impl; - std::auto_ptr pimpl_; + std::unique_ptr pimpl_; }; } // namespace xmlpp diff --git a/libxml++/xsdschema.h b/libxml++/xsdschema.h index 13330257..8220e4e7 100644 --- a/libxml++/xsdschema.h +++ b/libxml++/xsdschema.h @@ -21,7 +21,7 @@ #include #include -#include // std::auto_ptr +#include // std::unique_ptr #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { @@ -96,7 +96,7 @@ class XsdSchema : public SchemaBase private: struct Impl; - std::auto_ptr pimpl_; + std::unique_ptr pimpl_; }; } // namespace xmlpp From 03e96a1ae6c5665d0ed745e3b0cd1f08333e525f Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 21 Sep 2015 09:08:10 +0200 Subject: [PATCH 009/240] Parser: Replace ExtraParserData by private Pimpl struct * libxml++/parsers/parser.[h|cc]: Replace the ExtraParserData struct in parser.cc by a private Parser::Pimpl struct. Move some protected data to Pimpl. Add pure virtual parse_memory_raw(). Default in DOM parser is to throw both parse errors and validity errors in exceptions. * libxml++/parsers/domparser.h: * libxml++/parsers/saxparser.h: Add override to parse_memory_raw(). * libxml++/parsers/saxparser.cc: Call set_throw_messages(false) in ctor. Bug #754673. --- libxml++/parsers/domparser.h | 2 +- libxml++/parsers/parser.cc | 173 ++++++++++++++-------------------- libxml++/parsers/parser.h | 68 ++++++------- libxml++/parsers/saxparser.cc | 3 + libxml++/parsers/saxparser.h | 2 +- 5 files changed, 111 insertions(+), 137 deletions(-) diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index f90aa7ad..cc5bc91d 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -63,7 +63,7 @@ class DomParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - void parse_memory_raw(const unsigned char* contents, size_type bytes_count); + void parse_memory_raw(const unsigned char* contents, size_type bytes_count) override; /** Parse an XML document from a stream. * If the parser already contains a document, that document and all its nodes diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc index bd3865c8..70d9eb84 100644 --- a/libxml++/parsers/parser.cc +++ b/libxml++/parsers/parser.cc @@ -4,150 +4,106 @@ * included with libxml++ as the file COPYING. */ -// Include glibmm/threads.h first. It must be the first file to include glib.h, -// because it temporarily undefines G_DISABLE_DEPRECATED while it includes glib.h. -#include // For Glib::Threads::Mutex. Needed until the next API/ABI break. - #include "libxml++/exceptions/wrapped_exception.h" #include "libxml++/parsers/parser.h" #include -#include //For unique_ptr. -#include - -//TODO: See several TODOs in parser.h for changes at the next API/ABI break. - -namespace // anonymous +namespace xmlpp { -// These are new data members that can't be added to xmlpp::Parser now, -// because it would break ABI. -struct ExtraParserData + +struct Parser::Impl { - // Strange default values for throw_*_messages chosen for backward compatibility. - ExtraParserData() - : throw_parser_messages_(false), throw_validity_messages_(true), + Impl() + : + throw_messages_(true), validate_(false), substitute_entities_(false), include_default_attributes_(false), set_options_(0), clear_options_(0) {} + // Built gradually - used in an exception at the end of parsing. Glib::ustring parser_error_; Glib::ustring parser_warning_; - bool throw_parser_messages_; - bool throw_validity_messages_; + Glib::ustring validate_error_; + Glib::ustring validate_warning_; + + bool throw_messages_; + bool validate_; + bool substitute_entities_; bool include_default_attributes_; int set_options_; int clear_options_; }; -std::map extra_parser_data; -// Different Parser instances may run in different threads. -// Accesses to extra_parser_data must be thread-safe. -Glib::Threads::Mutex extra_parser_data_mutex; - -void on_parser_error(const xmlpp::Parser* parser, const Glib::ustring& message) -{ - Glib::Threads::Mutex::Lock lock(extra_parser_data_mutex); - //Throw an exception later when the whole message has been received: - extra_parser_data[parser].parser_error_ += message; -} - -void on_parser_warning(const xmlpp::Parser* parser, const Glib::ustring& message) -{ - Glib::Threads::Mutex::Lock lock(extra_parser_data_mutex); - //Throw an exception later when the whole message has been received: - extra_parser_data[parser].parser_warning_ += message; -} -} // anonymous - -namespace xmlpp { - Parser::Parser() -: context_(nullptr), exception_(nullptr), validate_(false), substitute_entities_(false) //See doxygen comment on set_substiute_entities(). +: context_(nullptr), exception_(nullptr), pimpl_(new Impl) { - } Parser::~Parser() { release_underlying(); delete exception_; - Glib::Threads::Mutex::Lock lock(extra_parser_data_mutex); - extra_parser_data.erase(this); } void Parser::set_validate(bool val) { - validate_ = val; + pimpl_->validate_ = val; } bool Parser::get_validate() const { - return validate_; + return pimpl_->validate_; } void Parser::set_substitute_entities(bool val) { - substitute_entities_ = val; + pimpl_->substitute_entities_ = val; } bool Parser::get_substitute_entities() const { - return substitute_entities_; + return pimpl_->substitute_entities_; } void Parser::set_throw_messages(bool val) { - Glib::Threads::Mutex::Lock lock(extra_parser_data_mutex); - extra_parser_data[this].throw_parser_messages_ = val; - extra_parser_data[this].throw_validity_messages_ = val; + pimpl_->throw_messages_ = val; } bool Parser::get_throw_messages() const { - Glib::Threads::Mutex::Lock lock(extra_parser_data_mutex); - return extra_parser_data[this].throw_parser_messages_; + return pimpl_->throw_messages_; } void Parser::set_include_default_attributes(bool val) { - Glib::Threads::Mutex::Lock lock(extra_parser_data_mutex); - extra_parser_data[this].include_default_attributes_ = val; + pimpl_->include_default_attributes_ = val; } bool Parser::get_include_default_attributes() { - Glib::Threads::Mutex::Lock lock(extra_parser_data_mutex); - return extra_parser_data[this].include_default_attributes_; + return pimpl_->include_default_attributes_; } void Parser::set_parser_options(int set_options, int clear_options) { - Glib::Threads::Mutex::Lock lock(extra_parser_data_mutex); - extra_parser_data[this].set_options_ = set_options; - extra_parser_data[this].clear_options_ = clear_options; + pimpl_->set_options_ = set_options; + pimpl_->clear_options_ = clear_options; } void Parser::get_parser_options(int& set_options, int& clear_options) { - Glib::Threads::Mutex::Lock lock(extra_parser_data_mutex); - set_options = extra_parser_data[this].set_options_; - clear_options = extra_parser_data[this].clear_options_; + set_options = pimpl_->set_options_; + clear_options = pimpl_->clear_options_; } void Parser::initialize_context() { - Glib::Threads::Mutex::Lock lock(extra_parser_data_mutex); - //Clear these temporary buffers: - extra_parser_data[this].parser_error_.erase(); - extra_parser_data[this].parser_warning_.erase(); - validate_error_.erase(); - validate_warning_.erase(); - - // Take a copy of the extra data, so we don't have to access - // the extra_parser_data map more than necessary. - const auto extra_parser_data_this = extra_parser_data[this]; - lock.release(); + pimpl_->parser_error_.erase(); + pimpl_->parser_warning_.erase(); + pimpl_->validate_error_.erase(); + pimpl_->validate_warning_.erase(); //Disactivate any non-standards-compliant libxml1 features. //These are disactivated by default, but if we don't deactivate them for each context @@ -157,28 +113,28 @@ void Parser::initialize_context() //Turn on/off validation, entity substitution and default attribute inclusion. int options = context_->options; - if (validate_) + if (pimpl_->validate_) options |= XML_PARSE_DTDVALID; else options &= ~XML_PARSE_DTDVALID; - if (substitute_entities_) + if (pimpl_->substitute_entities_) options |= XML_PARSE_NOENT; else options &= ~XML_PARSE_NOENT; - if (extra_parser_data_this.include_default_attributes_) + if (pimpl_->include_default_attributes_) options |= XML_PARSE_DTDATTR; else options &= ~XML_PARSE_DTDATTR; //Turn on/off any parser options. - options |= extra_parser_data_this.set_options_; - options &= ~extra_parser_data_this.clear_options_; + options |= pimpl_->set_options_; + options &= ~pimpl_->clear_options_; xmlCtxtUseOptions(context_, options); - if (context_->sax && extra_parser_data_this.throw_parser_messages_) + if (context_->sax && pimpl_->throw_messages_) { //Tell the parser context about the callbacks. context_->sax->fatalError = &callback_parser_error; @@ -186,7 +142,7 @@ void Parser::initialize_context() context_->sax->warning = &callback_parser_warning; } - if (extra_parser_data_this.throw_validity_messages_) + if (pimpl_->throw_messages_) { //Tell the validity context about the callbacks: //(These are only called if validation is on - see above) @@ -194,7 +150,7 @@ void Parser::initialize_context() context_->vctxt.warning = &callback_validity_warning; } - //Allow the callback_validity_*() methods to retrieve the C++ instance: + //Allow callback_error_or_warning() to retrieve the C++ instance: context_->_private = this; } @@ -214,51 +170,61 @@ void Parser::release_underlying() } } +void Parser::on_parser_error(const Glib::ustring& message) +{ + //Throw an exception later when the whole message has been received: + pimpl_->parser_error_ += message; +} + +void Parser::on_parser_warning(const Glib::ustring& message) +{ + //Throw an exception later when the whole message has been received: + pimpl_->parser_warning_ += message; +} void Parser::on_validity_error(const Glib::ustring& message) { //Throw an exception later when the whole message has been received: - validate_error_ += message; + pimpl_->validate_error_ += message; } void Parser::on_validity_warning(const Glib::ustring& message) { //Throw an exception later when the whole message has been received: - validate_warning_ += message; + pimpl_->validate_warning_ += message; } -void Parser::check_for_validity_messages() // Also checks parser messages +void Parser::check_for_error_and_warning_messages() { Glib::ustring msg(exception_ ? exception_->what() : ""); bool parser_msg = false; bool validity_msg = false; - Glib::Threads::Mutex::Lock lock(extra_parser_data_mutex); - if (!extra_parser_data[this].parser_error_.empty()) + if (!pimpl_->parser_error_.empty()) { parser_msg = true; - msg += "\nParser error:\n" + extra_parser_data[this].parser_error_; - extra_parser_data[this].parser_error_.erase(); + msg += "\nParser error:\n" + pimpl_->parser_error_; + pimpl_->parser_error_.erase(); } - if (!extra_parser_data[this].parser_warning_.empty()) + if (!pimpl_->parser_warning_.empty()) { parser_msg = true; - msg += "\nParser warning:\n" + extra_parser_data[this].parser_warning_; - extra_parser_data[this].parser_warning_.erase(); + msg += "\nParser warning:\n" + pimpl_->parser_warning_; + pimpl_->parser_warning_.erase(); } - if (!validate_error_.empty()) + if (!pimpl_->validate_error_.empty()) { validity_msg = true; - msg += "\nValidity error:\n" + validate_error_; - validate_error_.erase(); + msg += "\nValidity error:\n" + pimpl_->validate_error_; + pimpl_->validate_error_.erase(); } - if (!validate_warning_.empty()) + if (!pimpl_->validate_warning_.empty()) { validity_msg = true; - msg += "\nValidity warning:\n" + validate_warning_; - validate_warning_.erase(); + msg += "\nValidity warning:\n" + pimpl_->validate_warning_; + pimpl_->validate_warning_.erase(); } if (parser_msg || validity_msg) @@ -271,6 +237,7 @@ void Parser::check_for_validity_messages() // Also checks parser messages } } +//static void Parser::callback_parser_error(void* ctx, const char* msg, ...) { va_list var_args; @@ -279,6 +246,7 @@ void Parser::callback_parser_error(void* ctx, const char* msg, ...) va_end(var_args); } +//static void Parser::callback_parser_warning(void* ctx, const char* msg, ...) { va_list var_args; @@ -287,6 +255,7 @@ void Parser::callback_parser_warning(void* ctx, const char* msg, ...) va_end(var_args); } +//static void Parser::callback_validity_error(void* ctx, const char* msg, ...) { va_list var_args; @@ -295,6 +264,7 @@ void Parser::callback_validity_error(void* ctx, const char* msg, ...) va_end(var_args); } +//static void Parser::callback_validity_warning(void* ctx, const char* msg, ...) { va_list var_args; @@ -303,6 +273,7 @@ void Parser::callback_validity_warning(void* ctx, const char* msg, ...) va_end(var_args); } +//static void Parser::callback_error_or_warning(MsgType msg_type, void* ctx, const char* msg, va_list var_args) { @@ -334,10 +305,10 @@ void Parser::callback_error_or_warning(MsgType msg_type, void* ctx, switch (msg_type) { case MsgParserError: - on_parser_error(parser, ubuff); + parser->on_parser_error(ubuff); break; case MsgParserWarning: - on_parser_warning(parser, ubuff); + parser->on_parser_warning(ubuff); break; case MsgValidityError: parser->on_validity_error(ubuff); @@ -372,7 +343,7 @@ void Parser::handleException(const exception& e) void Parser::check_for_exception() { - check_for_validity_messages(); + check_for_error_and_warning_messages(); if(exception_) { diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index 96034af8..21f8a353 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -17,6 +17,7 @@ #include #include //For va_list. +#include // std::unique_ptr #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { @@ -28,6 +29,7 @@ namespace xmlpp { /** XML parser. * + * Abstract base class for DOM parser and SAX parser. */ class Parser : NonCopyable { @@ -37,39 +39,45 @@ class Parser : NonCopyable typedef unsigned int size_type; - //TODO: Remove virtuals when we can break ABI. - /** By default, the parser will not validate the XML file. * @param val Whether the document should be validated. */ - virtual void set_validate(bool val = true); + void set_validate(bool val = true); /** See set_validate(). * @returns Whether the parser will validate the XML file. */ - virtual bool get_validate() const; + bool get_validate() const; /** Set whether the parser will automatically substitute entity references with the text of the entities' definitions. * For instance, this affects the text returned by ContentNode::get_content(). * By default, the parser will not substitute entities, so that you do not lose the entity reference information. * @param val Whether entities will be substitued. */ - virtual void set_substitute_entities(bool val = true); + void set_substitute_entities(bool val = true); /** See set_substitute_entities(). * @returns Whether entities will be substituted during parsing. */ - virtual bool get_substitute_entities() const; + bool get_substitute_entities() const; /** Set whether the parser will collect and throw error and warning messages. + * * If messages are collected, they are included in an exception thrown at the - * end of parsing. If the messages are not collected, they are written on - * stderr. The messages written on stderr are slightly different, and may - * be preferred in a program started from the command-line. + * end of parsing. + * + * - DOM parser + * + * If the messages are not collected, they are written on stderr. + * The messages written on stderr are slightly different, and may be + * preferred in a program started from the command-line. The default, if + * set_throw_messages() is not called, is to collect and throw messages. + * + * - SAX parser * - * The default, if set_throw_messages() is not called, is to collect and throw - * only messages from validation. Other messages are written to stderr. - * This is for backward compatibility, and may change in the future. + * If the messages are not collected, the error handling on_*() methods in + * the user's SAX parser subclass are called. This is the default, if + * set_throw_messages() is not called. * * @newin{2,36} * @@ -82,7 +90,6 @@ class Parser : NonCopyable * @newin{2,36} * * @returns Whether messages will be collected and thrown in an exception. - * The default with only validation messages thrown is returned as false. */ bool get_throw_messages() const; @@ -136,7 +143,12 @@ class Parser : NonCopyable */ virtual void parse_file(const Glib::ustring& filename) = 0; - //TODO: In a future ABI-break, add a virtual void parse_memory_raw(const unsigned char* contents, size_type bytes_count); + /** Parse an XML document from raw memory. + * @throw exception + * @param contents The XML document as an array of bytes. + * @param bytes_count The number of bytes in the @a contents array. + */ + virtual void parse_memory_raw(const unsigned char* contents, size_type bytes_count) = 0; /** Parse an XML document from a string. * @throw exception @@ -156,19 +168,16 @@ class Parser : NonCopyable virtual void initialize_context(); virtual void release_underlying(); - //TODO: In a future ABI-break, add these virtual functions. - //virtual void on_parser_error(const Glib::ustring& message); - //virtual void on_parser_warning(const Glib::ustring& message); + virtual void on_parser_error(const Glib::ustring& message); + virtual void on_parser_warning(const Glib::ustring& message); virtual void on_validity_error(const Glib::ustring& message); virtual void on_validity_warning(const Glib::ustring& message); virtual void handleException(const exception& e); virtual void check_for_exception(); - //TODO: In a future API/ABI-break, change the name of this function to - // something more appropriate, such as check_for_error_and_warning_messages. - virtual void check_for_validity_messages(); - + virtual void check_for_error_and_warning_messages(); + static void callback_parser_error(void* ctx, const char* msg, ...); static void callback_parser_warning(void* ctx, const char* msg, ...); static void callback_validity_error(void* ctx, const char* msg, ...); @@ -187,19 +196,10 @@ class Parser : NonCopyable _xmlParserCtxt* context_; exception* exception_; - //TODO: In a future ABI-break, add these members. - //bool throw_messages_; - //Glib::ustring parser_error_; - //Glib::ustring parser_warning_; - Glib::ustring validate_error_; - Glib::ustring validate_warning_; //Built gradually - used in an exception at the end of parsing. - - bool validate_; - bool substitute_entities_; - //TODO: In a future ABI-break, add these members. - //bool include_default_attributes_; - //int set_options_; - //int clear_options_; + +private: + struct Impl; + std::unique_ptr pimpl_; }; /** Equivalent to Parser::parse_stream(). diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index 17531b20..ea817625 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -77,6 +77,9 @@ SaxParser::SaxParser(bool use_get_entity) 0, // serror }; *sax_handler_ = temp; + + // The default action is to call on_warning(), on_error(), on_fatal_error(). + set_throw_messages(false); } SaxParser::~SaxParser() diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index 3ed8e1e3..846c959b 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -103,7 +103,7 @@ class SaxParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - void parse_memory_raw(const unsigned char* contents, size_type bytes_count); + void parse_memory_raw(const unsigned char* contents, size_type bytes_count) override; /** Parse an XML document from a stream. * @param in The stream. From 75c0b1c9ed7fd86c99df9c7207c43b122deb9e96 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 22 Sep 2015 09:00:42 +0200 Subject: [PATCH 010/240] Remove wrapped_exception * libxml++/exceptions/wrapped_exception.[h|cc]: Remove these files. * libxml++/filelist.am: Remove wrapped_exception.h. * libxml++/validators/validator.[h|cc]: * libxml++/parsers/parser.[h|cc]: Replace handleException(const exception&) by handle_exception(). Replace exception* exception_ by std::exception_ptr exception_ptr_. * libxml++/parsers/saxparser.cc: Call handle_exception() instead of handleException(). Bug #754673. --- libxml++/exceptions/wrapped_exception.cc | 42 -------- libxml++/exceptions/wrapped_exception.h | 56 ----------- libxml++/filelist.am | 3 +- libxml++/parsers/parser.cc | 56 ++++++----- libxml++/parsers/parser.h | 8 +- libxml++/parsers/saxparser.cc | 118 ++++++----------------- libxml++/validators/validator.cc | 61 ++++++------ libxml++/validators/validator.h | 10 +- 8 files changed, 110 insertions(+), 244 deletions(-) delete mode 100644 libxml++/exceptions/wrapped_exception.cc delete mode 100644 libxml++/exceptions/wrapped_exception.h diff --git a/libxml++/exceptions/wrapped_exception.cc b/libxml++/exceptions/wrapped_exception.cc deleted file mode 100644 index 8799e741..00000000 --- a/libxml++/exceptions/wrapped_exception.cc +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2015 The libxml++ development team - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "wrapped_exception.h" - -namespace xmlpp -{ - -wrapped_exception::wrapped_exception(std::exception_ptr exception_ptr) - : exception("Wrapped exception"), exception_ptr_(exception_ptr) -{ -} - -wrapped_exception::~wrapped_exception() noexcept -{ -} - -void wrapped_exception::Raise() const -{ - std::rethrow_exception(exception_ptr_); -} - -exception* wrapped_exception::Clone() const -{ - return new wrapped_exception(exception_ptr_); -} - -} // namespace xmlpp diff --git a/libxml++/exceptions/wrapped_exception.h b/libxml++/exceptions/wrapped_exception.h deleted file mode 100644 index 6fa7baca..00000000 --- a/libxml++/exceptions/wrapped_exception.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2015 The libxml++ development team - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __LIBXMLPP_WRAPPED_EXCEPTION_H -#define __LIBXMLPP_WRAPPED_EXCEPTION_H - -#include - -#include - -namespace xmlpp -{ - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -//TODO: At the next ABI break, consider changing -// exception* exception_; -// to -// std::exception_ptr exception_ptr_; -// in xmlpp::Parser and xmlpp::Validator, and removing xmlpp::wrapped_exception. - -/** Helper class for propagating an exception through C code. - * Should not be used by applications. - * - * @newin{2,40} - */ -class wrapped_exception : public exception -{ -public: - explicit wrapped_exception(std::exception_ptr exception_ptr); - ~wrapped_exception() noexcept override; - - void Raise() const override; - exception* Clone() const override; - -private: - std::exception_ptr exception_ptr_; -}; -#endif //DOXYGEN_SHOULD_SKIP_THIS - -} // namespace xmlpp - -#endif // __LIBXMLPP_WRAPPED_EXCEPTION_H diff --git a/libxml++/filelist.am b/libxml++/filelist.am index 68a119db..b9b1f5b9 100644 --- a/libxml++/filelist.am +++ b/libxml++/filelist.am @@ -16,8 +16,7 @@ h_exceptions_sources_public = \ exceptions/exception.h \ exceptions/parse_error.h \ exceptions/validity_error.h \ - exceptions/internal_error.h \ - exceptions/wrapped_exception.h + exceptions/internal_error.h h_io_sources_public = \ io/istreamparserinputbuffer.h \ io/outputbuffer.h \ diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc index 70d9eb84..e45a9051 100644 --- a/libxml++/parsers/parser.cc +++ b/libxml++/parsers/parser.cc @@ -4,7 +4,6 @@ * included with libxml++ as the file COPYING. */ -#include "libxml++/exceptions/wrapped_exception.h" #include "libxml++/parsers/parser.h" #include @@ -35,14 +34,13 @@ struct Parser::Impl }; Parser::Parser() -: context_(nullptr), exception_(nullptr), pimpl_(new Impl) +: context_(nullptr), exception_ptr_(nullptr), pimpl_(new Impl) { } Parser::~Parser() { release_underlying(); - delete exception_; } void Parser::set_validate(bool val) @@ -195,7 +193,20 @@ void Parser::on_validity_warning(const Glib::ustring& message) void Parser::check_for_error_and_warning_messages() { - Glib::ustring msg(exception_ ? exception_->what() : ""); + Glib::ustring msg; + try + { + if (exception_ptr_) + std::rethrow_exception(exception_ptr_); + } + catch (const std::exception& e) + { + msg = e.what(); + } + catch (...) + { + msg = "Unknown exception\n"; + } bool parser_msg = false; bool validity_msg = false; @@ -227,13 +238,16 @@ void Parser::check_for_error_and_warning_messages() pimpl_->validate_warning_.erase(); } - if (parser_msg || validity_msg) + try { - delete exception_; if (validity_msg) - exception_ = new validity_error(msg); - else - exception_ = new parse_error(msg); + throw validity_error(msg); + else if (parser_msg) + throw parse_error(msg); + } + catch (...) + { + exception_ptr_ = std::current_exception(); } } @@ -318,24 +332,19 @@ void Parser::callback_error_or_warning(MsgType msg_type, void* ctx, break; } } - catch(const exception& e) - { - parser->handleException(e); - } - catch(...) + catch (...) { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } } } -void Parser::handleException(const exception& e) +void Parser::handle_exception() { - delete exception_; - exception_ = e.Clone(); + exception_ptr_ = std::current_exception(); - if(context_) + if (context_) xmlStopParser(context_); //release_underlying(); @@ -345,13 +354,12 @@ void Parser::check_for_exception() { check_for_error_and_warning_messages(); - if(exception_) + if (exception_ptr_) { - std::unique_ptr tmp(exception_); - exception_ = nullptr; - tmp->Raise(); + std::exception_ptr tmp(exception_ptr_); + exception_ptr_ = nullptr; + std::rethrow_exception(tmp); } } } // namespace xmlpp - diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index 21f8a353..6cf9b582 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -16,8 +16,9 @@ #include #include -#include //For va_list. +#include // va_list #include // std::unique_ptr +#include // std::exception_ptr #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { @@ -173,7 +174,8 @@ class Parser : NonCopyable virtual void on_validity_error(const Glib::ustring& message); virtual void on_validity_warning(const Glib::ustring& message); - virtual void handleException(const exception& e); + /// To be called in an exception handler. + virtual void handle_exception(); virtual void check_for_exception(); virtual void check_for_error_and_warning_messages(); @@ -195,7 +197,7 @@ class Parser : NonCopyable const char* msg, va_list var_args); _xmlParserCtxt* context_; - exception* exception_; + std::exception_ptr exception_ptr_; private: struct Impl; diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index ea817625..69ebae04 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -7,7 +7,6 @@ * 2002/01/21 Valentin Rusu - added CDATA handlers */ -#include "libxml++/exceptions/wrapped_exception.h" #include "libxml++/parsers/saxparser.h" #include "libxml++/nodes/element.h" #include "libxml++/keepblanks.h" @@ -245,8 +244,7 @@ void SaxParser::parse_stream(std::istream& in) //TODO: Shouldn't we use a Glib::ustring here, and some alternative to std::getline()? int firstParseError = XML_ERR_OK; std::string line; - while( ( ! exception_ ) - && std::getline(in, line)) + while (!exception_ptr_ && std::getline(in, line)) { // since getline does not get the line separator, we have to add it since the parser care // about layout in certain cases. @@ -262,7 +260,7 @@ void SaxParser::parse_stream(std::istream& in) firstParseError = parseError; } - if( ! exception_ ) + if (!exception_ptr_) { //This is called just to terminate parsing. const int parseError = xmlParseChunk(context_, 0 /* chunk */, 0 /* size */, 1 /* terminate (1 or 0) */); @@ -314,7 +312,7 @@ void SaxParser::parse_chunk_raw(const unsigned char* contents, size_type bytes_c xmlCtxtResetLastError(context_); int parseError = XML_ERR_OK; - if(!exception_) + if (!exception_ptr_) parseError = xmlParseChunk(context_, (const char*)contents, bytes_count, 0 /* don't terminate */); check_for_exception(); @@ -355,7 +353,7 @@ void SaxParser::finish_chunk_parsing() xmlCtxtResetLastError(context_); int parseError = XML_ERR_OK; - if(!exception_) + if (!exception_ptr_) //This is called just to terminate parsing. parseError = xmlParseChunk(context_, 0 /* chunk */, 0 /* size */, 1 /* terminate (1 or 0) */); @@ -384,13 +382,9 @@ xmlEntityPtr SaxParserCallback::get_entity(void* context, const xmlChar* name) { result = parser->on_get_entity((const char*)name); } - catch(const exception& e) + catch (...) { - parser->handleException(e); - } - catch(...) - { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } return result; @@ -410,13 +404,9 @@ void SaxParserCallback::entity_decl(void* context, const xmlChar* name, int type ( systemId ? Glib::ustring((const char*)systemId) : ""), ( content ? Glib::ustring((const char*)content) : "") ); } - catch(const exception& e) - { - parser->handleException(e); - } - catch(...) + catch (...) { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } @@ -429,13 +419,9 @@ void SaxParserCallback::start_document(void* context) { parser->on_start_document(); } - catch(const exception& e) + catch (...) { - parser->handleException(e); - } - catch(...) - { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } @@ -444,20 +430,16 @@ void SaxParserCallback::end_document(void* context) auto the_context = static_cast<_xmlParserCtxt*>(context); auto parser = static_cast(the_context->_private); - if(parser->exception_) + if (parser->exception_ptr_) return; try { parser->on_end_document(); } - catch(const exception& e) + catch (...) { - parser->handleException(e); - } - catch(...) - { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } @@ -479,13 +461,9 @@ void SaxParserCallback::start_element(void* context, { parser->on_start_element(Glib::ustring((const char*) name), attributes); } - catch(const exception& e) - { - parser->handleException(e); - } - catch(...) + catch (...) { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } @@ -498,13 +476,9 @@ void SaxParserCallback::end_element(void* context, const xmlChar* name) { parser->on_end_element(Glib::ustring((const char*) name)); } - catch(const exception& e) + catch (...) { - parser->handleException(e); - } - catch(...) - { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } @@ -523,13 +497,9 @@ void SaxParserCallback::characters(void * context, const xmlChar* ch, int len) reinterpret_cast(ch), reinterpret_cast(ch + len) ) ); } - catch(const exception& e) - { - parser->handleException(e); - } - catch(...) + catch (...) { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } @@ -542,13 +512,9 @@ void SaxParserCallback::comment(void* context, const xmlChar* value) { parser->on_comment(Glib::ustring((const char*) value)); } - catch(const exception& e) - { - parser->handleException(e); - } - catch(...) + catch (...) { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } @@ -568,13 +534,9 @@ void SaxParserCallback::warning(void* context, const char* fmt, ...) { parser->on_warning(Glib::ustring(buff)); } - catch(const exception& e) + catch (...) { - parser->handleException(e); - } - catch(...) - { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } @@ -586,7 +548,7 @@ void SaxParserCallback::error(void* context, const char* fmt, ...) va_list arg; char buff[1024]; //TODO: Larger/Shared - if(parser->exception_) + if (parser->exception_ptr_) return; va_start(arg, fmt); @@ -597,13 +559,9 @@ void SaxParserCallback::error(void* context, const char* fmt, ...) { parser->on_error(Glib::ustring(buff)); } - catch(const exception& e) - { - parser->handleException(e); - } - catch(...) + catch (...) { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } @@ -623,13 +581,9 @@ void SaxParserCallback::fatal_error(void* context, const char* fmt, ...) { parser->on_fatal_error(Glib::ustring(buff)); } - catch(const exception& e) + catch (...) { - parser->handleException(e); - } - catch(...) - { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } @@ -647,13 +601,9 @@ void SaxParserCallback::cdata_block(void* context, const xmlChar* value, int len reinterpret_cast(value), reinterpret_cast(value + len) ) ); } - catch(const exception& e) - { - parser->handleException(e); - } - catch(...) + catch (...) { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } @@ -670,13 +620,9 @@ void SaxParserCallback::internal_subset(void* context, const xmlChar* name, parser->on_internal_subset( Glib::ustring((const char*) name), pid, sid); } - catch(const exception& e) - { - parser->handleException(e); - } - catch(...) + catch (...) { - parser->handleException(wrapped_exception(std::current_exception())); + parser->handle_exception(); } } diff --git a/libxml++/validators/validator.cc b/libxml++/validators/validator.cc index 220d4598..71e59991 100644 --- a/libxml++/validators/validator.cc +++ b/libxml++/validators/validator.cc @@ -5,7 +5,6 @@ * included with libxml++ as the file COPYING. */ -#include "libxml++/exceptions/wrapped_exception.h" #include "libxml++/validators/validator.h" #include @@ -16,7 +15,7 @@ namespace xmlpp { Validator::Validator() -: valid_(nullptr), exception_(nullptr) +: valid_(nullptr), exception_ptr_(nullptr) { } @@ -69,7 +68,20 @@ void Validator::on_validity_warning(const Glib::ustring& message) void Validator::check_for_validity_messages() { - Glib::ustring msg(exception_ ? exception_->what() : ""); + Glib::ustring msg; + try + { + if (exception_ptr_) + std::rethrow_exception(exception_ptr_); + } + catch (const std::exception& e) + { + msg = e.what(); + } + catch (...) + { + msg = "Unknown exception\n"; + } bool validity_msg = false; if (!validate_error_.empty()) @@ -86,10 +98,14 @@ void Validator::check_for_validity_messages() validate_warning_.erase(); } - if (validity_msg) + try { - delete exception_; - exception_ = new validity_error(msg); + if (validity_msg) + throw validity_error(msg); + } + catch (...) + { + exception_ptr_ = std::current_exception(); } } @@ -111,13 +127,9 @@ void Validator::callback_validity_error(void* valid_, const char* msg, ...) { validator->on_validity_error(Glib::ustring(buff)); } - catch(const exception& e) - { - validator->handleException(e); - } - catch(...) + catch (...) { - validator->handleException(wrapped_exception(std::current_exception())); + validator->handle_exception(); } } } @@ -140,26 +152,21 @@ void Validator::callback_validity_warning(void* valid_, const char* msg, ...) { validator->on_validity_warning(Glib::ustring(buff)); } - catch(const exception& e) + catch (...) { - validator->handleException(e); - } - catch(...) - { - validator->handleException(wrapped_exception(std::current_exception())); + validator->handle_exception(); } } } -void Validator::handleException(const exception& e) +void Validator::handle_exception() { - delete exception_; - exception_ = e.Clone(); + exception_ptr_ = std::current_exception(); // Don't delete the DTD validation context or schema validation context // while validating. It would cause accesses to deallocated memory in libxml2 // functions after the return from Validator::callback_validity_...(). - // Parser::handleException() calls xmlStopParser(), but there is no + // Parser::handle_exception() calls xmlStopParser(), but there is no // xmlStopValidator() or similar function to call here. // We don't throw the exception here, since it would have to pass through // C functions. That's not guaranteed to work. It might work, but it depends @@ -171,12 +178,12 @@ void Validator::handleException(const exception& e) void Validator::check_for_exception() { check_for_validity_messages(); - - if(exception_) + + if (exception_ptr_) { - std::unique_ptr tmp(exception_); - exception_ = nullptr; - tmp->Raise(); + std::exception_ptr tmp(exception_ptr_); + exception_ptr_ = nullptr; + std::rethrow_exception(tmp); } } diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index cdf9f2fc..82c94c80 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -15,6 +15,7 @@ #include #include #include +#include // std::exception_ptr extern "C" { struct _xmlValidCtxt; @@ -37,7 +38,8 @@ class Validator : NonCopyable virtual void on_validity_error(const Glib::ustring& message); virtual void on_validity_warning(const Glib::ustring& message); - virtual void handleException(const exception& e); + /// To be called in an exception handler. + virtual void handle_exception(); virtual void check_for_exception(); virtual void check_for_validity_messages(); @@ -45,12 +47,12 @@ class Validator : NonCopyable static void callback_validity_warning(void* ctx, const char* msg, ...); _xmlValidCtxt* valid_; - exception* exception_; + std::exception_ptr exception_ptr_; + // Built gradually - used in an exception at the end of validation. Glib::ustring validate_error_; - Glib::ustring validate_warning_; //Built gradually - used in an exception at the end of parsing. + Glib::ustring validate_warning_; }; } // namespace xmlpp #endif //__LIBXMLPP_VALIDATOR_H - From cf1758e08721a8c5b6f2ef533150e198a19c9e40 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 22 Sep 2015 09:45:16 +0200 Subject: [PATCH 011/240] Remove the deprecated Schema and SchemaValidator classes * libxml++/schema.[h|cc]: * libxml++/validators/schemavalidator.[h|cc]: Remove these files. * examples/schemavalidation/main.cc: Remove test of SchemaValidator. * libxml++/filelist.am: Remove schema.h and schemavalidator.h. * libxml++/libxml++.h: Remove schemavalidator.h. Bug #754673. --- examples/schemavalidation/main.cc | 11 -- libxml++/filelist.am | 2 - libxml++/libxml++.h | 1 - libxml++/schema.cc | 131 -------------- libxml++/schema.h | 111 ------------ libxml++/validators/schemavalidator.cc | 232 ------------------------- libxml++/validators/schemavalidator.h | 155 ----------------- 7 files changed, 643 deletions(-) delete mode 100644 libxml++/schema.cc delete mode 100644 libxml++/schema.h delete mode 100644 libxml++/validators/schemavalidator.cc delete mode 100644 libxml++/validators/schemavalidator.h diff --git a/examples/schemavalidation/main.cc b/examples/schemavalidation/main.cc index 4cfddf38..f488bc0e 100644 --- a/examples/schemavalidation/main.cc +++ b/examples/schemavalidation/main.cc @@ -51,11 +51,6 @@ int main(int argc, char* argv[]) Glib::ustring phase; try { -#ifndef LIBXMLXX_DISABLE_DEPRECATED - phase = "XML"; // XSD schema, old validator class - xmlpp::SchemaValidator schemavalidator(xsdschemafilepath); -#endif // LIBXMLXX_DISABLE_DEPRECATED - phase = "XSD"; xmlpp::XsdValidator xsdvalidator(xsdschemafilepath); @@ -67,12 +62,6 @@ int main(int argc, char* argv[]) phase = "parsing"; xmlpp::DomParser parser(docfilepath); -#ifndef LIBXMLXX_DISABLE_DEPRECATED - phase = "XML validating"; - schemavalidator.validate(parser.get_document()); - std::cout << "Valid document, SchemaValidator" << std::endl; -#endif // LIBXMLXX_DISABLE_DEPRECATED - phase = "XSD validating"; xsdvalidator.validate(parser.get_document()); std::cout << "Valid document, XsdValidator" << std::endl; diff --git a/libxml++/filelist.am b/libxml++/filelist.am index b9b1f5b9..aeedd0c0 100644 --- a/libxml++/filelist.am +++ b/libxml++/filelist.am @@ -9,7 +9,6 @@ h_root_sources_public = \ keepblanks.h \ noncopyable.h \ relaxngschema.h \ - schema.h \ schemabase.h \ xsdschema.h h_exceptions_sources_public = \ @@ -42,7 +41,6 @@ h_parsers_sources_public = \ h_validators_sources_public = \ validators/dtdvalidator.h \ validators/relaxngvalidator.h \ - validators/schemavalidator.h \ validators/schemavalidatorbase.h \ validators/validator.h \ validators/xsdvalidator.h diff --git a/libxml++/libxml++.h b/libxml++/libxml++.h index 8aafb5c3..89cbf4e3 100644 --- a/libxml++/libxml++.h +++ b/libxml++/libxml++.h @@ -73,7 +73,6 @@ #include #include #include -#include #include #endif //__LIBXMLCPP_H diff --git a/libxml++/schema.cc b/libxml++/schema.cc deleted file mode 100644 index 1b39b24b..00000000 --- a/libxml++/schema.cc +++ /dev/null @@ -1,131 +0,0 @@ -/* schema.cc - * libxml++ and this file are copyright (C) 2000 by Ari Johnson, and - * are covered by the GNU Lesser General Public License, which should be - * included with libxml++ as the file COPYING. - */ - -#include // LIBXMLXX_DISABLE_DEPRECATED - -#ifndef LIBXMLXX_DISABLE_DEPRECATED - -#include - -#include -#include -#include - -namespace xmlpp -{ - -Schema::Schema(_xmlSchema* schema) -: impl_(schema) -, embedded_doc_(false) -{ - schema->_private = this; -} - -Schema::Schema(Document* document, bool embed) -: impl_(nullptr) -, embedded_doc_(false) -{ - set_document(document, embed); -} - -Schema::~Schema() -{ - release_underlying(); -} - -void Schema::set_document(Document* document, bool embed) -{ - release_underlying(); - - bool has_created_document = false; - if (!document) - { - document = new Document(); - has_created_document = true; - } - - xmlResetLastError(); - auto context = xmlSchemaNewDocParserCtxt( document->cobj() ); - - if(!context) - { - if (has_created_document) - delete document; - throw parse_error("Schema could not be parsed.\n" + format_xml_error()); - } - - impl_ = xmlSchemaParse(context); - if(!impl_) - { - xmlSchemaFreeParserCtxt(context); - if (has_created_document) - delete document; - throw parse_error("Schema could not be parsed.\n" + format_xml_error()); - } - - impl_->_private = this; - embedded_doc_ = embed; - xmlSchemaFreeParserCtxt(context); -} - -Glib::ustring Schema::get_name() const -{ - return (impl_ && impl_->name) ? (char*)impl_->name : ""; -} - -Glib::ustring Schema::get_target_namespace() const -{ - return (impl_ && impl_->targetNamespace) ? (char*)impl_->targetNamespace : ""; -} - -Glib::ustring Schema::get_version() const -{ - return (impl_ && impl_->version) ? (char*)impl_->version : ""; -} - -void Schema::release_underlying() -{ - if(embedded_doc_ && impl_ && impl_->doc && impl_->doc->_private) - { - delete (Document*) impl_->doc->_private; - embedded_doc_ = false; - } - - if(impl_) - { - xmlSchemaFree(impl_); - impl_ = nullptr; - } -} - -Document* Schema::get_document() -{ - if (!(impl_ && impl_->doc)) - return 0; - - if (!impl_->doc->_private) // Possible if *this was created with Schema(xmlSchema* schema). - new Document(impl_->doc); // Sets impl_->doc->_private - - return (Document*) impl_->doc->_private; -} - -const Document* Schema::get_document() const -{ - return const_cast(this)->get_document(); -} - -_xmlSchema* Schema::cobj() -{ - return impl_; -} - -const _xmlSchema* Schema::cobj() const -{ - return impl_; -} - -} //namespace xmlpp -#endif // LIBXMLXX_DISABLE_DEPRECATED diff --git a/libxml++/schema.h b/libxml++/schema.h deleted file mode 100644 index 69299c86..00000000 --- a/libxml++/schema.h +++ /dev/null @@ -1,111 +0,0 @@ -/* schema.h - * libxml++ and this file are copyright (C) 2000 by Ari Johnson, and - * are covered by the GNU Lesser General Public License, which should be - * included with libxml++ as the file COPYING. - */ - -#ifndef __LIBXMLPP_SCHEMA_H -#define __LIBXMLPP_SCHEMA_H - -#include -#include -#include -#include - -#ifndef LIBXMLXX_DISABLE_DEPRECATED - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -extern "C" { - struct _xmlSchema; -} -#endif //DOXYGEN_SHOULD_SKIP_THIS - -namespace xmlpp -{ - -/** Represents an XML Schema. - * - * @newin{2,24} - * - * @deprecated Use XsdSchema instead. - */ -class Schema : NonCopyable -{ -public: - /** Create a schema from the underlying libxml schema element. - * @deprecated Use XsdSchema instead. - */ - explicit Schema(_xmlSchema* schema); - - /** Create a schema from an XML document. - * @param document XMLSchema document, 0 to create an empty schema document. - * @param embed If true, the document will be deleted when - * the schema is deleted or another document is set. - * @throws xmlpp::parse_error - * @throws xmlpp::internal_error If an empty schema document can't be created. - * @deprecated Use XsdSchema instead. - */ - explicit Schema(Document* document = 0, bool embed = false); - ~Schema(); - - //TODO: Remove virtual when we can break ABI? - - /** Set a new document to the schema. - * If the old schema document is owned by the schema (embed == true), the old - * schema document and all its nodes are deleted. - * @param document XMLSchema document, 0 to create an empty schema document. - * @param embed If true, the document will be deleted when the schema is deleted or another document is set. - * @throws xmlpp::parse_error - * @throws xmlpp::internal_error If an empty schema document can't be created. - * @deprecated Use XsdSchema::parse_document() instead. - */ - virtual void set_document(Document* document = 0, bool embed = false); - - /** @deprecated There is no replacement. - */ - Glib::ustring get_name() const; - - /** @deprecated There is no replacement. - */ - Glib::ustring get_target_namespace() const; - - /** @deprecated There is no replacement. - */ - Glib::ustring get_version() const; - - /** Get the schema document. - * @returns A pointer to the schema document, or 0 if none exists. - * @deprecated There is no replacement. - */ - Document* get_document(); - - /** Get the schema document. - * @returns A pointer to the schema document, or 0 if none exists. - * @deprecated There is no replacement. - */ - const Document* get_document() const; - - /** Access the underlying libxml implementation. - * @deprecated Use XsdSchema::cobj() instead. - */ - _xmlSchema* cobj(); - - /** Access the underlying libxml implementation. - * @deprecated Use XsdSchema::cobj() instead. - */ - const _xmlSchema* cobj() const; - -protected: - virtual void release_underlying(); - -private: - _xmlSchema* impl_; - - /** If the base document is created with the schema. */ - bool embedded_doc_; -}; - -} // namespace xmlpp - -#endif // LIBXMLXX_DISABLE_DEPRECATED -#endif //__LIBXMLPP_SCHEMA_H diff --git a/libxml++/validators/schemavalidator.cc b/libxml++/validators/schemavalidator.cc deleted file mode 100644 index a3c239a2..00000000 --- a/libxml++/validators/schemavalidator.cc +++ /dev/null @@ -1,232 +0,0 @@ -/* dtdvalidator.cpp - * libxml++ and this file are copyright (C) 2000 by Ari Johnson - * (C) 2002-2004 by the libxml dev team and - * are covered by the GNU Lesser General Public License, which should be - * included with libxml++ as the file COPYING. - */ - -#include // LIBXMLXX_DISABLE_DEPRECATED - -#ifndef LIBXMLXX_DISABLE_DEPRECATED - -#include "libxml++/validators/schemavalidator.h" -#include "libxml++/schema.h" - -#include -#include - -#include -#include - -namespace -{ - // This class simply holds a xmlSchemaParserCtxtPtr and releases it on - // destruction. This way, we make sure we don't leak it in either case, - // even when an exception is thrown. - class XmlSchemaParserContextHolder - { - public: - XmlSchemaParserContextHolder(xmlSchemaParserCtxtPtr ptr): ptr_(ptr) {} - ~XmlSchemaParserContextHolder() { xmlSchemaFreeParserCtxt(ptr_); } - - private: - xmlSchemaParserCtxtPtr ptr_; - }; -} - -namespace xmlpp -{ - -SchemaValidator::SchemaValidator() -: schema_(nullptr) -, embbeded_shema_(false) -, ctxt_(nullptr) -{ -} - -SchemaValidator::SchemaValidator(const Glib::ustring& file) -: schema_(nullptr) -, embbeded_shema_(false) -, ctxt_(nullptr) -{ - parse_file( file ); -} - -SchemaValidator::SchemaValidator(Document& document) -: schema_(nullptr) -, embbeded_shema_(false) -, ctxt_(nullptr) -{ - parse_document( document ); -} - -SchemaValidator::SchemaValidator(Schema* schema) -: schema_(schema) -, embbeded_shema_(false) -, ctxt_(nullptr) -{ -} - -SchemaValidator::~SchemaValidator() -{ - release_underlying(); - Validator::release_underlying(); -} - -void SchemaValidator::parse_context(_xmlSchemaParserCtxt* context) -{ - if (!context) - throw parse_error("Could not create schema parser context\n" + format_xml_error()); - - release_underlying(); // Free any existing schema. - - auto schema = xmlSchemaParse( context ); - if ( ! schema ) - throw parse_error("Schema could not be parsed\n" + format_xml_error()); - - schema->_private = new Schema(schema); - - schema_ = static_cast(schema->_private); - embbeded_shema_ = true; -} - -void SchemaValidator::parse_file(const Glib::ustring& filename) -{ - xmlResetLastError(); - auto ctx = xmlSchemaNewParserCtxt( filename.c_str() ); - XmlSchemaParserContextHolder holder(ctx); - parse_context( ctx ); -} - -void SchemaValidator::parse_memory(const Glib::ustring& contents) -{ - xmlResetLastError(); - auto ctx = xmlSchemaNewMemParserCtxt( contents.c_str(), contents.bytes() ); - XmlSchemaParserContextHolder holder(ctx); - parse_context( ctx ); -} - -void SchemaValidator::parse_document(Document& document) -{ - xmlResetLastError(); - auto ctx = xmlSchemaNewDocParserCtxt( document.cobj() ); - XmlSchemaParserContextHolder holder(ctx); - parse_context( ctx ); -} - -void SchemaValidator::set_schema(Schema* schema) -{ - release_underlying(); - schema_ = schema; - embbeded_shema_ = false; -} - -void SchemaValidator::release_underlying() -{ - if(ctxt_) - { - xmlSchemaFreeValidCtxt( ctxt_ ); - ctxt_ = nullptr; - } - if(schema_) - { - if(embbeded_shema_) - delete schema_; - schema_ = nullptr; - } -} - -SchemaValidator::operator bool() const -{ - return schema_ != nullptr; -} - -Schema* SchemaValidator::get_schema() -{ - return schema_; -} - -const Schema* SchemaValidator::get_schema() const -{ - return schema_; -} - -void SchemaValidator::initialize_valid() -{ - xmlSchemaSetValidErrors(ctxt_, &callback_validity_error, &callback_validity_warning, this); - Validator::initialize_valid(); -} - - -bool SchemaValidator::validate(const Document* doc) -{ - if (!doc) - throw internal_error("Document pointer cannot be 0"); - - if (!schema_) - throw internal_error("Must have a schema to validate document"); - - // A context is required at this stage only - if (!ctxt_) - ctxt_ = xmlSchemaNewValidCtxt( schema_->cobj() ); - - if(!ctxt_) - { - throw internal_error("Couldn't create validating context"); - } - - xmlResetLastError(); - initialize_valid(); - - const int res = xmlSchemaValidateDoc( ctxt_, (xmlDoc*)doc->cobj() ); - - if(res != 0) - { - check_for_exception(); - - auto error_str = format_xml_error(); - if (error_str.empty()) - error_str = "Error code from xmlSchemaValidateDoc(): " + Glib::ustring::format(res); - throw validity_error("Document failed schema validation\n" + error_str); - } - - return res == 0; -} - -bool SchemaValidator::validate(const Glib::ustring& file) -{ - if (file.empty()) - throw internal_error("File path must not be empty"); - - if (!schema_) - throw internal_error("Must have a schema to validate document"); - - // A context is required at this stage only - if (!ctxt_) - ctxt_ = xmlSchemaNewValidCtxt( schema_->cobj() ); - - if(!ctxt_) - { - throw internal_error("Couldn't create validating context"); - } - - xmlResetLastError(); - initialize_valid(); - - const int res = xmlSchemaValidateFile( ctxt_, file.c_str(), 0 ); - - if(res != 0) - { - check_for_exception(); - - auto error_str = format_xml_error(); - if (error_str.empty()) - error_str = "Error code from xmlSchemaValidateFile(): " + Glib::ustring::format(res); - throw validity_error("Document failed schema validation\n" + error_str); - } - - return res == 0; -} - -} // namespace xmlpp -#endif // LIBXMLXX_DISABLE_DEPRECATED diff --git a/libxml++/validators/schemavalidator.h b/libxml++/validators/schemavalidator.h deleted file mode 100644 index 07d7eae4..00000000 --- a/libxml++/validators/schemavalidator.h +++ /dev/null @@ -1,155 +0,0 @@ -/* schemavalidator.h - * libxml++ and this file are copyright (C) 2000 by Ari Johnson, - * (C) 2002-2004 by the libxml dev team and - * are covered by the GNU Lesser General Public License, which should be - * included with libxml++ as the file COPYING. - */ - -#ifndef __LIBXMLPP_VALIDATOR_SCHEMAVALIDATOR_H -#define __LIBXMLPP_VALIDATOR_SCHEMAVALIDATOR_H - -#include -#include -#include - -#ifndef LIBXMLXX_DISABLE_DEPRECATED - -#ifndef DOXYGEN_SHOULD_SKIP_THIS -extern "C" { - struct _xmlSchemaParserCtxt; - struct _xmlSchemaValidCtxt; -} -#endif //DOXYGEN_SHOULD_SKIP_THIS - -namespace xmlpp { - -/** XML Schema Validator. - * - * @newin{2,24} - * - * @deprecated Use XsdValidator instead. - */ -class SchemaValidator : public Validator -{ -public: - SchemaValidator(); - - /** Create a validator and parse a schema definition file immediately. - * @param file The URL of the schema. - * @throws xmlpp::parse_error - * @deprecated Use XsdValidator instead. - */ - explicit SchemaValidator(const Glib::ustring& file); - - /** Create a validator and parse a schema definition document immediately. - * @param document A preparsed document tree, containing the schema definition. - * @note The document may be modified during the parsing process. - * @throws xmlpp::parse_error - * @deprecated Use XsdValidator instead. - */ - explicit SchemaValidator(Document& document); - - /** Create a schema validator. - * @param schema A pointer to the XML schema to use when validating XML documents. - * The validator does not take ownership of the schema. The caller must - * guarantee that the schema exists as long as the validator keeps a - * pointer to it. The caller is responsible for deleting the schema - * when it's no longer needed. - * @deprecated Use XsdValidator instead. - */ - explicit SchemaValidator(Schema* schema); - - ~SchemaValidator() override; - - //TODO: Remove virtuals when we can break ABI, - //or really put these in the base class. - - /** Parse a schema definition file. - * If the validator already contains a schema, that schema is released - * (deleted if the validator owns the schema). - * @param filename The URL of the schema. - * @throws xmlpp::parse_error - * @deprecated Use XsdValidator::parse_file() instead. - */ - virtual void parse_file(const Glib::ustring& filename); - - /** Parse a schema definition from a string. - * If the validator already contains a schema, that schema is released - * (deleted if the validator owns the schema). - * @param contents The schema definition as a string. - * @throws xmlpp::parse_error - * @deprecated Use XsdValidator::parse_memory() instead. - */ - virtual void parse_memory(const Glib::ustring& contents); - - /** Parse a schema definition from a document. - * If the validator already contains a schema, that schema is released - * (deleted if the validator owns the schema). - * @param document A preparsed document tree, containing the schema definition. - * @note The document may be modified during the parsing process. - * @throws xmlpp::parse_error - * @deprecated Use XsdValidator::parse_document() instead. - */ - virtual void parse_document(Document& document); - - /** Set a schema. - * If the validator already contains a schema, that schema is released - * (deleted if the validator owns the schema). - * @param schema A pointer to the XML schema to use when validating XML documents. - * The validator does not take ownership of the schema. The caller must - * guarantee that the schema exists as long as the validator keeps a - * pointer to it. The caller is responsible for deleting the schema - * when it's no longer needed. - * @deprecated Use XsdValidator::set_schema() instead. - */ - virtual void set_schema(Schema* schema); - - /** Test whether a schema has been parsed. - * @deprecated Use XsdValidator::operator BoolExpr() instead. - */ - operator bool() const; - - /** Get the parsed schema. - * @returns A pointer to the parsed schema, or 0. - * @deprecated Use XsdValidator::get_schema() instead. - */ - Schema* get_schema(); - - /** Get the parsed schema. - * @returns A pointer to the parsed schema, or 0. - * @deprecated Use XsdValidator::get_schema() instead. - */ - const Schema* get_schema() const; - - /** Validate a document, using a previously parsed schema. - * @param doc Pointer to the document. - * @returns Whether the document is valid. - * @throws xmlpp::internal_error - * @throws xmlpp::validity_error - * @deprecated Use XsdValidator::validate(const Document*) instead. - */ - bool validate(const Document* doc); - - /** Validate an XML file, using a previously parsed schema. - * @param file The URI of the XML file. - * @returns Whether the document is valid. - * @throws xmlpp::internal_error - * @throws xmlpp::validity_error - * @deprecated Use XsdValidator::validate(const Glib::ustring&) instead. - */ - bool validate(const Glib::ustring& file); - -protected: - void initialize_valid() override; - void parse_context(_xmlSchemaParserCtxt* context); - void release_underlying() override; - - Schema* schema_; - bool embbeded_shema_; //TODO Correct mis-spelling at the next API/ABI break. - _xmlSchemaValidCtxt* ctxt_; -}; - -} // namespace xmlpp - -#endif // LIBXMLXX_DISABLE_DEPRECATED -#endif //__LIBXMLPP_VALIDATOR_SCHEMAVALIDATOR_H From 485a960122a574f345a24ef587ff87e707bc95d9 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 23 Sep 2015 15:50:05 +0200 Subject: [PATCH 012/240] xmlpp::exception and its subclasses: Remove Raise() and Clone() Remove the virtual methods Raise() and Clone() from xmlpp::exception and its subclasses. These methods are not needed now that std::exception_ptr is used for storing and later rethrowing an exception. Bug #754673. --- examples/sax_exception/myparser.cc | 12 ------------ examples/sax_exception/myparser.h | 4 ---- libxml++/exceptions/exception.cc | 11 ----------- libxml++/exceptions/exception.h | 8 +------- libxml++/exceptions/internal_error.cc | 13 ------------- libxml++/exceptions/internal_error.h | 7 +------ libxml++/exceptions/parse_error.cc | 11 ----------- libxml++/exceptions/parse_error.h | 7 +------ libxml++/exceptions/validity_error.cc | 11 ----------- libxml++/exceptions/validity_error.h | 7 +------ 10 files changed, 4 insertions(+), 87 deletions(-) diff --git a/examples/sax_exception/myparser.cc b/examples/sax_exception/myparser.cc index 19b5417f..9c9013df 100644 --- a/examples/sax_exception/myparser.cc +++ b/examples/sax_exception/myparser.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* myparser.cc * * Copyright (C) 2002 The libxml++ development team @@ -36,16 +34,6 @@ MyException::~MyException() throw () { } -void MyException::Raise() const -{ - throw *this; -} - -xmlpp::exception * MyException::Clone() const -{ - return new MyException(*this); -} - /* * MySaxParser implementation */ diff --git a/examples/sax_exception/myparser.h b/examples/sax_exception/myparser.h index 7eb3a5d0..3e1c2ee0 100644 --- a/examples/sax_exception/myparser.h +++ b/examples/sax_exception/myparser.h @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* myparser.h * * Copyright (C) 2002 The libxml++ development team @@ -29,8 +27,6 @@ class MyException: public xmlpp::exception public: MyException(); ~MyException() noexcept override; - void Raise() const override; - xmlpp::exception * Clone() const override; }; class MySaxParser : public xmlpp::SaxParser diff --git a/libxml++/exceptions/exception.cc b/libxml++/exceptions/exception.cc index 89b5a4d9..38057791 100644 --- a/libxml++/exceptions/exception.cc +++ b/libxml++/exceptions/exception.cc @@ -17,16 +17,6 @@ const char* exception::what() const noexcept return message_.c_str(); } -void exception::Raise() const -{ - throw *this; -} - -exception * exception::Clone() const -{ - return new exception(*this); -} - Glib::ustring format_xml_error(const _xmlError* error) { if (!error) @@ -103,4 +93,3 @@ Glib::ustring format_xml_parser_error(const _xmlParserCtxt* parser_context) } } //namespace xmlpp - diff --git a/libxml++/exceptions/exception.h b/libxml++/exceptions/exception.h index dffbe5a0..4510075f 100644 --- a/libxml++/exceptions/exception.h +++ b/libxml++/exceptions/exception.h @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* exception.h * * Copyright (C) 2002 The libxml++ development team @@ -37,7 +35,7 @@ namespace xmlpp /** Base class for all xmlpp exceptions. */ -class LIBXMLPP_API exception: public std::exception +class LIBXMLPP_API exception : public std::exception { public: explicit exception(const Glib::ustring& message); @@ -45,10 +43,6 @@ class LIBXMLPP_API exception: public std::exception const char* what() const noexcept override; - //TODO: Use lower-case names when we can break ABI? - virtual void Raise() const; - virtual exception * Clone() const; - private: Glib::ustring message_; }; diff --git a/libxml++/exceptions/internal_error.cc b/libxml++/exceptions/internal_error.cc index 13f6392c..9f48cac2 100644 --- a/libxml++/exceptions/internal_error.cc +++ b/libxml++/exceptions/internal_error.cc @@ -1,6 +1,5 @@ #include "internal_error.h" - namespace xmlpp { internal_error::internal_error(const Glib::ustring& message) @@ -11,16 +10,4 @@ internal_error::internal_error(const Glib::ustring& message) internal_error::~internal_error() noexcept {} -void internal_error::Raise() const -{ - throw *this; -} - -exception * internal_error::Clone() const -{ - return new internal_error(*this); -} - } //namespace xmlpp - - diff --git a/libxml++/exceptions/internal_error.h b/libxml++/exceptions/internal_error.h index 887dd65b..303109f9 100644 --- a/libxml++/exceptions/internal_error.h +++ b/libxml++/exceptions/internal_error.h @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* internal_error.h * * Copyright (C) 2002 The libxml++ development team @@ -29,14 +27,11 @@ namespace xmlpp { -class internal_error: public exception +class internal_error : public exception { public: explicit internal_error(const Glib::ustring& message); ~internal_error() noexcept override; - - void Raise() const override; - exception * Clone() const override; }; } // namespace xmlpp diff --git a/libxml++/exceptions/parse_error.cc b/libxml++/exceptions/parse_error.cc index b9c19877..96bd53ef 100644 --- a/libxml++/exceptions/parse_error.cc +++ b/libxml++/exceptions/parse_error.cc @@ -10,15 +10,4 @@ parse_error::parse_error(const Glib::ustring& message) parse_error::~parse_error() noexcept {} -void parse_error::Raise() const -{ - throw *this; -} - -exception* parse_error::Clone() const -{ - return new parse_error(*this); -} - } //namespace xmlpp - diff --git a/libxml++/exceptions/parse_error.h b/libxml++/exceptions/parse_error.h index 12c80998..659b135e 100644 --- a/libxml++/exceptions/parse_error.h +++ b/libxml++/exceptions/parse_error.h @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* parse_error.h * * Copyright (C) 2002 The libxml++ development team @@ -32,14 +30,11 @@ namespace xmlpp /** This exception will be thrown when the parser encounters an error in the XML document. */ -class parse_error: public exception +class parse_error : public exception { public: explicit parse_error(const Glib::ustring& message); ~parse_error() noexcept override; - - void Raise() const override; - exception* Clone() const override; }; } // namespace xmlpp diff --git a/libxml++/exceptions/validity_error.cc b/libxml++/exceptions/validity_error.cc index d34332fc..b0fdc24c 100644 --- a/libxml++/exceptions/validity_error.cc +++ b/libxml++/exceptions/validity_error.cc @@ -10,15 +10,4 @@ validity_error::validity_error(const Glib::ustring& message) validity_error::~validity_error() noexcept {} -void validity_error::Raise() const -{ - throw *this; -} - -exception* validity_error::Clone() const -{ - return new validity_error(*this); -} - } //namespace xmlpp - diff --git a/libxml++/exceptions/validity_error.h b/libxml++/exceptions/validity_error.h index 513d0e1b..503eeb3e 100644 --- a/libxml++/exceptions/validity_error.h +++ b/libxml++/exceptions/validity_error.h @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* validity_error.h * * Copyright (C) 2002 The libxml++ development team @@ -29,14 +27,11 @@ namespace xmlpp /** This exception will be thrown when the parser encounters a validity error in the XML document. */ -class validity_error: public parse_error +class validity_error : public parse_error { public: explicit validity_error(const Glib::ustring& message); ~validity_error() noexcept override; - - void Raise() const override; - exception* Clone() const override; }; } // namespace xmlpp From 21b3fe88fe6c354548b5808dbefd4d0bc13fb250 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 23 Sep 2015 16:34:31 +0200 Subject: [PATCH 013/240] DomParser, SaxParser: Make some methods non-virtual * libxml++/parsers/domparser.h: Make parse_context() non-virtual. * libxml++/parsers/saxparser.h: Make parse_chunk(), finish_chunk_parsing() and parse() non-virtual. Bug #754673. --- libxml++/parsers/domparser.h | 3 +-- libxml++/parsers/saxparser.h | 17 +++++++---------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index cc5bc91d..3977e580 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -90,8 +90,7 @@ class DomParser : public Parser const Document* get_document() const; protected: - //TODO: Remove the virtual when we can break ABI? - virtual void parse_context(); + void parse_context(); void release_underlying() override; diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index 846c959b..60a18aa4 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -113,14 +113,13 @@ class SaxParser : public Parser */ void parse_stream(std::istream& in) override; - //TODO: Remove virtual when we can break ABI? /** Parse a chunk of data. * * This lets you pass a document in small chunks, e.g. from a network * connection. The on_* virtual functions are called each time the chunks * provide enough information to advance the parser. * - * The first call to parse_chunk will setup the parser. When the last chunk + * The first call to parse_chunk() will setup the parser. When the last chunk * has been parsed, call finish_chunk_parsing() to finish the parse. * * @param chunk The next piece of the XML document. @@ -128,7 +127,7 @@ class SaxParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - virtual void parse_chunk(const Glib::ustring& chunk); + void parse_chunk(const Glib::ustring& chunk); /** Parse a chunk of data. * @@ -138,7 +137,7 @@ class SaxParser : public Parser * connection. The on_* virtual functions are called each time the chunks * provide enough information to advance the parser. * - * The first call to parse_chunk will setup the parser. When the last chunk + * The first call to parse_chunk_raw() will setup the parser. When the last chunk * has been parsed, call finish_chunk_parsing() to finish the parse. * * @param contents The next piece of the XML document as an array of bytes. @@ -149,16 +148,15 @@ class SaxParser : public Parser */ void parse_chunk_raw(const unsigned char* contents, size_type bytes_count); - //TODO: Remove virtual when we can break ABI? /** Finish a chunk-wise parse. * - * Call this after the last call to parse_chunk(). Don't use this function with - * the other parsing methods. + * Call this after the last call to parse_chunk() or parse_chunk_raw(). + * Don't use this function with the other parsing methods. * @throws xmlpp::internal_error * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - virtual void finish_chunk_parsing(); + void finish_chunk_parsing(); protected: @@ -213,8 +211,7 @@ class SaxParser : public Parser void release_underlying() override; private: - //TODO: Remove the virtual when we can break ABI? - virtual void parse(); + void parse(); std::unique_ptr<_xmlSAXHandler> sax_handler_; From f24a21cd7f19feb79a2145fb3973e4cd4d69f322 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 23 Sep 2015 17:08:19 +0200 Subject: [PATCH 014/240] SaxParser: Start each parsing with a new Document for entity resolution * libxml++/parsers/saxparser.[h|cc]: Make entity_resolver_doc_ a unique_ptr. Create a new Document in an overridden initialize_context(). Bug #754673. --- libxml++/parsers/saxparser.cc | 33 ++++++++++++++++----------------- libxml++/parsers/saxparser.h | 3 ++- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index 69ebae04..20fc5d8c 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -39,7 +39,7 @@ struct SaxParserCallback SaxParser::SaxParser(bool use_get_entity) - : sax_handler_( new _xmlSAXHandler ) + : sax_handler_(new _xmlSAXHandler), entity_resolver_doc_(new Document) { xmlSAXHandler temp = { SaxParserCallback::internal_subset, @@ -88,12 +88,12 @@ SaxParser::~SaxParser() xmlEntityPtr SaxParser::on_get_entity(const Glib::ustring& name) { - return entity_resolver_doc_.get_entity(name); + return entity_resolver_doc_->get_entity(name); } void SaxParser::on_entity_declaration(const Glib::ustring& name, XmlEntityType type, const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content) { - entity_resolver_doc_.set_entity_declaration(name, type, publicId, systemId, content); + entity_resolver_doc_->set_entity_declaration(name, type, publicId, systemId, content); } void SaxParser::on_start_document() @@ -142,21 +142,13 @@ void SaxParser::on_internal_subset(const Glib::ustring& name, const Glib::ustring& publicId, const Glib::ustring& systemId) { - entity_resolver_doc_.set_internal_subset(name, publicId, systemId); + entity_resolver_doc_->set_internal_subset(name, publicId, systemId); } // implementation of this function is inspired by the SAX documentation by James Henstridge. // (http://www.daa.com.au/~james/gnome/xml-sax/implementing.html) void SaxParser::parse() { - //TODO If this is not the first parsing with this SaxParser, the xmlDoc object - // in entity_resolver_doc_ should be deleted and replaced by a new one. - // Otherwise entity declarations from a previous parsing may erroneously affect - // this parsing. This would be much easier if entity_resolver_doc_ were a - // std::unique_ptr, so the xmlpp::Document could be deleted and a new - // one created. A good place for such code would be in an overridden - // SaxParser::initialize_context(). It would be an ABI break. - if(!context_) { throw internal_error("Parser context not created."); @@ -326,11 +318,6 @@ void SaxParser::parse_chunk_raw(const unsigned char* contents, size_type bytes_c } } -void SaxParser::release_underlying() -{ - Parser::release_underlying(); -} - void SaxParser::finish_chunk_parsing() { xmlResetLastError(); @@ -371,6 +358,18 @@ void SaxParser::finish_chunk_parsing() } } +void SaxParser::release_underlying() +{ + Parser::release_underlying(); +} + +void SaxParser::initialize_context() +{ + Parser::initialize_context(); + // Start with an empty Document for entity resolution. + entity_resolver_doc_.reset(new Document); +} + xmlEntityPtr SaxParserCallback::get_entity(void* context, const xmlChar* name) { diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index 60a18aa4..90e845d8 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -209,6 +209,7 @@ class SaxParser : public Parser virtual void on_entity_declaration(const Glib::ustring& name, XmlEntityType type, const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content); void release_underlying() override; + void initialize_context() override; private: void parse(); @@ -217,7 +218,7 @@ class SaxParser : public Parser // A separate xmlpp::Document that is just used for entity resolution, // and never seen in the API: - xmlpp::Document entity_resolver_doc_; + std::unique_ptr entity_resolver_doc_; friend struct SaxParserCallback; }; From 31716dcae4acfdd9e85e1076e084f277eef2f554 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 24 Sep 2015 09:55:55 +0200 Subject: [PATCH 015/240] Validators: Change which methods are virtual, add override * libxml++/validators/validator.h: Add some pure virtual methods. * libxml++/validators/dtdvalidator.[h|cc]: Only overridden methods are virtual. operator bool() is explicit and overridden. validate() returns void. * libxml++/validators/schemavalidatorbase.h: Replace operator const void*() by explicit operator bool(). Remove typedef BoolExpr. * libxml++/validators/relaxngvalidator.[h|cc]: * libxml++/validators/xsdvalidator.[h|cc]: Replace operator const void*() by explicit operator bool(). Add override. Bug #754673. --- libxml++/validators/dtdvalidator.cc | 14 +++++----- libxml++/validators/dtdvalidator.h | 27 ++++++++++--------- libxml++/validators/relaxngvalidator.cc | 2 +- libxml++/validators/relaxngvalidator.h | 15 +++++------ libxml++/validators/schemavalidatorbase.h | 10 +------ libxml++/validators/validator.h | 32 ++++++++++++++++++++++- libxml++/validators/xsdvalidator.cc | 2 +- libxml++/validators/xsdvalidator.h | 15 +++++------ 8 files changed, 66 insertions(+), 51 deletions(-) diff --git a/libxml++/validators/dtdvalidator.cc b/libxml++/validators/dtdvalidator.cc index be4e6cab..210064f7 100644 --- a/libxml++/validators/dtdvalidator.cc +++ b/libxml++/validators/dtdvalidator.cc @@ -32,7 +32,7 @@ DtdValidator::DtdValidator(const Glib::ustring& file) parse_subset("",file); } -DtdValidator::DtdValidator(const Glib::ustring& external,const Glib::ustring& system) +DtdValidator::DtdValidator(const Glib::ustring& external, const Glib::ustring& system) : dtd_(nullptr) { parse_subset(external,system); @@ -49,7 +49,7 @@ void DtdValidator::parse_file(const Glib::ustring& filename) parse_subset("",filename); } -void DtdValidator::parse_subset(const Glib::ustring& external,const Glib::ustring& system) +void DtdValidator::parse_subset(const Glib::ustring& external, const Glib::ustring& system) { release_underlying(); // Free any existing dtd. xmlResetLastError(); @@ -106,7 +106,7 @@ void DtdValidator::release_underlying() } } -DtdValidator::operator bool() const +DtdValidator::operator bool() const noexcept { return dtd_ != nullptr; } @@ -121,9 +121,9 @@ const Dtd* DtdValidator::get_dtd() const return dtd_; } -bool DtdValidator::validate(const Document* doc) +void DtdValidator::validate(const Document* document) { - if (!doc) + if (!document) { throw internal_error("Document pointer cannot be 0."); } @@ -145,15 +145,13 @@ bool DtdValidator::validate(const Document* doc) xmlResetLastError(); initialize_valid(); - const bool res = (bool)xmlValidateDtd( valid_, (xmlDoc*)doc->cobj(), dtd_->cobj() ); + const bool res = (bool)xmlValidateDtd( valid_, (xmlDoc*)document->cobj(), dtd_->cobj() ); if (!res) { check_for_exception(); throw validity_error("Document failed DTD validation\n" + format_xml_error()); } - - return res; } } // namespace xmlpp diff --git a/libxml++/validators/dtdvalidator.h b/libxml++/validators/dtdvalidator.h index 01b04c1f..aaa7a8d3 100644 --- a/libxml++/validators/dtdvalidator.h +++ b/libxml++/validators/dtdvalidator.h @@ -15,6 +15,7 @@ namespace xmlpp { /** XML DTD validator. + * DTD = Document Type Definition */ class DtdValidator : public Validator { @@ -32,45 +33,47 @@ class DtdValidator : public Validator * @param system The URL of the DTD. * @throws xmlpp::parse_error */ - explicit DtdValidator(const Glib::ustring& external,const Glib::ustring& system); + explicit DtdValidator(const Glib::ustring& external, const Glib::ustring& system); ~DtdValidator() override; - //TODO: Remove virtuals when we can break ABI, - //or really put these in the base class. - /** Parse an external subset (DTD file). * If the validator already contains a DTD, that DTD is deleted. * @param external The external ID of the DTD. * @param system The URL of the DTD. * @throws xmlpp::parse_error */ - virtual void parse_subset(const Glib::ustring& external,const Glib::ustring& system); + void parse_subset(const Glib::ustring& external, const Glib::ustring& system); /** Parse an external subset (DTD file). * If the validator already contains a DTD, that DTD is deleted. * @param filename The URL of the DTD. * @throws xmlpp::parse_error */ - virtual void parse_file(const Glib::ustring& filename); + void parse_file(const Glib::ustring& filename) override; /** Parse a DTD from a string. * If the validator already contains a DTD, that DTD is deleted. * @param contents The DTD as a string. * @throws xmlpp::parse_error */ - virtual void parse_memory(const Glib::ustring& contents); + void parse_memory(const Glib::ustring& contents) override; /** Parse a DTD from a stream. * If the validator already contains a DTD, that DTD is deleted. * @param in The stream. * @throws xmlpp::parse_error */ - virtual void parse_stream(std::istream& in); + void parse_stream(std::istream& in); /** Test whether a DTD has been parsed. + * For instance + * @code + * if (validator) + * do_something(); + * @endcode */ - operator bool() const; + explicit operator bool() const noexcept override; /** Get the parsed DTD. * @returns A pointer to the parsed DTD, or 0. @@ -85,12 +88,11 @@ class DtdValidator : public Validator /** Validate a document, using a previously parsed DTD. * The internal subset (if present) is de-coupled (i.e. not used), * which could give problems if ID or IDREF is present. - * @param doc Pointer to the document. - * @returns Whether the document is valid. + * @param document Pointer to the document. * @throws xmlpp::internal_error * @throws xmlpp::validity_error */ - bool validate(const Document* doc); + void validate(const Document* document) override; protected: void release_underlying() override; @@ -101,4 +103,3 @@ class DtdValidator : public Validator } // namespace xmlpp #endif //__LIBXMLPP_VALIDATORS_DTDVALIDATOR_H - diff --git a/libxml++/validators/relaxngvalidator.cc b/libxml++/validators/relaxngvalidator.cc index 0d00560c..bbd9c9ad 100644 --- a/libxml++/validators/relaxngvalidator.cc +++ b/libxml++/validators/relaxngvalidator.cc @@ -117,7 +117,7 @@ const RelaxNGSchema* RelaxNGValidator::get_schema() const return pimpl_->schema; } -RelaxNGValidator::operator const void*() const +RelaxNGValidator::operator bool() const noexcept { return reinterpret_cast(pimpl_->schema && pimpl_->schema->cobj()); } diff --git a/libxml++/validators/relaxngvalidator.h b/libxml++/validators/relaxngvalidator.h index 1f86222f..38051c64 100644 --- a/libxml++/validators/relaxngvalidator.h +++ b/libxml++/validators/relaxngvalidator.h @@ -71,9 +71,6 @@ class RelaxNGValidator : public SchemaValidatorBase ~RelaxNGValidator() override; - //TODO: Remove virtuals when we can break ABI, - //or really put these in the base class. - /** Parse a schema definition file. * The schema must be defined with XML syntax (.rng file). The compact syntax * (.rnc file) is not supported. @@ -83,7 +80,7 @@ class RelaxNGValidator : public SchemaValidatorBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - virtual void parse_file(const Glib::ustring& filename); + void parse_file(const Glib::ustring& filename) override; /** Parse a schema definition from a string. * The schema must be defined with XML syntax. The compact syntax is not supported. @@ -93,7 +90,7 @@ class RelaxNGValidator : public SchemaValidatorBase * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ - virtual void parse_memory(const Glib::ustring& contents); + void parse_memory(const Glib::ustring& contents) override; /** Parse a schema definition from a document. * If the validator already contains a schema, that schema is released @@ -101,7 +98,7 @@ class RelaxNGValidator : public SchemaValidatorBase * @param document A preparsed document tree, containing the schema definition. * @throws xmlpp::parse_error */ - virtual void parse_document(const Document* document); + void parse_document(const Document* document) override; /** Set a schema. * If the validator already contains a schema, that schema is released @@ -123,7 +120,7 @@ class RelaxNGValidator : public SchemaValidatorBase * do_something(); * @endcode */ - virtual operator BoolExpr() const; + explicit operator bool() const noexcept override; /** Get the schema. * @returns A pointer to the schema, or 0. @@ -140,7 +137,7 @@ class RelaxNGValidator : public SchemaValidatorBase * @throws xmlpp::internal_error * @throws xmlpp::validity_error */ - virtual void validate(const Document* document); + void validate(const Document* document) override; /** Validate an XML file, using a previously parsed schema. * @param filename The URL of the XML file. @@ -148,7 +145,7 @@ class RelaxNGValidator : public SchemaValidatorBase * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - virtual void validate(const Glib::ustring& filename); + void validate(const Glib::ustring& filename) override; protected: void initialize_valid() override; diff --git a/libxml++/validators/schemavalidatorbase.h b/libxml++/validators/schemavalidatorbase.h index 85299fd0..18a6a35a 100644 --- a/libxml++/validators/schemavalidatorbase.h +++ b/libxml++/validators/schemavalidatorbase.h @@ -40,9 +40,6 @@ class SchemaValidatorBase : public Validator SchemaValidatorBase(); ~SchemaValidatorBase() override; - //TODO: Remove virtuals when we can break ABI, - //or really put these in the base class. - /** Parse a schema definition file. * If the validator already contains a schema, that schema is released * (deleted if the validator owns the schema). @@ -67,11 +64,6 @@ class SchemaValidatorBase : public Validator */ virtual void parse_document(const Document* document) = 0; - /** This typedef is just to make it more obvious that - * our operator const void* should be used like operator bool(). - */ - typedef const void* BoolExpr; - /** Test whether a schema has been parsed. * For instance * @code @@ -79,7 +71,7 @@ class SchemaValidatorBase : public Validator * do_something(); * @endcode */ - virtual operator BoolExpr() const = 0; + explicit virtual operator bool() const noexcept = 0; /** Validate a document, using a previously parsed schema. * @param document Pointer to the document. diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index 82c94c80..e46f8993 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -12,7 +12,7 @@ #pragma warning (disable : 4786) #endif -#include +#include #include #include #include // std::exception_ptr @@ -23,6 +23,8 @@ extern "C" { namespace xmlpp { +class Document; + /** Base class for XML validators. */ class Validator : NonCopyable @@ -31,6 +33,34 @@ class Validator : NonCopyable Validator(); ~Validator() override; + /** Parse a schema definition file or an external subset (DTD file). + * @param filename The URL of the schema or the DTD. + * @throws xmlpp::parse_error + */ + virtual void parse_file(const Glib::ustring& filename) = 0; + + /** Parse a schema definition or a DTD from a string. + * @param contents The schema definition or the DTD as a string. + * @throws xmlpp::parse_error + */ + virtual void parse_memory(const Glib::ustring& contents) = 0; + + /** Validate a document, using a previously parsed schema or DTD. + * @param document Pointer to the document. + * @throws xmlpp::internal_error + * @throws xmlpp::validity_error + */ + virtual void validate(const Document* document) = 0; + + /** Test whether a schema or a DTD has been parsed. + * For instance + * @code + * if (validator) + * do_something(); + * @endcode + */ + explicit virtual operator bool() const noexcept = 0; + protected: virtual void initialize_valid(); virtual void release_underlying(); diff --git a/libxml++/validators/xsdvalidator.cc b/libxml++/validators/xsdvalidator.cc index 674296e3..0dd8a099 100644 --- a/libxml++/validators/xsdvalidator.cc +++ b/libxml++/validators/xsdvalidator.cc @@ -114,7 +114,7 @@ const XsdSchema* XsdValidator::get_schema() const return pimpl_->schema; } -XsdValidator::operator const void*() const +XsdValidator::operator bool() const noexcept { return reinterpret_cast(pimpl_->schema && pimpl_->schema->cobj()); } diff --git a/libxml++/validators/xsdvalidator.h b/libxml++/validators/xsdvalidator.h index bf65ecd8..9f784bb3 100644 --- a/libxml++/validators/xsdvalidator.h +++ b/libxml++/validators/xsdvalidator.h @@ -67,16 +67,13 @@ class XsdValidator : public SchemaValidatorBase ~XsdValidator() override; - //TODO: Remove virtuals when we can break ABI, - //or really put these in the base class. - /** Parse a schema definition file. * If the validator already contains a schema, that schema is released * (deleted if the validator owns the schema). * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - virtual void parse_file(const Glib::ustring& filename); + void parse_file(const Glib::ustring& filename) override; /** Parse a schema definition from a string. * If the validator already contains a schema, that schema is released @@ -84,7 +81,7 @@ class XsdValidator : public SchemaValidatorBase * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ - virtual void parse_memory(const Glib::ustring& contents); + void parse_memory(const Glib::ustring& contents) override; /** Parse a schema definition from a document. * If the validator already contains a schema, that schema is released @@ -92,7 +89,7 @@ class XsdValidator : public SchemaValidatorBase * @param document A preparsed document tree, containing the schema definition. * @throws xmlpp::parse_error */ - virtual void parse_document(const Document* document); + void parse_document(const Document* document) override; /** Set a schema. * If the validator already contains a schema, that schema is released @@ -114,7 +111,7 @@ class XsdValidator : public SchemaValidatorBase * do_something(); * @endcode */ - virtual operator BoolExpr() const; + explicit operator bool() const noexcept override; /** Get the schema. * @returns A pointer to the schema, or 0. @@ -131,14 +128,14 @@ class XsdValidator : public SchemaValidatorBase * @throws xmlpp::internal_error * @throws xmlpp::validity_error */ - virtual void validate(const Document* document); + void validate(const Document* document) override; /** Validate an XML file, using a previously parsed schema. * @param filename The URL of the XML file. * @throws xmlpp::internal_error * @throws xmlpp::validity_error */ - virtual void validate(const Glib::ustring& filename); + void validate(const Glib::ustring& filename) override; protected: void initialize_valid() override; From a82fb4d25c6f6aac7a76f3cc5498771b2615a6d0 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 24 Sep 2015 17:20:17 +0200 Subject: [PATCH 016/240] Validators: Move _xmlValidCtxt pointer to DtdValidator * libxml++/validators/validator.[h|cc]: * libxml++/validators/dtdvalidator.[h|cc]: Rename _xmlValidCtxt* valid_ to context_ and move it from Validator to DtdValidator. Rename initialize_valid() to initialize_context(). * libxml++/validators/schemavalidatorbase.[h|cc]: * libxml++/validators/relaxngvalidator.[h|cc]: * libxml++/validators/xsdvalidator.[h|cc]: Rename initialize_valid() to initialize_context(). Bug #754673. --- libxml++/validators/dtdvalidator.cc | 44 +++++++++++++++++----- libxml++/validators/dtdvalidator.h | 2 + libxml++/validators/relaxngvalidator.cc | 6 +-- libxml++/validators/relaxngvalidator.h | 2 +- libxml++/validators/schemavalidatorbase.cc | 4 +- libxml++/validators/schemavalidatorbase.h | 2 +- libxml++/validators/validator.cc | 25 ++---------- libxml++/validators/validator.h | 3 +- libxml++/validators/xsdvalidator.cc | 8 ++-- libxml++/validators/xsdvalidator.h | 2 +- 10 files changed, 52 insertions(+), 46 deletions(-) diff --git a/libxml++/validators/dtdvalidator.cc b/libxml++/validators/dtdvalidator.cc index 210064f7..14f91267 100644 --- a/libxml++/validators/dtdvalidator.cc +++ b/libxml++/validators/dtdvalidator.cc @@ -22,18 +22,18 @@ namespace xmlpp { DtdValidator::DtdValidator() -: dtd_(nullptr) +: context_(nullptr), dtd_(nullptr) { } DtdValidator::DtdValidator(const Glib::ustring& file) -: dtd_(nullptr) +: context_(nullptr), dtd_(nullptr) { parse_subset("",file); } DtdValidator::DtdValidator(const Glib::ustring& external, const Glib::ustring& system) -: dtd_(nullptr) +: context_(nullptr), dtd_(nullptr) { parse_subset(external,system); } @@ -41,7 +41,6 @@ DtdValidator::DtdValidator(const Glib::ustring& external, const Glib::ustring& s DtdValidator::~DtdValidator() { release_underlying(); - Validator::release_underlying(); } void DtdValidator::parse_file(const Glib::ustring& filename) @@ -93,9 +92,32 @@ void DtdValidator::parse_stream(std::istream& in) dtd_ = static_cast(dtd->_private); } +void DtdValidator::initialize_context() +{ + Validator::initialize_context(); + + if (context_) + { + //Tell the validation context about the callbacks: + context_->error = &callback_validity_error; + context_->warning = &callback_validity_warning; + + //Allow the callback_validity_*() methods to retrieve the C++ instance: + context_->userData = this; + } +} + void DtdValidator::release_underlying() { - if(dtd_) + if (context_) + { + context_->userData = nullptr; //Not really necessary. + + xmlFreeValidCtxt(context_); + context_ = nullptr; + } + + if (dtd_) { //Make a local pointer to the underlying xmlDtd object as the wrapper is destroyed first. //After free_wrappers is called dtd_ will be invalid (e.g. delete dtd_) @@ -104,6 +126,8 @@ void DtdValidator::release_underlying() xmlFreeDtd(dtd); dtd_ = nullptr; } + + Validator::release_underlying(); } DtdValidator::operator bool() const noexcept @@ -134,18 +158,18 @@ void DtdValidator::validate(const Document* document) } // A context is required at this stage only - if (!valid_) - valid_ = xmlNewValidCtxt(); + if (!context_) + context_ = xmlNewValidCtxt(); - if(!valid_) + if(!context_) { throw internal_error("Couldn't create validation context"); } xmlResetLastError(); - initialize_valid(); + initialize_context(); - const bool res = (bool)xmlValidateDtd( valid_, (xmlDoc*)document->cobj(), dtd_->cobj() ); + const bool res = (bool)xmlValidateDtd( context_, (xmlDoc*)document->cobj(), dtd_->cobj() ); if (!res) { diff --git a/libxml++/validators/dtdvalidator.h b/libxml++/validators/dtdvalidator.h index aaa7a8d3..0ee0c71a 100644 --- a/libxml++/validators/dtdvalidator.h +++ b/libxml++/validators/dtdvalidator.h @@ -95,8 +95,10 @@ class DtdValidator : public Validator void validate(const Document* document) override; protected: + void initialize_context() override; void release_underlying() override; + _xmlValidCtxt* context_; Dtd* dtd_; }; diff --git a/libxml++/validators/relaxngvalidator.cc b/libxml++/validators/relaxngvalidator.cc index bbd9c9ad..8e92365a 100644 --- a/libxml++/validators/relaxngvalidator.cc +++ b/libxml++/validators/relaxngvalidator.cc @@ -123,10 +123,10 @@ RelaxNGValidator::operator bool() const noexcept } -void RelaxNGValidator::initialize_valid() +void RelaxNGValidator::initialize_context() { xmlRelaxNGSetValidErrors(pimpl_->context, &callback_validity_error, &callback_validity_warning, this); - SchemaValidatorBase::initialize_valid(); + SchemaValidatorBase::initialize_context(); } void RelaxNGValidator::validate(const Document* document) @@ -145,7 +145,7 @@ void RelaxNGValidator::validate(const Document* document) throw internal_error("RelaxNGValidator::validate(): Could not create validating context"); xmlResetLastError(); - initialize_valid(); + initialize_context(); const int res = xmlRelaxNGValidateDoc(pimpl_->context, const_cast(document->cobj())); if (res != 0) diff --git a/libxml++/validators/relaxngvalidator.h b/libxml++/validators/relaxngvalidator.h index 38051c64..a12b7105 100644 --- a/libxml++/validators/relaxngvalidator.h +++ b/libxml++/validators/relaxngvalidator.h @@ -148,7 +148,7 @@ class RelaxNGValidator : public SchemaValidatorBase void validate(const Glib::ustring& filename) override; protected: - void initialize_valid() override; + void initialize_context() override; void release_underlying() override; private: diff --git a/libxml++/validators/schemavalidatorbase.cc b/libxml++/validators/schemavalidatorbase.cc index 04aa74c7..f2824522 100644 --- a/libxml++/validators/schemavalidatorbase.cc +++ b/libxml++/validators/schemavalidatorbase.cc @@ -36,9 +36,9 @@ void SchemaValidatorBase::release_underlying() Validator::release_underlying(); } -void SchemaValidatorBase::initialize_valid() +void SchemaValidatorBase::initialize_context() { - Validator::initialize_valid(); + Validator::initialize_context(); } } // namespace xmlpp diff --git a/libxml++/validators/schemavalidatorbase.h b/libxml++/validators/schemavalidatorbase.h index 18a6a35a..f5b7f86d 100644 --- a/libxml++/validators/schemavalidatorbase.h +++ b/libxml++/validators/schemavalidatorbase.h @@ -89,7 +89,7 @@ class SchemaValidatorBase : public Validator virtual void validate(const Glib::ustring& filename) = 0; protected: - void initialize_valid() override; + void initialize_context() override; void release_underlying() override; }; diff --git a/libxml++/validators/validator.cc b/libxml++/validators/validator.cc index 71e59991..cd5d42d1 100644 --- a/libxml++/validators/validator.cc +++ b/libxml++/validators/validator.cc @@ -15,7 +15,7 @@ namespace xmlpp { Validator::Validator() -: valid_(nullptr), exception_ptr_(nullptr) +: exception_ptr_(nullptr) { } @@ -24,34 +24,15 @@ Validator::~Validator() release_underlying(); } -void Validator::initialize_valid() +void Validator::initialize_context() { - // valid_ is used only by DtdValidator. - //TODO: When we can break ABI, move valid_ to DtdValidator. - if (valid_) - { - //Tell the validation context about the callbacks: - valid_->error = &callback_validity_error; - valid_->warning = &callback_validity_warning; - - //Allow the callback_validity_*() methods to retrieve the C++ instance: - valid_->userData = this; - } - - //Clear these temporary buffers too: + //Clear these temporary buffers: validate_error_.erase(); validate_warning_.erase(); } void Validator::release_underlying() { - if(valid_) - { - valid_->userData = nullptr; //Not really necessary. - - xmlFreeValidCtxt(valid_); - valid_ = nullptr; - } } void Validator::on_validity_error(const Glib::ustring& message) diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index e46f8993..e25a176d 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -62,7 +62,7 @@ class Validator : NonCopyable explicit virtual operator bool() const noexcept = 0; protected: - virtual void initialize_valid(); + virtual void initialize_context(); virtual void release_underlying(); virtual void on_validity_error(const Glib::ustring& message); @@ -76,7 +76,6 @@ class Validator : NonCopyable static void callback_validity_error(void* ctx, const char* msg, ...); static void callback_validity_warning(void* ctx, const char* msg, ...); - _xmlValidCtxt* valid_; std::exception_ptr exception_ptr_; // Built gradually - used in an exception at the end of validation. Glib::ustring validate_error_; diff --git a/libxml++/validators/xsdvalidator.cc b/libxml++/validators/xsdvalidator.cc index 0dd8a099..44be9a05 100644 --- a/libxml++/validators/xsdvalidator.cc +++ b/libxml++/validators/xsdvalidator.cc @@ -120,10 +120,10 @@ XsdValidator::operator bool() const noexcept } -void XsdValidator::initialize_valid() +void XsdValidator::initialize_context() { xmlSchemaSetValidErrors(pimpl_->context, &callback_validity_error, &callback_validity_warning, this); - SchemaValidatorBase::initialize_valid(); + SchemaValidatorBase::initialize_context(); } @@ -143,7 +143,7 @@ void XsdValidator::validate(const Document* document) throw internal_error("XsdValidator::validate(): Could not create validating context"); xmlResetLastError(); - initialize_valid(); + initialize_context(); const int res = xmlSchemaValidateDoc(pimpl_->context, const_cast(document->cobj())); if (res != 0) @@ -170,7 +170,7 @@ void XsdValidator::validate(const Glib::ustring& filename) throw internal_error("XsdValidator::validate(): Could not create validating context"); xmlResetLastError(); - initialize_valid(); + initialize_context(); const int res = xmlSchemaValidateFile(pimpl_->context, filename.c_str(), 0); if (res != 0) diff --git a/libxml++/validators/xsdvalidator.h b/libxml++/validators/xsdvalidator.h index 9f784bb3..2269afb9 100644 --- a/libxml++/validators/xsdvalidator.h +++ b/libxml++/validators/xsdvalidator.h @@ -138,7 +138,7 @@ class XsdValidator : public SchemaValidatorBase void validate(const Glib::ustring& filename) override; protected: - void initialize_valid() override; + void initialize_context() override; void release_underlying() override; private: From fb20606fb058d3d1048ccf616475a163a5ea742c Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 28 Sep 2015 16:01:57 +0200 Subject: [PATCH 017/240] Move add_child() methods from Node to Element * libxml++/nodes/element.[h|cc]: * libxml++/nodes/node.[h|cc]: Move all add_child*() methods to Element and rename them to add_child_element*(). * examples/dom_build/main.cc: * examples/dom_update_namespace/main.cc: * examples/dtdvalidation/main.cc: * examples/sax_parser_build_dom/svgparser.cc: Change add_child() to add_child_element(). Bug #754673. --- examples/dom_build/main.cc | 9 +- examples/dom_update_namespace/main.cc | 10 +- examples/dtdvalidation/main.cc | 7 +- examples/sax_parser_build_dom/svgparser.cc | 4 +- libxml++/nodes/element.cc | 135 ++++++++++++++++++++- libxml++/nodes/element.h | 109 ++++++++++++++++- libxml++/nodes/node.cc | 135 --------------------- libxml++/nodes/node.h | 108 ----------------- 8 files changed, 250 insertions(+), 267 deletions(-) diff --git a/examples/dom_build/main.cc b/examples/dom_build/main.cc index c1409bd6..f22b4934 100644 --- a/examples/dom_build/main.cc +++ b/examples/dom_build/main.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* main.cc * * Copyright (C) 2002 The libxml++ development team @@ -48,7 +46,7 @@ main(int /* argc */, char** /* argv */) nodeRoot->set_namespace_declaration("http://foobar", "foobar"); //Also associate this prefix with this namespace: nodeRoot->set_child_text("\n"); - auto nodeChild = nodeRoot->add_child("examplechild"); + auto nodeChild = nodeRoot->add_child_element("examplechild"); //Associate prefix with namespace: nodeChild->set_namespace_declaration("http://bar", "bar"); @@ -62,9 +60,9 @@ main(int /* argc */, char** /* argv */) nodeChild->add_child_text("\n"); nodeChild->add_child_processing_instruction("application1", "This is an example node"); nodeChild->add_child_text("\n"); - nodeChild->add_child("child_of_child", "bar"); + nodeChild->add_child_element("child_of_child", "bar"); - nodeChild = nodeRoot->add_child("examplechild", "foobar"); //foobar is the namespace prefix + nodeChild = nodeRoot->add_child_element("examplechild", "foobar"); //foobar is the namespace prefix nodeChild->set_attribute("id", "2", "foobar"); //foobar is the namespace prefix. auto whole = document.write_to_string(); @@ -79,4 +77,3 @@ main(int /* argc */, char** /* argv */) return EXIT_SUCCESS; } - diff --git a/examples/dom_update_namespace/main.cc b/examples/dom_update_namespace/main.cc index 9a733c25..ed460415 100644 --- a/examples/dom_update_namespace/main.cc +++ b/examples/dom_update_namespace/main.cc @@ -100,10 +100,10 @@ void TestNamespace::test_create_new_node_with_default_namespace() "Input file shouldn't have any child in alternate default namespace"); // Add child nodes in default namespace and check document again - auto child = root_->add_child("child"); + auto child = root_->add_child_element("child"); child->set_namespace_declaration(nsmap_["ns1"], ""); root_->add_child_text("\n"); - root_->add_child_with_new_ns("child", nsmap_["ns1"]); + root_->add_child_element_with_new_ns("child", nsmap_["ns1"]); root_->add_child_text("\n"); std::cout << " File " << filename << " after modification" << std::endl @@ -128,12 +128,12 @@ void TestNamespace::test_create_new_node_using_existing_namespace_prefix() "Input file shouldn't have any child in child namespace"); // Add child nodes with specific namespace and check document again - auto child = root_->add_child("child", "ns0"); + auto child = root_->add_child_element("child", "ns0"); child->set_namespace_declaration(nsmap_["ns1"], ""); root_->add_child_text("\n"); - root_->add_child_with_new_ns("child", nsmap_["ns1"]); + root_->add_child_element_with_new_ns("child", nsmap_["ns1"]); root_->add_child_text("\n"); - root_->add_child_with_new_ns("child", nsmap_["ns1"], "ns3"); + root_->add_child_element_with_new_ns("child", nsmap_["ns1"], "ns3"); root_->add_child_text("\n"); std::cout << " File " << filename << " after modification" << std::endl diff --git a/examples/dtdvalidation/main.cc b/examples/dtdvalidation/main.cc index d5e594f5..6c10accc 100644 --- a/examples/dtdvalidation/main.cc +++ b/examples/dtdvalidation/main.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* main.cc * * Copyright (C) 2002 The libxml++ development team @@ -61,9 +59,9 @@ int main(int argc, char* argv[]) } /* auto nodeRoot2 = */document.create_root_node("example"); - auto child = document.get_root_node()->add_child("examplechild"); + auto child = document.get_root_node()->add_child_element("examplechild"); child->set_attribute("id", "an_id"); - child->add_child("child_of_child"); + child->add_child_element("child_of_child"); try { @@ -85,4 +83,3 @@ int main(int argc, char* argv[]) } return return_code; } - diff --git a/examples/sax_parser_build_dom/svgparser.cc b/examples/sax_parser_build_dom/svgparser.cc index 6e474a7c..b90592ee 100644 --- a/examples/sax_parser_build_dom/svgparser.cc +++ b/examples/sax_parser_build_dom/svgparser.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* svgparser.cc * * By Dan Dennedy @@ -69,7 +67,7 @@ void Parser::on_start_element(const Glib::ustring& name, else { // Create the other elements as child nodes of the last nodes: - element_normal = m_context.top()->add_child(elementName); + element_normal = m_context.top()->add_child_element(elementName); } // TODO: The following is a hack because it leverages knowledge of libxml++ diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc index ea97f6b3..d6b1df9f 100644 --- a/libxml++/nodes/element.cc +++ b/libxml++/nodes/element.cc @@ -10,6 +10,22 @@ #include +namespace // anonymous +{ +// Common part of all add_child_element*() methods. +xmlpp::Element* add_child_element_common(const Glib::ustring& name, xmlNode* child, xmlNode* node) +{ + if (!node) + { + xmlFreeNode(child); + throw xmlpp::internal_error("Could not add child element node " + name); + } + xmlpp::Node::create_wrapper(node); + return static_cast(node->_private); +} + +} // anonymous namespace + namespace xmlpp { @@ -128,6 +144,123 @@ void Element::remove_attribute(const Glib::ustring& name, const Glib::ustring& n } } +Element* Element::add_child_element(const Glib::ustring& name, + const Glib::ustring& ns_prefix) +{ + auto child = create_new_child_element_node(name, ns_prefix); + auto node = xmlAddChild(cobj(), child); + return add_child_element_common(name, child, node); +} + +Element* Element::add_child_element(xmlpp::Node* previous_sibling, + const Glib::ustring& name, const Glib::ustring& ns_prefix) +{ + if (!previous_sibling) + return 0; + + auto child = create_new_child_element_node(name, ns_prefix); + auto node = xmlAddNextSibling(previous_sibling->cobj(), child); + return add_child_element_common(name, child, node); +} + +Element* Element::add_child_element_before(xmlpp::Node* next_sibling, + const Glib::ustring& name, const Glib::ustring& ns_prefix) +{ + if (!next_sibling) + return 0; + + auto child = create_new_child_element_node(name, ns_prefix); + auto node = xmlAddPrevSibling(next_sibling->cobj(), child); + return add_child_element_common(name, child, node); +} + +Element* Element::add_child_element_with_new_ns(const Glib::ustring& name, + const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) +{ + auto child = create_new_child_element_node_with_new_ns(name, ns_uri, ns_prefix); + auto node = xmlAddChild(cobj(), child); + return add_child_element_common(name, child, node); +} + +Element* Element::add_child_element_with_new_ns(xmlpp::Node* previous_sibling, + const Glib::ustring& name, + const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) +{ + if (!previous_sibling) + return 0; + + auto child = create_new_child_element_node_with_new_ns(name, ns_uri, ns_prefix); + auto node = xmlAddNextSibling(previous_sibling->cobj(), child); + return add_child_element_common(name, child, node); +} + +Element* Element::add_child_element_before_with_new_ns(xmlpp::Node* next_sibling, + const Glib::ustring& name, + const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) +{ + if (!next_sibling) + return 0; + + auto child = create_new_child_element_node_with_new_ns(name, ns_uri, ns_prefix); + auto node = xmlAddPrevSibling(next_sibling->cobj(), child); + return add_child_element_common(name, child, node); +} + +_xmlNode* Element::create_new_child_element_node(const Glib::ustring& name, + const Glib::ustring& ns_prefix) +{ + xmlNs* ns = nullptr; + + if (cobj()->type != XML_ELEMENT_NODE) + throw internal_error("You can only add child nodes to element nodes"); + + if (ns_prefix.empty()) + { + //Retrieve default namespace if it exists + ns = xmlSearchNs(cobj()->doc, cobj(), 0); + } + else + { + //Use the existing namespace if one exists: + ns = xmlSearchNs(cobj()->doc, cobj(), (const xmlChar*)ns_prefix.c_str()); + if (!ns) + throw exception("The namespace prefix (" + ns_prefix + ") has not been declared."); + } + + return xmlNewNode(ns, (const xmlChar*)name.c_str()); +} + +_xmlNode* Element::create_new_child_element_node_with_new_ns(const Glib::ustring& name, + const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) +{ + if (cobj()->type != XML_ELEMENT_NODE) + throw internal_error("You can only add child nodes to element nodes."); + + auto child = xmlNewNode(0, (const xmlChar*)name.c_str()); + if (!child) + throw internal_error("Could not create new element node."); + + auto ns = xmlNewNs(child, (const xmlChar*)(ns_uri.empty() ? 0 : ns_uri.c_str()), + (const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) ); + // xmlNewNs() does not create a namespace node for the predefined xml prefix. + // It's usually defined in the document and not in any specific node. + if (!ns && ns_prefix == "xml") + { + ns = xmlSearchNs(cobj()->doc, cobj(), (const xmlChar*)ns_prefix.c_str()); + if (ns && (ns_uri != (ns->href ? (const char*)ns->href : ""))) + ns = nullptr; + } + if (!ns) + { + xmlFreeNode(child); + throw internal_error("Could not create new namespace node."); + } + + xmlSetNs(child, ns); + + return child; +} + const TextNode* Element::get_child_text() const { // FIXME: return only the first content node @@ -272,7 +405,6 @@ Glib::ustring Element::get_namespace_uri_for_prefix(const Glib::ustring& ns_pref return result; } - CommentNode* Element::add_child_comment(const Glib::ustring& content) { auto child = xmlNewComment((const xmlChar*)content.c_str()); @@ -288,7 +420,6 @@ CommentNode* Element::add_child_comment(const Glib::ustring& content) return static_cast(node->_private); } - CdataNode* Element::add_child_cdata(const Glib::ustring& content) { auto child = xmlNewCDataBlock(cobj()->doc, (const xmlChar*)content.c_str(), content.bytes()); diff --git a/libxml++/nodes/element.h b/libxml++/nodes/element.h index 5bb1aa38..472c4023 100644 --- a/libxml++/nodes/element.h +++ b/libxml++/nodes/element.h @@ -108,15 +108,110 @@ class Element : public Node void remove_attribute(const Glib::ustring& name, const Glib::ustring& ns_prefix = Glib::ustring()); + /** Add a child element to this node. + * + * @newin{3,0} Replaces Node::add_child() + * + * @param name The new node name + * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw an exception. + * @returns The newly-created element + * @throws xmlpp::exception If a namespace prefix is specified, but has not been declared. + * @throws xmlpp::internal_error If this node is not an element node, + * or the child node cannot be created. + */ + Element* add_child_element(const Glib::ustring& name, + const Glib::ustring& ns_prefix = Glib::ustring()); + + /** Add a child element to this node after the specified existing child node. + * + * @newin{3,0} Replaces Node::add_child() + * + * @param previous_sibling An existing child node. + * @param name The new node name + * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw an exception. + * @returns The newly-created element + * @throws xmlpp::exception If a namespace prefix is specified, but has not been declared. + * @throws xmlpp::internal_error If this node is not an element node, + * or the child node cannot be created. + */ + Element* add_child_element(xmlpp::Node* previous_sibling, const Glib::ustring& name, + const Glib::ustring& ns_prefix = Glib::ustring()); + + /** Add a child element to this node before the specified existing child node. + * + * @newin{3,0} Replaces Node::add_child_before() + * + * @param next_sibling An existing child node. + * @param name The new node name + * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw an exception. + * @returns The newly-created element + * @throws xmlpp::exception If a namespace prefix is specified, but has not been declared. + * @throws xmlpp::internal_error If this node is not an element node, + * or the child node cannot be created. + */ + Element* add_child_element_before(xmlpp::Node* next_sibling, const Glib::ustring& name, + const Glib::ustring& ns_prefix = Glib::ustring()); + + /** Add a child element to this node. + * + * @newin{3,0} Replaces Node::add_child_with_new_ns() + * + * @param name The new node name. + * @param ns_uri The namespace to associate with the prefix, + * or to use as the default namespace if no prefix is specified. + * @param ns_prefix The prefix of the node's namespace. If no prefix is specified + * then the namespace URI will be the default namespace. + * @returns The newly-created element. + * @throws xmlpp::internal_error If this node is not an element node, + * or the child node or the namespace node cannot be created. + */ + Element* add_child_element_with_new_ns(const Glib::ustring& name, + const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring()); + + /** Add a child element to this node after the specified existing child node. + * + * @newin{3,0} Replaces Node::add_child_with_new_ns() + * + * @param previous_sibling An existing child node. + * @param name The new node name. + * @param ns_uri The namespace to associate with the prefix, + * or to use as the default namespace if no prefix is specified. + * @param ns_prefix The prefix of the node's namespace. If no prefix is specified + * then the namespace URI will be the default namespace. + * @returns The newly-created element. + * @throws xmlpp::internal_error If this node is not an element node, + * or the child node or the namespace node cannot be created. + */ + Element* add_child_element_with_new_ns(xmlpp::Node* previous_sibling, const Glib::ustring& name, + const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring()); + + /** Add a child element to this node before the specified existing child node. + * + * @newin{3,0} Replaces Node::add_child_before_with_new_ns() + * + * @param next_sibling An existing child node. + * @param name The new node name. + * @param ns_uri The namespace to associate with the prefix, + * or to use as the default namespace if no prefix is specified. + * @param ns_prefix The prefix of the node's namespace. If no prefix is specified + * then the namespace URI will be the default namespace. + * @returns The newly-created element. + * @throws xmlpp::internal_error If this node is not an element node, + * or the child node or the namespace node cannot be created. + */ + Element* add_child_element_before_with_new_ns(xmlpp::Node* next_sibling, const Glib::ustring& name, + const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring()); /** Get the first child text content node. - * This is a convenience method, meant as an alternative to iterating over all the child nodes to find the first suitable node then and getting the text directly. + * This is a convenience method, meant as an alternative to iterating over all the + * child nodes to find the first suitable node then and getting the text directly. * @returns The first text node, if any. */ TextNode* get_child_text(); /** Get the first child text content node. - * This is a convenience method, meant as an alternative to iterating over all the child nodes to find the first suitable node then and getting the text directly. + * This is a convenience method, meant as an alternative to iterating over all the + * child nodes to find the first suitable node then and getting the text directly. * @returns The first text node, if any. */ const TextNode* get_child_text() const; @@ -205,8 +300,16 @@ class Element : public Node ProcessingInstructionNode* add_child_processing_instruction( const Glib::ustring& name, const Glib::ustring& content); -protected: +private: Glib::ustring get_namespace_uri_for_prefix(const Glib::ustring& ns_prefix) const; + + ///Create the C instance ready to be added to the parent node. + _xmlNode* create_new_child_element_node(const Glib::ustring& name, + const Glib::ustring& ns_prefix); + + ///Create the C instance ready to be added to the parent node. + _xmlNode* create_new_child_element_node_with_new_ns(const Glib::ustring& name, + const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix); }; } // namespace xmlpp diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index d9ba465e..d8f54e6a 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -213,18 +213,6 @@ Glib::ustring eval_common_to_string(const Glib::ustring& xpath, return Glib::ustring(); } -// Common part of all add_child*() methods. -xmlpp::Element* add_child_common(const Glib::ustring& name, xmlNode* child, xmlNode* node) -{ - if (!node) - { - xmlFreeNode(child); - throw xmlpp::internal_error("Could not add child element node " + name); - } - xmlpp::Node::create_wrapper(node); - return static_cast(node->_private); -} - } // anonymous namespace namespace xmlpp @@ -315,128 +303,6 @@ Node::const_NodeList Node::get_children(const Glib::ustring& name) const return get_children_common(name, impl_->children); } -Element* Node::add_child(const Glib::ustring& name, - const Glib::ustring& ns_prefix) -{ - auto child = create_new_child_node(name, ns_prefix); - auto node = xmlAddChild(impl_, child); - return add_child_common(name, child, node); -} - -Element* Node::add_child(xmlpp::Node* previous_sibling, - const Glib::ustring& name, - const Glib::ustring& ns_prefix) -{ - if (!previous_sibling) - return 0; - - auto child = create_new_child_node(name, ns_prefix); - auto node = xmlAddNextSibling(previous_sibling->cobj(), child); - return add_child_common(name, child, node); -} - -Element* Node::add_child_before(xmlpp::Node* next_sibling, - const Glib::ustring& name, - const Glib::ustring& ns_prefix) -{ - if (!next_sibling) - return 0; - - auto child = create_new_child_node(name, ns_prefix); - auto node = xmlAddPrevSibling(next_sibling->cobj(), child); - return add_child_common(name, child, node); -} - -Element* Node::add_child_with_new_ns(const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) -{ - auto child = create_new_child_node_with_new_ns(name, ns_uri, ns_prefix); - auto node = xmlAddChild(impl_, child); - return add_child_common(name, child, node); -} - -Element* Node::add_child_with_new_ns(xmlpp::Node* previous_sibling, - const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) -{ - if (!previous_sibling) - return 0; - - auto child = create_new_child_node_with_new_ns(name, ns_uri, ns_prefix); - auto node = xmlAddNextSibling(previous_sibling->cobj(), child); - return add_child_common(name, child, node); -} - -Element* Node::add_child_before_with_new_ns(xmlpp::Node* next_sibling, - const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) -{ - if (!next_sibling) - return 0; - - auto child = create_new_child_node_with_new_ns(name, ns_uri, ns_prefix); - auto node = xmlAddPrevSibling(next_sibling->cobj(), child); - return add_child_common(name, child, node); -} - -_xmlNode* Node::create_new_child_node(const Glib::ustring& name, const Glib::ustring& ns_prefix) -{ - xmlNs* ns = nullptr; - - if(impl_->type != XML_ELEMENT_NODE) - { - throw internal_error("You can only add child nodes to element nodes"); - } - - if(ns_prefix.empty()) - { - //Retrieve default namespace if it exists - ns = xmlSearchNs(impl_->doc, impl_, 0); - } - else - { - //Use the existing namespace if one exists: - ns = xmlSearchNs(impl_->doc, impl_, (const xmlChar*)ns_prefix.c_str()); - if (!ns) - { - throw exception("The namespace prefix (" + ns_prefix + ") has not been declared."); - } - } - - return xmlNewNode(ns, (const xmlChar*)name.c_str()); -} - -_xmlNode* Node::create_new_child_node_with_new_ns(const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) -{ - if (impl_->type != XML_ELEMENT_NODE) - throw internal_error("You can only add child nodes to element nodes."); - - auto child = xmlNewNode(0, (const xmlChar*)name.c_str()); - if (!child) - throw internal_error("Could not create new element node."); - - auto ns = xmlNewNs(child, (const xmlChar*)(ns_uri.empty() ? 0 : ns_uri.c_str()), - (const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) ); - // xmlNewNs() does not create a namespace node for the predefined xml prefix. - // It's usually defined in the document and not in any specific node. - if (!ns && ns_prefix == "xml") - { - ns = xmlSearchNs(impl_->doc, impl_, (const xmlChar*)ns_prefix.c_str()); - if (ns && (ns_uri != (ns->href ? (const char*)ns->href : ""))) - ns = nullptr; - } - if (!ns) - { - xmlFreeNode(child); - throw internal_error("Could not create new namespace node."); - } - - xmlSetNs(child, ns); - - return child; -} - void Node::remove_child(Node* node) { //TODO: Allow a node to be removed without deleting it, to allow it to be moved? @@ -788,5 +654,4 @@ void Node::free_wrappers(xmlNode* node) free_wrappers(reinterpret_cast(attr)); } - } //namespace xmlpp diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index f5b6e55d..02084eb9 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -23,9 +23,7 @@ extern "C" { namespace xmlpp { -class TextNode; class Element; -class Attribute; // xmlpp::XPathResultType is similar to xmlXPathObjectType in libxml2. /** An XPath expression is evaluated to yield a result, which @@ -153,103 +151,6 @@ class Node : public NonCopyable */ const_NodeList get_children(const Glib::ustring& name = Glib::ustring()) const; - /** Add a child element to this node. - * This node must be an element node. - * @param name The new node name - * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw an exception. - * @returns The newly-created element - * @throws xmlpp::exception If a namespace prefix is specified, but has not been declared. - * @throws xmlpp::internal_error If this node is not an element node, - * or the child node cannot be created. - */ - Element* add_child(const Glib::ustring& name, - const Glib::ustring& ns_prefix = Glib::ustring()); - - /** Add a child element to this node after the specified existing child node. - * This node must be an element node. - * - * @newin{2,24} - * - * @param previous_sibling An existing child node. - * @param name The new node name - * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw an exception. - * @returns The newly-created element - * @throws xmlpp::exception If a namespace prefix is specified, but has not been declared. - * @throws xmlpp::internal_error If this node is not an element node, - * or the child node cannot be created. - */ - Element* add_child(xmlpp::Node* previous_sibling, const Glib::ustring& name, - const Glib::ustring& ns_prefix = Glib::ustring()); - - /** Add a child element to this node before the specified existing child node. - * This node must be an element node. - * - * @newin{2,24} - * - * @param next_sibling An existing child node. - * @param name The new node name - * @param ns_prefix The namespace prefix. If the prefix has not been declared then this method will throw an exception. - * @returns The newly-created element - * @throws xmlpp::exception If a namespace prefix is specified, but has not been declared. - * @throws xmlpp::internal_error If this node is not an element node, - * or the child node cannot be created. - */ - Element* add_child_before(xmlpp::Node* next_sibling, const Glib::ustring& name, - const Glib::ustring& ns_prefix = Glib::ustring()); - - /** Add a child element to this node. - * This node must be an element node. - * - * @newin{2,38} - * - * @param name The new node name. - * @param ns_uri The namespace to associate with the prefix, - * or to use as the default namespace if no prefix is specified. - * @param ns_prefix The prefix of the node's namespace. If no prefix is specified - * then the namespace URI will be the default namespace. - * @returns The newly-created element. - * @throws xmlpp::internal_error If this node is not an element node, - * or the child node or the namespace node cannot be created. - */ - Element* add_child_with_new_ns(const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring()); - - /** Add a child element to this node after the specified existing child node. - * This node must be an element node. - * - * @newin{2,38} - * - * @param previous_sibling An existing child node. - * @param name The new node name. - * @param ns_uri The namespace to associate with the prefix, - * or to use as the default namespace if no prefix is specified. - * @param ns_prefix The prefix of the node's namespace. If no prefix is specified - * then the namespace URI will be the default namespace. - * @returns The newly-created element. - * @throws xmlpp::internal_error If this node is not an element node, - * or the child node or the namespace node cannot be created. - */ - Element* add_child_with_new_ns(xmlpp::Node* previous_sibling, const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring()); - - /** Add a child element to this node before the specified existing child node. - * This node must be an element node. - * - * @newin{2,38} - * - * @param next_sibling An existing child node. - * @param name The new node name. - * @param ns_uri The namespace to associate with the prefix, - * or to use as the default namespace if no prefix is specified. - * @param ns_prefix The prefix of the node's namespace. If no prefix is specified - * then the namespace URI will be the default namespace. - * @returns The newly-created element. - * @throws xmlpp::internal_error If this node is not an element node, - * or the child node or the namespace node cannot be created. - */ - Element* add_child_before_with_new_ns(xmlpp::Node* next_sibling, const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring()); - /** Remove the child node. * @param node The child node to remove. This Node will be deleted and therefore unusable after calling this method. */ @@ -421,15 +322,6 @@ class Node : public NonCopyable */ static void free_wrappers(_xmlNode* node); -protected: - - ///Create the C instance ready to be added to the parent node. - _xmlNode* create_new_child_node(const Glib::ustring& name, const Glib::ustring& ns_prefix); - - ///Create the C instance ready to be added to the parent node. - _xmlNode* create_new_child_node_with_new_ns(const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix); - private: _xmlNode* impl_; }; From 30e996f1cddf150d51ec348a974674bd7eded9fd Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 28 Sep 2015 17:00:44 +0200 Subject: [PATCH 018/240] Attribute and subclasses: Move some methods * libxml++/attribute.[h|cc]: Remove get_name(). Make get_value() virtual. Move set_value() and cobj() to AttributeNode. * libxml++/attributedeclaration.h: get_value() is overridden. * libxml++/attributenode.[h|cc]: Add get_value(), set_value(), cobj(). Bug #754673. --- libxml++/attribute.cc | 56 --------------------------------- libxml++/attribute.h | 36 +-------------------- libxml++/attributedeclaration.h | 2 +- libxml++/attributenode.cc | 36 +++++++++++++++++++++ libxml++/attributenode.h | 23 ++++++++++++++ 5 files changed, 61 insertions(+), 92 deletions(-) diff --git a/libxml++/attribute.cc b/libxml++/attribute.cc index 949afd51..56f659ad 100644 --- a/libxml++/attribute.cc +++ b/libxml++/attribute.cc @@ -21,61 +21,5 @@ Attribute::~Attribute() { } -Glib::ustring Attribute::get_name() const -{ - // This will get the name also for an AttributeDeclaration. The name is in - // the same position in xmlNode, xmlAttr and xmlAttribute. - return cobj()->name ? (char*)cobj()->name : Glib::ustring(); -} - -//TODO when we can break ABI: Make get_value() virtual. -Glib::ustring Attribute::get_value() const -{ - const AttributeDeclaration* const attributeDecl = - dynamic_cast(this); - if (attributeDecl) // AttributeDeclaration - return attributeDecl->get_value(); - - // AttributeNode - xmlChar* value = nullptr; - if (cobj()->ns && cobj()->ns->href) - value = xmlGetNsProp(cobj()->parent, cobj()->name, cobj()->ns->href); - else - value = xmlGetNoNsProp(cobj()->parent, cobj()->name); - - const Glib::ustring retn = value ? (const char*)value : ""; - if (value) - xmlFree(value); - return retn; -} - -//TODO when we can break ABI: Move set_value() to AttributeNode. -void Attribute::set_value(const Glib::ustring& value) -{ - if (dynamic_cast(this)) - return; // Won't change the value of an AttributeDeclaration - - if (cobj()->ns) - xmlSetNsProp(cobj()->parent, cobj()->ns, cobj()->name, (const xmlChar*)value.c_str()); - else - xmlSetProp(cobj()->parent, cobj()->name, (const xmlChar*)value.c_str()); -} - -xmlAttr* Attribute::cobj() -{ - // yes, this does what it looks like: it takes an xmlNode pointer - // and *reinterprets* it as an xmlAttr pointer - // -stefan - return reinterpret_cast(Node::cobj()); -} - -const xmlAttr* Attribute::cobj() const -{ - // yes, this does what it looks like: it takes an xmlNode pointer - // and *reinterprets* it as an xmlAttr pointer - // -stefan - return reinterpret_cast(Node::cobj()); -} - } //namespace xmlpp diff --git a/libxml++/attribute.h b/libxml++/attribute.h index 37945822..57193b93 100644 --- a/libxml++/attribute.h +++ b/libxml++/attribute.h @@ -30,44 +30,10 @@ class Attribute : public Node explicit Attribute(_xmlNode* node); ~Attribute() override; - //TODO: Can we remove this and just use Node::get_name()? - // Yes, when we can break ABI. /Kjell Ahlstedt 2012-02-09 - - /** Get the name of this attribute. - * See also Node::get_namespace_prefix() and Node::get_namespace_uri() - * @returns The attribute's name. - */ - Glib::ustring get_name() const; - /** Get the value of this attribute. - * Can be used for both an AttributeDeclaration and an AttributeNode. * @returns The attribute's value. */ - Glib::ustring get_value() const; - - /** Set the value of this attribute. - * - * If this is an AttributeDeclaration, the value will not be changed. - * This method is here for backward compatibility. It may be moved to - * AttributeNode in the future. - */ - void set_value(const Glib::ustring& value); - - /** Access the underlying libxml implementation. - * - * If this is an AttributeDeclaration, use AttributeDeclaration::cobj() instead. - * This method is here for backward compatibility. It may be moved to - * AttributeNode in the future. - */ - _xmlAttr* cobj(); - - /** Access the underlying libxml implementation. - * - * If this is an AttributeDeclaration, use AttributeDeclaration::cobj() instead. - * This method is here for backward compatibility. It may be moved to - * AttributeNode in the future. - */ - const _xmlAttr* cobj() const; + virtual Glib::ustring get_value() const = 0; }; } // namespace xmlpp diff --git a/libxml++/attributedeclaration.h b/libxml++/attributedeclaration.h index 3178cf39..446436f9 100644 --- a/libxml++/attributedeclaration.h +++ b/libxml++/attributedeclaration.h @@ -34,7 +34,7 @@ class AttributeDeclaration : public Attribute /** Get the default value of this attribute. * @returns The attribute's default value. */ - Glib::ustring get_value() const; + Glib::ustring get_value() const override; ///Access the underlying libxml implementation. _xmlAttribute* cobj(); diff --git a/libxml++/attributenode.cc b/libxml++/attributenode.cc index a8744158..267af7ad 100644 --- a/libxml++/attributenode.cc +++ b/libxml++/attributenode.cc @@ -20,4 +20,40 @@ AttributeNode::~AttributeNode() { } +Glib::ustring AttributeNode::get_value() const +{ + xmlChar* value = nullptr; + if (cobj()->ns && cobj()->ns->href) + value = xmlGetNsProp(cobj()->parent, cobj()->name, cobj()->ns->href); + else + value = xmlGetNoNsProp(cobj()->parent, cobj()->name); + + const Glib::ustring retn = value ? (const char*)value : ""; + if (value) + xmlFree(value); + return retn; +} + +void AttributeNode::set_value(const Glib::ustring& value) +{ + if (cobj()->ns) + xmlSetNsProp(cobj()->parent, cobj()->ns, cobj()->name, (const xmlChar*)value.c_str()); + else + xmlSetProp(cobj()->parent, cobj()->name, (const xmlChar*)value.c_str()); +} + +xmlAttr* AttributeNode::cobj() +{ + // An XML_ATTRIBUTE_NODE is represented by an xmlAttr struct. Reinterpret + // the xmlNode pointer stored in the base class as an xmlAttr pointer. + return reinterpret_cast(Node::cobj()); +} + +const xmlAttr* AttributeNode::cobj() const +{ + // An XML_ATTRIBUTE_NODE is represented by an xmlAttr struct. Reinterpret + // the xmlNode pointer stored in the base class as an xmlAttr pointer. + return reinterpret_cast(Node::cobj()); +} + } //namespace xmlpp diff --git a/libxml++/attributenode.h b/libxml++/attributenode.h index a60874f9..435ba497 100644 --- a/libxml++/attributenode.h +++ b/libxml++/attributenode.h @@ -25,6 +25,29 @@ class AttributeNode : public Attribute public: explicit AttributeNode(_xmlNode* node); ~AttributeNode() override; + + /** Get the value of this attribute. + * @returns The attribute's value. + */ + Glib::ustring get_value() const override; + + /** Set the value of this attribute. + * + * @newin{3,0} Replaces Attribute::set_value() + */ + void set_value(const Glib::ustring& value); + + /** Access the underlying libxml implementation. + * + * @newin{3,0} Replaces Attribute::cobj() + */ + _xmlAttr* cobj(); + + /** Access the underlying libxml implementation. + * + * @newin{3,0} Replaces Attribute::cobj() const + */ + const _xmlAttr* cobj() const; }; } // namespace xmlpp From 480e92f042e86b04c748fffd884fd57d9e6247d3 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 28 Sep 2015 17:18:05 +0200 Subject: [PATCH 019/240] Document: Make some methods non-virtual * libxml++/document.h: Make some private methods non-virtual. Bug #754673. --- libxml++/document.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libxml++/document.h b/libxml++/document.h index a70a566c..e49eda9f 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -53,9 +53,7 @@ class Document : NonCopyable { public: Init(); - - //TODO: Remove the virtual when we can break ABI? - virtual ~Init(); + ~Init(); }; friend class SaxParser; @@ -253,11 +251,9 @@ class Document : NonCopyable _xmlEntity* get_entity(const Glib::ustring& name); private: - //TODO: Remove virtuals when we can break ABI. - - virtual void do_write_to_file(const Glib::ustring& filename, const Glib::ustring& encoding, bool format); - virtual Glib::ustring do_write_to_string(const Glib::ustring& encoding, bool format); - virtual void do_write_to_stream(std::ostream& output, const Glib::ustring& encoding, bool format); + void do_write_to_file(const Glib::ustring& filename, const Glib::ustring& encoding, bool format); + Glib::ustring do_write_to_string(const Glib::ustring& encoding, bool format); + void do_write_to_stream(std::ostream& output, const Glib::ustring& encoding, bool format); static Init init_; From 0d7d0c96dba53f3bd0d854b5dfb736d39eade4ff Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 29 Sep 2015 10:50:58 +0200 Subject: [PATCH 020/240] Use std::string for filenames Since filenames are not necessarily UTF-8 encoded, store them in std::strings instead of Glib::ustrings. Bug #754673. --- libxml++/document.cc | 6 +++--- libxml++/document.h | 18 ++++++++++++++---- libxml++/parsers/domparser.cc | 4 ++-- libxml++/parsers/domparser.h | 4 ++-- libxml++/parsers/parser.h | 3 ++- libxml++/parsers/saxparser.cc | 2 +- libxml++/parsers/saxparser.h | 2 +- libxml++/relaxngschema.cc | 4 ++-- libxml++/relaxngschema.h | 4 ++-- libxml++/schemabase.h | 3 ++- libxml++/validators/dtdvalidator.cc | 10 +++++----- libxml++/validators/dtdvalidator.h | 6 +++--- libxml++/validators/relaxngvalidator.cc | 6 +++--- libxml++/validators/relaxngvalidator.h | 6 +++--- libxml++/validators/schemavalidatorbase.h | 4 ++-- libxml++/validators/validator.h | 3 ++- libxml++/validators/xsdvalidator.cc | 6 +++--- libxml++/validators/xsdvalidator.h | 6 +++--- libxml++/xsdschema.cc | 4 ++-- libxml++/xsdschema.h | 4 ++-- 20 files changed, 59 insertions(+), 46 deletions(-) diff --git a/libxml++/document.cc b/libxml++/document.cc index c3ced5c7..e8ddd747 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -320,12 +320,12 @@ ProcessingInstructionNode* Document::add_processing_instruction( return static_cast(node->_private); } -void Document::write_to_file(const Glib::ustring& filename, const Glib::ustring& encoding) +void Document::write_to_file(const std::string& filename, const Glib::ustring& encoding) { do_write_to_file(filename, encoding, false); } -void Document::write_to_file_formatted(const Glib::ustring& filename, const Glib::ustring& encoding) +void Document::write_to_file_formatted(const std::string& filename, const Glib::ustring& encoding) { do_write_to_file(filename, encoding, true); } @@ -351,7 +351,7 @@ void Document::write_to_stream_formatted(std::ostream& output, const Glib::ustri } void Document::do_write_to_file( - const Glib::ustring& filename, + const std::string& filename, const Glib::ustring& encoding, bool format) { diff --git a/libxml++/document.h b/libxml++/document.h index e49eda9f..07c25c28 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -16,8 +16,19 @@ #include #include +#include #include +/* std::string or Glib::ustring in function prototypes in libxml++? + * + * If it's propagated to a libxml2 function that takes a xmlChar*, it's + * UTF-8 encoded, and Glib::ustring is the right choice. + * + * If it's propagated to a libxml2 function that takes a char*, it's not + * necessarily UTF-8 encoded, and std::string is usually the right choice. + * Most of these strings are filenames or URLs. + */ + #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { struct _xmlDoc; @@ -153,13 +164,12 @@ class Document : NonCopyable ProcessingInstructionNode* add_processing_instruction( const Glib::ustring& name, const Glib::ustring& content); - //TODO: Use std::string for filenames. /** Write the document to a file. * @param filename * @param encoding If not provided, UTF-8 is used * @throws xmlpp::exception */ - void write_to_file(const Glib::ustring& filename, const Glib::ustring& encoding = Glib::ustring()); + void write_to_file(const std::string& filename, const Glib::ustring& encoding = Glib::ustring()); /** Write the document to a file. * The output is formatted by inserting whitespaces, which is easier to read for a human, @@ -168,7 +178,7 @@ class Document : NonCopyable * @param encoding If not provided, UTF-8 is used * @throws xmlpp::exception */ - void write_to_file_formatted(const Glib::ustring& filename, const Glib::ustring& encoding = Glib::ustring()); + void write_to_file_formatted(const std::string& filename, const Glib::ustring& encoding = Glib::ustring()); /** Write the document to the memory. * @param encoding If not provided, UTF-8 is used @@ -251,7 +261,7 @@ class Document : NonCopyable _xmlEntity* get_entity(const Glib::ustring& name); private: - void do_write_to_file(const Glib::ustring& filename, const Glib::ustring& encoding, bool format); + void do_write_to_file(const std::string& filename, const Glib::ustring& encoding, bool format); Glib::ustring do_write_to_string(const Glib::ustring& encoding, bool format); void do_write_to_stream(std::ostream& output, const Glib::ustring& encoding, bool format); diff --git a/libxml++/parsers/domparser.cc b/libxml++/parsers/domparser.cc index e8ba7ede..2628a537 100644 --- a/libxml++/parsers/domparser.cc +++ b/libxml++/parsers/domparser.cc @@ -26,7 +26,7 @@ DomParser::DomParser() doc_ = new Document(); } -DomParser::DomParser(const Glib::ustring& filename, bool validate) +DomParser::DomParser(const std::string& filename, bool validate) : doc_(nullptr) { set_validate(validate); @@ -38,7 +38,7 @@ DomParser::~DomParser() release_underlying(); } -void DomParser::parse_file(const Glib::ustring& filename) +void DomParser::parse_file(const std::string& filename) { release_underlying(); //Free any existing document. diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index 3977e580..df13a9c8 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -31,7 +31,7 @@ class DomParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - explicit DomParser(const Glib::ustring& filename, bool validate = false); + explicit DomParser(const std::string& filename, bool validate = false); ~DomParser() override; /** Parse an XML document from a file. @@ -42,7 +42,7 @@ class DomParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - void parse_file(const Glib::ustring& filename) override; + void parse_file(const std::string& filename) override; /** Parse an XML document from a string. * If the parser already contains a document, that document and all its nodes diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index 6cf9b582..802a1594 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -15,6 +15,7 @@ #include #include +#include #include #include // va_list #include // std::unique_ptr @@ -142,7 +143,7 @@ class Parser : NonCopyable * @throw exception * @param filename The path to the file. */ - virtual void parse_file(const Glib::ustring& filename) = 0; + virtual void parse_file(const std::string& filename) = 0; /** Parse an XML document from raw memory. * @throw exception diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index 20fc5d8c..bb415494 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -178,7 +178,7 @@ void SaxParser::parse() } } -void SaxParser::parse_file(const Glib::ustring& filename) +void SaxParser::parse_file(const std::string& filename) { if(context_) { diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index 90e845d8..c3aa1bf9 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -86,7 +86,7 @@ class SaxParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - void parse_file(const Glib::ustring& filename) override; + void parse_file(const std::string& filename) override; /** Parse an XML document from a string. * @param contents The XML document as a string. diff --git a/libxml++/relaxngschema.cc b/libxml++/relaxngschema.cc index 96bd8807..cf35ba8e 100644 --- a/libxml++/relaxngschema.cc +++ b/libxml++/relaxngschema.cc @@ -61,7 +61,7 @@ RelaxNGSchema::RelaxNGSchema(_xmlRelaxNG* schema) pimpl_->schema = schema; } -RelaxNGSchema::RelaxNGSchema(const Glib::ustring& filename) +RelaxNGSchema::RelaxNGSchema(const std::string& filename) : pimpl_(new Impl) { parse_file(filename); @@ -78,7 +78,7 @@ RelaxNGSchema::~RelaxNGSchema() release_underlying(); } -void RelaxNGSchema::parse_file(const Glib::ustring& filename) +void RelaxNGSchema::parse_file(const std::string& filename) { parse_context(xmlRelaxNGNewParserCtxt(filename.c_str())); } diff --git a/libxml++/relaxngschema.h b/libxml++/relaxngschema.h index ffe2eaa4..b658cfd7 100644 --- a/libxml++/relaxngschema.h +++ b/libxml++/relaxngschema.h @@ -57,7 +57,7 @@ class RelaxNGSchema : public SchemaBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - explicit RelaxNGSchema(const Glib::ustring& filename); + explicit RelaxNGSchema(const std::string& filename); /** Create a schema from an XML document. * @param document A preparsed document tree, containing the schema definition. @@ -75,7 +75,7 @@ class RelaxNGSchema : public SchemaBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - void parse_file(const Glib::ustring& filename) override; + void parse_file(const std::string& filename) override; /** Parse a schema definition from a string. * The schema must be defined with XML syntax. The compact syntax is not supported. diff --git a/libxml++/schemabase.h b/libxml++/schemabase.h index 8f61226e..e0f3461c 100644 --- a/libxml++/schemabase.h +++ b/libxml++/schemabase.h @@ -20,6 +20,7 @@ #define __LIBXMLPP_SCHEMABASE_H #include +#include namespace Glib { @@ -45,7 +46,7 @@ class SchemaBase : NonCopyable * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - virtual void parse_file(const Glib::ustring& filename) = 0; + virtual void parse_file(const std::string& filename) = 0; /** Parse a schema definition from a string. * If another schema has been parsed before, that schema is replaced by the new one. diff --git a/libxml++/validators/dtdvalidator.cc b/libxml++/validators/dtdvalidator.cc index 14f91267..d91fb052 100644 --- a/libxml++/validators/dtdvalidator.cc +++ b/libxml++/validators/dtdvalidator.cc @@ -26,16 +26,16 @@ DtdValidator::DtdValidator() { } -DtdValidator::DtdValidator(const Glib::ustring& file) +DtdValidator::DtdValidator(const std::string& filename) : context_(nullptr), dtd_(nullptr) { - parse_subset("",file); + parse_subset("", filename); } DtdValidator::DtdValidator(const Glib::ustring& external, const Glib::ustring& system) : context_(nullptr), dtd_(nullptr) { - parse_subset(external,system); + parse_subset(external, system); } DtdValidator::~DtdValidator() @@ -43,9 +43,9 @@ DtdValidator::~DtdValidator() release_underlying(); } -void DtdValidator::parse_file(const Glib::ustring& filename) +void DtdValidator::parse_file(const std::string& filename) { - parse_subset("",filename); + parse_subset("", filename); } void DtdValidator::parse_subset(const Glib::ustring& external, const Glib::ustring& system) diff --git a/libxml++/validators/dtdvalidator.h b/libxml++/validators/dtdvalidator.h index 0ee0c71a..ac546a7f 100644 --- a/libxml++/validators/dtdvalidator.h +++ b/libxml++/validators/dtdvalidator.h @@ -23,10 +23,10 @@ class DtdValidator : public Validator DtdValidator(); /** Create a validator and parse an external subset (DTD file) immediately. - * @param file The URL of the DTD. + * @param filename The URL of the DTD. * @throws xmlpp::parse_error */ - explicit DtdValidator(const Glib::ustring& file); + explicit DtdValidator(const std::string& filename); /** Create a validator and parse an external subset (DTD file) immediately. * @param external The external ID of the DTD. @@ -50,7 +50,7 @@ class DtdValidator : public Validator * @param filename The URL of the DTD. * @throws xmlpp::parse_error */ - void parse_file(const Glib::ustring& filename) override; + void parse_file(const std::string& filename) override; /** Parse a DTD from a string. * If the validator already contains a DTD, that DTD is deleted. diff --git a/libxml++/validators/relaxngvalidator.cc b/libxml++/validators/relaxngvalidator.cc index 8e92365a..4cd9a9c6 100644 --- a/libxml++/validators/relaxngvalidator.cc +++ b/libxml++/validators/relaxngvalidator.cc @@ -42,7 +42,7 @@ RelaxNGValidator::RelaxNGValidator() { } -RelaxNGValidator::RelaxNGValidator(const Glib::ustring& filename) +RelaxNGValidator::RelaxNGValidator(const std::string& filename) : pimpl_(new Impl) { parse_file(filename); @@ -65,7 +65,7 @@ RelaxNGValidator::~RelaxNGValidator() release_underlying(); } -void RelaxNGValidator::parse_file(const Glib::ustring& filename) +void RelaxNGValidator::parse_file(const std::string& filename) { set_schema(new RelaxNGSchema(filename), true); } @@ -159,7 +159,7 @@ void RelaxNGValidator::validate(const Document* document) } } -void RelaxNGValidator::validate(const Glib::ustring& filename) +void RelaxNGValidator::validate(const std::string& filename) { // There is no xmlRelaxNGValidateFile(). DomParser parser(filename); diff --git a/libxml++/validators/relaxngvalidator.h b/libxml++/validators/relaxngvalidator.h index a12b7105..7d873093 100644 --- a/libxml++/validators/relaxngvalidator.h +++ b/libxml++/validators/relaxngvalidator.h @@ -50,7 +50,7 @@ class RelaxNGValidator : public SchemaValidatorBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - explicit RelaxNGValidator(const Glib::ustring& filename); + explicit RelaxNGValidator(const std::string& filename); /** Create a validator and parse a schema definition document. * @param document A preparsed document tree, containing the schema definition. @@ -80,7 +80,7 @@ class RelaxNGValidator : public SchemaValidatorBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - void parse_file(const Glib::ustring& filename) override; + void parse_file(const std::string& filename) override; /** Parse a schema definition from a string. * The schema must be defined with XML syntax. The compact syntax is not supported. @@ -145,7 +145,7 @@ class RelaxNGValidator : public SchemaValidatorBase * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - void validate(const Glib::ustring& filename) override; + void validate(const std::string& filename) override; protected: void initialize_context() override; diff --git a/libxml++/validators/schemavalidatorbase.h b/libxml++/validators/schemavalidatorbase.h index f5b7f86d..274ad94c 100644 --- a/libxml++/validators/schemavalidatorbase.h +++ b/libxml++/validators/schemavalidatorbase.h @@ -46,7 +46,7 @@ class SchemaValidatorBase : public Validator * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - virtual void parse_file(const Glib::ustring& filename) = 0; + virtual void parse_file(const std::string& filename) = 0; /** Parse a schema definition from a string. * If the validator already contains a schema, that schema is released @@ -86,7 +86,7 @@ class SchemaValidatorBase : public Validator * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - virtual void validate(const Glib::ustring& filename) = 0; + virtual void validate(const std::string& filename) = 0; protected: void initialize_context() override; diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index e25a176d..15285012 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -16,6 +16,7 @@ #include #include #include // std::exception_ptr +#include extern "C" { struct _xmlValidCtxt; @@ -37,7 +38,7 @@ class Validator : NonCopyable * @param filename The URL of the schema or the DTD. * @throws xmlpp::parse_error */ - virtual void parse_file(const Glib::ustring& filename) = 0; + virtual void parse_file(const std::string& filename) = 0; /** Parse a schema definition or a DTD from a string. * @param contents The schema definition or the DTD as a string. diff --git a/libxml++/validators/xsdvalidator.cc b/libxml++/validators/xsdvalidator.cc index 44be9a05..9d496a06 100644 --- a/libxml++/validators/xsdvalidator.cc +++ b/libxml++/validators/xsdvalidator.cc @@ -39,7 +39,7 @@ XsdValidator::XsdValidator() { } -XsdValidator::XsdValidator(const Glib::ustring& filename) +XsdValidator::XsdValidator(const std::string& filename) : pimpl_(new Impl) { parse_file(filename); @@ -62,7 +62,7 @@ XsdValidator::~XsdValidator() release_underlying(); } -void XsdValidator::parse_file(const Glib::ustring& filename) +void XsdValidator::parse_file(const std::string& filename) { set_schema(new XsdSchema(filename), true); } @@ -157,7 +157,7 @@ void XsdValidator::validate(const Document* document) } } -void XsdValidator::validate(const Glib::ustring& filename) +void XsdValidator::validate(const std::string& filename) { if (!*this) throw internal_error("XsdValidator::validate(): Must have a schema to validate file."); diff --git a/libxml++/validators/xsdvalidator.h b/libxml++/validators/xsdvalidator.h index 2269afb9..ff4840bc 100644 --- a/libxml++/validators/xsdvalidator.h +++ b/libxml++/validators/xsdvalidator.h @@ -46,7 +46,7 @@ class XsdValidator : public SchemaValidatorBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - explicit XsdValidator(const Glib::ustring& filename); + explicit XsdValidator(const std::string& filename); /** Create a validator and parse a schema definition document. * @param document A preparsed document tree, containing the schema definition. @@ -73,7 +73,7 @@ class XsdValidator : public SchemaValidatorBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - void parse_file(const Glib::ustring& filename) override; + void parse_file(const std::string& filename) override; /** Parse a schema definition from a string. * If the validator already contains a schema, that schema is released @@ -135,7 +135,7 @@ class XsdValidator : public SchemaValidatorBase * @throws xmlpp::internal_error * @throws xmlpp::validity_error */ - void validate(const Glib::ustring& filename) override; + void validate(const std::string& filename) override; protected: void initialize_context() override; diff --git a/libxml++/xsdschema.cc b/libxml++/xsdschema.cc index 94a92384..4ad470e6 100644 --- a/libxml++/xsdschema.cc +++ b/libxml++/xsdschema.cc @@ -60,7 +60,7 @@ XsdSchema::XsdSchema(_xmlSchema* schema) pimpl_->schema = schema; } -XsdSchema::XsdSchema(const Glib::ustring& filename) +XsdSchema::XsdSchema(const std::string& filename) : pimpl_(new Impl) { parse_file(filename); @@ -77,7 +77,7 @@ XsdSchema::~XsdSchema() release_underlying(); } -void XsdSchema::parse_file(const Glib::ustring& filename) +void XsdSchema::parse_file(const std::string& filename) { xmlResetLastError(); release_underlying(); diff --git a/libxml++/xsdschema.h b/libxml++/xsdschema.h index 8220e4e7..2c26c11b 100644 --- a/libxml++/xsdschema.h +++ b/libxml++/xsdschema.h @@ -53,7 +53,7 @@ class XsdSchema : public SchemaBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - explicit XsdSchema(const Glib::ustring& filename); + explicit XsdSchema(const std::string& filename); /** Create a schema from an XML document. * @param document A preparsed document tree, containing the schema definition. @@ -68,7 +68,7 @@ class XsdSchema : public SchemaBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - void parse_file(const Glib::ustring& filename) override; + void parse_file(const std::string& filename) override; /** Parse a schema definition from a string. * If another schema has been parsed before, that schema is replaced by the new one. From 6ea9dbc728a07444db28f62e059599927b114eac Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 29 Sep 2015 15:57:47 +0200 Subject: [PATCH 021/240] Node: Replace remove_child() by remove_node() * libxml++/nodes/node.[h|cc]: Replace remove_child() by the static remove_node(). Improve the documentation of remove_node() and the destructor. Bug #754673 --- libxml++/nodes/node.cc | 8 +++++--- libxml++/nodes/node.h | 23 +++++++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index d8f54e6a..16cb55f9 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -303,14 +303,16 @@ Node::const_NodeList Node::get_children(const Glib::ustring& name) const return get_children_common(name, impl_->children); } -void Node::remove_child(Node* node) +//static +void Node::remove_node(Node* node) { - //TODO: Allow a node to be removed without deleting it, to allow it to be moved? + //TODO: Allow a node to be disconnected from its parent without deleting it, + // to allow it to be moved? //This would require a more complex memory management API. if (!node) return; auto cnode = node->cobj(); - Node::free_wrappers(cnode); //This delete the C++ node (not this) itself. + Node::free_wrappers(cnode); // This deletes the C++ node. xmlUnlinkNode(cnode); xmlFreeNode(cnode); } diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index 02084eb9..8966b8d2 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -43,7 +43,10 @@ enum XPathResultType }; /** Represents XML Nodes. - * You should never new or delete Nodes. The Parser will create and manage them for you. + * + * You should never new and delete Nodes. The Parser will create and + * manage them for you. Furthermore, Document and Element have methods for + * adding Nodes to a Document. */ class Node : public NonCopyable { @@ -57,6 +60,11 @@ class Node : public NonCopyable /** @throws xmlpp::internal_error If @a node is 0. */ explicit Node(_xmlNode* node); + + /** Destructor. + * Does not destroy the underlying xmlNode. The xmlNode is owned by a xmlDoc + * document. If you want to also destroy the xmlNode, use remove_node(). + */ ~Node() override; /** Get the name of this node. @@ -151,10 +159,17 @@ class Node : public NonCopyable */ const_NodeList get_children(const Glib::ustring& name = Glib::ustring()) const; - /** Remove the child node. - * @param node The child node to remove. This Node will be deleted and therefore unusable after calling this method. + /** Remove a node and its children. + * + * The node is disconnected from its parent. The underlying libxml xmlNode + * instances are also removed. + * + * @newin{3,0} Replaces remove_child() + * + * @param node The node to remove. This Node and all its descendants will be + * deleted and therefore unusable after calling this method. */ - void remove_child(Node* node); + static void remove_node(Node* node); /** Import node(s) from another document under this node, without affecting the source node. * From 293594ffd7bc810564d2868968487830a90559b6 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 1 Oct 2015 12:45:42 +0200 Subject: [PATCH 022/240] Move some code from DtdValidator to Dtd * libxml++/dtd.[h|cc]: * libxml++/validators/dtdvalidator.[h|cc]: Move the code for parsing a DTD from xmlpp::DtdValidator to xmlpp::Dtd. The code is arranged like that in the other validators. Bug #754673. --- libxml++/dtd.cc | 116 +++++++++++++++++++++++++--- libxml++/dtd.h | 108 ++++++++++++++++++++++---- libxml++/validators/dtdvalidator.cc | 114 +++++++++++++-------------- libxml++/validators/dtdvalidator.h | 42 ++++++++-- 4 files changed, 292 insertions(+), 88 deletions(-) diff --git a/libxml++/dtd.cc b/libxml++/dtd.cc index 13703a7f..2ec0c15c 100644 --- a/libxml++/dtd.cc +++ b/libxml++/dtd.cc @@ -5,45 +5,143 @@ */ #include +#include +#include #include namespace xmlpp { -Dtd::Dtd(_xmlDtd* dtd) -: impl_(dtd) +struct Dtd::Impl { - dtd->_private = this; + Impl() : dtd(nullptr), is_dtd_owner(false) {} + + _xmlDtd* dtd; + bool is_dtd_owner; +}; + +Dtd::Dtd() +: pimpl_(new Impl) +{ +} + +Dtd::Dtd(_xmlDtd* dtd, bool take_ownership) +: pimpl_(new Impl) +{ + pimpl_->dtd = dtd; + if (dtd) + { + pimpl_->dtd->_private = this; + pimpl_->is_dtd_owner = take_ownership; + } +} + +Dtd::Dtd(const std::string& filename) +: pimpl_(new Impl) +{ + parse_subset("", filename); +} + +Dtd::Dtd(const Glib::ustring& external, const Glib::ustring& system) +: pimpl_(new Impl) +{ + parse_subset(external, system); } Dtd::~Dtd() -{ +{ + release_underlying(); +} + +void Dtd::parse_file(const std::string& filename) +{ + parse_subset("", filename); +} + +void Dtd::parse_subset(const Glib::ustring& external, const Glib::ustring& system) +{ + release_underlying(); // Free any existing dtd. + xmlResetLastError(); + + auto dtd = xmlParseDTD( + external.empty() ? nullptr : (const xmlChar*)external.c_str(), + system.empty() ? nullptr : (const xmlChar*)system.c_str()); + + if (!dtd) + { + throw parse_error("Dtd could not be parsed.\n" + format_xml_error()); + } + + pimpl_->dtd = dtd; + pimpl_->dtd->_private = this; + pimpl_->is_dtd_owner = true; +} + +void Dtd::parse_memory(const Glib::ustring& contents) +{ + // Prepare an istream with buffer + std::istringstream is(contents); + + parse_stream(is); +} + +void Dtd::parse_stream(std::istream& in) +{ + release_underlying(); // Free any existing dtd. + xmlResetLastError(); + + IStreamParserInputBuffer ibuff(in); + + auto dtd = xmlIOParseDTD(0, ibuff.cobj(), XML_CHAR_ENCODING_UTF8); + + if (!dtd) + { + throw parse_error("Dtd could not be parsed.\n" + format_xml_error()); + } + + pimpl_->dtd = dtd; + pimpl_->dtd->_private = this; + pimpl_->is_dtd_owner = true; } Glib::ustring Dtd::get_name() const { - return (char*)impl_->name; + return (pimpl_->dtd && pimpl_->dtd->name) ? (const char*)pimpl_->dtd->name : ""; } Glib::ustring Dtd::get_external_id() const { - return (char*)impl_->ExternalID; + return (pimpl_->dtd && pimpl_->dtd->ExternalID) ? (const char*)pimpl_->dtd->ExternalID : ""; } Glib::ustring Dtd::get_system_id() const { - return (char*)impl_->SystemID; + return (pimpl_->dtd && pimpl_->dtd->SystemID) ? (const char*)pimpl_->dtd->SystemID : ""; } _xmlDtd* Dtd::cobj() { - return impl_; + return pimpl_->dtd; } const _xmlDtd* Dtd::cobj() const { - return impl_; + return pimpl_->dtd; +} + +void Dtd::release_underlying() +{ + if (pimpl_->dtd) + { + pimpl_->dtd->_private = nullptr; + if (pimpl_->is_dtd_owner) + { + xmlFreeDtd(pimpl_->dtd); + pimpl_->is_dtd_owner = false; + } + pimpl_->dtd = nullptr; + } } } //namespace xmlpp diff --git a/libxml++/dtd.h b/libxml++/dtd.h index 6198072e..30a6bfdb 100644 --- a/libxml++/dtd.h +++ b/libxml++/dtd.h @@ -7,27 +7,107 @@ #ifndef __LIBXMLPP_DTD_H #define __LIBXMLPP_DTD_H -#include -#include -#include +#include +#include +#include +#include // std::unique_ptr #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { struct _xmlDtd; } -#endif //DOXYGEN_SHOULD_SKIP_THIS4 +#endif //DOXYGEN_SHOULD_SKIP_THIS namespace xmlpp { -/** Represents XML DTDs. - * +//TODO: Derive from Node? +/** Represents an XML DTD for validating XML files. + * DTD = Document Type Definition */ -class Dtd //TODO: Derive from Node? +class Dtd : public NonCopyable { public: - Dtd(_xmlDtd* dtd); - ~Dtd(); + Dtd(); + + /** Create a Dtd from the underlying libxml DTD element. + * @param dtd A pointer to the libxml DTD element. + * @param take_ownership If true, this Dtd instance takes ownership of + * the libxml DTD element. The caller must not delete it.
+ * If false, this Dtd does not take ownership of the libxml + * DTD element. The caller must guarantee that the libxml DTD element + * exists as long as this Dtd keeps a pointer to it. The caller is + * responsible for deleting the libxml DTD element when it's no longer + * needed, unless it belongs to a Document, in which case it's deleted + * when the Document is deleted. + */ + explicit Dtd(_xmlDtd* dtd, bool take_ownership = false); + + /** Create a Dtd and parse an external subset (DTD file) immediately. + * + * @newin{3,0} + * + * @param filename The URL of the DTD. + * @throws xmlpp::parse_error + */ + explicit Dtd(const std::string& filename); + + /** Create a Dtd and parse an external subset (DTD file) immediately. + * + * @newin{3,0} + * + * @param external The external ID of the DTD. + * @param system The URL of the DTD. + * @throws xmlpp::parse_error + */ + Dtd(const Glib::ustring& external, const Glib::ustring& system); + + ~Dtd() override; + + /** Parse an external subset (DTD file). + * If another DTD has been parsed before, that DTD is replaced by the new one + * (deleted if this Dtd owns it). + * + * @newin{3,0} + * + * @param filename The URL of the DTD. + * @throws xmlpp::parse_error + */ + void parse_file(const std::string& filename); + + /** Parse an external subset (DTD file). + * If another DTD has been parsed before, that DTD is replaced by the new one + * (deleted if this Dtd owns it). + * + * @newin{3,0} + * + * @param external The external ID of the DTD. + * @param system The URL of the DTD. + * @throws xmlpp::parse_error + */ + void parse_subset(const Glib::ustring& external, const Glib::ustring& system); + + /** Parse a DTD from a string. + * If another DTD has been parsed before, that DTD is replaced by the new one + * (deleted if this Dtd owns it). + * + * @newin{3,0} + * + * @param contents The DTD as a string. + * @throws xmlpp::parse_error + */ + void parse_memory(const Glib::ustring& contents); + + /** Parse a DTD from a stream. + * If another DTD has been parsed before, that DTD is replaced by the new one + * (deleted if this Dtd owns it). + * + * @newin{3,0} + * + * @param in The stream. + * @throws xmlpp::parse_error + */ + void parse_stream(std::istream& in); Glib::ustring get_name() const; Glib::ustring get_external_id() const; @@ -40,13 +120,15 @@ class Dtd //TODO: Derive from Node? /** Access the underlying libxml implementation. */ const _xmlDtd* cobj() const; + +protected: + void release_underlying(); + private: - _xmlDtd* impl_; + struct Impl; + std::unique_ptr pimpl_; }; } // namespace xmlpp #endif //__LIBXMLPP_DTD_H - - - diff --git a/libxml++/validators/dtdvalidator.cc b/libxml++/validators/dtdvalidator.cc index d91fb052..f5b718eb 100644 --- a/libxml++/validators/dtdvalidator.cc +++ b/libxml++/validators/dtdvalidator.cc @@ -21,23 +21,39 @@ namespace xmlpp { +struct DtdValidator::Impl +{ + Impl() : dtd(nullptr), is_dtd_owner(false), context(nullptr) {} + + Dtd* dtd; + bool is_dtd_owner; + _xmlValidCtxt* context; +}; + + DtdValidator::DtdValidator() -: context_(nullptr), dtd_(nullptr) +: pimpl_(new Impl) { } DtdValidator::DtdValidator(const std::string& filename) -: context_(nullptr), dtd_(nullptr) +: pimpl_(new Impl) { - parse_subset("", filename); + parse_file(filename); } DtdValidator::DtdValidator(const Glib::ustring& external, const Glib::ustring& system) -: context_(nullptr), dtd_(nullptr) +: pimpl_(new Impl) { parse_subset(external, system); } +DtdValidator::DtdValidator(Dtd* dtd, bool take_ownership) +: pimpl_(new Impl) +{ + set_dtd(dtd, take_ownership); +} + DtdValidator::~DtdValidator() { release_underlying(); @@ -45,86 +61,65 @@ DtdValidator::~DtdValidator() void DtdValidator::parse_file(const std::string& filename) { - parse_subset("", filename); + set_dtd(new Dtd(filename), true); } void DtdValidator::parse_subset(const Glib::ustring& external, const Glib::ustring& system) { - release_underlying(); // Free any existing dtd. - xmlResetLastError(); - - auto dtd = xmlParseDTD( - external.empty() ? 0 : (const xmlChar *)external.c_str(), - system.empty() ? 0 : (const xmlChar *)system.c_str()); - - if (!dtd) - { - throw parse_error("Dtd could not be parsed.\n" + format_xml_error()); - } - - Node::create_wrapper(reinterpret_cast(dtd)); - dtd_ = static_cast(dtd->_private); + set_dtd(new Dtd(external, system), true); } void DtdValidator::parse_memory(const Glib::ustring& contents) { - // Prepare an istream with buffer - std::istringstream is( contents ); - - parse_stream( is ); + std::unique_ptr dtd(new Dtd()); + dtd->parse_memory(contents); + set_dtd(dtd.release(), true); } void DtdValidator::parse_stream(std::istream& in) { - release_underlying(); // Free any existing dtd. - xmlResetLastError(); - - IStreamParserInputBuffer ibuff( in ); - - auto dtd = xmlIOParseDTD( 0, ibuff.cobj(), XML_CHAR_ENCODING_UTF8 ); - - if (!dtd) - { - throw parse_error("Dtd could not be parsed.\n" + format_xml_error()); - } + std::unique_ptr dtd(new Dtd()); + dtd->parse_stream(in); + set_dtd(dtd.release(), true); +} - Node::create_wrapper(reinterpret_cast(dtd)); - dtd_ = static_cast(dtd->_private); +void DtdValidator::set_dtd(Dtd* dtd, bool take_ownership) +{ + release_underlying(); + pimpl_->dtd = dtd; + pimpl_->is_dtd_owner = take_ownership; } void DtdValidator::initialize_context() { Validator::initialize_context(); - if (context_) + if (pimpl_->context) { //Tell the validation context about the callbacks: - context_->error = &callback_validity_error; - context_->warning = &callback_validity_warning; + pimpl_->context->error = &callback_validity_error; + pimpl_->context->warning = &callback_validity_warning; //Allow the callback_validity_*() methods to retrieve the C++ instance: - context_->userData = this; + pimpl_->context->userData = this; } } void DtdValidator::release_underlying() { - if (context_) + if (pimpl_->context) { - context_->userData = nullptr; //Not really necessary. + pimpl_->context->userData = nullptr; //Not really necessary. - xmlFreeValidCtxt(context_); - context_ = nullptr; + xmlFreeValidCtxt(pimpl_->context); + pimpl_->context = nullptr; } - if (dtd_) + if (pimpl_->dtd) { - //Make a local pointer to the underlying xmlDtd object as the wrapper is destroyed first. - //After free_wrappers is called dtd_ will be invalid (e.g. delete dtd_) - auto dtd = dtd_->cobj(); - Node::free_wrappers(reinterpret_cast(dtd)); - xmlFreeDtd(dtd); - dtd_ = nullptr; + if (pimpl_->is_dtd_owner) + delete pimpl_->dtd; + pimpl_->dtd = nullptr; } Validator::release_underlying(); @@ -132,17 +127,17 @@ void DtdValidator::release_underlying() DtdValidator::operator bool() const noexcept { - return dtd_ != nullptr; + return pimpl_->dtd && pimpl_->dtd->cobj(); } Dtd* DtdValidator::get_dtd() { - return dtd_; + return pimpl_->dtd; } const Dtd* DtdValidator::get_dtd() const { - return dtd_; + return pimpl_->dtd; } void DtdValidator::validate(const Document* document) @@ -152,16 +147,16 @@ void DtdValidator::validate(const Document* document) throw internal_error("Document pointer cannot be 0."); } - if (!dtd_) + if (!pimpl_->dtd) { throw internal_error("No DTD to use for validation."); } // A context is required at this stage only - if (!context_) - context_ = xmlNewValidCtxt(); + if (!pimpl_->context) + pimpl_->context = xmlNewValidCtxt(); - if(!context_) + if (!pimpl_->context) { throw internal_error("Couldn't create validation context"); } @@ -169,7 +164,8 @@ void DtdValidator::validate(const Document* document) xmlResetLastError(); initialize_context(); - const bool res = (bool)xmlValidateDtd( context_, (xmlDoc*)document->cobj(), dtd_->cobj() ); + const bool res = (bool)xmlValidateDtd(pimpl_->context, (xmlDoc*)document->cobj(), + pimpl_->dtd->cobj()); if (!res) { diff --git a/libxml++/validators/dtdvalidator.h b/libxml++/validators/dtdvalidator.h index ac546a7f..4513f8cd 100644 --- a/libxml++/validators/dtdvalidator.h +++ b/libxml++/validators/dtdvalidator.h @@ -35,22 +35,36 @@ class DtdValidator : public Validator */ explicit DtdValidator(const Glib::ustring& external, const Glib::ustring& system); + /** Create a validator. + * + * @newin{3,0} + * + * @param dtd A pointer to the DTD to use when validating XML documents. + * @param take_ownership If true, the validator takes ownership of + * the DTD. The caller must not delete it.
+ * If false, the validator does not take ownership of the DTD. + * The caller must guarantee that the DTD exists as long as the + * validator keeps a pointer to it. The caller is responsible for + * deleting the DTD when it's no longer needed. + */ + explicit DtdValidator(Dtd* dtd, bool take_ownership); + ~DtdValidator() override; /** Parse an external subset (DTD file). * If the validator already contains a DTD, that DTD is deleted. - * @param external The external ID of the DTD. - * @param system The URL of the DTD. + * @param filename The URL of the DTD. * @throws xmlpp::parse_error */ - void parse_subset(const Glib::ustring& external, const Glib::ustring& system); + void parse_file(const std::string& filename) override; /** Parse an external subset (DTD file). * If the validator already contains a DTD, that DTD is deleted. - * @param filename The URL of the DTD. + * @param external The external ID of the DTD. + * @param system The URL of the DTD. * @throws xmlpp::parse_error */ - void parse_file(const std::string& filename) override; + void parse_subset(const Glib::ustring& external, const Glib::ustring& system); /** Parse a DTD from a string. * If the validator already contains a DTD, that DTD is deleted. @@ -66,6 +80,19 @@ class DtdValidator : public Validator */ void parse_stream(std::istream& in); + /** Set a DTD. + * If the validator already contains a DTD, that DTD is released + * (deleted if the validator owns the DTD). + * @param dtd A pointer to the DTD to use when validating XML documents. + * @param take_ownership If true, the validator takes ownership of + * the DTD. The caller must not delete it.
+ * If false, the validator does not take ownership of the DTD. + * The caller must guarantee that the DTD exists as long as the + * validator keeps a pointer to it. The caller is responsible for + * deleting the DTD when it's no longer needed. + */ + void set_dtd(Dtd* dtd, bool take_ownership); + /** Test whether a DTD has been parsed. * For instance * @code @@ -98,8 +125,9 @@ class DtdValidator : public Validator void initialize_context() override; void release_underlying() override; - _xmlValidCtxt* context_; - Dtd* dtd_; +private: + struct Impl; + std::unique_ptr pimpl_; }; } // namespace xmlpp From 3b943c2b104be315a23154b89fc74d16bd53d4f3 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 1 Oct 2015 14:40:37 +0200 Subject: [PATCH 023/240] Remove some unnecessary #include and reinterpret_cast --- libxml++/attribute.cc | 2 -- libxml++/attribute.h | 6 ------ libxml++/attributenode.h | 6 ++++++ libxml++/document.cc | 1 - libxml++/document.h | 7 ++++--- libxml++/dtd.h | 2 ++ libxml++/exceptions/internal_error.h | 3 --- libxml++/exceptions/parse_error.h | 3 --- libxml++/nodes/cdatanode.cc | 1 - libxml++/nodes/commentnode.cc | 1 - libxml++/nodes/element.cc | 1 - libxml++/nodes/entityreference.cc | 1 - libxml++/nodes/processinginstructionnode.cc | 1 - libxml++/nodes/textnode.cc | 1 - libxml++/parsers/domparser.h | 3 +-- libxml++/parsers/saxparser.h | 2 +- libxml++/validators/relaxngvalidator.cc | 2 +- libxml++/validators/xsdvalidator.cc | 2 +- 18 files changed, 16 insertions(+), 29 deletions(-) diff --git a/libxml++/attribute.cc b/libxml++/attribute.cc index 56f659ad..18b1f44b 100644 --- a/libxml++/attribute.cc +++ b/libxml++/attribute.cc @@ -5,7 +5,6 @@ */ #include "libxml++/attribute.h" -#include "libxml++/attributedeclaration.h" #include @@ -22,4 +21,3 @@ Attribute::~Attribute() } } //namespace xmlpp - diff --git a/libxml++/attribute.h b/libxml++/attribute.h index 57193b93..8458f22e 100644 --- a/libxml++/attribute.h +++ b/libxml++/attribute.h @@ -12,12 +12,6 @@ #include -#ifndef DOXYGEN_SHOULD_SKIP_THIS -extern "C" { - struct _xmlAttr; -} -#endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS - namespace xmlpp { diff --git a/libxml++/attributenode.h b/libxml++/attributenode.h index 435ba497..cc281147 100644 --- a/libxml++/attributenode.h +++ b/libxml++/attributenode.h @@ -12,6 +12,12 @@ #include +#ifndef DOXYGEN_SHOULD_SKIP_THIS +extern "C" { + struct _xmlAttr; +} +#endif //#ifndef DOXYGEN_SHOULD_SKIP_THIS + namespace xmlpp { diff --git a/libxml++/document.cc b/libxml++/document.cc index e8ddd747..fed17180 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -9,7 +9,6 @@ #include #include -#include #include #include #include diff --git a/libxml++/document.h b/libxml++/document.h index 07c25c28..722e883e 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -48,12 +48,13 @@ typedef enum { XML_INTERNAL_PREDEFINED_ENTITY = 6 } XmlEntityType; -class Document; - //TODO: Make Document inherit from Node, when we can break ABI one day? // //libxml might intend xmlDoc to derive (theoretically) from xmlNode. -//This is suggested because the xmlNodeSet returned by xmlXPathEval (see the Node::find() implementation) can contain either xmlNode or xmlDocument elements. +//This is suggested because the xmlNodeSet returned by xmlXPathEval (see the +//Node::find() implementation) can contain either xmlNode or xmlDocument elements. +// See https://bugzilla.gnome.org/show_bug.cgi?id=754673#c8 for an explanation +// why it has not been done in libxml++ 3.0. /** * Represents an XML document in the DOM model. */ diff --git a/libxml++/dtd.h b/libxml++/dtd.h index 30a6bfdb..16e50cfa 100644 --- a/libxml++/dtd.h +++ b/libxml++/dtd.h @@ -22,6 +22,8 @@ namespace xmlpp { //TODO: Derive from Node? +// See https://bugzilla.gnome.org/show_bug.cgi?id=754673#c8 for an explanation +// why it has not been done in libxml++ 3.0. /** Represents an XML DTD for validating XML files. * DTD = Document Type Definition */ diff --git a/libxml++/exceptions/internal_error.h b/libxml++/exceptions/internal_error.h index 303109f9..e43d4525 100644 --- a/libxml++/exceptions/internal_error.h +++ b/libxml++/exceptions/internal_error.h @@ -22,9 +22,6 @@ #include -#include -#include - namespace xmlpp { class internal_error : public exception diff --git a/libxml++/exceptions/parse_error.h b/libxml++/exceptions/parse_error.h index 659b135e..3b386d85 100644 --- a/libxml++/exceptions/parse_error.h +++ b/libxml++/exceptions/parse_error.h @@ -22,9 +22,6 @@ #include -#include -#include - namespace xmlpp { diff --git a/libxml++/nodes/cdatanode.cc b/libxml++/nodes/cdatanode.cc index 0955732f..167d5af8 100644 --- a/libxml++/nodes/cdatanode.cc +++ b/libxml++/nodes/cdatanode.cc @@ -5,7 +5,6 @@ */ #include -#include #include diff --git a/libxml++/nodes/commentnode.cc b/libxml++/nodes/commentnode.cc index 046205c4..aa066cf7 100644 --- a/libxml++/nodes/commentnode.cc +++ b/libxml++/nodes/commentnode.cc @@ -5,7 +5,6 @@ */ #include -#include #include diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc index d6b1df9f..30e912ca 100644 --- a/libxml++/nodes/element.cc +++ b/libxml++/nodes/element.cc @@ -6,7 +6,6 @@ #include #include -#include #include diff --git a/libxml++/nodes/entityreference.cc b/libxml++/nodes/entityreference.cc index d8e2f4d9..3c35405b 100644 --- a/libxml++/nodes/entityreference.cc +++ b/libxml++/nodes/entityreference.cc @@ -5,7 +5,6 @@ */ #include -#include #include diff --git a/libxml++/nodes/processinginstructionnode.cc b/libxml++/nodes/processinginstructionnode.cc index 074fce72..9c3d394a 100644 --- a/libxml++/nodes/processinginstructionnode.cc +++ b/libxml++/nodes/processinginstructionnode.cc @@ -5,7 +5,6 @@ */ #include -#include #include diff --git a/libxml++/nodes/textnode.cc b/libxml++/nodes/textnode.cc index b640e024..d76a0626 100644 --- a/libxml++/nodes/textnode.cc +++ b/libxml++/nodes/textnode.cc @@ -5,7 +5,6 @@ */ #include -#include #include diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index df13a9c8..bcf997c7 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -8,13 +8,12 @@ #define __LIBXMLPP_PARSERS_DOMPARSER_H #include -#include #include namespace xmlpp { /** DOM XML parser. - * + * DOM = Document Object Model */ class DomParser : public Parser { diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index c3aa1bf9..83ce3a9c 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -9,7 +9,6 @@ #include -#include #include #include #include "libxml++/document.h" @@ -25,6 +24,7 @@ namespace xmlpp { /** SAX XML parser. * Derive your own class and override the on_*() methods. + * SAX = Simple API for XML */ class SaxParser : public Parser { diff --git a/libxml++/validators/relaxngvalidator.cc b/libxml++/validators/relaxngvalidator.cc index 4cd9a9c6..7eb1036d 100644 --- a/libxml++/validators/relaxngvalidator.cc +++ b/libxml++/validators/relaxngvalidator.cc @@ -119,7 +119,7 @@ const RelaxNGSchema* RelaxNGValidator::get_schema() const RelaxNGValidator::operator bool() const noexcept { - return reinterpret_cast(pimpl_->schema && pimpl_->schema->cobj()); + return pimpl_->schema && pimpl_->schema->cobj(); } diff --git a/libxml++/validators/xsdvalidator.cc b/libxml++/validators/xsdvalidator.cc index 9d496a06..ebe1c91b 100644 --- a/libxml++/validators/xsdvalidator.cc +++ b/libxml++/validators/xsdvalidator.cc @@ -116,7 +116,7 @@ const XsdSchema* XsdValidator::get_schema() const XsdValidator::operator bool() const noexcept { - return reinterpret_cast(pimpl_->schema && pimpl_->schema->cobj()); + return pimpl_->schema && pimpl_->schema->cobj(); } From ad65ef4efc924cae9a04afc4c8951914c9ee30fa Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 1 Oct 2015 15:39:55 +0200 Subject: [PATCH 024/240] Element: Rename set/get_child_text() to set/get_first_child_text() * libxml++/nodes/element.[h|cc]: Rename set/get_child_text() to set/get_first_child_text() by analogy with Node::get_first_child(). * examples/dom_build/main.cc: * examples/dom_xpath/main.cc: * examples/import_node/main.cc: Replace set/get_child_text() by set/get_first_child_text(). Bug #754673. --- examples/dom_build/main.cc | 4 ++-- examples/dom_xpath/main.cc | 4 ++-- examples/import_node/main.cc | 2 +- libxml++/nodes/element.cc | 28 +++++++++------------------- libxml++/nodes/element.h | 19 +++++++++++++------ 5 files changed, 27 insertions(+), 30 deletions(-) diff --git a/examples/dom_build/main.cc b/examples/dom_build/main.cc index f22b4934..3674b0ee 100644 --- a/examples/dom_build/main.cc +++ b/examples/dom_build/main.cc @@ -45,7 +45,7 @@ main(int /* argc */, char** /* argv */) auto nodeRoot = document.create_root_node("exampleroot", "http://foo", "foo"); //Declares the namespace and uses its prefix for this node nodeRoot->set_namespace_declaration("http://foobar", "foobar"); //Also associate this prefix with this namespace: - nodeRoot->set_child_text("\n"); + nodeRoot->set_first_child_text("\n"); auto nodeChild = nodeRoot->add_child_element("examplechild"); //Associate prefix with namespace: @@ -53,7 +53,7 @@ main(int /* argc */, char** /* argv */) nodeChild->set_namespace("bar"); //So it will be bar::examplechild. nodeChild->set_attribute("id", "1", "foo"); //foo is the namespace prefix. You could also just use a name of foo:id". - nodeChild->set_child_text("\nSome content\n"); + nodeChild->set_first_child_text("\nSome content\n"); nodeChild->add_child_comment("Some comments"); nodeChild->add_child_entity_reference("example1"); nodeChild->add_child_entity_reference("#x20ac"); // € diff --git a/examples/dom_xpath/main.cc b/examples/dom_xpath/main.cc index 8000df87..c35e4094 100644 --- a/examples/dom_xpath/main.cc +++ b/examples/dom_xpath/main.cc @@ -72,9 +72,9 @@ bool xpath_test(const xmlpp::Node* node, const Glib::ustring& xpath) auto element = dynamic_cast(child); if (element) { - auto text_node = element->get_child_text(); + auto text_node = element->get_first_child_text(); if (text_node) - std::cout << ", child_text=\"" << text_node->get_content() << "\""; + std::cout << ", first_child_text=\"" << text_node->get_content() << "\""; } std::cout << std::endl; } diff --git a/examples/import_node/main.cc b/examples/import_node/main.cc index a539721c..edcbaa06 100644 --- a/examples/import_node/main.cc +++ b/examples/import_node/main.cc @@ -46,7 +46,7 @@ int main (int /* argc */, char** /* argv */) cerr << "first_child2 == nullptr" << endl; return EXIT_FAILURE; } - auto text_to_add = first_child2->get_child_text(); + auto text_to_add = first_child2->get_first_child_text(); // Import the text under the first "child" element in example1. // Adjacent text nodes are merged. diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc index 30e912ca..cb9baa98 100644 --- a/libxml++/nodes/element.cc +++ b/libxml++/nodes/element.cc @@ -260,36 +260,26 @@ _xmlNode* Element::create_new_child_element_node_with_new_ns(const Glib::ustring return child; } -const TextNode* Element::get_child_text() const +TextNode* Element::get_first_child_text() { - // FIXME: return only the first content node - for(auto child = cobj()->children; child; child = child->next) - if(child->type == XML_TEXT_NODE) + for (auto child = cobj()->children; child; child = child->next) + if (child->type == XML_TEXT_NODE) { Node::create_wrapper(child); return static_cast(child->_private); } - return 0; + return nullptr; } -TextNode* Element::get_child_text() +const TextNode* Element::get_first_child_text() const { - // TODO: This only returns the first content node. - // What should we do instead? Update the documentation if we change this. murrayc. - for(auto child = cobj()->children; child; child = child->next) - if(child->type == XML_TEXT_NODE) - { - Node::create_wrapper(child); - return static_cast(child->_private); - } - - return 0; + return const_cast(this)->get_first_child_text(); } -void Element::set_child_text(const Glib::ustring& content) +void Element::set_first_child_text(const Glib::ustring& content) { - auto node = get_child_text(); + auto node = get_first_child_text(); if(node) node->set_content(content); else @@ -361,7 +351,7 @@ TextNode* Element::add_child_text_before(xmlpp::Node* next_sibling, const Glib:: bool Element::has_child_text() const { - return get_child_text() != nullptr; + return get_first_child_text() != nullptr; } void Element::set_namespace_declaration(const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) diff --git a/libxml++/nodes/element.h b/libxml++/nodes/element.h index 472c4023..bc879d9e 100644 --- a/libxml++/nodes/element.h +++ b/libxml++/nodes/element.h @@ -204,17 +204,21 @@ class Element : public Node /** Get the first child text content node. * This is a convenience method, meant as an alternative to iterating over all the - * child nodes to find the first suitable node then and getting the text directly. + * child nodes to find the first suitable node and then getting the text directly. * @returns The first text node, if any. + * + * @newin{3,0} Replaces get_child_text(). */ - TextNode* get_child_text(); + TextNode* get_first_child_text(); /** Get the first child text content node. * This is a convenience method, meant as an alternative to iterating over all the - * child nodes to find the first suitable node then and getting the text directly. + * child nodes to find the first suitable node and then getting the text directly. * @returns The first text node, if any. + * + * @newin{3,0} Replaces get_child_text(). */ - const TextNode* get_child_text() const; + const TextNode* get_first_child_text() const; /** Append a new text node. * @param content The text. This should be unescaped - see ContentNode::set_content(). @@ -246,11 +250,14 @@ class Element : public Node TextNode* add_child_text_before(xmlpp::Node* next_sibling, const Glib::ustring& content = Glib::ustring()); /** Set the text of the first text node, adding one if necessary. - * This is a convenience method, meant as an alternative to iterating over all the child nodes to find the first suitable node then and setting the text directly. + * This is a convenience method, meant as an alternative to iterating over all the + * child nodes to find the first suitable node and then setting the text directly. * @param content The text. This should be unescaped - see ContentNode::set_content(). * @throws xmlpp::internal_error + * + * @newin{3,0} Replaces set_child_text(). */ - void set_child_text(const Glib::ustring& content); + void set_first_child_text(const Glib::ustring& content); /** Discover whether one of the child nodes is a text node. * This is a convenience method, meant as an alternative to iterating over all the child nodes and examining them directly. From b1ab496121b3362f7584c36a451a6765168b8e7b Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 1 Oct 2015 16:23:52 +0200 Subject: [PATCH 025/240] Inherit NonCopyable publicly Inherit NonCopyable publicly instead of privatly. It doesn't really matter, but private inheritance is unusual. There's no good reason to use it for NonCopyable. Bug #754673. --- libxml++/document.h | 2 +- libxml++/parsers/parser.h | 2 +- libxml++/parsers/textreader.h | 2 +- libxml++/schemabase.h | 2 +- libxml++/validators/validator.h | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/libxml++/document.h b/libxml++/document.h index 722e883e..73ca18f7 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -58,7 +58,7 @@ typedef enum { /** * Represents an XML document in the DOM model. */ -class Document : NonCopyable +class Document : public NonCopyable { //Ensure that libxml is properly initialised: class Init diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index 802a1594..4384b9f8 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -33,7 +33,7 @@ namespace xmlpp { * * Abstract base class for DOM parser and SAX parser. */ -class Parser : NonCopyable +class Parser : public NonCopyable { public: Parser(); diff --git a/libxml++/parsers/textreader.h b/libxml++/parsers/textreader.h index 9acd6cda..1ebd81aa 100644 --- a/libxml++/parsers/textreader.h +++ b/libxml++/parsers/textreader.h @@ -26,7 +26,7 @@ namespace xmlpp * A reader that provides fast, non-cached, forward-only access to XML data, * in the style of .Net's XmlTextReader class. */ -class TextReader: NonCopyable +class TextReader: public NonCopyable { public: enum xmlNodeType { diff --git a/libxml++/schemabase.h b/libxml++/schemabase.h index e0f3461c..c7330b26 100644 --- a/libxml++/schemabase.h +++ b/libxml++/schemabase.h @@ -35,7 +35,7 @@ class Document; * * @newin{2,38} */ -class SchemaBase : NonCopyable +class SchemaBase : public NonCopyable { public: SchemaBase(); diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index 15285012..93f443fc 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -28,7 +28,7 @@ class Document; /** Base class for XML validators. */ -class Validator : NonCopyable +class Validator : public NonCopyable { public: Validator(); From efd7860f79ecc471777c856f448a172b39908363 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 5 Oct 2015 11:52:19 +0200 Subject: [PATCH 026/240] 2.91.1 --- NEWS | 37 ++++++++++++++++++++++++++++++++++++- configure.ac | 2 +- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index cee70a16..55a0f3dc 100644 --- a/NEWS +++ b/NEWS @@ -1,8 +1,43 @@ -2.90.0 (unstable): +2.91.1 (unstable): * Renamed ABI from libxml++-2.6 to libxml++-3.0. This requires applications to change their pkg-config check to libxml++-3.0 when they wish to use libxml++ 2.9x or 3.x instead of libxml++ 2.x. + (Kjell Ahlstedt) Bug #754673. + There may be more changes in ABI and/or API before the first stable + libxml++-3.0 release. + +* Node: Add const_NodeList and use it in a const version of get_children(). + Add const_NodeSet and use it in a const version of find(). + Replace xmlpp::NodeSet by xmlpp::Node::NodeSet. + Element: Add const_Attribute_list and use it in a const version of + get_attributes(). + (Kjell Ahlstedt) Bug #338907 (Marcos Mayorga) +* Document: Add a non-const version of get_root_node(). Let the const version + return a const pointer. + (Knut Aksel Røysland) Bug #632522 +* Element: Add a non-const version of get_attribute(). Let the const version + return a const pointer. + (Knut Aksel Røysland) Bug #632524 +* Replace the deprecated std::auto_ptr by std::unique_ptr + (Kjell Ahlstedt) Bug #753123 +* DomParser: The default behaviour is to throw both parse errors and + validity errors in an exception instead of printing some messages on stderr. +* Parser: Some protected data has become private. +* Several classes: Some virtual methods have become non-virtual, and some + non-virtual methods have become virtual. +* Remove class xmlpp::wrapped_exception and the deprecated classes + Schema and SchemaValidator. +* xmlpp::exception and its subclasses: Remove Raise() and Clone(). +* SaxParser: Start each parsing with a new Document for entity resolution. +* Move all Node::add_child*() methods to Element and rename them to + add_child_element*(). +* Attribute: Move set_value() to AttributeNode. +* Use std::string instead of Glib::ustring for filenames. +* Node: Replace remove_child() by remove_node(). +* Move some code from DtdValidator to Dtd. +* Element: Rename set/get_child_text() to set/get_first_child_text(). + 2.39.2 (unstable): diff --git a/configure.ac b/configure.ac index 673198b6..d771313a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [2.90.0], +AC_INIT([libxml++], [2.91.1], [https://bugzilla.gnome.org/enter_bug.cgi?product=libxml%2B%2B], [libxml++], [http://libxmlplusplus.sourceforge.net/]) AC_PREREQ([2.59]) From 5abab30c22d21130380a9c233d25418698044f4d Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 8 Oct 2015 08:53:12 +0200 Subject: [PATCH 027/240] Add xmlpp::format_printf_message() * libxml++/exceptions/exception.[h|cc]: Add format_printf_message(). * libxml++/parsers/parser.cc: * libxml++/parsers/saxparser.cc: * libxml++/validators/validator.cc: Call format_printf_message(). --- libxml++/exceptions/exception.cc | 20 ++++++++++++++++++++ libxml++/exceptions/exception.h | 26 ++++++++++++++++++++++++-- libxml++/parsers/parser.cc | 5 +---- libxml++/parsers/saxparser.cc | 20 +++++++------------- libxml++/validators/validator.cc | 14 +++++--------- 5 files changed, 57 insertions(+), 28 deletions(-) diff --git a/libxml++/exceptions/exception.cc b/libxml++/exceptions/exception.cc index 38057791..6042c372 100644 --- a/libxml++/exceptions/exception.cc +++ b/libxml++/exceptions/exception.cc @@ -1,6 +1,8 @@ #include "exception.h" #include #include +#include +#include namespace xmlpp { @@ -92,4 +94,22 @@ Glib::ustring format_xml_parser_error(const _xmlParserCtxt* parser_context) return str + format_xml_error(error); } +Glib::ustring format_printf_message(const char* fmt, va_list args) +{ + // This code was inspired by the example at + // http://en.cppreference.com/w/cpp/io/c/vfprintf + va_list args2; + va_copy(args2, args); + // Number of characters (bytes) in the resulting string; + // error, if < 0. + const int nchar = std::vsnprintf(nullptr, 0, fmt, args2); + va_end(args2); + if (nchar < 0) + return Glib::ustring::format("Error code from std::vsnprintf = ", nchar); + + std::vector buf(nchar+1); + std::vsnprintf(buf.data(), buf.size(), fmt, args); + return Glib::ustring(buf.data()); +} + } //namespace xmlpp diff --git a/libxml++/exceptions/exception.h b/libxml++/exceptions/exception.h index 4510075f..cb027178 100644 --- a/libxml++/exceptions/exception.h +++ b/libxml++/exceptions/exception.h @@ -21,6 +21,7 @@ #define __LIBXMLPP_EXCEPTION_H #include +#include // va_list #include #include @@ -51,8 +52,8 @@ class LIBXMLPP_API exception : public std::exception * * @newin{2,36} * - * @param error Pointer to an _xmlError struct or 0. If 0, - * the error returned by xmlGetLastError() is used. + * @param error Pointer to an _xmlError struct or nullptr. + * If nullptr, the error returned by xmlGetLastError() is used. * @returns A formatted text string. If the error struct does not contain an * error (error->code == XML_ERR_OK), an empty string is returned. */ @@ -69,6 +70,27 @@ Glib::ustring format_xml_error(const _xmlError* error = nullptr); */ Glib::ustring format_xml_parser_error(const _xmlParserCtxt* parser_context); +/** Format a message from a function with C-style variadic parameters. + * + * Helper function that formats a message supplied in the form of a printf-style + * format specification and zero or more ... parameters. + * + * @code + * // Typical call: + * void f(const char* fmt, ...) + * { + * va_list args; + * va_start(args, fmt); + * Glib::ustring msg = xmlpp::format_printf_message(fmt, args); + * va_end(args); + * // ... + * } + * @endcode + * + * @newin{3,0} + */ +Glib::ustring format_printf_message(const char* fmt, va_list args); + } // namespace xmlpp #endif // __LIBXMLPP_EXCEPTION_H diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc index e45a9051..019ffc15 100644 --- a/libxml++/parsers/parser.cc +++ b/libxml++/parsers/parser.cc @@ -308,10 +308,7 @@ void Parser::callback_error_or_warning(MsgType msg_type, void* ctx, // returns an error message (as it usually does). //Convert the ... to a string: - char buff[1024]; - - vsnprintf(buff, sizeof(buff)/sizeof(buff[0]), msg, var_args); - ubuff = buff; + ubuff = format_printf_message(msg, var_args); } try diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index bb415494..8a83bf6f 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -523,15 +523,13 @@ void SaxParserCallback::warning(void* context, const char* fmt, ...) auto parser = static_cast(the_context->_private); va_list arg; - char buff[1024]; //TODO: Larger/Shared - va_start(arg, fmt); - vsnprintf(buff, sizeof(buff)/sizeof(buff[0]), fmt, arg); + const Glib::ustring buff = format_printf_message(fmt, arg); va_end(arg); try { - parser->on_warning(Glib::ustring(buff)); + parser->on_warning(buff); } catch (...) { @@ -544,19 +542,17 @@ void SaxParserCallback::error(void* context, const char* fmt, ...) auto the_context = static_cast<_xmlParserCtxt*>(context); auto parser = static_cast(the_context->_private); - va_list arg; - char buff[1024]; //TODO: Larger/Shared - if (parser->exception_ptr_) return; + va_list arg; va_start(arg, fmt); - vsnprintf(buff, sizeof(buff)/sizeof(buff[0]), fmt, arg); + const Glib::ustring buff = format_printf_message(fmt, arg); va_end(arg); try { - parser->on_error(Glib::ustring(buff)); + parser->on_error(buff); } catch (...) { @@ -570,15 +566,13 @@ void SaxParserCallback::fatal_error(void* context, const char* fmt, ...) auto parser = static_cast(the_context->_private); va_list arg; - char buff[1024]; //TODO: Larger/Shared - va_start(arg, fmt); - vsnprintf(buff, sizeof(buff)/sizeof(buff[0]), fmt, arg); + const Glib::ustring buff = format_printf_message(fmt, arg); va_end(arg); try { - parser->on_fatal_error(Glib::ustring(buff)); + parser->on_fatal_error(buff); } catch (...) { diff --git a/libxml++/validators/validator.cc b/libxml++/validators/validator.cc index cd5d42d1..4858cee8 100644 --- a/libxml++/validators/validator.cc +++ b/libxml++/validators/validator.cc @@ -1,4 +1,4 @@ -/* xml++.cc +/* validator.cc * libxml++ and this file are copyright (C) 2000 by Ari Johnson * (C) 2002-2004 by the libxml dev team and * are covered by the GNU Lesser General Public License, which should be @@ -98,15 +98,13 @@ void Validator::callback_validity_error(void* valid_, const char* msg, ...) { //Convert the ... to a string: va_list arg; - char buff[1024]; //TODO: Larger/Shared - va_start(arg, msg); - vsnprintf(buff, sizeof(buff)/sizeof(buff[0]), msg, arg); + const Glib::ustring buff = format_printf_message(msg, arg); va_end(arg); try { - validator->on_validity_error(Glib::ustring(buff)); + validator->on_validity_error(buff); } catch (...) { @@ -123,15 +121,13 @@ void Validator::callback_validity_warning(void* valid_, const char* msg, ...) { //Convert the ... to a string: va_list arg; - char buff[1024]; //TODO: Larger/Shared - va_start(arg, msg); - vsnprintf(buff, sizeof(buff)/sizeof(buff[0]), msg, arg); + const Glib::ustring buff = format_printf_message(msg, arg); va_end(arg); try { - validator->on_validity_warning(Glib::ustring(buff)); + validator->on_validity_warning(buff); } catch (...) { From a6e487e26f5c3a2a17bd2d15e03e04c04ce53cf4 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 8 Oct 2015 09:54:49 +0200 Subject: [PATCH 028/240] Remove some TODO comments --- libxml++/parsers/domparser.cc | 19 +++++++++++-------- libxml++/parsers/saxparser.cc | 6 +++++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/libxml++/parsers/domparser.cc b/libxml++/parsers/domparser.cc index 2628a537..6b76ed3a 100644 --- a/libxml++/parsers/domparser.cc +++ b/libxml++/parsers/domparser.cc @@ -121,12 +121,12 @@ void DomParser::parse_context() } doc_ = new Document(context_->myDoc); - // This is to indicate to release_underlying that we took the + // This is to indicate to release_underlying() that we took the // ownership on the doc. context_->myDoc = nullptr; - //Free the parse context, but keep the document alive so people can navigate the DOM tree: - //TODO: Why not keep the context alive too? + // Free the parser context because it's not needed anymore, + // but keep the document alive so people can navigate the DOM tree: Parser::release_underlying(); } @@ -151,7 +151,11 @@ void DomParser::parse_stream(std::istream& in) initialize_context(); - //TODO: Shouldn't we use a Glib::ustring here, and some alternative to std::getline()? + // std::string or Glib::ustring? + // Output from the XML parser is UTF-8 encoded. + // But the istream "in" is input, i.e. an XML file. It can use any encoding. + // If it's not UTF-8, the file itself must contain information about which + // encoding it uses. See the XML specification. Thus use std::string. int firstParseError = XML_ERR_OK; std::string line; while(std::getline(in, line)) @@ -194,13 +198,12 @@ void DomParser::parse_stream(std::istream& in) } doc_ = new Document(context_->myDoc); - // This is to indicate to release_underlying that we took the + // This is to indicate to release_underlying() that we took the // ownership on the doc. context_->myDoc = nullptr; - - //Free the parse context, but keep the document alive so people can navigate the DOM tree: - //TODO: Why not keep the context alive too? + // Free the parser context because it's not needed anymore, + // but keep the document alive so people can navigate the DOM tree: Parser::release_underlying(); } diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index 8a83bf6f..7b16c3c8 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -233,7 +233,11 @@ void SaxParser::parse_stream(std::istream& in) initialize_context(); - //TODO: Shouldn't we use a Glib::ustring here, and some alternative to std::getline()? + // std::string or Glib::ustring? + // Output from the XML parser is UTF-8 encoded. + // But the istream "in" is input, i.e. an XML file. It can use any encoding. + // If it's not UTF-8, the file itself must contain information about which + // encoding it uses. See the XML specification. Thus use std::string. int firstParseError = XML_ERR_OK; std::string line; while (!exception_ptr_ && std::getline(in, line)) From a96e5fa354cb59e8300a77d0b85df7332887f2c6 Mon Sep 17 00:00:00 2001 From: Gaurav Gupta Date: Thu, 8 Oct 2015 12:59:47 +0530 Subject: [PATCH 029/240] Use nullptr instead of 0 at missing places - C++-11 --- libxml++/document.cc | 6 +++--- libxml++/nodes/element.cc | 24 ++++++++++++------------ libxml++/nodes/node.cc | 12 ++++++------ libxml++/parsers/textreader.cc | 4 ++-- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/libxml++/document.cc b/libxml++/document.cc index fed17180..f85d70ef 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -201,7 +201,7 @@ Dtd* Document::get_internal_subset() const { auto dtd = xmlGetIntSubset(impl_); if(!dtd) - return 0; + return nullptr; if(!dtd->_private) dtd->_private = new Dtd(dtd); @@ -226,7 +226,7 @@ Element* Document::get_root_node() { auto root = xmlDocGetRootElement(impl_); if(root == nullptr) - return 0; + return nullptr; else { Node::create_wrapper(root); @@ -270,7 +270,7 @@ Element* Document::create_root_node_by_import(const Node* node, bool recursive) { if (!node) - return 0; + return nullptr; //Create the node, by copying: auto imported_node = xmlDocCopyNode(const_cast(node->cobj()), impl_, recursive); diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc index cb9baa98..62a66059 100644 --- a/libxml++/nodes/element.cc +++ b/libxml++/nodes/element.cc @@ -67,7 +67,7 @@ Attribute* Element::get_attribute(const Glib::ustring& name, { ns_uri = get_namespace_uri_for_prefix(ns_prefix); if (ns_uri.empty()) - return 0; // No such prefix. + return nullptr; // No such prefix. } // The return value of xmlHasNsProp() may be either an xmlAttr*, pointing to an @@ -82,7 +82,7 @@ Attribute* Element::get_attribute(const Glib::ustring& name, return reinterpret_cast(attr->_private); } - return 0; + return nullptr; } const Attribute* Element::get_attribute(const Glib::ustring& name, @@ -128,7 +128,7 @@ Attribute* Element::set_attribute(const Glib::ustring& name, const Glib::ustring return reinterpret_cast(attr->_private); } else - return 0; + return nullptr; } void Element::remove_attribute(const Glib::ustring& name, const Glib::ustring& ns_prefix) @@ -155,7 +155,7 @@ Element* Element::add_child_element(xmlpp::Node* previous_sibling, const Glib::ustring& name, const Glib::ustring& ns_prefix) { if (!previous_sibling) - return 0; + return nullptr; auto child = create_new_child_element_node(name, ns_prefix); auto node = xmlAddNextSibling(previous_sibling->cobj(), child); @@ -166,7 +166,7 @@ Element* Element::add_child_element_before(xmlpp::Node* next_sibling, const Glib::ustring& name, const Glib::ustring& ns_prefix) { if (!next_sibling) - return 0; + return nullptr; auto child = create_new_child_element_node(name, ns_prefix); auto node = xmlAddPrevSibling(next_sibling->cobj(), child); @@ -186,7 +186,7 @@ Element* Element::add_child_element_with_new_ns(xmlpp::Node* previous_sibling, const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) { if (!previous_sibling) - return 0; + return nullptr; auto child = create_new_child_element_node_with_new_ns(name, ns_uri, ns_prefix); auto node = xmlAddNextSibling(previous_sibling->cobj(), child); @@ -198,7 +198,7 @@ Element* Element::add_child_element_before_with_new_ns(xmlpp::Node* next_sibling const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) { if (!next_sibling) - return 0; + return nullptr; auto child = create_new_child_element_node_with_new_ns(name, ns_uri, ns_prefix); auto node = xmlAddPrevSibling(next_sibling->cobj(), child); @@ -302,13 +302,13 @@ TextNode* Element::add_child_text(const Glib::ustring& content) Node::create_wrapper(node); return static_cast(node->_private); } - return 0; + return nullptr; } TextNode* Element::add_child_text(xmlpp::Node* previous_sibling, const Glib::ustring& content) { if(!previous_sibling) - return 0; + return nullptr; if(cobj()->type == XML_ELEMENT_NODE) { @@ -324,13 +324,13 @@ TextNode* Element::add_child_text(xmlpp::Node* previous_sibling, const Glib::ust Node::create_wrapper(node); return static_cast(node->_private); } - return 0; + return nullptr; } TextNode* Element::add_child_text_before(xmlpp::Node* next_sibling, const Glib::ustring& content) { if(!next_sibling) - return 0; + return nullptr; if(cobj()->type == XML_ELEMENT_NODE) { @@ -346,7 +346,7 @@ TextNode* Element::add_child_text_before(xmlpp::Node* next_sibling, const Glib:: Node::create_wrapper(node); return static_cast(node->_private); } - return 0; + return nullptr; } bool Element::has_child_text() const diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index 16cb55f9..177ca9f8 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -238,7 +238,7 @@ const Element* Node::get_parent() const Element* Node::get_parent() { if(!(cobj()->parent && cobj()->parent->type == XML_ELEMENT_NODE)) - return 0; + return nullptr; Node::create_wrapper(cobj()->parent); return static_cast(cobj()->parent->_private); @@ -252,7 +252,7 @@ const Node* Node::get_next_sibling() const Node* Node::get_next_sibling() { if(!cobj()->next) - return 0; + return nullptr; Node::create_wrapper(cobj()->next); return static_cast(cobj()->next->_private); @@ -266,7 +266,7 @@ const Node* Node::get_previous_sibling() const Node* Node::get_previous_sibling() { if(!cobj()->prev) - return 0; + return nullptr; Node::create_wrapper(cobj()->prev); return static_cast(cobj()->prev->_private); @@ -276,7 +276,7 @@ Node* Node::get_first_child(const Glib::ustring& name) { auto child = impl_->children; if(!child) - return 0; + return nullptr; do { @@ -285,7 +285,7 @@ Node* Node::get_first_child(const Glib::ustring& name) } while((child = child->next)); - return 0; + return nullptr; } const Node* Node::get_first_child(const Glib::ustring& name) const @@ -320,7 +320,7 @@ void Node::remove_node(Node* node) Node* Node::import_node(const Node* node, bool recursive) { if (!node) - return 0; + return nullptr; //Create the node, by copying: auto imported_node = xmlDocCopyNode(const_cast(node->cobj()), impl_->doc, recursive); diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc index 5eb04144..74804e3c 100644 --- a/libxml++/parsers/textreader.cc +++ b/libxml++/parsers/textreader.cc @@ -301,7 +301,7 @@ Node* TextReader::get_current_node() } check_for_exceptions(); - return 0; + return nullptr; } const Node* TextReader::get_current_node() const @@ -329,7 +329,7 @@ Node* TextReader::expand() } check_for_exceptions(); - return 0; + return nullptr; } bool TextReader::next() From a1012116d0deaeeb32a60606f4af3c2b71837230 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 8 Oct 2015 15:36:13 +0200 Subject: [PATCH 030/240] More use of nullptr instead of 0 Bug #756166 (also the previous commit) --- libxml++/document.cc | 12 ++++++------ libxml++/document.h | 10 +++++----- libxml++/nodes/element.cc | 16 ++++++++-------- libxml++/nodes/element.h | 6 +++--- libxml++/nodes/node.cc | 16 ++++++++-------- libxml++/nodes/node.h | 30 +++++++++++++++--------------- libxml++/parsers/textreader.cc | 6 +++--- libxml++/parsers/textreader.h | 8 ++++---- 8 files changed, 52 insertions(+), 52 deletions(-) diff --git a/libxml++/document.cc b/libxml++/document.cc index f85d70ef..c6e43393 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -138,7 +138,7 @@ static const char* get_encoding_or_utf8(const Glib::ustring& encoding) { if(encoding.empty()) { - //If we don't specify this to the xmlDocDump* functions (using 0 instead), + //If we don't specify this to the xmlDocDump* functions (using nullptr instead), //then some other encoding is used, causing them to fail on non-ASCII characters. return "UTF-8"; } @@ -215,8 +215,8 @@ void Document::set_internal_subset(const Glib::ustring& name, { auto dtd = xmlCreateIntSubset(impl_, (const xmlChar*)name.c_str(), - external_id.empty() ? (const xmlChar*)0 : (const xmlChar*)external_id.c_str(), - system_id.empty() ? (const xmlChar*)0 : (const xmlChar*)system_id.c_str()); + external_id.empty() ? nullptr : (const xmlChar*)external_id.c_str(), + system_id.empty() ? nullptr : (const xmlChar*)system_id.c_str()); if (dtd && !dtd->_private) dtd->_private = new Dtd(dtd); @@ -243,7 +243,7 @@ Element* Document::create_root_node(const Glib::ustring& name, const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) { - auto node = xmlNewDocNode(impl_, 0, (const xmlChar*)name.c_str(), 0); + auto node = xmlNewDocNode(impl_, nullptr, (const xmlChar*)name.c_str(), nullptr); if (!node) throw internal_error("Could not create root element node " + name); @@ -416,8 +416,8 @@ void Document::set_entity_declaration(const Glib::ustring& name, XmlEntityType t const Glib::ustring& content) { auto entity = xmlAddDocEntity( impl_, (const xmlChar*) name.c_str(), type, - publicId.empty() ? (const xmlChar*)0 : (const xmlChar*)publicId.c_str(), - systemId.empty() ? (const xmlChar*)0 : (const xmlChar*)systemId.c_str(), + publicId.empty() ? nullptr : (const xmlChar*)publicId.c_str(), + systemId.empty() ? nullptr : (const xmlChar*)systemId.c_str(), (const xmlChar*) content.c_str() ); if (!entity) throw internal_error("Could not add entity declaration " + name); diff --git a/libxml++/document.h b/libxml++/document.h index 73ca18f7..ea81b3f3 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -80,7 +80,7 @@ class Document : public NonCopyable /** Create a new C++ wrapper for an xmlDoc struct. * The created xmlpp::Document takes ownership of the xmlDoc. * When the Document is deleted, so is the xmlDoc and all its nodes. - * @param doc A pointer to an xmlDoc struct. Must not be 0. + * @param doc A pointer to an xmlDoc struct. Must not be nullptr. */ explicit Document(_xmlDoc* doc); @@ -91,7 +91,7 @@ class Document : public NonCopyable Glib::ustring get_encoding() const; /** Get the internal subset of this document. - * @returns A pointer to the DTD, or 0 if not found. + * @returns A pointer to the DTD, or nullptr if not found. */ Dtd* get_internal_subset() const; @@ -107,13 +107,13 @@ class Document : public NonCopyable /** Return the root node. * This function does @b not create a default root node if it doesn't exist. - * @return A pointer to the root node if it exists, 0 otherwise. + * @return A pointer to the root node if it exists, nullptr otherwise. */ Element* get_root_node(); /** Return the root node. * This function does @b not create a default root node if it doesn't exist. - * @return A pointer to the root node if it exists, 0 otherwise. + * @return A pointer to the root node if it exists, nullptr otherwise. */ const Element* get_root_node() const; @@ -257,7 +257,7 @@ class Document : public NonCopyable /** Retrieve an Entity. * The entity can be from an external subset or internally declared. * @param name The name of the entity to get. - * @returns A pointer to the libxml2 entity structure, or 0 if not found. + * @returns A pointer to the libxml2 entity structure, or nullptr if not found. */ _xmlEntity* get_entity(const Glib::ustring& name); diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc index 62a66059..3cc36979 100644 --- a/libxml++/nodes/element.cc +++ b/libxml++/nodes/element.cc @@ -75,7 +75,7 @@ Attribute* Element::get_attribute(const Glib::ustring& name, // cast to an xmlAttr*, pointing to the declaration of an attribute with a // default value (XML_ATTRIBUTE_DECL). auto attr = xmlHasNsProp(const_cast(cobj()), (const xmlChar*)name.c_str(), - ns_uri.empty() ? 0 : (const xmlChar*)ns_uri.c_str()); + ns_uri.empty() ? nullptr : (const xmlChar*)ns_uri.c_str()); if (attr) { Node::create_wrapper(reinterpret_cast(attr)); @@ -216,7 +216,7 @@ _xmlNode* Element::create_new_child_element_node(const Glib::ustring& name, if (ns_prefix.empty()) { //Retrieve default namespace if it exists - ns = xmlSearchNs(cobj()->doc, cobj(), 0); + ns = xmlSearchNs(cobj()->doc, cobj(), nullptr); } else { @@ -235,12 +235,12 @@ _xmlNode* Element::create_new_child_element_node_with_new_ns(const Glib::ustring if (cobj()->type != XML_ELEMENT_NODE) throw internal_error("You can only add child nodes to element nodes."); - auto child = xmlNewNode(0, (const xmlChar*)name.c_str()); + auto child = xmlNewNode(nullptr, (const xmlChar*)name.c_str()); if (!child) throw internal_error("Could not create new element node."); - auto ns = xmlNewNs(child, (const xmlChar*)(ns_uri.empty() ? 0 : ns_uri.c_str()), - (const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) ); + auto ns = xmlNewNs(child, (const xmlChar*)(ns_uri.empty() ? nullptr : ns_uri.c_str()), + (const xmlChar*)(ns_prefix.empty() ? nullptr : ns_prefix.c_str()) ); // xmlNewNs() does not create a namespace node for the predefined xml prefix. // It's usually defined in the document and not in any specific node. if (!ns && ns_prefix == "xml") @@ -357,13 +357,13 @@ bool Element::has_child_text() const void Element::set_namespace_declaration(const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) { //Create a new namespace declaration for this element: - auto ns = xmlNewNs(cobj(), (const xmlChar*)(ns_uri.empty() ? 0 : ns_uri.c_str()), - (const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) ); + auto ns = xmlNewNs(cobj(), (const xmlChar*)(ns_uri.empty() ? nullptr : ns_uri.c_str()), + (const xmlChar*)(ns_prefix.empty() ? nullptr : ns_prefix.c_str()) ); if (!ns) { // Not an error, if we try to assign the same uri to the prefix once again. ns = xmlSearchNs(cobj()->doc, cobj(), - (const xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str())); + (const xmlChar*)(ns_prefix.empty() ? nullptr : ns_prefix.c_str())); const char* const previous_href = (ns && ns->href) ? (const char*)ns->href : ""; if (!ns || ns_uri != previous_href) throw exception("Could not add namespace declaration with URI=" + ns_uri + diff --git a/libxml++/nodes/element.h b/libxml++/nodes/element.h index bc879d9e..e013828d 100644 --- a/libxml++/nodes/element.h +++ b/libxml++/nodes/element.h @@ -59,7 +59,7 @@ class Element : public Node /** Get the attribute with this name, and optionally with this namespace. * @param name The name of the attribute that will be retrieved. * @param ns_prefix Namespace prefix. - * @return The attribute, or 0 if no suitable Attribute was found. + * @return The attribute, or nullptr if no suitable Attribute was found. * Is either an AttributeNode*, pointing to an explicitly set * attribute, or an AttributeDeclaration*, pointing to the declaration * of an attribute with a default value. @@ -70,7 +70,7 @@ class Element : public Node /** Get the attribute with this name, and optionally with this namespace. * @param name The name of the attribute that will be retrieved. * @param ns_prefix Namespace prefix. - * @return The attribute, or 0 if no suitable Attribute was found. + * @return The attribute, or nullptr if no suitable Attribute was found. * Is either an AttributeNode*, pointing to an explicitly set * attribute, or an AttributeDeclaration*, pointing to the declaration * of an attribute with a default value. @@ -95,7 +95,7 @@ class Element : public Node * @param name The name of the attribute whose value will change. * @param value The new value for the attribute * @param ns_prefix Namespace prefix. If the prefix has not been declared then this method will throw an exception. - * @return The attribute that was changed, or 0 is no suitable Attribute was found. + * @return The attribute that was changed, or nullptr is no suitable Attribute was found. * @throws xmlpp::exception */ Attribute* set_attribute(const Glib::ustring& name, const Glib::ustring& value, diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index 177ca9f8..71eab857 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -222,7 +222,7 @@ Node::Node(xmlNode* node) : impl_(node) { if (!impl_) - throw internal_error("xmlNode pointer cannot be 0"); + throw internal_error("xmlNode pointer cannot be nullptr"); impl_->_private = this; } @@ -332,7 +332,7 @@ Node* Node::import_node(const Node* node, bool recursive) if (imported_node->type == XML_ATTRIBUTE_NODE && impl_->type == XML_ELEMENT_NODE) { auto old_attr = xmlHasNsProp(impl_, imported_node->name, - imported_node->ns ? imported_node->ns->href : 0); + imported_node->ns ? imported_node->ns->href : nullptr); if (old_attr && old_attr->type != XML_ATTRIBUTE_DECL) { // *this has an attribute with the same name as the imported attribute. @@ -396,12 +396,12 @@ Glib::ustring Node::get_path() const Node::NodeSet Node::find(const Glib::ustring& xpath) { - return find_common(xpath, 0, impl_); + return find_common(xpath, nullptr, impl_); } Node::const_NodeSet Node::find(const Glib::ustring& xpath) const { - return find_common(xpath, 0, impl_); + return find_common(xpath, nullptr, impl_); } Node::NodeSet Node::find(const Glib::ustring& xpath, const PrefixNsMap& namespaces) @@ -416,7 +416,7 @@ Node::const_NodeSet Node::find(const Glib::ustring& xpath, const PrefixNsMap& na bool Node::eval_to_boolean(const Glib::ustring& xpath, XPathResultType* result_type) const { - return eval_common_to_boolean(xpath, 0, result_type, impl_); + return eval_common_to_boolean(xpath, nullptr, result_type, impl_); } bool Node::eval_to_boolean(const Glib::ustring& xpath, const PrefixNsMap& namespaces, @@ -427,7 +427,7 @@ bool Node::eval_to_boolean(const Glib::ustring& xpath, const PrefixNsMap& namesp double Node::eval_to_number(const Glib::ustring& xpath, XPathResultType* result_type) const { - return eval_common_to_number(xpath, 0, result_type, impl_); + return eval_common_to_number(xpath, nullptr, result_type, impl_); } double Node::eval_to_number(const Glib::ustring& xpath, const PrefixNsMap& namespaces, @@ -438,7 +438,7 @@ double Node::eval_to_number(const Glib::ustring& xpath, const PrefixNsMap& names Glib::ustring Node::eval_to_string(const Glib::ustring& xpath, XPathResultType* result_type) const { - return eval_common_to_string(xpath, 0, result_type, impl_); + return eval_common_to_string(xpath, nullptr, result_type, impl_); } Glib::ustring Node::eval_to_string(const Glib::ustring& xpath, const PrefixNsMap& namespaces, @@ -502,7 +502,7 @@ void Node::set_namespace(const Glib::ustring& ns_prefix) } //Look for the existing namespace to use: - auto ns = xmlSearchNs( cobj()->doc, cobj(), (xmlChar*)(ns_prefix.empty() ? 0 : ns_prefix.c_str()) ); + auto ns = xmlSearchNs( cobj()->doc, cobj(), (xmlChar*)(ns_prefix.empty() ? nullptr : ns_prefix.c_str()) ); if(ns) { //Use it for this element: diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index 8966b8d2..577505d2 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -57,7 +57,7 @@ class Node : public NonCopyable typedef std::vector NodeSet; typedef std::vector const_NodeSet; - /** @throws xmlpp::internal_error If @a node is 0. + /** @throws xmlpp::internal_error If @a node is nullptr. */ explicit Node(_xmlNode* node); @@ -100,39 +100,39 @@ class Node : public NonCopyable int get_line() const; /** Get the parent element for this node. - * @returns The parent node, or 0 if the node has no parent element. + * @returns The parent node, or nullptr if the node has no parent element. */ const Element* get_parent() const; /** Get the parent element for this node. - * @returns The parent node, or 0 if the node has no parent element. + * @returns The parent node, or nullptr if the node has no parent element. */ Element* get_parent(); /** Get the next sibling for this node. - * @returns The next sibling, or 0 if the node has no next sibling. + * @returns The next sibling, or nullptr if the node has no next sibling. */ const Node* get_next_sibling() const; /** Get the next sibling for this node. - * @returns The next sibling, or 0 if the node has no next sibling. + * @returns The next sibling, or nullptr if the node has no next sibling. */ Node* get_next_sibling(); /** Get the previous sibling for this node . - * @returns The previous sibling, or 0 if the node has no previous sibling. + * @returns The previous sibling, or nullptr if the node has no previous sibling. */ const Node* get_previous_sibling() const; /** Get the previous sibling for this node. - * @returns The previous sibling, or 0 if the node has no previous sibling. + * @returns The previous sibling, or nullptr if the node has no previous sibling. */ Node* get_previous_sibling(); /** Get the first child of this node. * You may optionally get the first child node which has a certain name. * @param name The name of the requested child node, or an empty string. - * @returns The first child, or 0 if no child node (with the specified name) exists. + * @returns The first child, or nullptr if no child node (with the specified name) exists. * * @newin{2,36} */ @@ -141,7 +141,7 @@ class Node : public NonCopyable /** Get the first child of this node. * You may optionally get the first child node which has a certain name. * @param name The name of the requested child node, or an empty string. - * @returns The first child, or 0 if no child node (with the specified name) exists. + * @returns The first child, or nullptr if no child node (with the specified name) exists. * * @newin{2,36} */ @@ -233,7 +233,7 @@ class Node : public NonCopyable /** Evaluate an XPath expression. * @param xpath The XPath expression. * @param[out] result_type Result type of the XPath expression before conversion - * to boolean. If 0, the result type is not returned. + * to boolean. If nullptr, the result type is not returned. * @returns The value of the XPath expression. If the value is not of type boolean, * it is converted to boolean. * @throws xmlpp::exception If the XPath expression cannot be evaluated. @@ -248,7 +248,7 @@ class Node : public NonCopyable * @param xpath The XPath expression. * @param namespaces A map of namespace prefixes to namespace URIs to be used while evaluating. * @param[out] result_type Result type of the XPath expression before conversion - * to boolean. If 0, the result type is not returned. + * to boolean. If nullptr, the result type is not returned. * @returns The value of the XPath expression. If the value is not of type boolean, * it is converted to boolean. * @throws xmlpp::exception If the XPath expression cannot be evaluated. @@ -262,7 +262,7 @@ class Node : public NonCopyable /** Evaluate an XPath expression. * @param xpath The XPath expression. * @param[out] result_type Result type of the XPath expression before conversion - * to number. If 0, the result type is not returned. + * to number. If nullptr, the result type is not returned. * @returns The value of the XPath expression. If the value is not of type number, * it is converted to number. * @throws xmlpp::exception If the XPath expression cannot be evaluated. @@ -276,7 +276,7 @@ class Node : public NonCopyable * @param xpath The XPath expression. * @param namespaces A map of namespace prefixes to namespace URIs to be used while evaluating. * @param[out] result_type Result type of the XPath expression before conversion - * to number. If 0, the result type is not returned. + * to number. If nullptr, the result type is not returned. * @returns The value of the XPath expression. If the value is not of type number, * it is converted to number. * @throws xmlpp::exception If the XPath expression cannot be evaluated. @@ -290,7 +290,7 @@ class Node : public NonCopyable /** Evaluate an XPath expression. * @param xpath The XPath expression. * @param[out] result_type Result type of the XPath expression before conversion - * to string. If 0, the result type is not returned. + * to string. If nullptr, the result type is not returned. * @returns The value of the XPath expression. If the value is not of type string, * it is converted to string. * @throws xmlpp::exception If the XPath expression cannot be evaluated. @@ -304,7 +304,7 @@ class Node : public NonCopyable * @param xpath The XPath expression. * @param namespaces A map of namespace prefixes to namespace URIs to be used while evaluating. * @param[out] result_type Result type of the XPath expression before conversion - * to string. If 0, the result type is not returned. + * to string. If nullptr, the result type is not returned. * @returns The value of the XPath expression. If the value is not of type string, * it is converted to string. * @throws xmlpp::exception If the XPath expression cannot be evaluated. diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc index 74804e3c..223dd9ae 100644 --- a/libxml++/parsers/textreader.cc +++ b/libxml++/parsers/textreader.cc @@ -38,7 +38,7 @@ TextReader::TextReader( size_type size, const Glib::ustring& uri) : propertyreader(new PropertyReader(*this)), - impl_( xmlReaderForMemory ((const char*)data, size, uri.c_str(), 0, 0) ), + impl_( xmlReaderForMemory ((const char*)data, size, uri.c_str(), nullptr, 0) ), severity_( 0 ) { if( ! impl_ ) @@ -407,7 +407,7 @@ Glib::ustring TextReader::PropertyReader::String(xmlChar* value, bool free) { owner_.check_for_exceptions(); - if(value == (xmlChar *)0) + if (!value) return Glib::ustring(); const Glib::ustring result = (char *)value; @@ -422,7 +422,7 @@ Glib::ustring TextReader::PropertyReader::String(xmlChar const* value) { owner_.check_for_exceptions(); - if(value == (xmlChar *)0) + if (!value) return Glib::ustring(); return (const char*)value; diff --git a/libxml++/parsers/textreader.h b/libxml++/parsers/textreader.h index 1ebd81aa..15a67f04 100644 --- a/libxml++/parsers/textreader.h +++ b/libxml++/parsers/textreader.h @@ -94,7 +94,7 @@ class TextReader: public NonCopyable */ TextReader(const unsigned char* data, size_type size, const Glib::ustring& uri = Glib::ustring()); - ~TextReader(); + ~TextReader() override; /** Moves the position of the current instance to the next node in the stream, exposing its properties. * @return true if the node was read successfully, false if there are no more nodes to read. @@ -221,13 +221,13 @@ class TextReader: public NonCopyable * The C++ wrapper is not deleted. Using this method causes memory leaks, * unless you call xmlpp::Node::free_wrappers(), which is not intended to be * called by the application. - * @returns A pointer to the current node, or 0 in case of error. + * @returns A pointer to the current node, or nullptr in case of error. */ Node* get_current_node(); /** Get a pointer to the current node. * @warning See the non-const get_current_node(). - * @returns A pointer to the current node, or 0 in case of error. + * @returns A pointer to the current node, or nullptr in case of error. */ const Node* get_current_node() const; @@ -239,7 +239,7 @@ class TextReader: public NonCopyable * @warning The C++ wrappers are not deleted. Using this method causes memory leaks, * unless you call xmlpp::Node::free_wrappers(), which is not intended to be * called by the application. - * @returns A pointer to the current node, or 0 in case of error. + * @returns A pointer to the current node, or nullptr in case of error. * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ From 5a611c885680e88a36b7ae6e786348f9662c5aa9 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 9 Oct 2015 15:33:47 +0200 Subject: [PATCH 031/240] Still more use of nullptr instead of 0 --- libxml++/dtd.cc | 2 +- libxml++/io/parserinputbuffer.cc | 4 +- libxml++/parsers/domparser.cc | 12 ++--- libxml++/parsers/domparser.h | 4 +- libxml++/parsers/saxparser.cc | 68 ++++++++++++------------- libxml++/parsers/saxparser.h | 2 +- libxml++/relaxngschema.cc | 2 +- libxml++/validators/dtdvalidator.cc | 2 +- libxml++/validators/dtdvalidator.h | 6 +-- libxml++/validators/relaxngvalidator.cc | 2 +- libxml++/validators/relaxngvalidator.h | 4 +- libxml++/validators/xsdvalidator.cc | 2 +- libxml++/validators/xsdvalidator.h | 4 +- libxml++/xsdschema.cc | 2 +- 14 files changed, 58 insertions(+), 58 deletions(-) diff --git a/libxml++/dtd.cc b/libxml++/dtd.cc index 2ec0c15c..ff2663e2 100644 --- a/libxml++/dtd.cc +++ b/libxml++/dtd.cc @@ -93,7 +93,7 @@ void Dtd::parse_stream(std::istream& in) IStreamParserInputBuffer ibuff(in); - auto dtd = xmlIOParseDTD(0, ibuff.cobj(), XML_CHAR_ENCODING_UTF8); + auto dtd = xmlIOParseDTD(nullptr, ibuff.cobj(), XML_CHAR_ENCODING_UTF8); if (!dtd) { diff --git a/libxml++/io/parserinputbuffer.cc b/libxml++/io/parserinputbuffer.cc index 891b5acd..b1732b45 100644 --- a/libxml++/io/parserinputbuffer.cc +++ b/libxml++/io/parserinputbuffer.cc @@ -1,4 +1,4 @@ -/* document.h +/* parserinputbuffer.cc * this file is part of libxml++ * * copyright (C) 2003 by libxml++ developer's team @@ -39,7 +39,7 @@ namespace xmlpp &ParserInputBufferCallback::on_close, static_cast(this), XML_CHAR_ENCODING_NONE); - if(impl_ == 0) + if (!impl_) { throw internal_error("Cannot initialise underlying xmlParserInputBuffer"); } diff --git a/libxml++/parsers/domparser.cc b/libxml++/parsers/domparser.cc index 6b76ed3a..8ca3e7f1 100644 --- a/libxml++/parsers/domparser.cc +++ b/libxml++/parsers/domparser.cc @@ -138,11 +138,11 @@ void DomParser::parse_stream(std::istream& in) xmlResetLastError(); context_ = xmlCreatePushParserCtxt( - 0, // Setting those two parameters to 0 force the parser - 0, // to create a document while parsing. - 0, // chunk - 0, // size - 0); // no filename for fetching external entities + nullptr, // Setting those two parameters to nullptr force the parser + nullptr, // to create a document while parsing. + nullptr, // chunk + 0, // size + nullptr); // no filename for fetching external entities if(!context_) { @@ -173,7 +173,7 @@ void DomParser::parse_stream(std::istream& in) firstParseError = parseError; } - const int parseError = xmlParseChunk(context_, 0, 0, 1 /* last chunk */); + const int parseError = xmlParseChunk(context_, nullptr, 0, 1 /* last chunk */); if (parseError != XML_ERR_OK && firstParseError == XML_ERR_OK) firstParseError = parseError; diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index bcf997c7..63010ccf 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -79,12 +79,12 @@ class DomParser : public Parser operator bool() const; /** Get the parsed document. - * @returns A pointer to the parsed document, or 0. + * @returns A pointer to the parsed document, or nullptr. */ Document* get_document(); /** Get the parsed document. - * @returns A pointer to the parsed document, or 0. + * @returns A pointer to the parsed document, or nullptr. */ const Document* get_document() const; diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index 7b16c3c8..acbb9a29 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -43,37 +43,37 @@ SaxParser::SaxParser(bool use_get_entity) { xmlSAXHandler temp = { SaxParserCallback::internal_subset, - 0, // isStandalone - 0, // hasInternalSubset - 0, // hasExternalSubset - 0, // resolveEntity - use_get_entity ? SaxParserCallback::get_entity : 0, // getEntity + nullptr, // isStandalone + nullptr, // hasInternalSubset + nullptr, // hasExternalSubset + nullptr, // resolveEntity + use_get_entity ? SaxParserCallback::get_entity : nullptr, // getEntity SaxParserCallback::entity_decl, // entityDecl - 0, // notationDecl - 0, // attributeDecl - 0, // elementDecl - 0, // unparsedEntityDecl - 0, // setDocumentLocator + nullptr, // notationDecl + nullptr, // attributeDecl + nullptr, // elementDecl + nullptr, // unparsedEntityDecl + nullptr, // setDocumentLocator SaxParserCallback::start_document, // startDocument SaxParserCallback::end_document, // endDocument SaxParserCallback::start_element, // startElement SaxParserCallback::end_element, // endElement - 0, // reference + nullptr, // reference SaxParserCallback::characters, // characters - 0, // ignorableWhitespace - 0, // processingInstruction + nullptr, // ignorableWhitespace + nullptr, // processingInstruction SaxParserCallback::comment, // comment SaxParserCallback::warning, // warning SaxParserCallback::error, // error SaxParserCallback::fatal_error, // fatalError - 0, // getParameterEntity + nullptr, // getParameterEntity SaxParserCallback::cdata_block, // cdataBlock - 0, // externalSubset - 0, // initialized - 0, // private - 0, // startElementNs - 0, // endElementNs - 0, // serror + nullptr, // externalSubset + 0, // initialized + nullptr, // private + nullptr, // startElementNs + nullptr, // endElementNs + nullptr, // serror }; *sax_handler_ = temp; @@ -221,10 +221,10 @@ void SaxParser::parse_stream(std::istream& in) context_ = xmlCreatePushParserCtxt( sax_handler_.get(), - 0, // user_data - 0, // chunk - 0, // size - 0); // no filename for fetching external entities + nullptr, // user_data + nullptr, // chunk + 0, // size + nullptr); // no filename for fetching external entities if(!context_) { @@ -259,7 +259,7 @@ void SaxParser::parse_stream(std::istream& in) if (!exception_ptr_) { //This is called just to terminate parsing. - const int parseError = xmlParseChunk(context_, 0 /* chunk */, 0 /* size */, 1 /* terminate (1 or 0) */); + const int parseError = xmlParseChunk(context_, nullptr /* chunk */, 0 /* size */, 1 /* terminate (1 or 0) */); if (parseError != XML_ERR_OK && firstParseError == XML_ERR_OK) firstParseError = parseError; @@ -293,10 +293,10 @@ void SaxParser::parse_chunk_raw(const unsigned char* contents, size_type bytes_c { context_ = xmlCreatePushParserCtxt( sax_handler_.get(), - 0, // user_data - 0, // chunk - 0, // size - 0); // no filename for fetching external entities + nullptr, // user_data + nullptr, // chunk + 0, // size + nullptr); // no filename for fetching external entities if(!context_) { @@ -329,10 +329,10 @@ void SaxParser::finish_chunk_parsing() { context_ = xmlCreatePushParserCtxt( sax_handler_.get(), - 0, // this, // user_data - 0, // chunk - 0, // size - 0); // no filename for fetching external entities + nullptr, // user_data + nullptr, // chunk + 0, // size + nullptr); // no filename for fetching external entities if(!context_) { @@ -346,7 +346,7 @@ void SaxParser::finish_chunk_parsing() int parseError = XML_ERR_OK; if (!exception_ptr_) //This is called just to terminate parsing. - parseError = xmlParseChunk(context_, 0 /* chunk */, 0 /* size */, 1 /* terminate (1 or 0) */); + parseError = xmlParseChunk(context_, nullptr /* chunk */, 0 /* size */, 1 /* terminate (1 or 0) */); auto error_str = format_xml_parser_error(context_); if (error_str.empty() && parseError != XML_ERR_OK) diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index 83ce3a9c..58cab4da 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -194,7 +194,7 @@ class SaxParser : public Parser * Unlike the DomParser, the SaxParser will also tell you about entity references for the 5 predefined entities. * * @param name The entity reference name. - * @returns The resolved xmlEntity for the entity reference, or 0 if not found. + * @returns The resolved xmlEntity for the entity reference, or nullptr if not found. * You must include libxml/parser.h in order to use this C struct. * This instance will not be freed by the caller. */ diff --git a/libxml++/relaxngschema.cc b/libxml++/relaxngschema.cc index cf35ba8e..02a2f162 100644 --- a/libxml++/relaxngschema.cc +++ b/libxml++/relaxngschema.cc @@ -91,7 +91,7 @@ void RelaxNGSchema::parse_memory(const Glib::ustring& contents) void RelaxNGSchema::parse_document(const Document* document) { if (!document) - throw parse_error("RelaxNGSchema::parse_document(): document must not be 0."); + throw parse_error("RelaxNGSchema::parse_document(): document must not be nullptr."); // xmlRelaxNGNewDocParserCtxt() takes a copy of the xmlDoc. parse_context(xmlRelaxNGNewDocParserCtxt(const_cast(document->cobj()))); diff --git a/libxml++/validators/dtdvalidator.cc b/libxml++/validators/dtdvalidator.cc index f5b718eb..27560de8 100644 --- a/libxml++/validators/dtdvalidator.cc +++ b/libxml++/validators/dtdvalidator.cc @@ -144,7 +144,7 @@ void DtdValidator::validate(const Document* document) { if (!document) { - throw internal_error("Document pointer cannot be 0."); + throw internal_error("Document pointer cannot be nullptr."); } if (!pimpl_->dtd) diff --git a/libxml++/validators/dtdvalidator.h b/libxml++/validators/dtdvalidator.h index 4513f8cd..e8b841b4 100644 --- a/libxml++/validators/dtdvalidator.h +++ b/libxml++/validators/dtdvalidator.h @@ -1,4 +1,4 @@ -/* xml++.h +/* dtdvalidator.h * libxml++ and this file are copyright (C) 2000 by Ari Johnson, * (C) 2002-2004 by the libxml dev team and * are covered by the GNU Lesser General Public License, which should be @@ -103,12 +103,12 @@ class DtdValidator : public Validator explicit operator bool() const noexcept override; /** Get the parsed DTD. - * @returns A pointer to the parsed DTD, or 0. + * @returns A pointer to the parsed DTD, or nullptr. */ Dtd* get_dtd(); /** Get the parsed DTD. - * @returns A pointer to the parsed DTD, or 0. + * @returns A pointer to the parsed DTD, or nullptr. */ const Dtd* get_dtd() const; diff --git a/libxml++/validators/relaxngvalidator.cc b/libxml++/validators/relaxngvalidator.cc index 7eb1036d..4b7a58fe 100644 --- a/libxml++/validators/relaxngvalidator.cc +++ b/libxml++/validators/relaxngvalidator.cc @@ -132,7 +132,7 @@ void RelaxNGValidator::initialize_context() void RelaxNGValidator::validate(const Document* document) { if (!document) - throw internal_error("RelaxNGValidator::validate(): document must not be 0."); + throw internal_error("RelaxNGValidator::validate(): document must not be nullptr."); if (!*this) throw internal_error("RelaxNGValidator::validate(): Must have a schema to validate document"); diff --git a/libxml++/validators/relaxngvalidator.h b/libxml++/validators/relaxngvalidator.h index 7d873093..e67b6b56 100644 --- a/libxml++/validators/relaxngvalidator.h +++ b/libxml++/validators/relaxngvalidator.h @@ -123,12 +123,12 @@ class RelaxNGValidator : public SchemaValidatorBase explicit operator bool() const noexcept override; /** Get the schema. - * @returns A pointer to the schema, or 0. + * @returns A pointer to the schema, or nullptr. */ RelaxNGSchema* get_schema(); /** Get the schema. - * @returns A pointer to the schema, or 0. + * @returns A pointer to the schema, or nullptr. */ const RelaxNGSchema* get_schema() const; diff --git a/libxml++/validators/xsdvalidator.cc b/libxml++/validators/xsdvalidator.cc index ebe1c91b..cc26d07f 100644 --- a/libxml++/validators/xsdvalidator.cc +++ b/libxml++/validators/xsdvalidator.cc @@ -130,7 +130,7 @@ void XsdValidator::initialize_context() void XsdValidator::validate(const Document* document) { if (!document) - throw internal_error("XsdValidator::validate(): document must not be 0."); + throw internal_error("XsdValidator::validate(): document must not be nullptr."); if (!*this) throw internal_error("XsdValidator::validate(): Must have a schema to validate document"); diff --git a/libxml++/validators/xsdvalidator.h b/libxml++/validators/xsdvalidator.h index ff4840bc..c012f41e 100644 --- a/libxml++/validators/xsdvalidator.h +++ b/libxml++/validators/xsdvalidator.h @@ -114,12 +114,12 @@ class XsdValidator : public SchemaValidatorBase explicit operator bool() const noexcept override; /** Get the schema. - * @returns A pointer to the schema, or 0. + * @returns A pointer to the schema, or nullptr. */ XsdSchema* get_schema(); /** Get the schema. - * @returns A pointer to the schema, or 0. + * @returns A pointer to the schema, or nullptr. */ const XsdSchema* get_schema() const; diff --git a/libxml++/xsdschema.cc b/libxml++/xsdschema.cc index 4ad470e6..1bcd9433 100644 --- a/libxml++/xsdschema.cc +++ b/libxml++/xsdschema.cc @@ -94,7 +94,7 @@ void XsdSchema::parse_memory(const Glib::ustring& contents) void XsdSchema::parse_document(const Document* document) { if (!document) - throw parse_error("XsdSchema::parse_document(): document must not be 0."); + throw parse_error("XsdSchema::parse_document(): document must not be nullptr."); xmlResetLastError(); release_underlying(); From c2f8011cf64d5599ca64fc40cb7219d50f0dd9de Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 9 Oct 2015 16:28:36 +0200 Subject: [PATCH 032/240] Still more use of nullptr instead of 0 --- libxml++/io/parserinputbuffer.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxml++/io/parserinputbuffer.cc b/libxml++/io/parserinputbuffer.cc index b1732b45..e4d24730 100644 --- a/libxml++/io/parserinputbuffer.cc +++ b/libxml++/io/parserinputbuffer.cc @@ -54,7 +54,7 @@ namespace xmlpp bool result = do_close(); // the underlying structure is being freed by libxml, the pointer will soon be // invalid. - impl_ = 0; + impl_ = nullptr; return result; } From add8c88584f01000b9a2947fb792d4ce4b99d367 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 12 Oct 2015 09:43:40 +0200 Subject: [PATCH 033/240] Remove LIBXMLCPP_EXCEPTIONS_ENABLED * configure.ac: * libxml++config.h.in: Remove LIBXMLCPP_EXCEPTIONS_ENABLED. Bug #754673. --- configure.ac | 3 --- libxml++config.h.in | 3 --- 2 files changed, 6 deletions(-) diff --git a/configure.ac b/configure.ac index d771313a..402e7950 100644 --- a/configure.ac +++ b/configure.ac @@ -60,9 +60,6 @@ AC_PATH_PROGS([DB2LATEX], [db2latex docbook2latex], [db2latex]) AC_ARG_VAR([DB2LATEX], [path to db2latex utility]) MM_CHECK_PERL() -# This is just defined to avoid breaking old code: -AC_DEFINE([LIBXMLCPP_EXCEPTIONS_ENABLED],[1], [This is always set. This is only for backwards compatibility.]) - AC_CONFIG_FILES([Makefile libxml++/Makefile examples/Makefile diff --git a/libxml++config.h.in b/libxml++config.h.in index fa360735..19601ae0 100755 --- a/libxml++config.h.in +++ b/libxml++config.h.in @@ -6,9 +6,6 @@ /* Define to omit deprecated API from the library. */ #undef LIBXMLXX_DISABLE_DEPRECATED -/* This is always set. This is only for backwards compatibility. */ -#undef LIBXMLCPP_EXCEPTIONS_ENABLED - /* Major version number of libxml++. */ #undef LIBXMLXX_MAJOR_VERSION From 58dbe5cb0b496d7486a0c54ae04c4d9d76e8e522 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 27 Oct 2015 19:05:29 +0100 Subject: [PATCH 034/240] Add LIBXMLXX_HAVE_EXCEPTION_PTR * build/.gitignore: New file. * build/cxx_std.m4: New file with LIBXMLXX_CXX_HAS_EXCEPTION_PTR autoconf macro. Defines LIBXMLXX_HAVE_EXCEPTION_PTR if std::exception_ptr exists. * .gitignore: Move some lines to build/.gitignore. * configure.ac: Store some build files in the build directory, like most mm packages. Don't use the macros directory. * libxml++config.h.in: Add LIBXMLXX_HAVE_EXCEPTION_PTR. * Makefile.am: * docs/Makefile.am: macros -> build. Bug #757042. Thanks to Daniel Trebbien , who supplied a patch with the test code in LIBXMLXX_HAVE_EXCEPTION_PTR. --- .gitignore | 19 ----------------- Makefile.am | 4 ++-- build/.gitignore | 13 ++++++++++++ build/cxx_std.m4 | 52 +++++++++++++++++++++++++++++++++++++++++++++ configure.ac | 5 +++-- docs/Makefile.am | 2 +- libxml++config.h.in | 3 +++ 7 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 build/.gitignore create mode 100644 build/cxx_std.m4 diff --git a/.gitignore b/.gitignore index e6428597..66748672 100644 --- a/.gitignore +++ b/.gitignore @@ -65,25 +65,6 @@ stamp-h? /examples/*/make_check.sh.trs /examples/test-suite.log -# macros -/macros/compile -/macros/compile-binding.am -/macros/config.guess -/macros/config.sub -/macros/depcomp -/macros/dist-changelog.am -/macros/doc-reference.am -/macros/generate-binding.am -/macros/install-sh -/macros/libtool.m4 -/macros/ltmain.sh -/macros/ltoptions.m4 -/macros/ltsugar.m4 -/macros/ltversion.m4 -/macros/lt~obsolete.m4 -/macros/missing -/macros/test-driver - # tests /tests/*/test /tests/*/test.log diff --git a/Makefile.am b/Makefile.am index 2779bb72..9f02ec44 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ## This file is part of libxml++. -ACLOCAL_AMFLAGS = -I macros ${ACLOCAL_FLAGS} +ACLOCAL_AMFLAGS = -I build ${ACLOCAL_FLAGS} DISTCHECK_CONFIGURE_FLAGS = --enable-warnings=fatal if ENABLE_DOCUMENTATION @@ -25,4 +25,4 @@ dist_noinst_SCRIPTS = autogen.sh DISTCLEANFILES = MSVC_Net2010/libxml++/libxml++config.h # Optional: auto-generate the ChangeLog file from the git log on make dist -include $(top_srcdir)/macros/dist-changelog.am +include $(top_srcdir)/build/dist-changelog.am diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 00000000..189b364c --- /dev/null +++ b/build/.gitignore @@ -0,0 +1,13 @@ +/compile +/compile-binding.am +/config.* +/depcomp +/dist-changelog.am +/doc-reference.am +/generate-binding.am +/install-sh +/libtool.m4 +/lt*.m4 +/ltmain.sh +/missing +/test-driver diff --git a/build/cxx_std.m4 b/build/cxx_std.m4 new file mode 100644 index 00000000..7977f9b7 --- /dev/null +++ b/build/cxx_std.m4 @@ -0,0 +1,52 @@ +## Copyright (C) 2015 The libxml++ development team +## +## This file is part of libxml++. +## +## This library is free software; you can redistribute it and/or +## modify it under the terms of the GNU Lesser General Public +## License as published by the Free Software Foundation; either +## version 2.1 of the License, or (at your option) any later version. +## +## This library is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## Lesser General Public License for more details. +## +## You should have received a copy of the GNU Lesser General Public +## License along with this library. If not, see . + +## LIBXMLXX_CXX_HAS_EXCEPTION_PTR() +## +## Test whether std::exception_ptr, std::current_exception() and +## std::rethrow_exception() are defined. +## +## On success, #define LIBXMLXX_HAVE_EXCEPTION_PTR to 1. +## +AC_DEFUN([LIBXMLXX_CXX_HAS_EXCEPTION_PTR], +[ + AC_CACHE_CHECK( + [whether C++ library supports std::exception_ptr], + [libxmlxx_cv_cxx_has_exception_ptr], + [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [[ + #include + ]],[[ + try + { + throw "custom error"; + } + catch(...) + { + std::exception_ptr ep = std::current_exception(); + std::rethrow_exception(ep); + } + ]])], + [libxmlxx_cv_cxx_has_exception_ptr='yes'], + [libxmlxx_cv_cxx_has_exception_ptr='no'] + ) + ]) + + AS_IF([test "x${libxmlxx_cv_cxx_has_exception_ptr}" = 'xyes'], + [AC_DEFINE([LIBXMLXX_HAVE_EXCEPTION_PTR], [1], [Defined if the C++ library supports std::exception_ptr.])]) +]) diff --git a/configure.ac b/configure.ac index 402e7950..0b1a589f 100644 --- a/configure.ac +++ b/configure.ac @@ -6,8 +6,8 @@ AC_INIT([libxml++], [2.91.1], AC_PREREQ([2.59]) AC_CONFIG_SRCDIR([libxml++/libxml++.h]) -AC_CONFIG_AUX_DIR([macros]) -AC_CONFIG_MACRO_DIR([macros]) +AC_CONFIG_AUX_DIR([build]) +AC_CONFIG_MACRO_DIR([build]) AC_CONFIG_HEADERS([config.h libxml++config.h]) AM_INIT_AUTOMAKE([1.9 -Wno-portability dist-bzip2 no-define nostdinc subdir-objects]) @@ -39,6 +39,7 @@ PKG_CHECK_MODULES([LIBXMLXX], [$LIBXMLXX_MODULES]) AC_LANG([C++]) AC_CHECK_HEADERS([string list map], [], [AC_MSG_ERROR([required headers not found])]) +LIBXMLXX_CXX_HAS_EXCEPTION_PTR MM_ARG_ENABLE_DOCUMENTATION MM_ARG_WITH_TAGFILE_DOC([libstdc++.tag], [mm-common-libstdc++]) diff --git a/docs/Makefile.am b/docs/Makefile.am index 9458f002..edd69f45 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -19,7 +19,7 @@ book_name = $(LIBXMLXX_MODULE_NAME) doc_input = $(addprefix $(top_srcdir)/libxml++/,$(h_sources_public)) # Sets dist_noinst_DATA, DISTCLEANFILES and MAINTAINERCLEANFILES -include $(top_srcdir)/macros/doc-reference.am +include $(top_srcdir)/build/doc-reference.am manual/libxml++.xml: manual/libxml++_without_code.xml manual/insert_example_code.pl $(AM_V_GEN)$(PERL) -- manual/insert_example_code.pl ../examples $< >$@ diff --git a/libxml++config.h.in b/libxml++config.h.in index 19601ae0..0a908003 100755 --- a/libxml++config.h.in +++ b/libxml++config.h.in @@ -6,6 +6,9 @@ /* Define to omit deprecated API from the library. */ #undef LIBXMLXX_DISABLE_DEPRECATED +/* Defined if the C++ library supports std::exception_ptr. */ +#undef LIBXMLXX_HAVE_EXCEPTION_PTR + /* Major version number of libxml++. */ #undef LIBXMLXX_MAJOR_VERSION From 6d57f92e1faf51adb23bb3776c67a050e0fa02dd Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 29 Oct 2015 09:37:10 +0100 Subject: [PATCH 035/240] Work around some platforms' lack of support for std::exception_ptr * libxml++/exceptions/exception.[cc|h]: * libxml++/exceptions/internal_error.[cc|h]: * libxml++/exceptions/parse_error.[cc|h]: * libxml++/exceptions/validity_error.[cc|h]: Reintroduce Raise() and Clone(), now renamed to raise() and clone(). * libxml++/exceptions/wrapped_exception.[cc|h]: Reintroduced files, now with the wrapped_exception class declared only if LIBXMLXX_HAVE_EXCEPTION_PTR is defined. * libxml++/filelist.am: Add wrapped_exception.h. * libxml++/parsers/parser.[cc|h]: Replace std::exception_ptr exception_ptr_ by std::unique_ptr exception_. * libxml++/parsers/saxparser.cc: exception_ptr_ -> exception_ * libxml++/parsers/saxparser.h: Note in the class description that some exceptions are replaced by xmlpp::exception if std::exception_ptr is not supported. * libxml++/validators/validator.[cc|h]: Replace std::exception_ptr exception_ptr_ by std::unique_ptr exception_. * examples/sax_exception/myparser.[cc|h]: Reintroduce Raise() and Clone(), now renamed to raise() and clone(). * tests/saxparser_chunk_parsing_inconsistent_state/main.cc: * tests/saxparser_parse_double_free/main.cc: * tests/saxparser_parse_stream_inconsistent_state/main.cc: Catch xmlpp::exception, if LIBXMLXX_HAVE_EXCEPTION_PTR is not defined. Bug #757042. The substitution of exception_ for exception_ptr_ in Parser and Validator breaks ABI. The ABI of libxml++ 3.x has not yet been frozen. Thanks to Daniel Trebbien , who supplied a patch for libxml++ 2.40. --- examples/sax_exception/myparser.cc | 10 +++ examples/sax_exception/myparser.h | 2 + libxml++/exceptions/exception.cc | 10 +++ libxml++/exceptions/exception.h | 3 + libxml++/exceptions/internal_error.cc | 10 +++ libxml++/exceptions/internal_error.h | 3 + libxml++/exceptions/parse_error.cc | 10 +++ libxml++/exceptions/parse_error.h | 3 + libxml++/exceptions/validity_error.cc | 10 +++ libxml++/exceptions/validity_error.h | 3 + libxml++/exceptions/wrapped_exception.cc | 46 +++++++++++++ libxml++/exceptions/wrapped_exception.h | 56 ++++++++++++++++ libxml++/filelist.am | 3 +- libxml++/parsers/parser.cc | 65 ++++++++++--------- libxml++/parsers/parser.h | 3 +- libxml++/parsers/saxparser.cc | 12 ++-- libxml++/parsers/saxparser.h | 5 ++ libxml++/validators/validator.cc | 61 ++++++++--------- libxml++/validators/validator.h | 4 +- .../main.cc | 13 +++- tests/saxparser_parse_double_free/main.cc | 46 ++++++++++++- .../main.cc | 13 +++- 22 files changed, 313 insertions(+), 78 deletions(-) create mode 100644 libxml++/exceptions/wrapped_exception.cc create mode 100644 libxml++/exceptions/wrapped_exception.h diff --git a/examples/sax_exception/myparser.cc b/examples/sax_exception/myparser.cc index 9c9013df..70f8bdaf 100644 --- a/examples/sax_exception/myparser.cc +++ b/examples/sax_exception/myparser.cc @@ -34,6 +34,16 @@ MyException::~MyException() throw () { } +void MyException::raise() const +{ + throw *this; +} + +xmlpp::exception* MyException::clone() const +{ + return new MyException(*this); +} + /* * MySaxParser implementation */ diff --git a/examples/sax_exception/myparser.h b/examples/sax_exception/myparser.h index 3e1c2ee0..6c2376d3 100644 --- a/examples/sax_exception/myparser.h +++ b/examples/sax_exception/myparser.h @@ -27,6 +27,8 @@ class MyException: public xmlpp::exception public: MyException(); ~MyException() noexcept override; + void raise() const override; + xmlpp::exception* clone() const override; }; class MySaxParser : public xmlpp::SaxParser diff --git a/libxml++/exceptions/exception.cc b/libxml++/exceptions/exception.cc index 6042c372..e7fbf513 100644 --- a/libxml++/exceptions/exception.cc +++ b/libxml++/exceptions/exception.cc @@ -19,6 +19,16 @@ const char* exception::what() const noexcept return message_.c_str(); } +void exception::raise() const +{ + throw *this; +} + +exception* exception::clone() const +{ + return new exception(*this); +} + Glib::ustring format_xml_error(const _xmlError* error) { if (!error) diff --git a/libxml++/exceptions/exception.h b/libxml++/exceptions/exception.h index cb027178..7fbaf1e7 100644 --- a/libxml++/exceptions/exception.h +++ b/libxml++/exceptions/exception.h @@ -44,6 +44,9 @@ class LIBXMLPP_API exception : public std::exception const char* what() const noexcept override; + virtual void raise() const; + virtual exception* clone() const; + private: Glib::ustring message_; }; diff --git a/libxml++/exceptions/internal_error.cc b/libxml++/exceptions/internal_error.cc index 9f48cac2..2bdbe1c7 100644 --- a/libxml++/exceptions/internal_error.cc +++ b/libxml++/exceptions/internal_error.cc @@ -10,4 +10,14 @@ internal_error::internal_error(const Glib::ustring& message) internal_error::~internal_error() noexcept {} +void internal_error::raise() const +{ + throw *this; +} + +exception* internal_error::clone() const +{ + return new internal_error(*this); +} + } //namespace xmlpp diff --git a/libxml++/exceptions/internal_error.h b/libxml++/exceptions/internal_error.h index e43d4525..07912cbb 100644 --- a/libxml++/exceptions/internal_error.h +++ b/libxml++/exceptions/internal_error.h @@ -29,6 +29,9 @@ class internal_error : public exception public: explicit internal_error(const Glib::ustring& message); ~internal_error() noexcept override; + + void raise() const override; + exception* clone() const override; }; } // namespace xmlpp diff --git a/libxml++/exceptions/parse_error.cc b/libxml++/exceptions/parse_error.cc index 96bd53ef..a83a3fc5 100644 --- a/libxml++/exceptions/parse_error.cc +++ b/libxml++/exceptions/parse_error.cc @@ -10,4 +10,14 @@ parse_error::parse_error(const Glib::ustring& message) parse_error::~parse_error() noexcept {} +void parse_error::raise() const +{ + throw *this; +} + +exception* parse_error::clone() const +{ + return new parse_error(*this); +} + } //namespace xmlpp diff --git a/libxml++/exceptions/parse_error.h b/libxml++/exceptions/parse_error.h index 3b386d85..724f9315 100644 --- a/libxml++/exceptions/parse_error.h +++ b/libxml++/exceptions/parse_error.h @@ -32,6 +32,9 @@ class parse_error : public exception public: explicit parse_error(const Glib::ustring& message); ~parse_error() noexcept override; + + void raise() const override; + exception* clone() const override; }; } // namespace xmlpp diff --git a/libxml++/exceptions/validity_error.cc b/libxml++/exceptions/validity_error.cc index b0fdc24c..81006b66 100644 --- a/libxml++/exceptions/validity_error.cc +++ b/libxml++/exceptions/validity_error.cc @@ -10,4 +10,14 @@ validity_error::validity_error(const Glib::ustring& message) validity_error::~validity_error() noexcept {} +void validity_error::raise() const +{ + throw *this; +} + +exception* validity_error::clone() const +{ + return new validity_error(*this); +} + } //namespace xmlpp diff --git a/libxml++/exceptions/validity_error.h b/libxml++/exceptions/validity_error.h index 503eeb3e..e264e4b7 100644 --- a/libxml++/exceptions/validity_error.h +++ b/libxml++/exceptions/validity_error.h @@ -32,6 +32,9 @@ class validity_error : public parse_error public: explicit validity_error(const Glib::ustring& message); ~validity_error() noexcept override; + + void raise() const override; + exception* clone() const override; }; } // namespace xmlpp diff --git a/libxml++/exceptions/wrapped_exception.cc b/libxml++/exceptions/wrapped_exception.cc new file mode 100644 index 00000000..062dbebc --- /dev/null +++ b/libxml++/exceptions/wrapped_exception.cc @@ -0,0 +1,46 @@ +/* Copyright (C) 2015 The libxml++ development team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "wrapped_exception.h" + +namespace xmlpp +{ + +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR + +wrapped_exception::wrapped_exception(std::exception_ptr exception_ptr) + : exception("Wrapped exception"), exception_ptr_(exception_ptr) +{ +} + +wrapped_exception::~wrapped_exception() noexcept +{ +} + +void wrapped_exception::raise() const +{ + std::rethrow_exception(exception_ptr_); +} + +exception* wrapped_exception::clone() const +{ + return new wrapped_exception(exception_ptr_); +} + +#endif // LIBXMLXX_HAVE_EXCEPTION_PTR + +} // namespace xmlpp diff --git a/libxml++/exceptions/wrapped_exception.h b/libxml++/exceptions/wrapped_exception.h new file mode 100644 index 00000000..ffcafea6 --- /dev/null +++ b/libxml++/exceptions/wrapped_exception.h @@ -0,0 +1,56 @@ +/* Copyright (C) 2015 The libxml++ development team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef __LIBXMLPP_WRAPPED_EXCEPTION_H +#define __LIBXMLPP_WRAPPED_EXCEPTION_H + +#include + +#include +#include + +namespace xmlpp +{ + +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR + +#ifndef DOXYGEN_SHOULD_SKIP_THIS +/** Helper class for propagating an exception through C code. + * Should not be used by applications. + * Does not exist in systems that don't support std::exception_ptr. + * + * @newin{2,40} + */ +class wrapped_exception : public exception +{ +public: + explicit wrapped_exception(std::exception_ptr exception_ptr); + ~wrapped_exception() noexcept override; + + void raise() const override; + exception* clone() const override; + +private: + std::exception_ptr exception_ptr_; +}; +#endif //DOXYGEN_SHOULD_SKIP_THIS + +#endif // LIBXMLXX_HAVE_EXCEPTION_PTR + +} // namespace xmlpp + +#endif // __LIBXMLPP_WRAPPED_EXCEPTION_H diff --git a/libxml++/filelist.am b/libxml++/filelist.am index aeedd0c0..ee338a84 100644 --- a/libxml++/filelist.am +++ b/libxml++/filelist.am @@ -15,7 +15,8 @@ h_exceptions_sources_public = \ exceptions/exception.h \ exceptions/parse_error.h \ exceptions/validity_error.h \ - exceptions/internal_error.h + exceptions/internal_error.h \ + exceptions/wrapped_exception.h h_io_sources_public = \ io/istreamparserinputbuffer.h \ io/outputbuffer.h \ diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc index 019ffc15..503987a4 100644 --- a/libxml++/parsers/parser.cc +++ b/libxml++/parsers/parser.cc @@ -4,6 +4,7 @@ * included with libxml++ as the file COPYING. */ +#include "libxml++/exceptions/wrapped_exception.h" #include "libxml++/parsers/parser.h" #include @@ -34,7 +35,7 @@ struct Parser::Impl }; Parser::Parser() -: context_(nullptr), exception_ptr_(nullptr), pimpl_(new Impl) +: context_(nullptr), exception_(nullptr), pimpl_(new Impl) { } @@ -193,20 +194,7 @@ void Parser::on_validity_warning(const Glib::ustring& message) void Parser::check_for_error_and_warning_messages() { - Glib::ustring msg; - try - { - if (exception_ptr_) - std::rethrow_exception(exception_ptr_); - } - catch (const std::exception& e) - { - msg = e.what(); - } - catch (...) - { - msg = "Unknown exception\n"; - } + Glib::ustring msg(exception_ ? exception_->what() : ""); bool parser_msg = false; bool validity_msg = false; @@ -238,17 +226,10 @@ void Parser::check_for_error_and_warning_messages() pimpl_->validate_warning_.erase(); } - try - { - if (validity_msg) - throw validity_error(msg); - else if (parser_msg) - throw parse_error(msg); - } - catch (...) - { - exception_ptr_ = std::current_exception(); - } + if (validity_msg) + exception_.reset(new validity_error(msg)); + else if (parser_msg) + exception_.reset(new parse_error(msg)); } //static @@ -339,7 +320,30 @@ void Parser::callback_error_or_warning(MsgType msg_type, void* ctx, void Parser::handle_exception() { - exception_ptr_ = std::current_exception(); + try + { + throw; // Re-throw current exception + } + catch (const exception& e) + { + exception_.reset(e.clone()); + } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR + catch (...) + { + exception_.reset(new wrapped_exception(std::current_exception())); + } +#else + catch (const std::exception& e) + { + exception_.reset(new exception(e.what())); + } + catch (...) + { + exception_.reset(new exception("An exception was thrown that is not derived from std::exception or xmlpp::exception.\n" + "It could not be caught and rethrown because this platform does not support std::exception_ptr.")); + } +#endif if (context_) xmlStopParser(context_); @@ -351,11 +355,10 @@ void Parser::check_for_exception() { check_for_error_and_warning_messages(); - if (exception_ptr_) + if (exception_) { - std::exception_ptr tmp(exception_ptr_); - exception_ptr_ = nullptr; - std::rethrow_exception(tmp); + std::unique_ptr tmp(std::move(exception_)); + tmp->raise(); } } diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index 4384b9f8..71e65a27 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -19,7 +19,6 @@ #include #include // va_list #include // std::unique_ptr -#include // std::exception_ptr #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { @@ -198,7 +197,7 @@ class Parser : public NonCopyable const char* msg, va_list var_args); _xmlParserCtxt* context_; - std::exception_ptr exception_ptr_; + std::unique_ptr exception_; private: struct Impl; diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index acbb9a29..473f90d6 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -240,7 +240,7 @@ void SaxParser::parse_stream(std::istream& in) // encoding it uses. See the XML specification. Thus use std::string. int firstParseError = XML_ERR_OK; std::string line; - while (!exception_ptr_ && std::getline(in, line)) + while (!exception_ && std::getline(in, line)) { // since getline does not get the line separator, we have to add it since the parser care // about layout in certain cases. @@ -256,7 +256,7 @@ void SaxParser::parse_stream(std::istream& in) firstParseError = parseError; } - if (!exception_ptr_) + if (!exception_) { //This is called just to terminate parsing. const int parseError = xmlParseChunk(context_, nullptr /* chunk */, 0 /* size */, 1 /* terminate (1 or 0) */); @@ -308,7 +308,7 @@ void SaxParser::parse_chunk_raw(const unsigned char* contents, size_type bytes_c xmlCtxtResetLastError(context_); int parseError = XML_ERR_OK; - if (!exception_ptr_) + if (!exception_) parseError = xmlParseChunk(context_, (const char*)contents, bytes_count, 0 /* don't terminate */); check_for_exception(); @@ -344,7 +344,7 @@ void SaxParser::finish_chunk_parsing() xmlCtxtResetLastError(context_); int parseError = XML_ERR_OK; - if (!exception_ptr_) + if (!exception_) //This is called just to terminate parsing. parseError = xmlParseChunk(context_, nullptr /* chunk */, 0 /* size */, 1 /* terminate (1 or 0) */); @@ -433,7 +433,7 @@ void SaxParserCallback::end_document(void* context) auto the_context = static_cast<_xmlParserCtxt*>(context); auto parser = static_cast(the_context->_private); - if (parser->exception_ptr_) + if (parser->exception_) return; try @@ -546,7 +546,7 @@ void SaxParserCallback::error(void* context, const char* fmt, ...) auto the_context = static_cast<_xmlParserCtxt*>(context); auto parser = static_cast(the_context->_private); - if (parser->exception_ptr_) + if (parser->exception_) return; va_list arg; diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index 58cab4da..cba267bc 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -25,6 +25,11 @@ namespace xmlpp { /** SAX XML parser. * Derive your own class and override the on_*() methods. * SAX = Simple API for XML + * + * In a system that does not support std::exception_ptr: If an overridden on_*() + * method throws an exception which is not derived from xmlpp::exception, + * that exception is replaced by a xmlpp::exception before it is propagated + * out of the parse method, such as parse_file(). */ class SaxParser : public Parser { diff --git a/libxml++/validators/validator.cc b/libxml++/validators/validator.cc index 4858cee8..69d02765 100644 --- a/libxml++/validators/validator.cc +++ b/libxml++/validators/validator.cc @@ -5,6 +5,7 @@ * included with libxml++ as the file COPYING. */ +#include "libxml++/exceptions/wrapped_exception.h" #include "libxml++/validators/validator.h" #include @@ -15,7 +16,7 @@ namespace xmlpp { Validator::Validator() -: exception_ptr_(nullptr) +: exception_(nullptr) { } @@ -49,20 +50,7 @@ void Validator::on_validity_warning(const Glib::ustring& message) void Validator::check_for_validity_messages() { - Glib::ustring msg; - try - { - if (exception_ptr_) - std::rethrow_exception(exception_ptr_); - } - catch (const std::exception& e) - { - msg = e.what(); - } - catch (...) - { - msg = "Unknown exception\n"; - } + Glib::ustring msg(exception_ ? exception_->what() : ""); bool validity_msg = false; if (!validate_error_.empty()) @@ -79,15 +67,8 @@ void Validator::check_for_validity_messages() validate_warning_.erase(); } - try - { - if (validity_msg) - throw validity_error(msg); - } - catch (...) - { - exception_ptr_ = std::current_exception(); - } + if (validity_msg) + exception_.reset(new validity_error(msg)); } void Validator::callback_validity_error(void* valid_, const char* msg, ...) @@ -138,7 +119,30 @@ void Validator::callback_validity_warning(void* valid_, const char* msg, ...) void Validator::handle_exception() { - exception_ptr_ = std::current_exception(); + try + { + throw; // Re-throw current exception + } + catch (const exception& e) + { + exception_.reset(e.clone()); + } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR + catch (...) + { + exception_.reset(new wrapped_exception(std::current_exception())); + } +#else + catch (const std::exception& e) + { + exception_.reset(new exception(e.what())); + } + catch (...) + { + exception_.reset(new exception("An exception was thrown that is not derived from std::exception or xmlpp::exception.\n" + "It could not be caught and rethrown because this platform does not support std::exception_ptr.")); + } +#endif // Don't delete the DTD validation context or schema validation context // while validating. It would cause accesses to deallocated memory in libxml2 @@ -156,11 +160,10 @@ void Validator::check_for_exception() { check_for_validity_messages(); - if (exception_ptr_) + if (exception_) { - std::exception_ptr tmp(exception_ptr_); - exception_ptr_ = nullptr; - std::rethrow_exception(tmp); + std::unique_ptr tmp(std::move(exception_)); + tmp->raise(); } } diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index 93f443fc..ed324608 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -15,7 +15,7 @@ #include #include #include -#include // std::exception_ptr +#include // std::unique_ptr #include extern "C" { @@ -77,7 +77,7 @@ class Validator : public NonCopyable static void callback_validity_error(void* ctx, const char* msg, ...); static void callback_validity_warning(void* ctx, const char* msg, ...); - std::exception_ptr exception_ptr_; + std::unique_ptr exception_; // Built gradually - used in an exception at the end of validation. Glib::ustring validate_error_; Glib::ustring validate_warning_; diff --git a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc index 5e342339..136bfb76 100644 --- a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc +++ b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc @@ -15,13 +15,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include + #include #include #include #include -#include - class MySaxParser : public xmlpp::SaxParser { protected: @@ -48,7 +49,11 @@ int main() parser.parse_chunk(" +#include + #include #include #include -#include - - class OnCdataBlockTestParser : public xmlpp::SaxParser { protected: @@ -40,7 +40,11 @@ void test_on_cdata_block() { parser.parse_memory(""); } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) +#else + catch(const xmlpp::exception& e) +#endif { exceptionThrown = true; g_assert_cmpstr(e.what(), ==, "on_cdata_block runtime exception"); @@ -67,7 +71,11 @@ void test_on_characters() { parser.parse_memory("abc"); } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) +#else + catch(const xmlpp::exception& e) +#endif { exceptionThrown = true; g_assert_cmpstr(e.what(), ==, "on_characters runtime exception"); @@ -94,7 +102,11 @@ void test_on_comment() { parser.parse_memory(""); } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) +#else + catch(const xmlpp::exception& e) +#endif { exceptionThrown = true; g_assert_cmpstr(e.what(), ==, "on_comment runtime exception"); @@ -120,7 +132,11 @@ void test_on_end_document() { parser.parse_memory(""); } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) +#else + catch(const xmlpp::exception& e) +#endif { exceptionThrown = true; g_assert_cmpstr(e.what(), ==, "on_end_document runtime exception"); @@ -147,7 +163,11 @@ void test_on_end_element() { parser.parse_memory(""); } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) +#else + catch(const xmlpp::exception& e) +#endif { exceptionThrown = true; g_assert_cmpstr(e.what(), ==, "on_end_element runtime exception"); @@ -177,7 +197,11 @@ void test_on_entity_declaration() { parser.parse_memory("]>"); } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) +#else + catch(const xmlpp::exception& e) +#endif { exceptionThrown = true; g_assert_cmpstr(e.what(), ==, "on_entity_declaration runtime exception"); @@ -203,7 +227,11 @@ void test_on_error() { parser.parse_memory("&unknown;"); } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) +#else + catch(const xmlpp::exception& e) +#endif { exceptionThrown = true; g_assert_cmpstr(e.what(), ==, "on_error runtime exception"); @@ -235,7 +263,11 @@ void test_on_get_entity() { parser.parse_memory("]>&number;"); } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) +#else + catch(const xmlpp::exception& e) +#endif { exceptionThrown = true; g_assert_cmpstr(e.what(), ==, "on_get_entity runtime exception"); @@ -261,7 +293,11 @@ void test_on_start_document() { parser.parse_memory(""); } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) +#else + catch(const xmlpp::exception& e) +#endif { exceptionThrown = true; g_assert_cmpstr(e.what(), ==, "on_start_document runtime exception"); @@ -289,7 +325,11 @@ void test_on_start_element() { parser.parse_memory(""); } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) +#else + catch(const xmlpp::exception& e) +#endif { exceptionThrown = true; g_assert_cmpstr(e.what(), ==, "on_start_element runtime exception"); diff --git a/tests/saxparser_parse_stream_inconsistent_state/main.cc b/tests/saxparser_parse_stream_inconsistent_state/main.cc index ea8cf443..4fd13200 100644 --- a/tests/saxparser_parse_stream_inconsistent_state/main.cc +++ b/tests/saxparser_parse_stream_inconsistent_state/main.cc @@ -15,13 +15,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include +#include + #include #include #include #include -#include - class MySaxParser : public xmlpp::SaxParser { protected: @@ -44,7 +45,11 @@ int main() std::stringstream ss(""); parser.parse_stream(ss); } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) +#else + catch(const xmlpp::exception& e) +#endif { exceptionThrown = true; g_assert_cmpstr(e.what(), ==, "some custom runtime exception"); @@ -64,7 +69,11 @@ int main() // error should not have been thrown. g_assert_not_reached(); } +#ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) +#else + catch(const xmlpp::exception& e) +#endif { exceptionThrown = true; g_assert_cmpstr(e.what(), ==, "some custom runtime exception"); From d9e759163ed46f572b1e64e3726ec793e450532f Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 30 Oct 2015 10:53:14 +0100 Subject: [PATCH 036/240] 2.91.2 --- NEWS | 15 +++++++++++++++ configure.ac | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 55a0f3dc..fc6d7b12 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,18 @@ +2.91.2 (unstable): + +* Remove the preprocessor constant LIBXMLCPP_EXCEPTIONS_ENABLED. + It was always 1. + +* Add a config-time test for support of std::exception_ptr. Don't try to + use std::exception_ptr on a system where it does not exist. + This includes re-implementing the wrapped_exception class and the + raise() and clone() methods in xmlpp::exception and its subclasses. + (Daniel Trebbien, Kjell Ahlstedt) Bug #757042 (Michael Biebl) + +* The ABI is not identical to that of libxml++ 2.91.1. + There may be more changes in ABI and/or API before the first stable + libxml++-3.0 release. + 2.91.1 (unstable): * Renamed ABI from libxml++-2.6 to libxml++-3.0. diff --git a/configure.ac b/configure.ac index 0b1a589f..561949ad 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [2.91.1], +AC_INIT([libxml++], [2.91.2], [https://bugzilla.gnome.org/enter_bug.cgi?product=libxml%2B%2B], [libxml++], [http://libxmlplusplus.sourceforge.net/]) AC_PREREQ([2.59]) From 8f81e383bd7d7cbe3f8318bf2a65f05ce5f4b91e Mon Sep 17 00:00:00 2001 From: Renu Tyagi Date: Thu, 5 Nov 2015 10:22:29 +0100 Subject: [PATCH 037/240] Element: Remove redundant null check Bug #757515 --- libxml++/nodes/element.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc index 3cc36979..c03dee6f 100644 --- a/libxml++/nodes/element.cc +++ b/libxml++/nodes/element.cc @@ -384,12 +384,9 @@ Glib::ustring Element::get_namespace_uri_for_prefix(const Glib::ustring& ns_pref //Find the namespace: const auto ns = xmlSearchNs( cobj()->doc, const_cast(cobj()), (xmlChar*)ns_prefix.c_str() ); - if(ns) - { - //Get the namespace URI associated with this prefix: - if(ns && ns->href) - result = (const char*)ns->href; - } + //Get the namespace URI associated with this prefix: + if (ns && ns->href) + result = (const char*)ns->href; return result; } From 9d16fdc48338a527ddc47d33ead44f2bdb55de6b Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 5 Nov 2015 12:44:03 +0100 Subject: [PATCH 038/240] Remove trailing blanks --- examples/dom_build/main.cc | 6 +++--- examples/dom_parse_entities/main.cc | 6 +++--- examples/dom_parser/main.cc | 10 +++++----- examples/dom_parser_raw/main.cc | 8 +++----- examples/dom_xinclude/main.cc | 2 +- examples/import_node/example2.xml | 2 +- examples/import_node/main.cc | 10 +++++----- examples/sax_exception/main.cc | 4 +--- examples/sax_parser/main.cc | 7 ++----- examples/sax_parser_build_dom/main.cc | 4 ++-- examples/sax_parser_build_dom/svgdocument.h | 4 ++-- examples/sax_parser_build_dom/svgelement.cc | 8 +++----- examples/sax_parser_build_dom/svgelement.h | 10 ++++------ examples/sax_parser_build_dom/svggroup.h | 6 ++---- examples/sax_parser_build_dom/svgparser.cc | 6 +++--- examples/sax_parser_build_dom/svgparser.h | 6 ++---- examples/sax_parser_build_dom/svgpath.h | 8 +++----- examples/sax_parser_entities/main.cc | 4 +--- examples/sax_parser_entities/myparser.cc | 6 +----- libxml++/attribute.h | 2 +- libxml++/document.cc | 12 +++++------ libxml++/document.h | 4 ++-- libxml++/dtd.cc | 2 +- libxml++/dtd.h | 2 +- libxml++/exceptions/exception.cc | 2 +- libxml++/exceptions/internal_error.h | 2 +- libxml++/exceptions/parse_error.h | 2 +- libxml++/io/ostreamoutputbuffer.cc | 2 +- libxml++/keepblanks.cc | 2 +- libxml++/nodes/cdatanode.cc | 2 +- libxml++/nodes/contentnode.cc | 4 ++-- libxml++/nodes/element.cc | 10 +++++----- libxml++/nodes/entityreference.cc | 4 ++-- libxml++/nodes/node.cc | 12 +++++------ libxml++/nodes/node.h | 22 ++++++++++----------- libxml++/nodes/processinginstructionnode.cc | 3 +-- libxml++/nodes/textnode.cc | 2 +- libxml++/parsers/domparser.cc | 2 +- libxml++/parsers/domparser.h | 10 +++++----- libxml++/parsers/parser.cc | 8 ++++---- libxml++/parsers/parser.h | 2 +- libxml++/parsers/saxparser.cc | 10 +++++----- libxml++/parsers/saxparser.h | 14 ++++++------- libxml++/parsers/textreader.cc | 20 +++++++++---------- libxml++/relaxngschema.cc | 4 ++-- libxml++/validators/validator.cc | 2 +- libxml++/xsdschema.cc | 4 ++-- 47 files changed, 130 insertions(+), 154 deletions(-) diff --git a/examples/dom_build/main.cc b/examples/dom_build/main.cc index 3674b0ee..568d9445 100644 --- a/examples/dom_build/main.cc +++ b/examples/dom_build/main.cc @@ -43,14 +43,14 @@ main(int /* argc */, char** /* argv */) //foo is the default namespace prefix. auto nodeRoot = document.create_root_node("exampleroot", "http://foo", "foo"); //Declares the namespace and uses its prefix for this node - nodeRoot->set_namespace_declaration("http://foobar", "foobar"); //Also associate this prefix with this namespace: + nodeRoot->set_namespace_declaration("http://foobar", "foobar"); //Also associate this prefix with this namespace: nodeRoot->set_first_child_text("\n"); auto nodeChild = nodeRoot->add_child_element("examplechild"); //Associate prefix with namespace: - nodeChild->set_namespace_declaration("http://bar", "bar"); - + nodeChild->set_namespace_declaration("http://bar", "bar"); + nodeChild->set_namespace("bar"); //So it will be bar::examplechild. nodeChild->set_attribute("id", "1", "foo"); //foo is the namespace prefix. You could also just use a name of foo:id". nodeChild->set_first_child_text("\nSome content\n"); diff --git a/examples/dom_parse_entities/main.cc b/examples/dom_parse_entities/main.cc index 1b220243..d7a38700 100644 --- a/examples/dom_parse_entities/main.cc +++ b/examples/dom_parse_entities/main.cc @@ -28,7 +28,7 @@ #include void print_node(const xmlpp::Node* node, bool substitute_entities, unsigned int indentation = 0) -{ +{ const Glib::ustring indent(indentation, ' '); std::cout << std::endl; //Separate nodes by an empty line. @@ -58,7 +58,7 @@ void print_node(const xmlpp::Node* node, bool substitute_entities, unsigned int { //Recurse through child nodes: for(const auto& child : node->get_children()) - { + { print_node(child, substitute_entities, indentation + 2); //recursive } } @@ -75,7 +75,7 @@ int main(int argc, char* argv[]) filepath = argv[1]; //Allow the user to specify a different XML file to parse. else filepath = "example.xml"; - + // Parse first without, then with, entity substitution. int return_code = EXIT_SUCCESS; bool substitute_entities = false; diff --git a/examples/dom_parser/main.cc b/examples/dom_parser/main.cc index 26b46d81..389a7ecd 100644 --- a/examples/dom_parser/main.cc +++ b/examples/dom_parser/main.cc @@ -30,14 +30,14 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) { const Glib::ustring indent(indentation, ' '); std::cout << std::endl; //Separate nodes by an empty line. - + const auto nodeContent = dynamic_cast(node); const auto nodeText = dynamic_cast(node); const auto nodeComment = dynamic_cast(node); if(nodeText && nodeText->is_white_space()) //Let's ignore the indenting - you don't always want to do this. return; - + const auto nodename = node->get_name(); if(!nodeText && !nodeComment && !nodename.empty()) //Let's not say "name: text". @@ -54,7 +54,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) std::cout << indent << "Text Node" << std::endl; } - //Treat the various node types differently: + //Treat the various node types differently: if(nodeText) { std::cout << indent << "text = \"" << CatchConvertError(nodeText->get_content()) << "\"" << std::endl; @@ -97,7 +97,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) std::cout << "title = " << CatchConvertError(attribute->get_value()) << std::endl; } } - + if(!nodeContent) { //Recurse through child nodes: @@ -158,7 +158,7 @@ int main(int argc, char* argv[]) filepath = argv[argi]; //Allow the user to specify a different XML file to parse. else filepath = "example.xml"; - + try { xmlpp::DomParser parser; diff --git a/examples/dom_parser_raw/main.cc b/examples/dom_parser_raw/main.cc index 5051784c..496bb30f 100644 --- a/examples/dom_parser_raw/main.cc +++ b/examples/dom_parser_raw/main.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* main.cc * * Copyright (C) 2002 The libxml++ development team @@ -29,7 +27,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) { std::cout << std::endl; //Separate nodes by an empty line. - + std::cout << "Node name = " << node->get_name() << std::endl; //Recurse through child nodes: @@ -68,13 +66,13 @@ int main(int argc, char* argv[]) filepath = argv[1]; //Allow the user to specify a different XML file to parse. else filepath = "example.xml"; - + try { xmlpp::DomParser parser; parser.set_validate(); parser.set_substitute_entities(); //We just want the text to be resolved/unescaped automatically. - + auto contents = read_from_disk(filepath); std::string contents_ucs2; diff --git a/examples/dom_xinclude/main.cc b/examples/dom_xinclude/main.cc index 71e538c4..fe63c4d2 100644 --- a/examples/dom_xinclude/main.cc +++ b/examples/dom_xinclude/main.cc @@ -156,7 +156,7 @@ int main(int argc, char* argv[]) filepath = argv[argi]; //Allow the user to specify a different XML file to parse. else filepath = "example.xml"; - + try { xmlpp::DomParser parser; diff --git a/examples/import_node/example2.xml b/examples/import_node/example2.xml index adf538b5..b55c0685 100644 --- a/examples/import_node/example2.xml +++ b/examples/import_node/example2.xml @@ -1,6 +1,6 @@ added content from other document -grand child content +grand child content diff --git a/examples/import_node/main.cc b/examples/import_node/main.cc index edcbaa06..726d2ec0 100644 --- a/examples/import_node/main.cc +++ b/examples/import_node/main.cc @@ -14,13 +14,13 @@ int main (int /* argc */, char** /* argv */) std::locale::global(std::locale("")); try - { + { DomParser example1("example1.xml"); DomParser example2("example2.xml"); - + auto doc1 = example1.get_document(); auto doc2 = example2.get_document(); - + auto root1 = doc1->get_root_node(); auto root2 = doc2->get_root_node(); @@ -34,11 +34,11 @@ int main (int /* argc */, char** /* argv */) // Import an attribute that will replace an existing attribute in the root element. auto attribute_to_add = root2->get_attribute("name"); root1->import_node(attribute_to_add); - + // Import an attribute that will be added to the root element. attribute_to_add = root2->get_attribute("type"); root1->import_node(attribute_to_add); - + // Find the first text child of the first "child" element in example2. auto first_child2 = dynamic_cast(child_list2.front()); if (!first_child2) diff --git a/examples/sax_exception/main.cc b/examples/sax_exception/main.cc index f5b2c579..ac4ed551 100644 --- a/examples/sax_exception/main.cc +++ b/examples/sax_exception/main.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* main.cc * * Copyright (C) 2002 The libxml++ development team @@ -38,7 +36,7 @@ int main(int /* argc */, char** /* argv */) std::locale::global(std::locale("")); MySaxParser parser; - + try { parser.parse_file("example.xml"); diff --git a/examples/sax_parser/main.cc b/examples/sax_parser/main.cc index b786780f..be405a5f 100644 --- a/examples/sax_parser/main.cc +++ b/examples/sax_parser/main.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* main.cc * * Copyright (C) 2002 The libxml++ development team @@ -42,7 +40,7 @@ main(int argc, char* argv[]) filepath = argv[1]; //Allow the user to specify a different XML file to parse. else filepath = "example.xml"; - + // Parse the entire document in one go: auto return_code = EXIT_SUCCESS; try @@ -61,7 +59,7 @@ main(int argc, char* argv[]) try { std::cout << std::endl << "Incremental SAX Parser:" << std::endl; - + std::ifstream is(filepath.c_str()); if (!is) throw xmlpp::exception("Could not open file " + filepath); @@ -97,4 +95,3 @@ main(int argc, char* argv[]) return return_code; } - diff --git a/examples/sax_parser_build_dom/main.cc b/examples/sax_parser_build_dom/main.cc index 132b51d5..613d85f1 100644 --- a/examples/sax_parser_build_dom/main.cc +++ b/examples/sax_parser_build_dom/main.cc @@ -1,6 +1,6 @@ /* main.cc * - * By Dan Dennedy + * By Dan Dennedy * * Copyright (C) 2003 The libxml++ development team * @@ -72,6 +72,6 @@ main(int argc, char* argv[]) std::cerr << "libxml++ exception: " << ex.what() << std::endl; return EXIT_FAILURE; } - + return EXIT_SUCCESS; } diff --git a/examples/sax_parser_build_dom/svgdocument.h b/examples/sax_parser_build_dom/svgdocument.h index 6261b6ad..9c343919 100644 --- a/examples/sax_parser_build_dom/svgdocument.h +++ b/examples/sax_parser_build_dom/svgdocument.h @@ -1,9 +1,9 @@ /* svgdocument.h * - * By Dan Dennedy + * By Dan Dennedy * * Copyright (C) 2003 The libxml++ development team - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either diff --git a/examples/sax_parser_build_dom/svgelement.cc b/examples/sax_parser_build_dom/svgelement.cc index d2e07ee3..8a39ced3 100644 --- a/examples/sax_parser_build_dom/svgelement.cc +++ b/examples/sax_parser_build_dom/svgelement.cc @@ -1,8 +1,6 @@ -// -*- C++ -*- - /* svgelement.cc * - * By Dan Dennedy + * By Dan Dennedy * * Copyright (C) 2003 The libxml++ development team * @@ -28,7 +26,7 @@ namespace SVG { Element::Element(xmlNode* node) : xmlpp::Element(node) {} - + Element::~Element() {} @@ -37,7 +35,7 @@ void Element::set_style(const Glib::ustring& style) { set_attribute("style", style); } - + const Glib::ustring Element::get_style() const { return get_attribute("style")->get_value(); diff --git a/examples/sax_parser_build_dom/svgelement.h b/examples/sax_parser_build_dom/svgelement.h index 1ea8ce1c..0440b144 100644 --- a/examples/sax_parser_build_dom/svgelement.h +++ b/examples/sax_parser_build_dom/svgelement.h @@ -1,11 +1,9 @@ -// -*- C++ -*- - /* svgelement.h * - * By Dan Dennedy + * By Dan Dennedy * * Copyright (C) 2003 The libxml++ development team - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either @@ -40,8 +38,8 @@ class Element : public xmlpp::Element // example custom methods void set_style(const Glib::ustring& style); const Glib::ustring get_style() const; - - // TODO: add custom methods + + // TODO: add custom methods private: // TODO: add custom properties diff --git a/examples/sax_parser_build_dom/svggroup.h b/examples/sax_parser_build_dom/svggroup.h index dd288e16..e0c6de89 100644 --- a/examples/sax_parser_build_dom/svggroup.h +++ b/examples/sax_parser_build_dom/svggroup.h @@ -1,11 +1,9 @@ -// -*- C++ -*- - /* svggroup.h * - * By Dan Dennedy + * By Dan Dennedy * * Copyright (C) 2003 The libxml++ development team - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either diff --git a/examples/sax_parser_build_dom/svgparser.cc b/examples/sax_parser_build_dom/svgparser.cc index b90592ee..73980022 100644 --- a/examples/sax_parser_build_dom/svgparser.cc +++ b/examples/sax_parser_build_dom/svgparser.cc @@ -1,6 +1,6 @@ /* svgparser.cc * - * By Dan Dennedy + * By Dan Dennedy * * Copyright (C) 2003 The libxml++ development team * @@ -46,11 +46,11 @@ void Parser::on_start_element(const Glib::ustring& name, //with an instance of a derived node. //This is not a recommended technique, and might not //work with future versions of libxml++. - + // Parse namespace prefix and save for later: Glib::ustring elementPrefix; Glib::ustring elementName = name; - Glib::ustring::size_type idx = name.find(':'); + Glib::ustring::size_type idx = name.find(':'); if (idx != Glib::ustring::npos) //If the separator was found { elementPrefix = name.substr(0, idx); diff --git a/examples/sax_parser_build_dom/svgparser.h b/examples/sax_parser_build_dom/svgparser.h index b7d99fcf..201de741 100644 --- a/examples/sax_parser_build_dom/svgparser.h +++ b/examples/sax_parser_build_dom/svgparser.h @@ -1,11 +1,9 @@ -// -*- C++ -*- - /* svgparser.h * - * By Dan Dennedy + * By Dan Dennedy * * Copyright (C) 2003 The libxml++ development team - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either diff --git a/examples/sax_parser_build_dom/svgpath.h b/examples/sax_parser_build_dom/svgpath.h index 990546be..854e13c9 100644 --- a/examples/sax_parser_build_dom/svgpath.h +++ b/examples/sax_parser_build_dom/svgpath.h @@ -1,11 +1,9 @@ -// -*- C++ -*- - /* svgpath.h * - * By Dan Dennedy + * By Dan Dennedy * * Copyright (C) 2003 The libxml++ development team - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either @@ -36,7 +34,7 @@ class Path : public Element Path(xmlNode* node) : Element(node) {} - + const Glib::ustring get_data() const { return get_attribute("d")->get_value(); diff --git a/examples/sax_parser_entities/main.cc b/examples/sax_parser_entities/main.cc index 1466c8db..fd19391d 100644 --- a/examples/sax_parser_entities/main.cc +++ b/examples/sax_parser_entities/main.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* main.cc * * Copyright (C) 2002 The libxml++ development team @@ -53,7 +51,7 @@ main(int argc, char* argv[]) std::cerr << "libxml++ exception: " << ex.what() << std::endl; return EXIT_FAILURE; } - + return EXIT_SUCCESS; } diff --git a/examples/sax_parser_entities/myparser.cc b/examples/sax_parser_entities/myparser.cc index c891fcf1..4ea7145f 100644 --- a/examples/sax_parser_entities/myparser.cc +++ b/examples/sax_parser_entities/myparser.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* myparser.cc * * Copyright (C) 2002 The libxml++ development team @@ -87,7 +85,7 @@ void MySaxParser::on_fatal_error(const Glib::ustring& text) _xmlEntity* MySaxParser::on_get_entity(const Glib::ustring& name) { std::cout << "on_get_entity(): " << name << std::endl; - + //Call the base class: return SaxParser::on_get_entity(name); } @@ -99,5 +97,3 @@ void MySaxParser::on_entity_declaration(const Glib::ustring& name, xmlpp::XmlEnt //Call the base class: SaxParser::on_entity_declaration(name, type, publicId, systemId, content); } - - diff --git a/libxml++/attribute.h b/libxml++/attribute.h index 8458f22e..8ac9155f 100644 --- a/libxml++/attribute.h +++ b/libxml++/attribute.h @@ -23,7 +23,7 @@ class Attribute : public Node public: explicit Attribute(_xmlNode* node); ~Attribute() override; - + /** Get the value of this attribute. * @returns The attribute's value. */ diff --git a/libxml++/document.cc b/libxml++/document.cc index c6e43393..d441b1d1 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -31,7 +31,7 @@ void find_wrappers(xmlNode* node, NodeMap& node_map) { if (!node) return; - + //If an entity declaration contains an entity reference, there can be cyclic //references between entity declarations and entity references. (It's not //a tree.) We must avoid an infinite recursion. @@ -69,9 +69,9 @@ void find_wrappers(xmlNode* node, NodeMap& node_map) return; //Walk the attributes list. - //Note that some "derived" structs have a different layout, so + //Note that some "derived" structs have a different layout, so //_xmlNode::properties would be a nonsense value, leading to crashes - //(and shown as valgrind warnings), so we return above, to avoid + //(and shown as valgrind warnings), so we return above, to avoid //checking it here. for (auto attr = node->properties; attr; attr = attr->next) find_wrappers(reinterpret_cast(attr), node_map); @@ -83,7 +83,7 @@ void remove_found_wrappers(xmlNode* node, NodeMap& node_map) { if (!node) return; - + if (node->type != XML_ENTITY_REF_NODE) { // Walk the children list. @@ -293,7 +293,7 @@ Element* Document::create_root_node_by_import(const Node* node, CommentNode* Document::add_comment(const Glib::ustring& content) { auto child = xmlNewComment((const xmlChar*)content.c_str()); - + // Use the result, because child can be freed when merging text nodes: auto node = xmlAddChild((xmlNode*)impl_, child); if (!node) @@ -404,7 +404,7 @@ void Document::do_write_to_stream(std::ostream& output, const Glib::ustring& enc xmlResetLastError(); const int result = xmlSaveFormatFileTo(buffer.cobj(), impl_, get_encoding_or_utf8(encoding), format ? 1 : 0); - + if(result == -1) { throw exception("do_write_to_stream() failed.\n" + format_xml_error()); diff --git a/libxml++/document.h b/libxml++/document.h index ea81b3f3..23b9d8d8 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -76,14 +76,14 @@ class Document : public NonCopyable * @throws xmlpp::internal_error If memory allocation fails. */ explicit Document(const Glib::ustring& version = "1.0"); - + /** Create a new C++ wrapper for an xmlDoc struct. * The created xmlpp::Document takes ownership of the xmlDoc. * When the Document is deleted, so is the xmlDoc and all its nodes. * @param doc A pointer to an xmlDoc struct. Must not be nullptr. */ explicit Document(_xmlDoc* doc); - + ~Document() override; /** @return The encoding used in the source from which the document has been loaded. diff --git a/libxml++/dtd.cc b/libxml++/dtd.cc index ff2663e2..8a6d6012 100644 --- a/libxml++/dtd.cc +++ b/libxml++/dtd.cc @@ -12,7 +12,7 @@ namespace xmlpp { - + struct Dtd::Impl { Impl() : dtd(nullptr), is_dtd_owner(false) {} diff --git a/libxml++/dtd.h b/libxml++/dtd.h index 16e50cfa..d3f9030a 100644 --- a/libxml++/dtd.h +++ b/libxml++/dtd.h @@ -114,7 +114,7 @@ class Dtd : public NonCopyable Glib::ustring get_name() const; Glib::ustring get_external_id() const; Glib::ustring get_system_id() const; - + /** Access the underlying libxml implementation. */ _xmlDtd* cobj(); diff --git a/libxml++/exceptions/exception.cc b/libxml++/exceptions/exception.cc index e7fbf513..99fcfc79 100644 --- a/libxml++/exceptions/exception.cc +++ b/libxml++/exceptions/exception.cc @@ -5,7 +5,7 @@ #include namespace xmlpp { - + exception::exception(const Glib::ustring& message) : message_(message) { diff --git a/libxml++/exceptions/internal_error.h b/libxml++/exceptions/internal_error.h index 07912cbb..d60b0547 100644 --- a/libxml++/exceptions/internal_error.h +++ b/libxml++/exceptions/internal_error.h @@ -23,7 +23,7 @@ #include namespace xmlpp { - + class internal_error : public exception { public: diff --git a/libxml++/exceptions/parse_error.h b/libxml++/exceptions/parse_error.h index 724f9315..1abb0916 100644 --- a/libxml++/exceptions/parse_error.h +++ b/libxml++/exceptions/parse_error.h @@ -26,7 +26,7 @@ namespace xmlpp { /** This exception will be thrown when the parser encounters an error in the XML document. - */ + */ class parse_error : public exception { public: diff --git a/libxml++/io/ostreamoutputbuffer.cc b/libxml++/io/ostreamoutputbuffer.cc index b23a8b61..f8b7a7f0 100644 --- a/libxml++/io/ostreamoutputbuffer.cc +++ b/libxml++/io/ostreamoutputbuffer.cc @@ -21,7 +21,7 @@ namespace xmlpp OStreamOutputBuffer::~OStreamOutputBuffer() { } - + bool OStreamOutputBuffer::do_write( const char * buffer, int len) diff --git a/libxml++/keepblanks.cc b/libxml++/keepblanks.cc index a91f2a6a..b49b3cfb 100644 --- a/libxml++/keepblanks.cc +++ b/libxml++/keepblanks.cc @@ -15,7 +15,7 @@ namespace xmlpp #if _MSC_VER == 1200 // detect MSVC 6.0 const bool KeepBlanks::Default = true; #endif - + KeepBlanks::KeepBlanks(bool value) { oldIndentTreeOutput_ = xmlIndentTreeOutput; diff --git a/libxml++/nodes/cdatanode.cc b/libxml++/nodes/cdatanode.cc index 167d5af8..12a0e846 100644 --- a/libxml++/nodes/cdatanode.cc +++ b/libxml++/nodes/cdatanode.cc @@ -10,7 +10,7 @@ namespace xmlpp { - + CdataNode::CdataNode(xmlNode* node) : ContentNode(node) {} diff --git a/libxml++/nodes/contentnode.cc b/libxml++/nodes/contentnode.cc index 7153c3c0..7a0ff57e 100644 --- a/libxml++/nodes/contentnode.cc +++ b/libxml++/nodes/contentnode.cc @@ -11,7 +11,7 @@ namespace xmlpp { - + ContentNode::ContentNode(xmlNode* node) : Node(node) {} @@ -34,7 +34,7 @@ void ContentNode::set_content(const Glib::ustring& content) if(cobj()->type == XML_ELEMENT_NODE) { throw internal_error("can't set content for this node type"); - } + } xmlNodeSetContent(cobj(), (xmlChar*)content.c_str()); } diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc index c03dee6f..d3d3dd81 100644 --- a/libxml++/nodes/element.cc +++ b/libxml++/nodes/element.cc @@ -151,7 +151,7 @@ Element* Element::add_child_element(const Glib::ustring& name, return add_child_element_common(name, child, node); } -Element* Element::add_child_element(xmlpp::Node* previous_sibling, +Element* Element::add_child_element(xmlpp::Node* previous_sibling, const Glib::ustring& name, const Glib::ustring& ns_prefix) { if (!previous_sibling) @@ -162,7 +162,7 @@ Element* Element::add_child_element(xmlpp::Node* previous_sibling, return add_child_element_common(name, child, node); } -Element* Element::add_child_element_before(xmlpp::Node* next_sibling, +Element* Element::add_child_element_before(xmlpp::Node* next_sibling, const Glib::ustring& name, const Glib::ustring& ns_prefix) { if (!next_sibling) @@ -381,20 +381,20 @@ void Element::set_namespace_declaration(const Glib::ustring& ns_uri, const Glib: Glib::ustring Element::get_namespace_uri_for_prefix(const Glib::ustring& ns_prefix) const { Glib::ustring result; - + //Find the namespace: const auto ns = xmlSearchNs( cobj()->doc, const_cast(cobj()), (xmlChar*)ns_prefix.c_str() ); //Get the namespace URI associated with this prefix: if (ns && ns->href) result = (const char*)ns->href; - + return result; } CommentNode* Element::add_child_comment(const Glib::ustring& content) { auto child = xmlNewComment((const xmlChar*)content.c_str()); - + // Use the result, because child can be freed when merging text nodes: auto node = xmlAddChild(cobj(), child); if (!node) diff --git a/libxml++/nodes/entityreference.cc b/libxml++/nodes/entityreference.cc index 3c35405b..3f83c013 100644 --- a/libxml++/nodes/entityreference.cc +++ b/libxml++/nodes/entityreference.cc @@ -10,7 +10,7 @@ namespace xmlpp { - + EntityReference::EntityReference(xmlNode* node) : Node(node) {} @@ -31,7 +31,7 @@ Glib::ustring EntityReference::get_resolved_text() const if(pch) result = (const char*)pch; } - + return result; } diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index 71eab857..46d202e3 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -111,9 +111,9 @@ Tvector find_common(const Glib::ustring& xpath, std::cerr << "Node::find(): Ignoring an xmlNs object." << std::endl; continue; } - + //TODO: Check for other cnode->type values? - + nodes.push_back(_convert_node(cnode)); } } @@ -284,7 +284,7 @@ Node* Node::get_first_child(const Glib::ustring& name) return _convert_node(child); } while((child = child->next)); - + return nullptr; } @@ -610,7 +610,7 @@ void Node::free_wrappers(xmlNode* node) { if(!node) return; - + //If an entity declaration contains an entity reference, there can be cyclic //references between entity declarations and entity references. (It's not //a tree.) We must avoid an infinite recursion. @@ -648,9 +648,9 @@ void Node::free_wrappers(xmlNode* node) } //Walk the attributes list. - //Note that some "derived" struct have a different layout, so + //Note that some "derived" struct have a different layout, so //_xmlNode::properties would be a nonsense value, leading to crashes, - //(and shown as valgrind warnings), so we return above, to avoid + //(and shown as valgrind warnings), so we return above, to avoid //checking it here. for(auto attr = node->properties; attr; attr = attr->next) free_wrappers(reinterpret_cast(attr)); diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index 577505d2..8e56348f 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -98,36 +98,36 @@ class Node : public NonCopyable * @returns The line number. */ int get_line() const; - + /** Get the parent element for this node. * @returns The parent node, or nullptr if the node has no parent element. */ - const Element* get_parent() const; + const Element* get_parent() const; /** Get the parent element for this node. * @returns The parent node, or nullptr if the node has no parent element. */ - Element* get_parent(); + Element* get_parent(); /** Get the next sibling for this node. * @returns The next sibling, or nullptr if the node has no next sibling. */ - const Node* get_next_sibling() const; + const Node* get_next_sibling() const; /** Get the next sibling for this node. * @returns The next sibling, or nullptr if the node has no next sibling. */ - Node* get_next_sibling(); + Node* get_next_sibling(); /** Get the previous sibling for this node . * @returns The previous sibling, or nullptr if the node has no previous sibling. */ - const Node* get_previous_sibling() const; + const Node* get_previous_sibling() const; /** Get the previous sibling for this node. * @returns The previous sibling, or nullptr if the node has no previous sibling. */ - Node* get_previous_sibling(); + Node* get_previous_sibling(); /** Get the first child of this node. * You may optionally get the first child node which has a certain name. @@ -186,7 +186,7 @@ class Node : public NonCopyable */ Node* import_node(const Node* node, bool recursive = true); - + /** Get the XPath of this node. * @result The XPath of the node. */ @@ -328,15 +328,15 @@ class Node : public NonCopyable * @param node A pointer to an xmlNode or a "derived" struct, such as xmlDoc, xmlAttr, etc. */ static void create_wrapper(_xmlNode* node); - - /** Delete the C++ instance for a given libxml C struct instance, and also + + /** Delete the C++ instance for a given libxml C struct instance, and also * recursively destroy the C++ instances for any children. * * This is only for use by the libxml++ implementation. * @param node A pointer to an xmlNode or a "derived" struct, such as xmlDoc, xmlAttr, etc. */ static void free_wrappers(_xmlNode* node); - + private: _xmlNode* impl_; }; diff --git a/libxml++/nodes/processinginstructionnode.cc b/libxml++/nodes/processinginstructionnode.cc index 9c3d394a..8c033bb6 100644 --- a/libxml++/nodes/processinginstructionnode.cc +++ b/libxml++/nodes/processinginstructionnode.cc @@ -10,7 +10,7 @@ namespace xmlpp { - + ProcessingInstructionNode::ProcessingInstructionNode(xmlNode* node) : ContentNode(node) {} @@ -19,4 +19,3 @@ ProcessingInstructionNode::~ProcessingInstructionNode() {} } //namespace xmlpp - diff --git a/libxml++/nodes/textnode.cc b/libxml++/nodes/textnode.cc index d76a0626..f686fb23 100644 --- a/libxml++/nodes/textnode.cc +++ b/libxml++/nodes/textnode.cc @@ -10,7 +10,7 @@ namespace xmlpp { - + TextNode::TextNode(xmlNode* node) : ContentNode(node) {} diff --git a/libxml++/parsers/domparser.cc b/libxml++/parsers/domparser.cc index 8ca3e7f1..329bae53 100644 --- a/libxml++/parsers/domparser.cc +++ b/libxml++/parsers/domparser.cc @@ -34,7 +34,7 @@ DomParser::DomParser(const std::string& filename, bool validate) } DomParser::~DomParser() -{ +{ release_underlying(); } diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index 63010ccf..a608739b 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -25,7 +25,7 @@ class DomParser : public Parser /** Instantiate the parser and parse a document immediately. * @param filename The path to the file. - * @param validate Whether the parser should validate the XML. + * @param validate Whether the parser should validate the XML. * @throws xmlpp::internal_error * @throws xmlpp::parse_error * @throws xmlpp::validity_error @@ -52,7 +52,7 @@ class DomParser : public Parser * @throws xmlpp::validity_error */ void parse_memory(const Glib::ustring& contents) override; - + /** Parse an XML document from raw memory. * If the parser already contains a document, that document and all its nodes * are deleted. @@ -77,7 +77,7 @@ class DomParser : public Parser /** Test whether a document has been parsed. */ operator bool() const; - + /** Get the parsed document. * @returns A pointer to the parsed document, or nullptr. */ @@ -87,12 +87,12 @@ class DomParser : public Parser * @returns A pointer to the parsed document, or nullptr. */ const Document* get_document() const; - + protected: void parse_context(); void release_underlying() override; - + Document* doc_; }; diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc index 503987a4..d4ecdc64 100644 --- a/libxml++/parsers/parser.cc +++ b/libxml++/parsers/parser.cc @@ -158,7 +158,7 @@ void Parser::release_underlying() if(context_) { context_->_private = nullptr; //Not really necessary. - + if( context_->myDoc != nullptr ) { xmlFreeDoc(context_->myDoc); @@ -231,7 +231,7 @@ void Parser::check_for_error_and_warning_messages() else if (parser_msg) exception_.reset(new parse_error(msg)); } - + //static void Parser::callback_parser_error(void* ctx, const char* msg, ...) { @@ -273,7 +273,7 @@ void Parser::callback_error_or_warning(MsgType msg_type, void* ctx, const char* msg, va_list var_args) { //See xmlHTMLValidityError() in xmllint.c in libxml for more about this: - + auto context = (xmlParserCtxtPtr)ctx; if(context) { @@ -354,7 +354,7 @@ void Parser::handle_exception() void Parser::check_for_exception() { check_for_error_and_warning_messages(); - + if (exception_) { std::unique_ptr tmp(std::move(exception_)); diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index 71e65a27..a101d600 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -150,7 +150,7 @@ class Parser : public NonCopyable * @param bytes_count The number of bytes in the @a contents array. */ virtual void parse_memory_raw(const unsigned char* contents, size_type bytes_count) = 0; - + /** Parse an XML document from a string. * @throw exception * @param contents The XML document as a string. diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index 473f90d6..4ce408be 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -94,7 +94,7 @@ xmlEntityPtr SaxParser::on_get_entity(const Glib::ustring& name) void SaxParser::on_entity_declaration(const Glib::ustring& name, XmlEntityType type, const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content) { entity_resolver_doc_->set_entity_declaration(name, type, publicId, systemId, content); -} +} void SaxParser::on_start_document() { @@ -159,7 +159,7 @@ void SaxParser::parse() xmlResetLastError(); initialize_context(); - + const int parseError = xmlParseDocument(context_); context_->sax = old_sax; @@ -203,7 +203,7 @@ void SaxParser::parse_memory_raw(const unsigned char* contents, size_type bytes_ context_ = xmlCreateMemoryParserCtxt((const char*)contents, bytes_count); parse(); } - + void SaxParser::parse_memory(const Glib::ustring& contents) { parse_memory_raw((const unsigned char*)contents.c_str(), contents.bytes()); @@ -306,7 +306,7 @@ void SaxParser::parse_chunk_raw(const unsigned char* contents, size_type bytes_c } else xmlCtxtResetLastError(context_); - + int parseError = XML_ERR_OK; if (!exception_) parseError = xmlParseChunk(context_, (const char*)contents, bytes_count, 0 /* don't terminate */); @@ -609,7 +609,7 @@ void SaxParserCallback::internal_subset(void* context, const xmlChar* name, { auto the_context = static_cast<_xmlParserCtxt*>(context); auto parser = static_cast(the_context->_private); - + try { const auto pid = publicId ? Glib::ustring((const char*) publicId) : ""; diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index cba267bc..0fe462d1 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -53,7 +53,7 @@ class SaxParser : public Parser /** This functor is a helper to find an attribute by name in an * AttributeList using the standard algorithm std::find_if - * + * * Example:@n * * Glib::ustring name = "foo";@n @@ -74,8 +74,8 @@ class SaxParser : public Parser return attribute.name == name; } }; - - /** + + /** * @param use_get_entity Set this to true if you will override on_get_entity(). * In theory, if you do not override on_get_entity() the parser should behave exactly the same * whether you use true or false here. But the default implementation of on_get_entity(), needed @@ -117,7 +117,7 @@ class SaxParser : public Parser * @throws xmlpp::validity_error */ void parse_stream(std::istream& in) override; - + /** Parse a chunk of data. * * This lets you pass a document in small chunks, e.g. from a network @@ -164,7 +164,7 @@ class SaxParser : public Parser void finish_chunk_parsing(); protected: - + virtual void on_start_document(); virtual void on_end_document(); virtual void on_start_element(const Glib::ustring& name, const AttributeList& attributes); @@ -215,10 +215,10 @@ class SaxParser : public Parser void release_underlying() override; void initialize_context() override; - + private: void parse(); - + std::unique_ptr<_xmlSAXHandler> sax_handler_; // A separate xmlpp::Document that is just used for entity resolution, diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc index 223dd9ae..01ff921d 100644 --- a/libxml++/parsers/textreader.cc +++ b/libxml++/parsers/textreader.cc @@ -8,7 +8,7 @@ namespace xmlpp { - + class TextReader::PropertyReader { public: @@ -34,10 +34,10 @@ TextReader::TextReader( } TextReader::TextReader( - const unsigned char* data, + const unsigned char* data, size_type size, const Glib::ustring& uri) - : propertyreader(new PropertyReader(*this)), + : propertyreader(new PropertyReader(*this)), impl_( xmlReaderForMemory ((const char*)data, size, uri.c_str(), nullptr, 0) ), severity_( 0 ) { @@ -299,7 +299,7 @@ Node* TextReader::get_current_node() Node::create_wrapper(node); return static_cast(node->_private); } - + check_for_exceptions(); return nullptr; } @@ -327,7 +327,7 @@ Node* TextReader::expand() Node::create_wrapper(node); return static_cast(node->_private); } - + check_for_exceptions(); return nullptr; } @@ -347,7 +347,7 @@ bool TextReader::is_valid() const void TextReader::setup_exceptions() { xmlTextReaderErrorFunc func = nullptr; - void* arg = nullptr; + void* arg = nullptr; // We respect any other error handlers already setup: xmlTextReaderGetErrorHandler(impl_, &func, &arg); @@ -369,7 +369,7 @@ void TextReader::check_for_exceptions() const { if( severity_ == 0 ) return; - + auto ths = const_cast(this); int severity = severity_; @@ -393,7 +393,7 @@ bool TextReader::PropertyReader::Bool(int value) { if(value == -1) owner_.check_for_exceptions(); - + return value > 0; } @@ -406,10 +406,10 @@ char TextReader::PropertyReader::Char(int value) Glib::ustring TextReader::PropertyReader::String(xmlChar* value, bool free) { owner_.check_for_exceptions(); - + if (!value) return Glib::ustring(); - + const Glib::ustring result = (char *)value; if(free) diff --git a/libxml++/relaxngschema.cc b/libxml++/relaxngschema.cc index 02a2f162..36a65b9a 100644 --- a/libxml++/relaxngschema.cc +++ b/libxml++/relaxngschema.cc @@ -49,7 +49,7 @@ struct RelaxNGSchema::Impl _xmlRelaxNG* schema; }; - + RelaxNGSchema::RelaxNGSchema() : pimpl_(new Impl) { @@ -104,7 +104,7 @@ void RelaxNGSchema::parse_context(_xmlRelaxNGParserCtxt* context) if (!context) throw parse_error("RelaxNGSchema::parse_context(): Could not create parser context.\n" + format_xml_error()); - + RelaxNGSchemaParserContextHolder holder(context); pimpl_->schema = xmlRelaxNGParse(context); diff --git a/libxml++/validators/validator.cc b/libxml++/validators/validator.cc index 69d02765..e91a2f6f 100644 --- a/libxml++/validators/validator.cc +++ b/libxml++/validators/validator.cc @@ -159,7 +159,7 @@ void Validator::handle_exception() void Validator::check_for_exception() { check_for_validity_messages(); - + if (exception_) { std::unique_ptr tmp(std::move(exception_)); diff --git a/libxml++/xsdschema.cc b/libxml++/xsdschema.cc index 1bcd9433..2357e87d 100644 --- a/libxml++/xsdschema.cc +++ b/libxml++/xsdschema.cc @@ -48,7 +48,7 @@ struct XsdSchema::Impl _xmlDoc* document; }; - + XsdSchema::XsdSchema() : pimpl_(new Impl) { @@ -111,7 +111,7 @@ void XsdSchema::parse_context(_xmlSchemaParserCtxt* context) { if (!context) throw parse_error("XsdSchema::parse_context(): Could not create parser context.\n" + format_xml_error()); - + XsdSchemaParserContextHolder holder(context); pimpl_->schema = xmlSchemaParse(context); From dcda6a10ee46501cc11559495f4040eb44d24a74 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 5 Nov 2015 23:16:44 +0100 Subject: [PATCH 039/240] SchemaValidatorBase: Use the override keyword. Though this is strange on pure virtual methods. These only seem to be repeated here so they can have more specific documentation than in the base class. --- libxml++/validators/schemavalidatorbase.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libxml++/validators/schemavalidatorbase.h b/libxml++/validators/schemavalidatorbase.h index 274ad94c..bc7b315a 100644 --- a/libxml++/validators/schemavalidatorbase.h +++ b/libxml++/validators/schemavalidatorbase.h @@ -46,7 +46,7 @@ class SchemaValidatorBase : public Validator * @param filename The URL of the schema. * @throws xmlpp::parse_error */ - virtual void parse_file(const std::string& filename) = 0; + void parse_file(const std::string& filename) override = 0; /** Parse a schema definition from a string. * If the validator already contains a schema, that schema is released @@ -54,7 +54,7 @@ class SchemaValidatorBase : public Validator * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ - virtual void parse_memory(const Glib::ustring& contents) = 0; + void parse_memory(const Glib::ustring& contents) override = 0; /** Parse a schema definition from a document. * If the validator already contains a schema, that schema is released @@ -71,14 +71,14 @@ class SchemaValidatorBase : public Validator * do_something(); * @endcode */ - explicit virtual operator bool() const noexcept = 0; + explicit virtual operator bool() const noexcept override = 0; /** Validate a document, using a previously parsed schema. * @param document Pointer to the document. * @throws xmlpp::internal_error * @throws xmlpp::validity_error */ - virtual void validate(const Document* document) = 0; + void validate(const Document* document) override = 0; /** Validate an XML file, using a previously parsed schema. * @param filename The URL of the XML file. From 30730dffc71248deb04f944b21cafb65aa678d9b Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 16 Nov 2015 16:36:47 +0100 Subject: [PATCH 040/240] Examples: More use of override keyword * examples/sax_parser_build_dom/svgparser.h: * examples/sax_parser_entities/myparser.h: Use the override keyword on all overridden virtual methods. --- examples/sax_parser_build_dom/svgparser.h | 20 ++++++++++---------- examples/sax_parser_entities/myparser.h | 10 ++++------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/examples/sax_parser_build_dom/svgparser.h b/examples/sax_parser_build_dom/svgparser.h index 201de741..27ce4eac 100644 --- a/examples/sax_parser_build_dom/svgparser.h +++ b/examples/sax_parser_build_dom/svgparser.h @@ -36,17 +36,17 @@ class Parser : public xmlpp::SaxParser protected: // SAX parser callbacks - void on_start_document() {}; - void on_end_document() {}; + void on_start_document() override {}; + void on_end_document() override {}; void on_start_element(const Glib::ustring& name, - const AttributeList& properties); - void on_end_element(const Glib::ustring& name); - void on_characters(const Glib::ustring& characters); - void on_comment(const Glib::ustring& text); - void on_warning(const Glib::ustring& text); - void on_error(const Glib::ustring& text); - void on_fatal_error(const Glib::ustring& text); - void on_cdata_block(const Glib::ustring& text); + const AttributeList& properties) override; + void on_end_element(const Glib::ustring& name) override; + void on_characters(const Glib::ustring& characters) override; + void on_comment(const Glib::ustring& text) override; + void on_warning(const Glib::ustring& text) override; + void on_error(const Glib::ustring& text) override; + void on_fatal_error(const Glib::ustring& text) override; + void on_cdata_block(const Glib::ustring& text) override; private: // context is a stack to keep track of parent node while the SAX parser diff --git a/examples/sax_parser_entities/myparser.h b/examples/sax_parser_entities/myparser.h index 91476ff2..30001095 100644 --- a/examples/sax_parser_entities/myparser.h +++ b/examples/sax_parser_entities/myparser.h @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* myparser.h * * Copyright (C) 2002 The libxml++ development team @@ -34,8 +32,8 @@ class MySaxParser : public xmlpp::SaxParser //overrides: void on_start_document() override; void on_end_document() override; - virtual void on_start_element(const Glib::ustring& name, - const AttributeList& properties); + void on_start_element(const Glib::ustring& name, + const AttributeList& properties) override; void on_end_element(const Glib::ustring& name) override; void on_characters(const Glib::ustring& characters) override; void on_comment(const Glib::ustring& text) override; @@ -44,8 +42,8 @@ class MySaxParser : public xmlpp::SaxParser void on_fatal_error(const Glib::ustring& text) override; _xmlEntity* on_get_entity(const Glib::ustring& name) override; - void on_entity_declaration(const Glib::ustring& name, xmlpp::XmlEntityType type, const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content) override; + void on_entity_declaration(const Glib::ustring& name, xmlpp::XmlEntityType type, + const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content) override; }; - #endif //__LIBXMLPP_EXAMPLES_MYPARSER_H From 74475f3dde1c4efe764d79d1118cd00c48faa36a Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 16 Nov 2015 16:37:11 +0100 Subject: [PATCH 041/240] configure.ac: Use -Wsuggest-override with --enable-warnings=fatal --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 561949ad..a24a9b7d 100644 --- a/configure.ac +++ b/configure.ac @@ -49,7 +49,7 @@ MM_ARG_WITH_TAGFILE_DOC([glibmm-2.4.tag], [glibmm-2.4]) # Evaluate the --enable-warnings=level option. MM_ARG_ENABLE_WARNINGS([LIBXMLXX_WXXFLAGS], [-Wall], - [-pedantic -Wall -Wextra -Wformat-security -Wshadow -Wno-long-long], + [-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow -Wno-long-long], [G GLIBMM SIGCXX]) # Offer the ability to omit some API from the library. From 46d6e388191a18a50e883a3221844b37eade062a Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 30 Dec 2015 19:41:10 +0100 Subject: [PATCH 042/240] Use scoped enums (enum class) instead of unscoped enums * examples/dom_build/main.cc: * examples/dom_xpath/main.cc: Update names of enum constants. * libxml++/document.[cc|h]: * libxml++/nodes/node.[cc|h]: * libxml++/parsers/parser.[cc|h]: * libxml++/parsers/textreader.[cc|h]: Replace enum by enum class. Modify the names of the enum constants. E.g. XML_INTERNAL_GENERAL_ENTITY -> XmlEntityType::INTERNAL_GENERAL. This patch breaks API and ABI. The API and ABI of libxml++ 3.x has not yet been frozen. --- examples/dom_build/main.cc | 2 +- examples/dom_xpath/main.cc | 10 +++---- libxml++/document.cc | 5 ++-- libxml++/document.h | 20 +++++++------ libxml++/nodes/node.cc | 4 +-- libxml++/nodes/node.h | 12 ++++---- libxml++/parsers/parser.cc | 16 +++++------ libxml++/parsers/parser.h | 10 +++---- libxml++/parsers/textreader.cc | 8 +++--- libxml++/parsers/textreader.h | 51 +++++++++++++++++++++------------- 10 files changed, 78 insertions(+), 60 deletions(-) diff --git a/examples/dom_build/main.cc b/examples/dom_build/main.cc index 568d9445..13e081c1 100644 --- a/examples/dom_build/main.cc +++ b/examples/dom_build/main.cc @@ -36,7 +36,7 @@ main(int /* argc */, char** /* argv */) { xmlpp::Document document; document.set_internal_subset("example_xml_doc", "", "example_xml_doc.dtd"); - document.set_entity_declaration("example1", xmlpp::XML_INTERNAL_GENERAL_ENTITY, + document.set_entity_declaration("example1", xmlpp::XmlEntityType::INTERNAL_GENERAL, "", "example_xml_doc.dtd", "Entity content"); document.add_processing_instruction("application1", "This is an example document"); document.add_comment("First comment"); diff --git a/examples/dom_xpath/main.cc b/examples/dom_xpath/main.cc index c35e4094..52c0bd80 100644 --- a/examples/dom_xpath/main.cc +++ b/examples/dom_xpath/main.cc @@ -29,12 +29,12 @@ Glib::ustring result_type_to_ustring(xmlpp::XPathResultType result_type) { switch (result_type) { - case xmlpp::XPATH_RESULT_NODESET: return "nodeset"; - case xmlpp::XPATH_RESULT_BOOLEAN: return "boolean"; - case xmlpp::XPATH_RESULT_NUMBER: return "number"; - case xmlpp::XPATH_RESULT_STRING: return "string"; + case xmlpp::XPathResultType::NODESET: return "nodeset"; + case xmlpp::XPathResultType::BOOLEAN: return "boolean"; + case xmlpp::XPathResultType::NUMBER: return "number"; + case xmlpp::XPathResultType::STRING: return "string"; - case xmlpp::XPATH_RESULT_UNDEFINED: + case xmlpp::XPathResultType::UNDEFINED: default: return "undefined"; } diff --git a/libxml++/document.cc b/libxml++/document.cc index d441b1d1..5de36c06 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -415,10 +415,11 @@ void Document::set_entity_declaration(const Glib::ustring& name, XmlEntityType t const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content) { - auto entity = xmlAddDocEntity( impl_, (const xmlChar*) name.c_str(), type, + auto entity = xmlAddDocEntity(impl_, (const xmlChar*)name.c_str(), + static_cast(type), publicId.empty() ? nullptr : (const xmlChar*)publicId.c_str(), systemId.empty() ? nullptr : (const xmlChar*)systemId.c_str(), - (const xmlChar*) content.c_str() ); + (const xmlChar*)content.c_str()); if (!entity) throw internal_error("Could not add entity declaration " + name); } diff --git a/libxml++/document.h b/libxml++/document.h index 23b9d8d8..99f3fa57 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -39,14 +39,18 @@ extern "C" { namespace xmlpp { -typedef enum { - XML_INTERNAL_GENERAL_ENTITY = 1, - XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2, - XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3, - XML_INTERNAL_PARAMETER_ENTITY = 4, - XML_EXTERNAL_PARAMETER_ENTITY = 5, - XML_INTERNAL_PREDEFINED_ENTITY = 6 -} XmlEntityType; +// xmlpp::XmlEntityType is similar to xmlEntityType in libxml2. +/** The valid entity types. + */ +enum class XmlEntityType +{ + INTERNAL_GENERAL = 1, + EXTERNAL_GENERAL_PARSED = 2, + EXTERNAL_GENERAL_UNPARSED = 3, + INTERNAL_PARAMETER = 4, + EXTERNAL_PARAMETER = 5, + INTERNAL_PREDEFINED = 6 +}; //TODO: Make Document inherit from Node, when we can break ABI one day? // diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index 46d202e3..86a78466 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -155,7 +155,7 @@ xmlXPathObject* eval_common(const Glib::ustring& xpath, if (!xpath_value) { if (result_type) - *result_type = xmlpp::XPATH_RESULT_UNDEFINED; + *result_type = xmlpp::XPathResultType::UNDEFINED; throw xmlpp::exception("Invalid XPath: " + xpath); } @@ -168,7 +168,7 @@ xmlXPathObject* eval_common(const Glib::ustring& xpath, xpath_value->type == XPATH_STRING) *result_type = static_cast(xpath_value->type); else - *result_type = xmlpp::XPATH_RESULT_UNDEFINED; + *result_type = xmlpp::XPathResultType::UNDEFINED; } return xpath_value; diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index 8e56348f..53ea51ea 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -33,13 +33,13 @@ class Element; * - number * - string */ -enum XPathResultType +enum class XPathResultType { - XPATH_RESULT_UNDEFINED = 0, - XPATH_RESULT_NODESET = 1, - XPATH_RESULT_BOOLEAN = 2, - XPATH_RESULT_NUMBER = 3, - XPATH_RESULT_STRING = 4 + UNDEFINED = 0, + NODESET = 1, + BOOLEAN = 2, + NUMBER = 3, + STRING = 4 }; /** Represents XML Nodes. diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc index d4ecdc64..e1b98835 100644 --- a/libxml++/parsers/parser.cc +++ b/libxml++/parsers/parser.cc @@ -237,7 +237,7 @@ void Parser::callback_parser_error(void* ctx, const char* msg, ...) { va_list var_args; va_start(var_args, msg); - callback_error_or_warning(MsgParserError, ctx, msg, var_args); + callback_error_or_warning(MsgType::ParserError, ctx, msg, var_args); va_end(var_args); } @@ -246,7 +246,7 @@ void Parser::callback_parser_warning(void* ctx, const char* msg, ...) { va_list var_args; va_start(var_args, msg); - callback_error_or_warning(MsgParserWarning, ctx, msg, var_args); + callback_error_or_warning(MsgType::ParserWarning, ctx, msg, var_args); va_end(var_args); } @@ -255,7 +255,7 @@ void Parser::callback_validity_error(void* ctx, const char* msg, ...) { va_list var_args; va_start(var_args, msg); - callback_error_or_warning(MsgValidityError, ctx, msg, var_args); + callback_error_or_warning(MsgType::ValidityError, ctx, msg, var_args); va_end(var_args); } @@ -264,7 +264,7 @@ void Parser::callback_validity_warning(void* ctx, const char* msg, ...) { va_list var_args; va_start(var_args, msg); - callback_error_or_warning(MsgValidityWarning, ctx, msg, var_args); + callback_error_or_warning(MsgType::ValidityWarning, ctx, msg, var_args); va_end(var_args); } @@ -296,16 +296,16 @@ void Parser::callback_error_or_warning(MsgType msg_type, void* ctx, { switch (msg_type) { - case MsgParserError: + case MsgType::ParserError: parser->on_parser_error(ubuff); break; - case MsgParserWarning: + case MsgType::ParserWarning: parser->on_parser_warning(ubuff); break; - case MsgValidityError: + case MsgType::ValidityError: parser->on_validity_error(ubuff); break; - case MsgValidityWarning: + case MsgType::ValidityWarning: parser->on_validity_warning(ubuff); break; } diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index a101d600..b0d842d9 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -185,12 +185,12 @@ class Parser : public NonCopyable static void callback_validity_error(void* ctx, const char* msg, ...); static void callback_validity_warning(void* ctx, const char* msg, ...); - enum MsgType + enum class MsgType { - MsgParserError, - MsgParserWarning, - MsgValidityError, - MsgValidityWarning + ParserError, + ParserWarning, + ValidityError, + ValidityWarning }; static void callback_error_or_warning(MsgType msg_type, void* ctx, diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc index 01ff921d..66958a9b 100644 --- a/libxml++/parsers/textreader.cc +++ b/libxml++/parsers/textreader.cc @@ -157,12 +157,12 @@ Glib::ustring TextReader::get_namespace_uri() const xmlTextReaderNamespaceUri(impl_), true); } -TextReader::xmlNodeType TextReader::get_node_type() const +TextReader::NodeType TextReader::get_node_type() const { int result = xmlTextReaderNodeType(impl_); if(result == -1) check_for_exceptions(); - return (xmlNodeType)result; + return static_cast(result); } Glib::ustring TextReader::get_prefix() const @@ -189,12 +189,12 @@ Glib::ustring TextReader::get_xml_lang() const xmlTextReaderXmlLang(impl_)); } -TextReader::xmlReadState TextReader::get_read_state() const +TextReader::ReadState TextReader::get_read_state() const { int result = xmlTextReaderReadState(impl_); if(result == -1) check_for_exceptions(); - return (xmlReadState)result; + return static_cast(result); } void TextReader::close() diff --git a/libxml++/parsers/textreader.h b/libxml++/parsers/textreader.h index 15a67f04..2cd34e68 100644 --- a/libxml++/parsers/textreader.h +++ b/libxml++/parsers/textreader.h @@ -29,38 +29,47 @@ namespace xmlpp class TextReader: public NonCopyable { public: - enum xmlNodeType { + // xmlpp::TextReader::NodeType is similar to xmlReaderTypes in libxml2. + /** Node type of the current node. + * See DotGNU's XmlNodeType enum. + */ + enum class NodeType + { + InternalError = -1, + None = 0, + Element = 1, Attribute = 2, + Text = 3, CDATA = 4, + EntityReference = 5, + Entity = 6, + ProcessingInstruction = 7, Comment = 8, Document = 9, - DocumentFragment = 11, DocumentType = 10, - Element = 1, - EndElement = 15, - EndEntity = 16, - Entity = 6, - EntityReference = 5, - None = 0, + DocumentFragment = 11, Notation = 12, - ProcessingInstruction = 7, - SignificantWhitespace = 14, - Text = 3, Whitespace = 13, + SignificantWhitespace = 14, + EndElement = 15, + EndEntity = 16, XmlDeclaration = 17 }; - enum xmlReadState + // xmlpp::TextReader::ReadState is similar to xmlTextReaderMode in libxml2. + enum class ReadState { - Closed = 4, - EndOfFile = 3, - Error = 2, + InternalError = -1, Initial = 0, Interactive = 1, + Error = 2, + EndOfFile = 3, + Closed = 4, Reading = 5 }; - enum ParserProperties + // xmlpp::TextReader::ParserProperties is similar to xmlParserProperties in libxml2. + enum class ParserProperties { LoadDtd = 1, DefaultAttrs = 2, @@ -174,9 +183,13 @@ class TextReader: public NonCopyable Glib::ustring get_namespace_uri() const; /** Get the node type of the current node. - * @returns The xmlpp::xmlNodeType of the current node, or -1 in case of error. + * @returns The xmlpp::TextReader::NodeType of the current node. + * In case of error, either returns xmlpp::TextReader::NodeType::InternalError + * or throws an exception. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error */ - xmlNodeType get_node_type() const; + NodeType get_node_type() const; /** Get the namespace prefix associated with the current node. * @returns The namespace prefix, or an empty string if not available. @@ -191,7 +204,7 @@ class TextReader: public NonCopyable Glib::ustring get_value() const; Glib::ustring get_xml_lang() const; - xmlReadState get_read_state() const; + ReadState get_read_state() const; void close(); From a1d74cf2b60d17791220c133107fc46ad6f75613 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sat, 2 Jan 2016 10:42:32 +0100 Subject: [PATCH 043/240] Use using instead of typedef * libxml++/document.cc: * libxml++/nodes/element.h: * libxml++/nodes/node.h: * libxml++/parsers/parser.h: * libxml++/parsers/saxparser.h: * libxml++/parsers/textreader.h: Use using newtypename = oldtype instead of typedef oldtype newtypename. This is the recommended way of declaring type name aliases in C++11. --- libxml++/document.cc | 2 +- libxml++/nodes/element.h | 4 ++-- libxml++/nodes/node.h | 10 +++++----- libxml++/parsers/parser.h | 2 +- libxml++/parsers/saxparser.h | 2 +- libxml++/parsers/textreader.h | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libxml++/document.cc b/libxml++/document.cc index 5de36c06..692a4a7b 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -23,7 +23,7 @@ namespace // anonymous { -typedef std::map NodeMap; +using NodeMap = std::map; // Find all C++ wrappers of 'node' and its descendants. // Compare xmlpp::Node::free_wrappers(). diff --git a/libxml++/nodes/element.h b/libxml++/nodes/element.h index e013828d..e29264b6 100644 --- a/libxml++/nodes/element.h +++ b/libxml++/nodes/element.h @@ -26,8 +26,8 @@ class Element : public Node explicit Element(_xmlNode* node); ~Element() override; - typedef std::list AttributeList; - typedef std::list const_AttributeList; + using AttributeList = std::list; + using const_AttributeList = std::list; /** Add a namespace declaration to this node which will apply to this node and all children. * diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index 53ea51ea..f53e0b8b 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -51,11 +51,11 @@ enum class XPathResultType class Node : public NonCopyable { public: - typedef std::list NodeList; - typedef std::list const_NodeList; + using NodeList = std::list; + using const_NodeList = std::list; - typedef std::vector NodeSet; - typedef std::vector const_NodeSet; + using NodeSet = std::vector; + using const_NodeSet = std::vector; /** @throws xmlpp::internal_error If @a node is nullptr. */ @@ -210,7 +210,7 @@ class Node : public NonCopyable /** A map of namespace prefixes to namespace URIs. */ - typedef std::map PrefixNsMap; + using PrefixNsMap = std::map; /** Find nodes from an XPath expression. * @param xpath The XPath of the nodes. diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index b0d842d9..d2953420 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -38,7 +38,7 @@ class Parser : public NonCopyable Parser(); ~Parser() override; - typedef unsigned int size_type; + using size_type = unsigned int; /** By default, the parser will not validate the XML file. * @param val Whether the document should be validated. diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index 0fe462d1..ba3be62c 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -49,7 +49,7 @@ class SaxParser : public Parser } }; - typedef std::deque< Attribute > AttributeList; + using AttributeList = std::deque; /** This functor is a helper to find an attribute by name in an * AttributeList using the standard algorithm std::find_if diff --git a/libxml++/parsers/textreader.h b/libxml++/parsers/textreader.h index 2cd34e68..c8b44a73 100644 --- a/libxml++/parsers/textreader.h +++ b/libxml++/parsers/textreader.h @@ -77,7 +77,7 @@ class TextReader: public NonCopyable SubstEntities = 4 }; - typedef unsigned int size_type; + using size_type = unsigned int; public: /** From c8ffc5e7e35a3886917dea1c45e1ef0236dbb372 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 7 Jan 2016 08:57:18 +0100 Subject: [PATCH 044/240] Add some noexcept --- libxml++/attributedeclaration.cc | 4 ++-- libxml++/attributedeclaration.h | 4 ++-- libxml++/attributenode.cc | 4 ++-- libxml++/attributenode.h | 4 ++-- libxml++/document.cc | 6 +++--- libxml++/document.h | 6 +++--- libxml++/dtd.cc | 6 +++--- libxml++/dtd.h | 4 ++-- libxml++/io/outputbuffer.cc | 4 ++-- libxml++/io/outputbuffer.h | 4 ++-- libxml++/io/parserinputbuffer.cc | 4 ++-- libxml++/io/parserinputbuffer.h | 4 ++-- libxml++/keepblanks.cc | 6 ++---- libxml++/keepblanks.h | 11 ++++------- libxml++/nodes/entitydeclaration.cc | 4 ++-- libxml++/nodes/entitydeclaration.h | 4 ++-- libxml++/nodes/node.cc | 4 ++-- libxml++/nodes/node.h | 4 ++-- libxml++/noncopyable.cc | 2 +- libxml++/noncopyable.h | 2 +- libxml++/parsers/domparser.cc | 6 +++--- libxml++/parsers/domparser.h | 6 +++--- libxml++/parsers/parser.cc | 20 ++++++++++---------- libxml++/parsers/parser.h | 20 ++++++++++---------- libxml++/relaxngschema.cc | 8 ++++---- libxml++/relaxngschema.h | 4 ++-- libxml++/schemabase.cc | 2 +- libxml++/schemabase.h | 2 +- libxml++/validators/dtdvalidator.cc | 6 +++--- libxml++/validators/dtdvalidator.h | 4 ++-- libxml++/validators/relaxngvalidator.cc | 6 +++--- libxml++/validators/relaxngvalidator.h | 4 ++-- libxml++/validators/schemavalidatorbase.cc | 2 +- libxml++/validators/schemavalidatorbase.h | 2 +- libxml++/validators/validator.cc | 2 +- libxml++/validators/validator.h | 2 +- libxml++/validators/xsdvalidator.cc | 6 +++--- libxml++/validators/xsdvalidator.h | 4 ++-- libxml++/xsdschema.cc | 8 ++++---- libxml++/xsdschema.h | 4 ++-- 40 files changed, 102 insertions(+), 107 deletions(-) diff --git a/libxml++/attributedeclaration.cc b/libxml++/attributedeclaration.cc index 16ff57bd..d1877217 100644 --- a/libxml++/attributedeclaration.cc +++ b/libxml++/attributedeclaration.cc @@ -25,14 +25,14 @@ Glib::ustring AttributeDeclaration::get_value() const return (const char*)cobj()->defaultValue; } -xmlAttribute* AttributeDeclaration::cobj() +xmlAttribute* AttributeDeclaration::cobj() noexcept { // An XML_ATTRIBUTE_DECL is represented by an xmlAttribute struct. Reinterpret // the xmlNode pointer stored in the base class as an xmlAttribute pointer. return reinterpret_cast(Node::cobj()); } -const xmlAttribute* AttributeDeclaration::cobj() const +const xmlAttribute* AttributeDeclaration::cobj() const noexcept { // An XML_ATTRIBUTE_DECL is represented by an xmlAttribute struct. Reinterpret // the xmlNode pointer stored in the base class as an xmlAttribute pointer. diff --git a/libxml++/attributedeclaration.h b/libxml++/attributedeclaration.h index 446436f9..6a9d986f 100644 --- a/libxml++/attributedeclaration.h +++ b/libxml++/attributedeclaration.h @@ -37,10 +37,10 @@ class AttributeDeclaration : public Attribute Glib::ustring get_value() const override; ///Access the underlying libxml implementation. - _xmlAttribute* cobj(); + _xmlAttribute* cobj() noexcept; ///Access the underlying libxml implementation. - const _xmlAttribute* cobj() const; + const _xmlAttribute* cobj() const noexcept; }; } // namespace xmlpp diff --git a/libxml++/attributenode.cc b/libxml++/attributenode.cc index 267af7ad..c585c312 100644 --- a/libxml++/attributenode.cc +++ b/libxml++/attributenode.cc @@ -42,14 +42,14 @@ void AttributeNode::set_value(const Glib::ustring& value) xmlSetProp(cobj()->parent, cobj()->name, (const xmlChar*)value.c_str()); } -xmlAttr* AttributeNode::cobj() +xmlAttr* AttributeNode::cobj() noexcept { // An XML_ATTRIBUTE_NODE is represented by an xmlAttr struct. Reinterpret // the xmlNode pointer stored in the base class as an xmlAttr pointer. return reinterpret_cast(Node::cobj()); } -const xmlAttr* AttributeNode::cobj() const +const xmlAttr* AttributeNode::cobj() const noexcept { // An XML_ATTRIBUTE_NODE is represented by an xmlAttr struct. Reinterpret // the xmlNode pointer stored in the base class as an xmlAttr pointer. diff --git a/libxml++/attributenode.h b/libxml++/attributenode.h index cc281147..68dada4f 100644 --- a/libxml++/attributenode.h +++ b/libxml++/attributenode.h @@ -47,13 +47,13 @@ class AttributeNode : public Attribute * * @newin{3,0} Replaces Attribute::cobj() */ - _xmlAttr* cobj(); + _xmlAttr* cobj() noexcept; /** Access the underlying libxml implementation. * * @newin{3,0} Replaces Attribute::cobj() const */ - const _xmlAttr* cobj() const; + const _xmlAttr* cobj() const noexcept; }; } // namespace xmlpp diff --git a/libxml++/document.cc b/libxml++/document.cc index 692a4a7b..be1ed2f4 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -152,7 +152,7 @@ Document::Init::Init() xmlInitParser(); //Not always necessary, but necessary for thread safety. } -Document::Init::~Init() +Document::Init::~Init() noexcept { //We don't call this because it breaks libxml generally and should only be //called at the very end of a process, such as at the end of a main(). @@ -470,12 +470,12 @@ _xmlEntity* Document::get_entity(const Glib::ustring& name) return xmlGetDocEntity(impl_, (const xmlChar*) name.c_str()); } -_xmlDoc* Document::cobj() +_xmlDoc* Document::cobj() noexcept { return impl_; } -const _xmlDoc* Document::cobj() const +const _xmlDoc* Document::cobj() const noexcept { return impl_; } diff --git a/libxml++/document.h b/libxml++/document.h index 99f3fa57..90ffaa41 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -69,7 +69,7 @@ class Document : public NonCopyable { public: Init(); - ~Init(); + ~Init() noexcept; }; friend class SaxParser; @@ -252,10 +252,10 @@ class Document : public NonCopyable int process_xinclude(bool generate_xinclude_nodes = true); ///Access the underlying libxml implementation. - _xmlDoc* cobj(); + _xmlDoc* cobj() noexcept; ///Access the underlying libxml implementation. - const _xmlDoc* cobj() const; + const _xmlDoc* cobj() const noexcept; protected: /** Retrieve an Entity. diff --git a/libxml++/dtd.cc b/libxml++/dtd.cc index 8a6d6012..586461cd 100644 --- a/libxml++/dtd.cc +++ b/libxml++/dtd.cc @@ -15,7 +15,7 @@ namespace xmlpp struct Dtd::Impl { - Impl() : dtd(nullptr), is_dtd_owner(false) {} + Impl() noexcept : dtd(nullptr), is_dtd_owner(false) {} _xmlDtd* dtd; bool is_dtd_owner; @@ -120,12 +120,12 @@ Glib::ustring Dtd::get_system_id() const return (pimpl_->dtd && pimpl_->dtd->SystemID) ? (const char*)pimpl_->dtd->SystemID : ""; } -_xmlDtd* Dtd::cobj() +_xmlDtd* Dtd::cobj() noexcept { return pimpl_->dtd; } -const _xmlDtd* Dtd::cobj() const +const _xmlDtd* Dtd::cobj() const noexcept { return pimpl_->dtd; } diff --git a/libxml++/dtd.h b/libxml++/dtd.h index d3f9030a..1686777a 100644 --- a/libxml++/dtd.h +++ b/libxml++/dtd.h @@ -117,11 +117,11 @@ class Dtd : public NonCopyable /** Access the underlying libxml implementation. */ - _xmlDtd* cobj(); + _xmlDtd* cobj() noexcept; /** Access the underlying libxml implementation. */ - const _xmlDtd* cobj() const; + const _xmlDtd* cobj() const noexcept; protected: void release_underlying(); diff --git a/libxml++/io/outputbuffer.cc b/libxml++/io/outputbuffer.cc index c454417d..9f3750bc 100644 --- a/libxml++/io/outputbuffer.cc +++ b/libxml++/io/outputbuffer.cc @@ -93,12 +93,12 @@ namespace xmlpp return true; } - _xmlOutputBuffer* OutputBuffer::cobj() + _xmlOutputBuffer* OutputBuffer::cobj() noexcept { return impl_; } - const _xmlOutputBuffer* OutputBuffer::cobj() const + const _xmlOutputBuffer* OutputBuffer::cobj() const noexcept { return impl_; } diff --git a/libxml++/io/outputbuffer.h b/libxml++/io/outputbuffer.h index 77115558..e07b1537 100644 --- a/libxml++/io/outputbuffer.h +++ b/libxml++/io/outputbuffer.h @@ -46,11 +46,11 @@ namespace xmlpp public: /** gives an access to the underlying libxml structure to the children */ - _xmlOutputBuffer* cobj(); + _xmlOutputBuffer* cobj() noexcept; /** gives an access to the underlying libxml structure to the children */ - const _xmlOutputBuffer* cobj() const; + const _xmlOutputBuffer* cobj() const noexcept; private: bool on_write(const char * buffer, int len); diff --git a/libxml++/io/parserinputbuffer.cc b/libxml++/io/parserinputbuffer.cc index e4d24730..24cd2a87 100644 --- a/libxml++/io/parserinputbuffer.cc +++ b/libxml++/io/parserinputbuffer.cc @@ -71,12 +71,12 @@ namespace xmlpp return true; } - _xmlParserInputBuffer* ParserInputBuffer::cobj() + _xmlParserInputBuffer* ParserInputBuffer::cobj() noexcept { return impl_; } - const _xmlParserInputBuffer* ParserInputBuffer::cobj() const + const _xmlParserInputBuffer* ParserInputBuffer::cobj() const noexcept { return impl_; } diff --git a/libxml++/io/parserinputbuffer.h b/libxml++/io/parserinputbuffer.h index a5847087..54dd6d26 100644 --- a/libxml++/io/parserinputbuffer.h +++ b/libxml++/io/parserinputbuffer.h @@ -37,11 +37,11 @@ namespace xmlpp public: /** gives an access to the underlying libxml structure to the children */ - _xmlParserInputBuffer* cobj(); + _xmlParserInputBuffer* cobj() noexcept; /** gives an access to the underlying libxml structure to the children */ - const _xmlParserInputBuffer* cobj() const; + const _xmlParserInputBuffer* cobj() const noexcept; private: int on_read(char * buffer, int len); diff --git a/libxml++/keepblanks.cc b/libxml++/keepblanks.cc index b49b3cfb..4228b8dd 100644 --- a/libxml++/keepblanks.cc +++ b/libxml++/keepblanks.cc @@ -11,21 +11,19 @@ namespace xmlpp { - #if _MSC_VER == 1200 // detect MSVC 6.0 const bool KeepBlanks::Default = true; #endif - KeepBlanks::KeepBlanks(bool value) + KeepBlanks::KeepBlanks(bool value) noexcept { oldIndentTreeOutput_ = xmlIndentTreeOutput; oldKeepBlanksDefault_ = xmlKeepBlanksDefault( value?1:0 ); } - KeepBlanks::~KeepBlanks() + KeepBlanks::~KeepBlanks() noexcept { xmlKeepBlanksDefault(oldKeepBlanksDefault_); xmlIndentTreeOutput = oldIndentTreeOutput_; } } - diff --git a/libxml++/keepblanks.h b/libxml++/keepblanks.h index a2002e27..99391a03 100644 --- a/libxml++/keepblanks.h +++ b/libxml++/keepblanks.h @@ -10,10 +10,8 @@ namespace xmlpp { - - /** - * This class set KeepBlanksDefault and IndentTreeOutput of libxmlpp - * and restore their initial value in its destructor. As a consequence + /** This class sets KeepBlanksDefault and IndentTreeOutput of libxmlpp + * and restores their initial values in its destructor. As a consequence * the wanted setting is kept during instance lifetime. */ class KeepBlanks { @@ -25,14 +23,13 @@ namespace xmlpp #endif public: - KeepBlanks(bool value); - ~KeepBlanks(); + KeepBlanks(bool value) noexcept; + ~KeepBlanks() noexcept; private: int oldKeepBlanksDefault_; int oldIndentTreeOutput_; }; - } #endif // __LIBXMLPP_KEEPBLANKS_H diff --git a/libxml++/nodes/entitydeclaration.cc b/libxml++/nodes/entitydeclaration.cc index 9486cb4d..3b5c08aa 100644 --- a/libxml++/nodes/entitydeclaration.cc +++ b/libxml++/nodes/entitydeclaration.cc @@ -27,14 +27,14 @@ Glib::ustring EntityDeclaration::get_original_text() const return cobj()->orig ? (const char*)cobj()->orig : ""; } -xmlEntity* EntityDeclaration::cobj() +xmlEntity* EntityDeclaration::cobj() noexcept { // An XML_ENTITY_DECL is represented by an xmlEntity struct. Reinterpret // the xmlNode pointer stored in the base class as an xmlEntity pointer. return reinterpret_cast(Node::cobj()); } -const xmlEntity* EntityDeclaration::cobj() const +const xmlEntity* EntityDeclaration::cobj() const noexcept { // An XML_ENTITY_DECL is represented by an xmlEntity struct. Reinterpret // the xmlNode pointer stored in the base class as an xmlEntity pointer. diff --git a/libxml++/nodes/entitydeclaration.h b/libxml++/nodes/entitydeclaration.h index 258e24bc..0cc3f3e7 100644 --- a/libxml++/nodes/entitydeclaration.h +++ b/libxml++/nodes/entitydeclaration.h @@ -43,10 +43,10 @@ class EntityDeclaration : public ContentNode Glib::ustring get_original_text() const; ///Access the underlying libxml implementation. - _xmlEntity* cobj(); + _xmlEntity* cobj() noexcept; ///Access the underlying libxml implementation. - const _xmlEntity* cobj() const; + const _xmlEntity* cobj() const noexcept; }; } // namespace xmlpp diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index 86a78466..3dd47c3b 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -376,12 +376,12 @@ int Node::get_line() const } -xmlNode* Node::cobj() +xmlNode* Node::cobj() noexcept { return impl_; } -const xmlNode* Node::cobj() const +const xmlNode* Node::cobj() const noexcept { return impl_; } diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index f53e0b8b..e5ac5a01 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -316,10 +316,10 @@ class Node : public NonCopyable XPathResultType* result_type = nullptr) const; ///Access the underlying libxml implementation. - _xmlNode* cobj(); + _xmlNode* cobj() noexcept; ///Access the underlying libxml implementation. - const _xmlNode* cobj() const; + const _xmlNode* cobj() const noexcept; /** Construct the correct C++ instance for a given libxml C struct instance. * diff --git a/libxml++/noncopyable.cc b/libxml++/noncopyable.cc index f809f480..76980e1d 100644 --- a/libxml++/noncopyable.cc +++ b/libxml++/noncopyable.cc @@ -10,7 +10,7 @@ namespace xmlpp { -NonCopyable::NonCopyable() +NonCopyable::NonCopyable() noexcept { } diff --git a/libxml++/noncopyable.h b/libxml++/noncopyable.h index d82395a1..81920c8b 100644 --- a/libxml++/noncopyable.h +++ b/libxml++/noncopyable.h @@ -17,7 +17,7 @@ namespace xmlpp class NonCopyable { protected: - NonCopyable(); + NonCopyable() noexcept; virtual ~NonCopyable(); NonCopyable(const NonCopyable&) = delete; diff --git a/libxml++/parsers/domparser.cc b/libxml++/parsers/domparser.cc index 329bae53..9d623d11 100644 --- a/libxml++/parsers/domparser.cc +++ b/libxml++/parsers/domparser.cc @@ -218,17 +218,17 @@ void DomParser::release_underlying() Parser::release_underlying(); } -DomParser::operator bool() const +DomParser::operator bool() const noexcept { return doc_ != nullptr; } -Document* DomParser::get_document() +Document* DomParser::get_document() noexcept { return doc_; } -const Document* DomParser::get_document() const +const Document* DomParser::get_document() const noexcept { return doc_; } diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index a608739b..df7ea23b 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -76,17 +76,17 @@ class DomParser : public Parser /** Test whether a document has been parsed. */ - operator bool() const; + operator bool() const noexcept; /** Get the parsed document. * @returns A pointer to the parsed document, or nullptr. */ - Document* get_document(); + Document* get_document() noexcept; /** Get the parsed document. * @returns A pointer to the parsed document, or nullptr. */ - const Document* get_document() const; + const Document* get_document() const noexcept; protected: void parse_context(); diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc index e1b98835..ac8cc787 100644 --- a/libxml++/parsers/parser.cc +++ b/libxml++/parsers/parser.cc @@ -44,53 +44,53 @@ Parser::~Parser() release_underlying(); } -void Parser::set_validate(bool val) +void Parser::set_validate(bool val) noexcept { pimpl_->validate_ = val; } -bool Parser::get_validate() const +bool Parser::get_validate() const noexcept { return pimpl_->validate_; } -void Parser::set_substitute_entities(bool val) +void Parser::set_substitute_entities(bool val) noexcept { pimpl_->substitute_entities_ = val; } -bool Parser::get_substitute_entities() const +bool Parser::get_substitute_entities() const noexcept { return pimpl_->substitute_entities_; } -void Parser::set_throw_messages(bool val) +void Parser::set_throw_messages(bool val) noexcept { pimpl_->throw_messages_ = val; } -bool Parser::get_throw_messages() const +bool Parser::get_throw_messages() const noexcept { return pimpl_->throw_messages_; } -void Parser::set_include_default_attributes(bool val) +void Parser::set_include_default_attributes(bool val) noexcept { pimpl_->include_default_attributes_ = val; } -bool Parser::get_include_default_attributes() +bool Parser::get_include_default_attributes() noexcept { return pimpl_->include_default_attributes_; } -void Parser::set_parser_options(int set_options, int clear_options) +void Parser::set_parser_options(int set_options, int clear_options) noexcept { pimpl_->set_options_ = set_options; pimpl_->clear_options_ = clear_options; } -void Parser::get_parser_options(int& set_options, int& clear_options) +void Parser::get_parser_options(int& set_options, int& clear_options) noexcept { set_options = pimpl_->set_options_; clear_options = pimpl_->clear_options_; diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index d2953420..fabbf80a 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -43,24 +43,24 @@ class Parser : public NonCopyable /** By default, the parser will not validate the XML file. * @param val Whether the document should be validated. */ - void set_validate(bool val = true); + void set_validate(bool val = true) noexcept; /** See set_validate(). * @returns Whether the parser will validate the XML file. */ - bool get_validate() const; + bool get_validate() const noexcept; /** Set whether the parser will automatically substitute entity references with the text of the entities' definitions. * For instance, this affects the text returned by ContentNode::get_content(). * By default, the parser will not substitute entities, so that you do not lose the entity reference information. * @param val Whether entities will be substitued. */ - void set_substitute_entities(bool val = true); + void set_substitute_entities(bool val = true) noexcept; /** See set_substitute_entities(). * @returns Whether entities will be substituted during parsing. */ - bool get_substitute_entities() const; + bool get_substitute_entities() const noexcept; /** Set whether the parser will collect and throw error and warning messages. * @@ -84,7 +84,7 @@ class Parser : public NonCopyable * * @param val Whether messages will be collected and thrown in an exception. */ - void set_throw_messages(bool val = true); + void set_throw_messages(bool val = true) noexcept; /** See set_throw_messages(). * @@ -92,7 +92,7 @@ class Parser : public NonCopyable * * @returns Whether messages will be collected and thrown in an exception. */ - bool get_throw_messages() const; + bool get_throw_messages() const noexcept; /** Set whether default attribute values from the DTD shall be included in the node tree. * If set, attributes not assigned a value in the XML file, but with a default value @@ -104,7 +104,7 @@ class Parser : public NonCopyable * * @param val Whether attributes with default values will be included in the node tree. */ - void set_include_default_attributes(bool val = true); + void set_include_default_attributes(bool val = true) noexcept; /** See set_include_default_attributes(). * @@ -112,7 +112,7 @@ class Parser : public NonCopyable * * @returns Whether attributes with default values will be included in the node tree. */ - bool get_include_default_attributes(); + bool get_include_default_attributes() noexcept; /** Set and/or clear parser option flags. * See the libxml2 documentation, enum xmlParserOption, for a list of parser options. @@ -126,7 +126,7 @@ class Parser : public NonCopyable * @param clear_options Set bits correspond to flags that shall be cleared during parsing. * Bits that are set in neither @a set_options nor @a clear_options are not affected. */ - void set_parser_options(int set_options = 0, int clear_options = 0); + void set_parser_options(int set_options = 0, int clear_options = 0) noexcept; /** See set_parser_options(). * @@ -136,7 +136,7 @@ class Parser : public NonCopyable * @param [out] clear_options Set bits correspond to flags that shall be cleared during parsing. * Bits that are set in neither @a set_options nor @a clear_options are not affected. */ - void get_parser_options(int& set_options, int& clear_options); + void get_parser_options(int& set_options, int& clear_options) noexcept; /** Parse an XML document from a file. * @throw exception diff --git a/libxml++/relaxngschema.cc b/libxml++/relaxngschema.cc index 36a65b9a..4e44f417 100644 --- a/libxml++/relaxngschema.cc +++ b/libxml++/relaxngschema.cc @@ -31,7 +31,7 @@ namespace class RelaxNGSchemaParserContextHolder { public: - RelaxNGSchemaParserContextHolder(xmlRelaxNGParserCtxtPtr ctx): ctx_(ctx) {} + RelaxNGSchemaParserContextHolder(xmlRelaxNGParserCtxtPtr ctx) noexcept : ctx_(ctx) {} ~RelaxNGSchemaParserContextHolder() { if (ctx_) xmlRelaxNGFreeParserCtxt(ctx_); } private: @@ -44,7 +44,7 @@ namespace xmlpp struct RelaxNGSchema::Impl { - Impl() : schema(nullptr) {} + Impl() noexcept : schema(nullptr) {} _xmlRelaxNG* schema; }; @@ -112,12 +112,12 @@ void RelaxNGSchema::parse_context(_xmlRelaxNGParserCtxt* context) throw parse_error("RelaxNGSchema::parse_context(): Schema could not be parsed.\n" + format_xml_error()); } -_xmlRelaxNG* RelaxNGSchema::cobj() +_xmlRelaxNG* RelaxNGSchema::cobj() noexcept { return pimpl_->schema; } -const _xmlRelaxNG* RelaxNGSchema::cobj() const +const _xmlRelaxNG* RelaxNGSchema::cobj() const noexcept { return pimpl_->schema; } diff --git a/libxml++/relaxngschema.h b/libxml++/relaxngschema.h index b658cfd7..b18e3594 100644 --- a/libxml++/relaxngschema.h +++ b/libxml++/relaxngschema.h @@ -94,10 +94,10 @@ class RelaxNGSchema : public SchemaBase void parse_document(const Document* document) override; /** Access the underlying libxml implementation. */ - _xmlRelaxNG* cobj(); + _xmlRelaxNG* cobj() noexcept; /** Access the underlying libxml implementation. */ - const _xmlRelaxNG* cobj() const; + const _xmlRelaxNG* cobj() const noexcept; protected: void release_underlying(); diff --git a/libxml++/schemabase.cc b/libxml++/schemabase.cc index 02eb660c..aec357b5 100644 --- a/libxml++/schemabase.cc +++ b/libxml++/schemabase.cc @@ -21,7 +21,7 @@ namespace xmlpp { -SchemaBase::SchemaBase() +SchemaBase::SchemaBase() noexcept { } diff --git a/libxml++/schemabase.h b/libxml++/schemabase.h index c7330b26..6ea2bddb 100644 --- a/libxml++/schemabase.h +++ b/libxml++/schemabase.h @@ -38,7 +38,7 @@ class Document; class SchemaBase : public NonCopyable { public: - SchemaBase(); + SchemaBase() noexcept; ~SchemaBase() override; /** Parse a schema definition file. diff --git a/libxml++/validators/dtdvalidator.cc b/libxml++/validators/dtdvalidator.cc index 27560de8..7ae5c994 100644 --- a/libxml++/validators/dtdvalidator.cc +++ b/libxml++/validators/dtdvalidator.cc @@ -23,7 +23,7 @@ namespace xmlpp struct DtdValidator::Impl { - Impl() : dtd(nullptr), is_dtd_owner(false), context(nullptr) {} + Impl() noexcept : dtd(nullptr), is_dtd_owner(false), context(nullptr) {} Dtd* dtd; bool is_dtd_owner; @@ -130,12 +130,12 @@ DtdValidator::operator bool() const noexcept return pimpl_->dtd && pimpl_->dtd->cobj(); } -Dtd* DtdValidator::get_dtd() +Dtd* DtdValidator::get_dtd() noexcept { return pimpl_->dtd; } -const Dtd* DtdValidator::get_dtd() const +const Dtd* DtdValidator::get_dtd() const noexcept { return pimpl_->dtd; } diff --git a/libxml++/validators/dtdvalidator.h b/libxml++/validators/dtdvalidator.h index e8b841b4..338005b3 100644 --- a/libxml++/validators/dtdvalidator.h +++ b/libxml++/validators/dtdvalidator.h @@ -105,12 +105,12 @@ class DtdValidator : public Validator /** Get the parsed DTD. * @returns A pointer to the parsed DTD, or nullptr. */ - Dtd* get_dtd(); + Dtd* get_dtd() noexcept; /** Get the parsed DTD. * @returns A pointer to the parsed DTD, or nullptr. */ - const Dtd* get_dtd() const; + const Dtd* get_dtd() const noexcept; /** Validate a document, using a previously parsed DTD. * The internal subset (if present) is de-coupled (i.e. not used), diff --git a/libxml++/validators/relaxngvalidator.cc b/libxml++/validators/relaxngvalidator.cc index 4b7a58fe..392a4cf1 100644 --- a/libxml++/validators/relaxngvalidator.cc +++ b/libxml++/validators/relaxngvalidator.cc @@ -29,7 +29,7 @@ namespace xmlpp struct RelaxNGValidator::Impl { - Impl() : schema(nullptr), is_schema_owner(false), context(nullptr) {} + Impl() noexcept : schema(nullptr), is_schema_owner(false), context(nullptr) {} RelaxNGSchema* schema; bool is_schema_owner; @@ -107,12 +107,12 @@ void RelaxNGValidator::release_underlying() SchemaValidatorBase::release_underlying(); } -RelaxNGSchema* RelaxNGValidator::get_schema() +RelaxNGSchema* RelaxNGValidator::get_schema() noexcept { return pimpl_->schema; } -const RelaxNGSchema* RelaxNGValidator::get_schema() const +const RelaxNGSchema* RelaxNGValidator::get_schema() const noexcept { return pimpl_->schema; } diff --git a/libxml++/validators/relaxngvalidator.h b/libxml++/validators/relaxngvalidator.h index e67b6b56..0e37852b 100644 --- a/libxml++/validators/relaxngvalidator.h +++ b/libxml++/validators/relaxngvalidator.h @@ -125,12 +125,12 @@ class RelaxNGValidator : public SchemaValidatorBase /** Get the schema. * @returns A pointer to the schema, or nullptr. */ - RelaxNGSchema* get_schema(); + RelaxNGSchema* get_schema() noexcept; /** Get the schema. * @returns A pointer to the schema, or nullptr. */ - const RelaxNGSchema* get_schema() const; + const RelaxNGSchema* get_schema() const noexcept; /** Validate a document, using a previously parsed schema. * @param document Pointer to the document. diff --git a/libxml++/validators/schemavalidatorbase.cc b/libxml++/validators/schemavalidatorbase.cc index f2824522..bbd1898a 100644 --- a/libxml++/validators/schemavalidatorbase.cc +++ b/libxml++/validators/schemavalidatorbase.cc @@ -22,7 +22,7 @@ namespace xmlpp { -SchemaValidatorBase::SchemaValidatorBase() +SchemaValidatorBase::SchemaValidatorBase() noexcept { } diff --git a/libxml++/validators/schemavalidatorbase.h b/libxml++/validators/schemavalidatorbase.h index bc7b315a..104fda76 100644 --- a/libxml++/validators/schemavalidatorbase.h +++ b/libxml++/validators/schemavalidatorbase.h @@ -37,7 +37,7 @@ class Document; class SchemaValidatorBase : public Validator { public: - SchemaValidatorBase(); + SchemaValidatorBase() noexcept; ~SchemaValidatorBase() override; /** Parse a schema definition file. diff --git a/libxml++/validators/validator.cc b/libxml++/validators/validator.cc index e91a2f6f..ec449945 100644 --- a/libxml++/validators/validator.cc +++ b/libxml++/validators/validator.cc @@ -15,7 +15,7 @@ namespace xmlpp { -Validator::Validator() +Validator::Validator() noexcept : exception_(nullptr) { } diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index ed324608..32ed3fcc 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -31,7 +31,7 @@ class Document; class Validator : public NonCopyable { public: - Validator(); + Validator() noexcept; ~Validator() override; /** Parse a schema definition file or an external subset (DTD file). diff --git a/libxml++/validators/xsdvalidator.cc b/libxml++/validators/xsdvalidator.cc index cc26d07f..b399db42 100644 --- a/libxml++/validators/xsdvalidator.cc +++ b/libxml++/validators/xsdvalidator.cc @@ -26,7 +26,7 @@ namespace xmlpp struct XsdValidator::Impl { - Impl() : schema(nullptr), is_schema_owner(false), context(nullptr) {} + Impl() noexcept : schema(nullptr), is_schema_owner(false), context(nullptr) {} XsdSchema* schema; bool is_schema_owner; @@ -104,12 +104,12 @@ void XsdValidator::release_underlying() SchemaValidatorBase::release_underlying(); } -XsdSchema* XsdValidator::get_schema() +XsdSchema* XsdValidator::get_schema() noexcept { return pimpl_->schema; } -const XsdSchema* XsdValidator::get_schema() const +const XsdSchema* XsdValidator::get_schema() const noexcept { return pimpl_->schema; } diff --git a/libxml++/validators/xsdvalidator.h b/libxml++/validators/xsdvalidator.h index c012f41e..71d23cf6 100644 --- a/libxml++/validators/xsdvalidator.h +++ b/libxml++/validators/xsdvalidator.h @@ -116,12 +116,12 @@ class XsdValidator : public SchemaValidatorBase /** Get the schema. * @returns A pointer to the schema, or nullptr. */ - XsdSchema* get_schema(); + XsdSchema* get_schema() noexcept; /** Get the schema. * @returns A pointer to the schema, or nullptr. */ - const XsdSchema* get_schema() const; + const XsdSchema* get_schema() const noexcept; /** Validate a document, using a previously parsed schema. * @param document Pointer to the document. diff --git a/libxml++/xsdschema.cc b/libxml++/xsdschema.cc index 2357e87d..c91ef375 100644 --- a/libxml++/xsdschema.cc +++ b/libxml++/xsdschema.cc @@ -29,7 +29,7 @@ namespace class XsdSchemaParserContextHolder { public: - XsdSchemaParserContextHolder(xmlSchemaParserCtxtPtr ctx): ctx_(ctx) {} + XsdSchemaParserContextHolder(xmlSchemaParserCtxtPtr ctx) noexcept : ctx_(ctx) {} ~XsdSchemaParserContextHolder() { if (ctx_) xmlSchemaFreeParserCtxt(ctx_); } private: @@ -42,7 +42,7 @@ namespace xmlpp struct XsdSchema::Impl { - Impl() : schema(nullptr), document(nullptr) {} + Impl() noexcept : schema(nullptr), document(nullptr) {} _xmlSchema* schema; _xmlDoc* document; @@ -122,12 +122,12 @@ void XsdSchema::parse_context(_xmlSchemaParserCtxt* context) } } -_xmlSchema* XsdSchema::cobj() +_xmlSchema* XsdSchema::cobj() noexcept { return pimpl_->schema; } -const _xmlSchema* XsdSchema::cobj() const +const _xmlSchema* XsdSchema::cobj() const noexcept { return pimpl_->schema; } diff --git a/libxml++/xsdschema.h b/libxml++/xsdschema.h index 2c26c11b..9d865269 100644 --- a/libxml++/xsdschema.h +++ b/libxml++/xsdschema.h @@ -85,10 +85,10 @@ class XsdSchema : public SchemaBase void parse_document(const Document* document) override; /** Access the underlying libxml implementation. */ - _xmlSchema* cobj(); + _xmlSchema* cobj() noexcept; /** Access the underlying libxml implementation. */ - const _xmlSchema* cobj() const; + const _xmlSchema* cobj() const noexcept; protected: void release_underlying(); From 4b814b35ee69e35bb39f210fb62cc727e6dfb907 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 7 Jan 2016 09:53:23 +0100 Subject: [PATCH 045/240] NonCopyable: Make it obvious that it can't be moved Declare the move operators deleted. They are deleted anyway, but this makes it obvious. --- libxml++/noncopyable.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libxml++/noncopyable.h b/libxml++/noncopyable.h index 81920c8b..244c7e0e 100644 --- a/libxml++/noncopyable.h +++ b/libxml++/noncopyable.h @@ -11,8 +11,7 @@ namespace xmlpp { -/** - * A base for classes which cannot be copied. +/** A base for classes which cannot be copied or moved. */ class NonCopyable { @@ -22,6 +21,8 @@ class NonCopyable NonCopyable(const NonCopyable&) = delete; NonCopyable& operator=(const NonCopyable&) = delete; + NonCopyable(NonCopyable&&) = delete; + NonCopyable& operator=(NonCopyable&&) = delete; }; } // namespace xmlpp From fa1ca3e3a02d78edcd0269fe9cde629af9a9af27 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 7 Jan 2016 09:54:14 +0100 Subject: [PATCH 046/240] Document: Test for nullptr in a constructor In Document(_xmlDoc* doc), throw an exception if doc==nullptr. --- libxml++/document.cc | 3 +++ libxml++/document.h | 1 + 2 files changed, 4 insertions(+) diff --git a/libxml++/document.cc b/libxml++/document.cc index be1ed2f4..acd1fe3f 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -179,6 +179,9 @@ Document::Document(const Glib::ustring& version) Document::Document(xmlDoc* doc) : impl_(doc) { + if (!impl_) + throw internal_error("xmlDoc pointer cannot be nullptr"); + impl_->_private = this; } diff --git a/libxml++/document.h b/libxml++/document.h index 90ffaa41..5d4ba601 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -85,6 +85,7 @@ class Document : public NonCopyable * The created xmlpp::Document takes ownership of the xmlDoc. * When the Document is deleted, so is the xmlDoc and all its nodes. * @param doc A pointer to an xmlDoc struct. Must not be nullptr. + * @throws xmlpp::internal_error If @a doc is nullptr. */ explicit Document(_xmlDoc* doc); From 5bf18a2f6c3f9f325e0c55392f2a1bf05840a48a Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 7 Jan 2016 09:54:47 +0100 Subject: [PATCH 047/240] DomParser: Make operator bool() explicit --- libxml++/parsers/domparser.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index df7ea23b..d40bce6c 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -76,7 +76,7 @@ class DomParser : public Parser /** Test whether a document has been parsed. */ - operator bool() const noexcept; + explicit operator bool() const noexcept; /** Get the parsed document. * @returns A pointer to the parsed document, or nullptr. From f21bcf61808fb8bad96575f8eb47cbc29729d5b6 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 12 Jan 2016 10:11:36 +0100 Subject: [PATCH 048/240] 2.91.3 --- NEWS | 14 ++++++++++++++ configure.ac | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index fc6d7b12..5c3c05c5 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,17 @@ +2.91.3 (unstable): + +* Element: Remove a redundant nullptr check + (Renu Tyagi) Bug #757515 + +* Use scoped enums (enum class) instead of unscoped enums +* Document: Test for nullptr in a constructor +* DomParser: Make operator bool() explicit + (Kjell Ahlstedt) + +* The ABI and API are not identical to libxml++ 2.91.2. + There may be more changes in ABI and/or API before the first stable + libxml++-3.0 release. + 2.91.2 (unstable): * Remove the preprocessor constant LIBXMLCPP_EXCEPTIONS_ENABLED. diff --git a/configure.ac b/configure.ac index a24a9b7d..643e5853 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [2.91.2], +AC_INIT([libxml++], [2.91.3], [https://bugzilla.gnome.org/enter_bug.cgi?product=libxml%2B%2B], [libxml++], [http://libxmlplusplus.sourceforge.net/]) AC_PREREQ([2.59]) From b00485947e4eefddcd8db956f9b97777b91263a6 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 2 Feb 2016 12:42:07 +0100 Subject: [PATCH 049/240] 3.0.0 --- NEWS | 13 +++++++++++++ configure.ac | 7 +++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 5c3c05c5..53660d3a 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,16 @@ +3.0.0 (stable): + +* This is the first stable release of libxml++-3.0. ABI and API are + incompatible with libxml++-2.6. These two series of libxml++ can be + installed in parallel. + Applications that want to upgrade from libxml++-2.6 to libxml++-3.0 + must change their pkg-config check to libxml++-3.0. + (Kjell Ahlstedt) Bug #754673. + +* This release is identical to the unstable 2.91.3, except for the so name, + which has now been bumped. + (Kjell Ahlstedt) Bug #760574 (Dominique Leuenberger) + 2.91.3 (unstable): * Element: Remove a redundant nullptr check diff --git a/configure.ac b/configure.ac index 643e5853..ba7c0ea5 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [2.91.3], +AC_INIT([libxml++], [3.0.0], [https://bugzilla.gnome.org/enter_bug.cgi?product=libxml%2B%2B], [libxml++], [http://libxmlplusplus.sourceforge.net/]) AC_PREREQ([2.59]) @@ -23,10 +23,9 @@ MM_INIT_MODULE([libxml++-3.0]) # so we can dist them to avoid a tarball-build dependency. MM_CONFIG_DOCTOOL_DIR([docs]) -# libxml++ does not use libtool's versioning system. -# Let LIBXMLXX_SO_VERSION remain equal to 0:0:0. +# Library version (so version) [current:revision:age] # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html -AC_SUBST([LIBXMLXX_SO_VERSION], [0:0:0]) +AC_SUBST([LIBXMLXX_SO_VERSION], [1:0:0]) AC_PROG_CXX MM_AX_CXX_COMPILE_STDCXX_11([noext],[mandatory]) From c75f521cefe1d6ded3e6d67397ecbbdde2ce3b48 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 6 Jul 2016 16:14:52 +0200 Subject: [PATCH 050/240] Element::remove_attribute(): Delete the C++ wrapper * libxml++/nodes/element.cc: Call Node::free_wrappers() before the call to xmlUnsetProp() or xmlUnsetNsProp(). Bug #768404. Based on a patch by Harald Schmalzl --- libxml++/nodes/element.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc index d3d3dd81..979b1db5 100644 --- a/libxml++/nodes/element.cc +++ b/libxml++/nodes/element.cc @@ -133,13 +133,35 @@ Attribute* Element::set_attribute(const Glib::ustring& name, const Glib::ustring void Element::remove_attribute(const Glib::ustring& name, const Glib::ustring& ns_prefix) { + // xmlHasProp() seaches for an attribute with a specified name in any namespace. + // Not useful here. + // xmlHasNsProp() seaches both for an attribute node in the element node + // and for an attribute declaration in the DTD. + // xmlUnsetProp() or xmlUnsetNsProp() won't delete an attribute declaration. + auto attr = xmlHasNsProp(cobj(), (const xmlChar*)name.c_str(), + ns_prefix.empty() ? nullptr : (const xmlChar*)ns_prefix.c_str()); + if (!attr || attr->type == XML_ATTRIBUTE_DECL) + return; + if (ns_prefix.empty()) + { + // *this has an attribute with the specified name and no namespace. + // xmlUnsetProp() will delete the existing attribute. + // Delete the C++ wrapper before the call to xmlUnsetProp(). + Node::free_wrappers(reinterpret_cast(attr)); xmlUnsetProp(cobj(), (const xmlChar*)name.c_str()); + } else { auto ns = xmlSearchNs(cobj()->doc, cobj(), (const xmlChar*)ns_prefix.c_str()); if (ns) + { + // *this has an attribute with the specified name and namespace. + // xmlUnsetNsProp() will delete the existing attribute. + // Delete the C++ wrapper before the call to xmlUnsetNsProp(). + Node::free_wrappers(reinterpret_cast(attr)); xmlUnsetNsProp(cobj(), ns, (const xmlChar*)name.c_str()); + } } } From d75d8ec4b2fd268aab807c9671c9da25d6c55335 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 6 Jul 2016 18:36:46 +0200 Subject: [PATCH 051/240] Docs: Suppress some links generated by Doxygen --- libxml++/attribute.h | 2 +- libxml++/attributedeclaration.h | 2 +- libxml++/attributenode.h | 2 +- libxml++/dtd.h | 2 +- libxml++/nodes/commentnode.h | 2 +- libxml++/nodes/contentnode.h | 2 +- libxml++/nodes/element.h | 3 ++- libxml++/nodes/textnode.h | 2 +- libxml++/nodes/xincludeend.h | 2 +- libxml++/nodes/xincludestart.h | 2 +- libxml++/parsers/domparser.h | 2 +- libxml++/validators/dtdvalidator.h | 2 +- 12 files changed, 13 insertions(+), 12 deletions(-) diff --git a/libxml++/attribute.h b/libxml++/attribute.h index 8ac9155f..01c46238 100644 --- a/libxml++/attribute.h +++ b/libxml++/attribute.h @@ -15,7 +15,7 @@ namespace xmlpp { -/** Represents an XML Node attribute. +/** Represents an XML attribute node or attribute declaration. * This will be instantiated by the parser. */ class Attribute : public Node diff --git a/libxml++/attributedeclaration.h b/libxml++/attributedeclaration.h index 6a9d986f..50448966 100644 --- a/libxml++/attributedeclaration.h +++ b/libxml++/attributedeclaration.h @@ -20,7 +20,7 @@ extern "C" { namespace xmlpp { -/** Represents the default value of an attribute of an XML Element node. +/** Represents the default value of an attribute of an XML element node. * This will be instantiated by the parser. * * @newin{2,36} diff --git a/libxml++/attributenode.h b/libxml++/attributenode.h index 68dada4f..af6c4c58 100644 --- a/libxml++/attributenode.h +++ b/libxml++/attributenode.h @@ -21,7 +21,7 @@ extern "C" { namespace xmlpp { -/** Represents an explicit attribute of an XML Element node. +/** Represents an explicit attribute of an XML element node. * This will be instantiated by the parser. * * @newin{2,36} diff --git a/libxml++/dtd.h b/libxml++/dtd.h index 1686777a..32ee21b8 100644 --- a/libxml++/dtd.h +++ b/libxml++/dtd.h @@ -25,7 +25,7 @@ namespace xmlpp // See https://bugzilla.gnome.org/show_bug.cgi?id=754673#c8 for an explanation // why it has not been done in libxml++ 3.0. /** Represents an XML DTD for validating XML files. - * DTD = Document Type Definition + * DTD = %Document Type Definition */ class Dtd : public NonCopyable { diff --git a/libxml++/nodes/commentnode.h b/libxml++/nodes/commentnode.h index 1dbcbe1c..bed857d6 100644 --- a/libxml++/nodes/commentnode.h +++ b/libxml++/nodes/commentnode.h @@ -12,7 +12,7 @@ namespace xmlpp { -/** Comment Node. This will be instantiated by the parser. +/** Comment node. This will be instantiated by the parser. */ class CommentNode : public ContentNode { diff --git a/libxml++/nodes/contentnode.h b/libxml++/nodes/contentnode.h index 592f57f0..20ffaad3 100644 --- a/libxml++/nodes/contentnode.h +++ b/libxml++/nodes/contentnode.h @@ -12,7 +12,7 @@ namespace xmlpp { -/** Content Node. This will be instantiated by the parser. +/** Content node. This will be instantiated by the parser. */ class ContentNode : public Node { diff --git a/libxml++/nodes/element.h b/libxml++/nodes/element.h index e29264b6..326df912 100644 --- a/libxml++/nodes/element.h +++ b/libxml++/nodes/element.h @@ -18,7 +18,8 @@ namespace xmlpp { -/** Element nodes have attributes as well as child nodes. This will be instantiated by the parser. +/** %Element nodes have attributes as well as child nodes. + * This will be instantiated by the parser. */ class Element : public Node { diff --git a/libxml++/nodes/textnode.h b/libxml++/nodes/textnode.h index b88f8bed..4348887a 100644 --- a/libxml++/nodes/textnode.h +++ b/libxml++/nodes/textnode.h @@ -12,7 +12,7 @@ namespace xmlpp { -/** Text Node. This will be instantiated by the parser. +/** Text node. This will be instantiated by the parser. */ class TextNode : public ContentNode { diff --git a/libxml++/nodes/xincludeend.h b/libxml++/nodes/xincludeend.h index 3b71b2da..2f12a58d 100644 --- a/libxml++/nodes/xincludeend.h +++ b/libxml++/nodes/xincludeend.h @@ -24,7 +24,7 @@ namespace xmlpp { -/** XIncludeEnd node. +/** %XIncludeEnd node. * This will be instantiated by xmlpp::Document::process_xinclude(). * * @newin{2,36} diff --git a/libxml++/nodes/xincludestart.h b/libxml++/nodes/xincludestart.h index d11c47f5..f02de808 100644 --- a/libxml++/nodes/xincludestart.h +++ b/libxml++/nodes/xincludestart.h @@ -24,7 +24,7 @@ namespace xmlpp { -/** XIncludeStart node. +/** %XIncludeStart node. * This will be instantiated by xmlpp::Document::process_xinclude(). * * @newin{2,36} diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index d40bce6c..046355d7 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -13,7 +13,7 @@ namespace xmlpp { /** DOM XML parser. - * DOM = Document Object Model + * DOM = %Document Object Model */ class DomParser : public Parser { diff --git a/libxml++/validators/dtdvalidator.h b/libxml++/validators/dtdvalidator.h index 338005b3..69a371fd 100644 --- a/libxml++/validators/dtdvalidator.h +++ b/libxml++/validators/dtdvalidator.h @@ -15,7 +15,7 @@ namespace xmlpp { /** XML DTD validator. - * DTD = Document Type Definition + * DTD = %Document Type Definition */ class DtdValidator : public Validator { From 3d26a7b09b250c2f2d2b95d03106e46f8c613f95 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 18 Jul 2016 15:12:00 +0200 Subject: [PATCH 052/240] Build: Fix silent builds * configure.ac: Pass yes to AM_SILENT_RULES, thus enabling silent builds. Replace MM_AX_CXX_COMPILE_STDCXX_11 by MM_AX_CXX_COMPILE_STDCXX (not necessary for silent builds). * docs/reference/Doxyfile.in: Set QUIET=YES. Update for doxygen 1.8.11 (not necessary for silent builds). Bug #768797 --- configure.ac | 6 ++++-- docs/reference/Doxyfile.in | 9 +++++++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index ba7c0ea5..40fc5af0 100644 --- a/configure.ac +++ b/configure.ac @@ -11,7 +11,9 @@ AC_CONFIG_MACRO_DIR([build]) AC_CONFIG_HEADERS([config.h libxml++config.h]) AM_INIT_AUTOMAKE([1.9 -Wno-portability dist-bzip2 no-define nostdinc subdir-objects]) -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES]) +# Support silent build rules. +# Disable by either passing --disable-silent-rules to configure or passing V=1 to make. +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AM_MAINTAINER_MODE([disable]) AC_ARG_VAR([ACLOCAL_FLAGS], [aclocal flags, e.g. -I ]) @@ -28,7 +30,7 @@ MM_CONFIG_DOCTOOL_DIR([docs]) AC_SUBST([LIBXMLXX_SO_VERSION], [1:0:0]) AC_PROG_CXX -MM_AX_CXX_COMPILE_STDCXX_11([noext],[mandatory]) +MM_AX_CXX_COMPILE_STDCXX([11], [noext],[mandatory]) LT_PREREQ([2.2.6]) LT_INIT([dlopen win32-dll disable-static]) diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in index 87fd6b58..b0aee117 100644 --- a/docs/reference/Doxyfile.in +++ b/docs/reference/Doxyfile.in @@ -1,4 +1,4 @@ -# Doxyfile 1.8.9.1 +# Doxyfile 1.8.11 # @configure_input@ #--------------------------------------------------------------------------- @@ -47,6 +47,7 @@ CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO IDL_PROPERTY_SUPPORT = YES DISTRIBUTE_GROUP_DOC = NO +GROUP_NESTED_COMPOUNDS = NO SUBGROUPING = YES INLINE_GROUPED_CLASSES = NO INLINE_SIMPLE_STRUCTS = NO @@ -95,11 +96,12 @@ CITE_BIB_FILES = #--------------------------------------------------------------------------- # Configuration options related to warning and progress messages #--------------------------------------------------------------------------- -QUIET = NO +QUIET = YES WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO +WARN_AS_ERROR = NO WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = reference/doxygen.log #--------------------------------------------------------------------------- @@ -143,6 +145,8 @@ REFERENCES_LINK_SOURCE = YES SOURCE_TOOLTIPS = YES USE_HTAGS = NO VERBATIM_HEADERS = NO +CLANG_ASSISTED_PARSING = NO +CLANG_OPTIONS = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- @@ -227,6 +231,7 @@ LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO LATEX_SOURCE_CODE = NO LATEX_BIB_STYLE = plain +LATEX_TIMESTAMP = NO #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- From 1583a494ea59ea1c595e62de0f5d583e8736eb61 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 18 Jul 2016 16:01:07 +0200 Subject: [PATCH 053/240] Fix even more silent 'make check' * examples/Makefile.am: Add $(AM_V_GEN) and $(AM_V_at) to 'echo' commands. Bug #768797 --- examples/Makefile.am | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/Makefile.am b/examples/Makefile.am index f73e2850..4fc3d732 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -153,18 +153,18 @@ dist_noinst_DATA = \ # Here it's necessary to specify parameters when the input file and the output # file are located in different directories. dom_read_write/make_check.sh: Makefile - echo '# Generated and used by "make check"' >$@ - echo 'dom_read_write/dom_read_write "$(srcdir)/dom_read_write/example.xml" dom_read_write/example_output.xml >/dev/null' >>$@ - chmod +x $@ + $(AM_V_GEN)echo '# Generated and used by "make check"' >$@ + $(AM_V_at)echo 'dom_read_write/dom_read_write "$(srcdir)/dom_read_write/example.xml" dom_read_write/example_output.xml >/dev/null' >>$@ + $(AM_V_at)chmod +x $@ script_template = cd "$(srcdir)/" && "$(abs_builddir)//" >/dev/null standard_scripts = $(filter-out dom_read_write/make_check.sh,$(check_SCRIPTS)) # All other script files are generated like so: $(standard_scripts): Makefile - echo '# Generated and used by "make check"' >$@ - echo '$(subst ,$(subst /make_check.sh,,$@),$(script_template))' >>$@ - chmod +x $@ + $(AM_V_GEN)echo '# Generated and used by "make check"' >$@ + $(AM_V_at)echo '$(subst ,$(subst /make_check.sh,,$@),$(script_template))' >>$@ + $(AM_V_at)chmod +x $@ CLEANFILES = \ dom_read_write/example_output.xml \ From 036f6301be396f7797922be27547037f47bee5c5 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 18 Jul 2016 16:35:08 +0200 Subject: [PATCH 054/240] Require mm-common 0.9.10 Necessary when MM_AX_CXX_COMPILE_STDCXX is used in configure.ac. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 40fc5af0..a525863d 100644 --- a/configure.ac +++ b/configure.ac @@ -17,7 +17,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) AM_MAINTAINER_MODE([disable]) AC_ARG_VAR([ACLOCAL_FLAGS], [aclocal flags, e.g. -I ]) -MM_PREREQ([0.9.8]) +MM_PREREQ([0.9.10]) MM_INIT_MODULE([libxml++-3.0]) # Tell mm-common-prepare to copy the mm-common .pl scripts From 61dfaacbad1459fe0248dc04b4e7d87a93044ace Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 27 Oct 2016 20:59:38 +0200 Subject: [PATCH 055/240] Doxyfile.in: Remove now-unsupported Doxygen tags. --- docs/reference/Doxyfile.in | 3 --- 1 file changed, 3 deletions(-) diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in index b0aee117..bd291170 100644 --- a/docs/reference/Doxyfile.in +++ b/docs/reference/Doxyfile.in @@ -47,7 +47,6 @@ CPP_CLI_SUPPORT = NO SIP_SUPPORT = NO IDL_PROPERTY_SUPPORT = YES DISTRIBUTE_GROUP_DOC = NO -GROUP_NESTED_COMPOUNDS = NO SUBGROUPING = YES INLINE_GROUPED_CLASSES = NO INLINE_SIMPLE_STRUCTS = NO @@ -101,7 +100,6 @@ WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = NO -WARN_AS_ERROR = NO WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = reference/doxygen.log #--------------------------------------------------------------------------- @@ -231,7 +229,6 @@ LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO LATEX_SOURCE_CODE = NO LATEX_BIB_STYLE = plain -LATEX_TIMESTAMP = NO #--------------------------------------------------------------------------- # Configuration options related to the RTF output #--------------------------------------------------------------------------- From 18b9537c1cff64814ada8217e0c4b88ca5cb847c Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Mon, 14 Nov 2016 10:57:42 +0100 Subject: [PATCH 056/240] 3.0.1 --- NEWS | 5 +++++ configure.ac | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 53660d3a..b640e309 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +3.0.1 (stable): + +* Element::remove_attribute(): Delete the C++ wrapper + (Harald Schmalzl, Kjell Ahlstedt) Bug #768404. + 3.0.0 (stable): * This is the first stable release of libxml++-3.0. ABI and API are diff --git a/configure.ac b/configure.ac index a525863d..998ad18d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [3.0.0], +AC_INIT([libxml++], [3.0.1], [https://bugzilla.gnome.org/enter_bug.cgi?product=libxml%2B%2B], [libxml++], [http://libxmlplusplus.sourceforge.net/]) AC_PREREQ([2.59]) From df72c313ed1e610c2b891a3e8dcbf2b469db70a7 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Mon, 14 Nov 2016 11:09:18 +0100 Subject: [PATCH 057/240] Change the ABI to libxml++-4.0 instead of libxml++-3.0. This installs in parallel with libxml++-3.0. --- configure.ac | 2 +- docs/manual/libxml++_without_code.xml | 6 +++--- libxml++/libxml++.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 998ad18d..1686cdbb 100644 --- a/configure.ac +++ b/configure.ac @@ -18,7 +18,7 @@ AM_MAINTAINER_MODE([disable]) AC_ARG_VAR([ACLOCAL_FLAGS], [aclocal flags, e.g. -I ]) MM_PREREQ([0.9.10]) -MM_INIT_MODULE([libxml++-3.0]) +MM_INIT_MODULE([libxml++-4.0]) # Tell mm-common-prepare to copy the mm-common .pl scripts # and some other files into docs/, and use them from there, diff --git a/docs/manual/libxml++_without_code.xml b/docs/manual/libxml++_without_code.xml index 1648f9fa..9158d119 100644 --- a/docs/manual/libxml++_without_code.xml +++ b/docs/manual/libxml++_without_code.xml @@ -47,7 +47,7 @@ url="http://www.gnome.org">GNOME project, of which libxml++ is a part.
- To check that you have the libxml++ development packages installed, and that your environment is working properly, try pkg-config libxml++-3.0 --modversion. + To check that you have the libxml++ development packages installed, and that your environment is working properly, try pkg-config libxml++-4.0 --modversion. Links for downloading and more documentation can be found at libxmlplusplus.sourceforge.net. libxml++ is licensed under the LGPL, which allows its use via dynamic linking in both open source and closed-source software. The underlying libxml2 library uses the even more generous MIT licence. @@ -64,11 +64,11 @@ url="http://libxmlplusplus.sourceforge.net">libxmlplusplus.sourceforge.net Compilation and Linking To use libxml++ in your application, you must tell the compiler where to find the include headers and where to find the libxml++ library. libxml++ provides a pkg-config .pc file to make this easy. For instance, the following command will provide the necessary compiler options: - pkg-config libxml++-3.0 --cflags --libs + pkg-config libxml++-4.0 --cflags --libs When using autoconf and automake, this is even easier with the PKG_CHECK_MODULES macro in your configure.ac file. For instance: - PKG_CHECK_MODULES(SOMEAPP, libxml++-3.0 >= 3.0.0) + PKG_CHECK_MODULES(SOMEAPP, libxml++-4.0 >= 4.0.0) AC_SUBST(SOMEAPP_CFLAGS) AC_SUBST(SOMEAPP_LIBS) diff --git a/libxml++/libxml++.h b/libxml++/libxml++.h index 89cbf4e3..81d8c8be 100644 --- a/libxml++/libxml++.h +++ b/libxml++/libxml++.h @@ -33,14 +33,14 @@ * * If your source file is @c program.cc, you can compile it with: * @code - * g++ program.cc -o program `pkg-config --cflags --libs libxml++-3.0` + * g++ program.cc -o program `pkg-config --cflags --libs libxml++-4.0` * @endcode * If your version of g++ is not C++11-compliant be default, * add the @c -std=c++11 or @c -std=c++0x option. * * Alternatively, if using autoconf, use the following in @c configure.ac: * @code - * PKG_CHECK_MODULES([LIBXMLXX], [libxml++-3.0]) + * PKG_CHECK_MODULES([LIBXMLXX], [libxml++-4.0]) * @endcode * Then use the generated @c LIBXMLXX_CFLAGS and @c LIBXMLXX_LIBS variables in * the project @c Makefile.am files. For example: From c19d0c606e0525832f16d2e34942725a6c6802f8 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Mon, 14 Nov 2016 11:09:48 +0100 Subject: [PATCH 058/240] Use glibmm-2.52 instead of glibmm-2.4. --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 1686cdbb..4cc3d974 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ MM_AX_CXX_COMPILE_STDCXX([11], [noext],[mandatory]) LT_PREREQ([2.2.6]) LT_INIT([dlopen win32-dll disable-static]) -AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.4 >= 2.32.0']) +AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.52 >= 2.32.0']) PKG_CHECK_MODULES([LIBXMLXX], [$LIBXMLXX_MODULES]) AC_LANG([C++]) @@ -44,8 +44,8 @@ LIBXMLXX_CXX_HAS_EXCEPTION_PTR MM_ARG_ENABLE_DOCUMENTATION MM_ARG_WITH_TAGFILE_DOC([libstdc++.tag], [mm-common-libstdc++]) -MM_ARG_WITH_TAGFILE_DOC([libsigc++-2.0.tag], [sigc++-2.0]) -MM_ARG_WITH_TAGFILE_DOC([glibmm-2.4.tag], [glibmm-2.4]) +MM_ARG_WITH_TAGFILE_DOC([libsigc++-3.0.tag], [sigc++-3.0]) +MM_ARG_WITH_TAGFILE_DOC([glibmm-2.52.tag], [glibmm-2.52]) # Evaluate the --enable-warnings=level option. MM_ARG_ENABLE_WARNINGS([LIBXMLXX_WXXFLAGS], From dad70571da6ed2da753def4c71a66930a21c02cb Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 8 Dec 2016 11:25:59 +0100 Subject: [PATCH 059/240] Fix tiny comment typo. --- examples/sax_parser_build_dom/svgparser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sax_parser_build_dom/svgparser.cc b/examples/sax_parser_build_dom/svgparser.cc index 73980022..44bfe91a 100644 --- a/examples/sax_parser_build_dom/svgparser.cc +++ b/examples/sax_parser_build_dom/svgparser.cc @@ -80,7 +80,7 @@ void Parser::on_start_element(const Glib::ustring& name, delete element_normal; element_normal = nullptr; - // TODO: Again, this requires knowledge of the libxml++ implemenation - + // TODO: Again, this requires knowledge of the libxml++ implementation - // specifically that the base xmlpp::Node() constructor will reassociate // the underyling C instance with this new C++ instance, by seeting _private. // From c8d8f5883b1339b0c1118ca90df1e8a64c5b8029 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Mon, 12 Dec 2016 09:12:28 +0100 Subject: [PATCH 060/240] Add explicit keyword to some single-parameter constructors. Noticed by cppcheck. --- examples/dom_update_namespace/main.cc | 2 +- examples/sax_parser_build_dom/svgelement.h | 2 +- examples/sax_parser_build_dom/svggroup.h | 2 +- examples/sax_parser_build_dom/svgparser.h | 2 +- examples/sax_parser_build_dom/svgpath.h | 2 +- examples/textreader/main.cc | 2 +- libxml++/parsers/textreader.cc | 2 +- libxml++/relaxngschema.cc | 2 +- libxml++/xsdschema.cc | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/examples/dom_update_namespace/main.cc b/examples/dom_update_namespace/main.cc index ed460415..3c47a4a0 100644 --- a/examples/dom_update_namespace/main.cc +++ b/examples/dom_update_namespace/main.cc @@ -43,7 +43,7 @@ class Tests class fail_exception : public std::exception { public: - fail_exception(const std::string& msg) : msg_(msg) {} + explicit fail_exception(const std::string& msg) : msg_(msg) {} ~fail_exception() noexcept override {} const char* what() const noexcept override { return msg_.c_str(); } diff --git a/examples/sax_parser_build_dom/svgelement.h b/examples/sax_parser_build_dom/svgelement.h index 0440b144..963c0f65 100644 --- a/examples/sax_parser_build_dom/svgelement.h +++ b/examples/sax_parser_build_dom/svgelement.h @@ -32,7 +32,7 @@ class Element : public xmlpp::Element { public: - Element(xmlNode* node); + explicit Element(xmlNode* node); ~Element() override; // example custom methods diff --git a/examples/sax_parser_build_dom/svggroup.h b/examples/sax_parser_build_dom/svggroup.h index e0c6de89..3502ad4e 100644 --- a/examples/sax_parser_build_dom/svggroup.h +++ b/examples/sax_parser_build_dom/svggroup.h @@ -30,7 +30,7 @@ namespace SVG { class Group : public Element { public: - Group(xmlNode* node) + explicit Group(xmlNode* node) : Element(node) {} }; diff --git a/examples/sax_parser_build_dom/svgparser.h b/examples/sax_parser_build_dom/svgparser.h index 27ce4eac..60b591f6 100644 --- a/examples/sax_parser_build_dom/svgparser.h +++ b/examples/sax_parser_build_dom/svgparser.h @@ -31,7 +31,7 @@ namespace SVG { class Parser : public xmlpp::SaxParser { public: - Parser(xmlpp::Document& document); + explicit Parser(xmlpp::Document& document); ~Parser() override; protected: diff --git a/examples/sax_parser_build_dom/svgpath.h b/examples/sax_parser_build_dom/svgpath.h index 854e13c9..9648e204 100644 --- a/examples/sax_parser_build_dom/svgpath.h +++ b/examples/sax_parser_build_dom/svgpath.h @@ -31,7 +31,7 @@ namespace SVG { class Path : public Element { public: - Path(xmlNode* node) + explicit Path(xmlNode* node) : Element(node) {} diff --git a/examples/textreader/main.cc b/examples/textreader/main.cc index 5b97f32b..adc78e4b 100644 --- a/examples/textreader/main.cc +++ b/examples/textreader/main.cc @@ -31,7 +31,7 @@ struct indent { int depth_; - indent(int depth): depth_(depth) {}; + explicit indent(int depth): depth_(depth) {}; }; std::ostream & operator<<(std::ostream & o, indent const & in) diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc index 66958a9b..ef2f8b97 100644 --- a/libxml++/parsers/textreader.cc +++ b/libxml++/parsers/textreader.cc @@ -12,7 +12,7 @@ namespace xmlpp class TextReader::PropertyReader { public: - PropertyReader(TextReader& owner) + explicit PropertyReader(TextReader& owner) : owner_(owner) {} diff --git a/libxml++/relaxngschema.cc b/libxml++/relaxngschema.cc index 4e44f417..3804f129 100644 --- a/libxml++/relaxngschema.cc +++ b/libxml++/relaxngschema.cc @@ -31,7 +31,7 @@ namespace class RelaxNGSchemaParserContextHolder { public: - RelaxNGSchemaParserContextHolder(xmlRelaxNGParserCtxtPtr ctx) noexcept : ctx_(ctx) {} + explicit RelaxNGSchemaParserContextHolder(xmlRelaxNGParserCtxtPtr ctx) noexcept : ctx_(ctx) {} ~RelaxNGSchemaParserContextHolder() { if (ctx_) xmlRelaxNGFreeParserCtxt(ctx_); } private: diff --git a/libxml++/xsdschema.cc b/libxml++/xsdschema.cc index c91ef375..7e13f2e8 100644 --- a/libxml++/xsdschema.cc +++ b/libxml++/xsdschema.cc @@ -29,7 +29,7 @@ namespace class XsdSchemaParserContextHolder { public: - XsdSchemaParserContextHolder(xmlSchemaParserCtxtPtr ctx) noexcept : ctx_(ctx) {} + explicit XsdSchemaParserContextHolder(xmlSchemaParserCtxtPtr ctx) noexcept : ctx_(ctx) {} ~XsdSchemaParserContextHolder() { if (ctx_) xmlSchemaFreeParserCtxt(ctx_); } private: From 0fa185ae51ed0a5149fc1c02ac3a4b2f1df7cee7 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Mon, 12 Dec 2016 09:13:49 +0100 Subject: [PATCH 061/240] Replace a C-style cast with static_cast<>(). Noticed by cppcheck. --- libxml++/parsers/textreader.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc index ef2f8b97..75a2c680 100644 --- a/libxml++/parsers/textreader.cc +++ b/libxml++/parsers/textreader.cc @@ -360,7 +360,7 @@ void TextReader::setup_exceptions() void TextReader::on_libxml_error(void* arg, const char* msg, int severity, void* /* locator */) { - auto ths = (TextReader*)arg; + auto ths = static_cast(arg); ths->severity_ = severity; ths->error_ = msg ? msg : "unknown parse error"; } From df299db8fcbb2a9ea38f8f983091d5374d102031 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Mon, 12 Dec 2016 09:16:11 +0100 Subject: [PATCH 062/240] Examples: Make some methods static. Noticed by cppcheck. --- examples/dom_update_namespace/main.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/dom_update_namespace/main.cc b/examples/dom_update_namespace/main.cc index 3c47a4a0..1e350030 100644 --- a/examples/dom_update_namespace/main.cc +++ b/examples/dom_update_namespace/main.cc @@ -32,12 +32,12 @@ class Tests protected: template - void assert_equal(const RefType& reference, const ValueType& value, const std::string& msg); + static void assert_equal(const RefType& reference, const ValueType& value, const std::string& msg); template - void assert_not_equal(const RefType& reference, const ValueType& value, const std::string& msg); + static void assert_not_equal(const RefType& reference, const ValueType& value, const std::string& msg); template - void fail(const RefType& reference, const ValueType& value, const std::string& msg); + static void fail(const RefType& reference, const ValueType& value, const std::string& msg); }; class fail_exception : public std::exception From 725c03ab217d79c7b40c388ee811f7b415dc3078 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Wed, 22 Mar 2017 10:23:30 +0100 Subject: [PATCH 063/240] Use glibmm-2.54 instead of glibmm-2.52 We changed the ABI name. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 4cc3d974..097ccf75 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ MM_AX_CXX_COMPILE_STDCXX([11], [noext],[mandatory]) LT_PREREQ([2.2.6]) LT_INIT([dlopen win32-dll disable-static]) -AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.52 >= 2.32.0']) +AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.54 >= 2.32.0']) PKG_CHECK_MODULES([LIBXMLXX], [$LIBXMLXX_MODULES]) AC_LANG([C++]) @@ -45,7 +45,7 @@ LIBXMLXX_CXX_HAS_EXCEPTION_PTR MM_ARG_ENABLE_DOCUMENTATION MM_ARG_WITH_TAGFILE_DOC([libstdc++.tag], [mm-common-libstdc++]) MM_ARG_WITH_TAGFILE_DOC([libsigc++-3.0.tag], [sigc++-3.0]) -MM_ARG_WITH_TAGFILE_DOC([glibmm-2.52.tag], [glibmm-2.52]) +MM_ARG_WITH_TAGFILE_DOC([glibmm-2.54.tag], [glibmm-2.54]) # Evaluate the --enable-warnings=level option. MM_ARG_ENABLE_WARNINGS([LIBXMLXX_WXXFLAGS], From 473000172794a8e006379afa1ba8667f4c3446d2 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 3 May 2017 15:41:18 +0200 Subject: [PATCH 064/240] Parser: Make some methods const --- libxml++/parsers/parser.cc | 4 ++-- libxml++/parsers/parser.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc index ac8cc787..69c859e7 100644 --- a/libxml++/parsers/parser.cc +++ b/libxml++/parsers/parser.cc @@ -79,7 +79,7 @@ void Parser::set_include_default_attributes(bool val) noexcept pimpl_->include_default_attributes_ = val; } -bool Parser::get_include_default_attributes() noexcept +bool Parser::get_include_default_attributes() const noexcept { return pimpl_->include_default_attributes_; } @@ -90,7 +90,7 @@ void Parser::set_parser_options(int set_options, int clear_options) noexcept pimpl_->clear_options_ = clear_options; } -void Parser::get_parser_options(int& set_options, int& clear_options) noexcept +void Parser::get_parser_options(int& set_options, int& clear_options) const noexcept { set_options = pimpl_->set_options_; clear_options = pimpl_->clear_options_; diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index fabbf80a..4cc92b18 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -112,7 +112,7 @@ class Parser : public NonCopyable * * @returns Whether attributes with default values will be included in the node tree. */ - bool get_include_default_attributes() noexcept; + bool get_include_default_attributes() const noexcept; /** Set and/or clear parser option flags. * See the libxml2 documentation, enum xmlParserOption, for a list of parser options. @@ -132,11 +132,11 @@ class Parser : public NonCopyable * * @newin{2,38} * - * @param [out] set_options Set bits correspond to flags that shall be set during parsing. - * @param [out] clear_options Set bits correspond to flags that shall be cleared during parsing. + * @param[out] set_options Set bits correspond to flags that shall be set during parsing. + * @param[out] clear_options Set bits correspond to flags that shall be cleared during parsing. * Bits that are set in neither @a set_options nor @a clear_options are not affected. */ - void get_parser_options(int& set_options, int& clear_options) noexcept; + void get_parser_options(int& set_options, int& clear_options) const noexcept; /** Parse an XML document from a file. * @throw exception From f23468537f41df398c5adba6dbe057788c7c2f24 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 3 May 2017 16:15:49 +0200 Subject: [PATCH 065/240] Document, DomParser: Improve XInclude processing * examples/Makefile.am: * examples/dom_xinclude/example.xml: Changed due to moved include files. * examples/dom_xinclude/include1.txt: * examples/dom_xinclude/include2.xml: Moved to examples/dom_xinclude/xinclude/ * examples/dom_xinclude/main.cc: Test both Document::process_xinclude() and Xinclude processing with DomParser::parse_file(). * libxml++/document.[cc|h]: Add fixup_base_uris parameter to process_xinclude(). * libxml++/parsers/domparser.[cc|h]: Add set/get_xinclude_options(). Add optional XInclude processing to the parse methods. Bug 781566 --- examples/Makefile.am | 4 +- examples/dom_xinclude/example.xml | 6 +-- examples/dom_xinclude/include1.txt | 1 - examples/dom_xinclude/main.cc | 35 +++++++++--- examples/dom_xinclude/xinclude/include1.txt | 1 + .../dom_xinclude/{ => xinclude}/include2.xml | 2 +- libxml++/document.cc | 13 +++-- libxml++/document.h | 7 ++- libxml++/parsers/domparser.cc | 53 ++++++++++++++++--- libxml++/parsers/domparser.h | 27 ++++++++++ 10 files changed, 122 insertions(+), 27 deletions(-) delete mode 100644 examples/dom_xinclude/include1.txt create mode 100644 examples/dom_xinclude/xinclude/include1.txt rename examples/dom_xinclude/{ => xinclude}/include2.xml (53%) diff --git a/examples/Makefile.am b/examples/Makefile.am index 4fc3d732..5a6dfe12 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -124,8 +124,8 @@ dist_noinst_DATA = \ dom_update_namespace/example1.xml \ dom_update_namespace/example2.xml \ dom_xinclude/example.xml \ - dom_xinclude/include1.txt \ - dom_xinclude/include2.xml \ + dom_xinclude/xinclude/include1.txt \ + dom_xinclude/xinclude/include2.xml \ dom_xpath/example.xml \ dtdvalidation/example.dtd \ import_node/example1.xml \ diff --git a/examples/dom_xinclude/example.xml b/examples/dom_xinclude/example.xml index e99a4a4e..b4d8bd18 100644 --- a/examples/dom_xinclude/example.xml +++ b/examples/dom_xinclude/example.xml @@ -1,7 +1,7 @@ -

- Did not find include1.txt. +

+ Did not find xinclude/include1.txt.

- +
diff --git a/examples/dom_xinclude/include1.txt b/examples/dom_xinclude/include1.txt deleted file mode 100644 index 6683a84a..00000000 --- a/examples/dom_xinclude/include1.txt +++ /dev/null @@ -1 +0,0 @@ -This is the contents of file include1.txt. \ No newline at end of file diff --git a/examples/dom_xinclude/main.cc b/examples/dom_xinclude/main.cc index fe63c4d2..dbf87241 100644 --- a/examples/dom_xinclude/main.cc +++ b/examples/dom_xinclude/main.cc @@ -117,6 +117,7 @@ int main(int argc, char* argv[]) bool throw_messages = false; bool substitute_entities = true; bool generate_xinclude_nodes = true; + bool fixup_base_uris = true; int argi = 1; while (argc > argi && *argv[argi] == '-') // option @@ -140,13 +141,17 @@ int main(int argc, char* argv[]) case 'X': generate_xinclude_nodes = false; break; + case 'B': + fixup_base_uris = false; + break; default: - std::cout << "Usage: " << argv[0] << " [-v] [-t] [-e] [-x] [filename]" << std::endl + std::cout << "Usage: " << argv[0] << " [options]... [filename]" << std::endl << " -v Validate" << std::endl << " -t Throw messages in an exception" << std::endl << " -e Write messages to stderr" << std::endl << " -E Do not substitute entities" << std::endl - << " -X Do not generate XInclude nodes" << std::endl; + << " -X Do not generate XInclude nodes" << std::endl + << " -B Do not fix up base URIs" << std::endl; return EXIT_FAILURE; } argi++; @@ -160,8 +165,7 @@ int main(int argc, char* argv[]) try { xmlpp::DomParser parser; - if (validate) - parser.set_validate(); + parser.set_validate(validate); if (set_throw_messages) parser.set_throw_messages(throw_messages); //We can have the text resolved/unescaped automatically. @@ -174,14 +178,31 @@ int main(int argc, char* argv[]) print_node(pNode); std::cout << std::endl << ">>>>> Number of XInclude substitutions: " - << parser.get_document()->process_xinclude(generate_xinclude_nodes) + << parser.get_document()->process_xinclude( + generate_xinclude_nodes, fixup_base_uris) + << std::endl << std::endl; + + std::cout << ">>>>> After XInclude processing with xmlpp::Document::process_xinclude(): " << std::endl << std::endl; pNode = parser.get_document()->get_root_node(); print_node(pNode); + // xmlpp::Document::write_to_string() does not write XIncludeStart and + // XIncludeEnd nodes. + const auto whole = parser.get_document()->write_to_string(); + std::cout << std::endl << whole << std::endl; + } + + parser.set_xinclude_options(true, generate_xinclude_nodes, fixup_base_uris); + parser.parse_file(filepath); + if (parser) + { + std::cout << ">>>>> After XInclude processing with xmlpp::DomParser::parse_file(): " + << std::endl << std::endl; + print_node(parser.get_document()->get_root_node()); + const auto whole = parser.get_document()->write_to_string(); - std::cout << std::endl << ">>>>> XML after XInclude processing: " << std::endl - << whole << std::endl; + std::cout << std::endl << whole << std::endl; } } catch (const std::exception& ex) diff --git a/examples/dom_xinclude/xinclude/include1.txt b/examples/dom_xinclude/xinclude/include1.txt new file mode 100644 index 00000000..8484d7c3 --- /dev/null +++ b/examples/dom_xinclude/xinclude/include1.txt @@ -0,0 +1 @@ +This is the contents of file xinclude/include1.txt. diff --git a/examples/dom_xinclude/include2.xml b/examples/dom_xinclude/xinclude/include2.xml similarity index 53% rename from examples/dom_xinclude/include2.xml rename to examples/dom_xinclude/xinclude/include2.xml index 19b2c9df..aaf8db1a 100644 --- a/examples/dom_xinclude/include2.xml +++ b/examples/dom_xinclude/xinclude/include2.xml @@ -1,4 +1,4 @@ -

This is the contents of file include2.xml.

+

This is the contents of file xinclude/include2.xml.

diff --git a/libxml++/document.cc b/libxml++/document.cc index acd1fe3f..9a5d39b0 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -16,7 +16,7 @@ #include #include -#include // XML_PARSE_NOXINCNODE +#include // XML_PARSE_NOXINCNODE, XML_PARSE_NOBASEFIX #include #include @@ -427,7 +427,7 @@ void Document::set_entity_declaration(const Glib::ustring& name, XmlEntityType t throw internal_error("Could not add entity declaration " + name); } -int Document::process_xinclude(bool generate_xinclude_nodes) +int Document::process_xinclude(bool generate_xinclude_nodes, bool fixup_base_uris) { NodeMap node_map; @@ -436,8 +436,13 @@ int Document::process_xinclude(bool generate_xinclude_nodes) find_wrappers(root, node_map); xmlResetLastError(); - const int n_substitutions = xmlXIncludeProcessTreeFlags(root, - generate_xinclude_nodes ? 0 : XML_PARSE_NOXINCNODE); + + int flags = 0; + if (!generate_xinclude_nodes) + flags |= XML_PARSE_NOXINCNODE; + if (!fixup_base_uris) + flags |= XML_PARSE_NOBASEFIX; + const int n_substitutions = xmlXIncludeProcessTreeFlags(root, flags); remove_found_wrappers(reinterpret_cast(impl_), node_map); diff --git a/libxml++/document.h b/libxml++/document.h index 5d4ba601..3bf8eeee 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -244,13 +244,18 @@ class Document : public NonCopyable * The type of a C++ wrapper can't change. The old wrapper is deleted, and a * new one is created if and when it's required.) * + * Parser::set_parser_options() and DomParser::set_xinclude_options() do not + * affect %Document::process_xinclude(). + * * @newin{2,36} * * @param generate_xinclude_nodes Generate XIncludeStart and XIncludeEnd nodes. + * @param fixup_base_uris Add or replace xml:base attributes in included element + * nodes, if necessary to preserve the target of relative URIs. * @returns The number of substitutions. * @throws xmlpp::exception */ - int process_xinclude(bool generate_xinclude_nodes = true); + int process_xinclude(bool generate_xinclude_nodes = true, bool fixup_base_uris = true); ///Access the underlying libxml implementation. _xmlDoc* cobj() noexcept; diff --git a/libxml++/parsers/domparser.cc b/libxml++/parsers/domparser.cc index 9d623d11..53a78258 100644 --- a/libxml++/parsers/domparser.cc +++ b/libxml++/parsers/domparser.cc @@ -12,6 +12,7 @@ #include "libxml++/keepblanks.h" #include "libxml++/exceptions/internal_error.h" #include //For xmlCreateFileParserCtxt(). +#include #include #include @@ -38,6 +39,26 @@ DomParser::~DomParser() release_underlying(); } +void DomParser::set_xinclude_options(bool process_xinclude, + bool generate_xinclude_nodes, bool fixup_base_uris) noexcept +{ + xinclude_options_ = 0; + if (process_xinclude) + xinclude_options_ |= XML_PARSE_XINCLUDE; + if (!generate_xinclude_nodes) + xinclude_options_ |= XML_PARSE_NOXINCNODE; + if (!fixup_base_uris) + xinclude_options_ |= XML_PARSE_NOBASEFIX; +} + +void DomParser::get_xinclude_options(bool& process_xinclude, + bool& generate_xinclude_nodes, bool& fixup_base_uris) const noexcept +{ + process_xinclude = (xinclude_options_ & XML_PARSE_XINCLUDE) != 0; + generate_xinclude_nodes = (xinclude_options_ & XML_PARSE_NOXINCNODE) == 0; + fixup_base_uris = (xinclude_options_ & XML_PARSE_NOBASEFIX) == 0; +} + void DomParser::parse_file(const std::string& filename) { release_underlying(); //Free any existing document. @@ -120,6 +141,29 @@ void DomParser::parse_context() throw parse_error(error_str); } + check_xinclude_and_finish_parsing(); +} + +void DomParser::check_xinclude_and_finish_parsing() +{ + int set_options = 0; + int clear_options = 0; + get_parser_options(set_options, clear_options); + + int options = xinclude_options_; + // Turn on/off any xinclude options. + options |= set_options; + options &= ~clear_options; + + if (options & XML_PARSE_XINCLUDE) + { + const int n_substitutions = xmlXIncludeProcessFlags(context_->myDoc, options); + if (n_substitutions < 0) + { + throw parse_error("Couldn't process XInclude\n" + format_xml_error()); + } + } + doc_ = new Document(context_->myDoc); // This is to indicate to release_underlying() that we took the // ownership on the doc. @@ -197,14 +241,7 @@ void DomParser::parse_stream(std::istream& in) throw parse_error(error_str); } - doc_ = new Document(context_->myDoc); - // This is to indicate to release_underlying() that we took the - // ownership on the doc. - context_->myDoc = nullptr; - - // Free the parser context because it's not needed anymore, - // but keep the document alive so people can navigate the DOM tree: - Parser::release_underlying(); + check_xinclude_and_finish_parsing(); } void DomParser::release_underlying() diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index 046355d7..ddccd24c 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -33,6 +33,31 @@ class DomParser : public Parser explicit DomParser(const std::string& filename, bool validate = false); ~DomParser() override; + /** Set whether and how the parser will perform XInclude substitution. + * + * @newin{3,2} + * + * @param process_xinclude Do XInclude substitution on the XML document. + * If false, the other parameters have no effect. + * @param generate_xinclude_nodes Generate XIncludeStart and XIncludeEnd nodes. + * @param fixup_base_uris Add or replace xml:base attributes in included element + * nodes, if necessary to preserve the target of relative URIs. + */ + void set_xinclude_options(bool process_xinclude = true, + bool generate_xinclude_nodes = true, bool fixup_base_uris = true) noexcept; + + /** Get whether and how the parser will perform XInclude substitution. + * + * @newin{3,2} + * + * @param[out] process_xinclude Do XInclude substitution on the XML document. + * @param[out] generate_xinclude_nodes Generate XIncludeStart and XIncludeEnd nodes. + * @param[out] fixup_base_uris Add or replace xml:base attributes in included element + * nodes, if necessary to preserve the target of relative URIs. + */ + void get_xinclude_options(bool& process_xinclude, + bool& generate_xinclude_nodes, bool& fixup_base_uris) const noexcept; + /** Parse an XML document from a file. * If the parser already contains a document, that document and all its nodes * are deleted. @@ -90,9 +115,11 @@ class DomParser : public Parser protected: void parse_context(); + void check_xinclude_and_finish_parsing(); void release_underlying() override; + int xinclude_options_ = 0; Document* doc_; }; From a56bfed2fab263aa127866520db622fc081d2d9c Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 22 Oct 2017 21:33:27 +0200 Subject: [PATCH 066/240] Build: Use glibmm-2.56 instead of glibmm-2.54. We changed the (unstable) ABI name in glibmm a while ago. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 097ccf75..f46f2e67 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ MM_AX_CXX_COMPILE_STDCXX([11], [noext],[mandatory]) LT_PREREQ([2.2.6]) LT_INIT([dlopen win32-dll disable-static]) -AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.54 >= 2.32.0']) +AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.56 >= 2.32.0']) PKG_CHECK_MODULES([LIBXMLXX], [$LIBXMLXX_MODULES]) AC_LANG([C++]) @@ -45,7 +45,7 @@ LIBXMLXX_CXX_HAS_EXCEPTION_PTR MM_ARG_ENABLE_DOCUMENTATION MM_ARG_WITH_TAGFILE_DOC([libstdc++.tag], [mm-common-libstdc++]) MM_ARG_WITH_TAGFILE_DOC([libsigc++-3.0.tag], [sigc++-3.0]) -MM_ARG_WITH_TAGFILE_DOC([glibmm-2.54.tag], [glibmm-2.54]) +MM_ARG_WITH_TAGFILE_DOC([glibmm-2.56.tag], [glibmm-2.56]) # Evaluate the --enable-warnings=level option. MM_ARG_ENABLE_WARNINGS([LIBXMLXX_WXXFLAGS], From 26c6a0fa1706f5e1389ea3172d823a4e785493b9 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 22 Oct 2017 21:50:50 +0200 Subject: [PATCH 067/240] docs: Update the bugs link. --- docs/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.html b/docs/index.html index 681c4552..b0e67229 100644 --- a/docs/index.html +++ b/docs/index.html @@ -36,7 +36,7 @@

Documentation

Development

Libxml++ uses the GNOME git repository.

-

Bugs and patches are tracked in GNOME's bugzilla. Here is a list of open bugs. Add new bugs here.

+

Bugs and patches are tracked in GNOME's bugzilla. Here is a list of open bugs. Add new bugs here.

Contact

Please use the libxmlplusplus-list mailing list or bugzilla. Please do not just email the developers directly.

From e31b3f61a5dd0cb9e0d51c03511faef1409c48df Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 22 Oct 2017 22:03:50 +0200 Subject: [PATCH 068/240] docs: manual: Fix srcdir!=buildir build. --- docs/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Makefile.am b/docs/Makefile.am index edd69f45..8011c32b 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -21,8 +21,8 @@ doc_input = $(addprefix $(top_srcdir)/libxml++/,$(h_sources_public)) # Sets dist_noinst_DATA, DISTCLEANFILES and MAINTAINERCLEANFILES include $(top_srcdir)/build/doc-reference.am -manual/libxml++.xml: manual/libxml++_without_code.xml manual/insert_example_code.pl - $(AM_V_GEN)$(PERL) -- manual/insert_example_code.pl ../examples $< >$@ +manual/libxml++.xml: ${top_srcdir}/docs/manual/libxml++_without_code.xml ${top_srcdir}/docs/manual/insert_example_code.pl + $(AM_V_GEN)$(PERL) -- ${top_srcdir}/docs/manual/insert_example_code.pl ../examples $< >$@ manualdir = $(docdir)/manual manual_htmldir = $(manualdir)/html From 8d7ef4c6fc2c9b8b701342c0cafc9ad4ddd72033 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 9 Apr 2018 17:04:12 +0200 Subject: [PATCH 069/240] Use glibmm-2.58 instead of glibmm-2.56 We have changed the ABI name in glibmm. Require C++14. glibmm-2.58 requires C++14. --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index f46f2e67..44923531 100644 --- a/configure.ac +++ b/configure.ac @@ -30,12 +30,12 @@ MM_CONFIG_DOCTOOL_DIR([docs]) AC_SUBST([LIBXMLXX_SO_VERSION], [1:0:0]) AC_PROG_CXX -MM_AX_CXX_COMPILE_STDCXX([11], [noext],[mandatory]) +MM_AX_CXX_COMPILE_STDCXX([14], [noext],[mandatory]) LT_PREREQ([2.2.6]) LT_INIT([dlopen win32-dll disable-static]) -AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.56 >= 2.32.0']) +AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.58 >= 2.32.0']) PKG_CHECK_MODULES([LIBXMLXX], [$LIBXMLXX_MODULES]) AC_LANG([C++]) @@ -45,7 +45,7 @@ LIBXMLXX_CXX_HAS_EXCEPTION_PTR MM_ARG_ENABLE_DOCUMENTATION MM_ARG_WITH_TAGFILE_DOC([libstdc++.tag], [mm-common-libstdc++]) MM_ARG_WITH_TAGFILE_DOC([libsigc++-3.0.tag], [sigc++-3.0]) -MM_ARG_WITH_TAGFILE_DOC([glibmm-2.56.tag], [glibmm-2.56]) +MM_ARG_WITH_TAGFILE_DOC([glibmm-2.58.tag], [glibmm-2.58]) # Evaluate the --enable-warnings=level option. MM_ARG_ENABLE_WARNINGS([LIBXMLXX_WXXFLAGS], From 1a2a37a470406920cb892d0821ac2d341dd28a63 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sat, 14 Jul 2018 10:46:04 +0200 Subject: [PATCH 070/240] Rename libxml++.doap to libxmlplusplus.doap --- libxml++.doap => libxmlplusplus.doap | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename libxml++.doap => libxmlplusplus.doap (86%) diff --git a/libxml++.doap b/libxmlplusplus.doap similarity index 86% rename from libxml++.doap rename to libxmlplusplus.doap index 155c05f6..ac9f8479 100644 --- a/libxml++.doap +++ b/libxmlplusplus.doap @@ -4,15 +4,15 @@ xmlns:gnome="http://api.gnome.org/doap-extensions#" xmlns="http://usefulinc.com/ns/doap#"> - libxml++ + libxmlplusplus C++ bindings for libxml2 - libxml++ is a C++ wrapper for the libxml2 XML parser library. + libxmlplusplus (aka libxml++) is a C++ wrapper for the libxml2 XML parser library. It has SAX and DOM-like APIs, but does not attempt to conform exactly to the DOM specification. Its API is simpler than the underlying libxml2 C API. - + From 223ffdd9ba8e96b88d316acd86b1dbedadef8019 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sat, 14 Jul 2018 10:49:32 +0200 Subject: [PATCH 071/240] tests: Don't require C++17 Don't include glibmm.h and don't call Glib::init(). Then no included header file requires C++17 support, just C++14 support. Glib::init() is not necessary, because libxml++ uses only a small part of glibmm, mainly Glib::ustring. --- tests/saxparser_chunk_parsing_inconsistent_state/main.cc | 5 +++-- tests/saxparser_parse_double_free/main.cc | 5 +++-- tests/saxparser_parse_stream_inconsistent_state/main.cc | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc index 136bfb76..ab44d0bf 100644 --- a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc +++ b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc @@ -19,7 +19,6 @@ #include #include -#include #include #include @@ -38,7 +37,9 @@ class MySaxParser : public xmlpp::SaxParser int main() { - Glib::init(); + // Set the global C and C++ locale to the user-configured locale, + // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. + std::locale::global(std::locale("")); { MySaxParser parser; diff --git a/tests/saxparser_parse_double_free/main.cc b/tests/saxparser_parse_double_free/main.cc index e1bd3b6a..09af02e4 100644 --- a/tests/saxparser_parse_double_free/main.cc +++ b/tests/saxparser_parse_double_free/main.cc @@ -19,7 +19,6 @@ #include #include -#include #include class OnCdataBlockTestParser : public xmlpp::SaxParser @@ -340,7 +339,9 @@ void test_on_start_element() int main() { - Glib::init(); + // Set the global C and C++ locale to the user-configured locale, + // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. + std::locale::global(std::locale("")); test_on_cdata_block(); test_on_characters(); diff --git a/tests/saxparser_parse_stream_inconsistent_state/main.cc b/tests/saxparser_parse_stream_inconsistent_state/main.cc index 4fd13200..6be414ec 100644 --- a/tests/saxparser_parse_stream_inconsistent_state/main.cc +++ b/tests/saxparser_parse_stream_inconsistent_state/main.cc @@ -19,7 +19,6 @@ #include #include -#include #include #include @@ -34,7 +33,9 @@ class MySaxParser : public xmlpp::SaxParser int main() { - Glib::init(); + // Set the global C and C++ locale to the user-configured locale, + // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. + std::locale::global(std::locale("")); { MySaxParser parser; From 78c2fefaaf2bb9f79e7879f17c8bcdae887182ac Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sat, 14 Jul 2018 10:58:57 +0200 Subject: [PATCH 072/240] Update README --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index cb4ff964..8846c382 100644 --- a/README +++ b/README @@ -17,5 +17,5 @@ See the examples directory for example code. Use pkg-config to discover the necessary include and linker arguments. For instance, - pkg-config libxml++-3.0 --cflags --libs + pkg-config libxml++-4.0 --cflags --libs Ideally you would use PKG_CHECK_MODULES in your configure.ac file. From 0e7b7f4967b7dae314eb348de9e49463a75c7b60 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 9 Nov 2018 18:10:12 +0100 Subject: [PATCH 073/240] Use glibmm-2.60 instead of glibmm-2.58, require C++17 We have changed the ABI name in glibmm. Require C++17. Glib::ustring in glibmm-2.60 requires C++17. --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 44923531..f335876a 100644 --- a/configure.ac +++ b/configure.ac @@ -30,12 +30,12 @@ MM_CONFIG_DOCTOOL_DIR([docs]) AC_SUBST([LIBXMLXX_SO_VERSION], [1:0:0]) AC_PROG_CXX -MM_AX_CXX_COMPILE_STDCXX([14], [noext],[mandatory]) +MM_AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory]) LT_PREREQ([2.2.6]) LT_INIT([dlopen win32-dll disable-static]) -AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.58 >= 2.32.0']) +AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.60 >= 2.59.1']) PKG_CHECK_MODULES([LIBXMLXX], [$LIBXMLXX_MODULES]) AC_LANG([C++]) @@ -45,7 +45,7 @@ LIBXMLXX_CXX_HAS_EXCEPTION_PTR MM_ARG_ENABLE_DOCUMENTATION MM_ARG_WITH_TAGFILE_DOC([libstdc++.tag], [mm-common-libstdc++]) MM_ARG_WITH_TAGFILE_DOC([libsigc++-3.0.tag], [sigc++-3.0]) -MM_ARG_WITH_TAGFILE_DOC([glibmm-2.58.tag], [glibmm-2.58]) +MM_ARG_WITH_TAGFILE_DOC([glibmm-2.60.tag], [glibmm-2.60]) # Evaluate the --enable-warnings=level option. MM_ARG_ENABLE_WARNINGS([LIBXMLXX_WXXFLAGS], From c02e7eac93f98076306f0496182cdf42b05524f9 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 21 Dec 2018 17:00:30 +0100 Subject: [PATCH 074/240] configure.ac: Update bug report address --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index f335876a..3814bddd 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ ## This file is part of libxml++. AC_INIT([libxml++], [3.0.1], - [https://bugzilla.gnome.org/enter_bug.cgi?product=libxml%2B%2B], + [https://gitlab.gnome.org/GNOME/libxmlplusplus/issues/], [libxml++], [http://libxmlplusplus.sourceforge.net/]) AC_PREREQ([2.59]) From 48dcb480f86895956ee0d14a0a556514c72e876e Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 3 Jan 2019 17:18:15 +0100 Subject: [PATCH 075/240] docs/manual: Fix builddir != sourcedir builds --- docs/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/Makefile.am b/docs/Makefile.am index 8011c32b..8dfc7b29 100644 --- a/docs/Makefile.am +++ b/docs/Makefile.am @@ -22,7 +22,8 @@ doc_input = $(addprefix $(top_srcdir)/libxml++/,$(h_sources_public)) include $(top_srcdir)/build/doc-reference.am manual/libxml++.xml: ${top_srcdir}/docs/manual/libxml++_without_code.xml ${top_srcdir}/docs/manual/insert_example_code.pl - $(AM_V_GEN)$(PERL) -- ${top_srcdir}/docs/manual/insert_example_code.pl ../examples $< >$@ + $(AM_V_at)$(MKDIR_P) manual + $(AM_V_GEN)$(PERL) -- ${top_srcdir}/docs/manual/insert_example_code.pl ${top_srcdir}/examples $< >$@ manualdir = $(docdir)/manual manual_htmldir = $(manualdir)/html From f6e5f9da529da5d43253949411979b0fd0562326 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 3 Jan 2019 17:18:39 +0100 Subject: [PATCH 076/240] docs/manual: Link to gitlab.gnome.org * docs/manual/libxml++_without_code.xml: Link to example code in the master branch in gitlab.gnome.org/GNOME/libxmlplusplus. --- docs/manual/libxml++_without_code.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/manual/libxml++_without_code.xml b/docs/manual/libxml++_without_code.xml index 9158d119..7dd39939 100644 --- a/docs/manual/libxml++_without_code.xml +++ b/docs/manual/libxml++_without_code.xml @@ -2,7 +2,7 @@ - + ]> From cceda01c5de822f96e48cf85d437363e59e5ae9e Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 24 Jan 2019 18:28:23 +0100 Subject: [PATCH 077/240] docs/index.html: Update bug report address --- docs/index.html | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/index.html b/docs/index.html index b0e67229..6bfba974 100644 --- a/docs/index.html +++ b/docs/index.html @@ -35,11 +35,13 @@

Documentation

Development

-

Libxml++ uses the GNOME git repository.

-

Bugs and patches are tracked in GNOME's bugzilla. Here is a list of open bugs. Add new bugs here.

+

Libxml++ uses the GNOME git repository.

+

Bugs and patches are tracked in GNOME's GitLab issue tracker. Here is a list of + open issues. + Add new issues here.

Contact

Please use the libxmlplusplus-list mailing -list or bugzilla. Please do not just email the developers directly.

+list or GitLab. Please do not just email the developers directly.

*SOURCEFORGE* From 3ae386237ea002ec9ff4dfd99ca2b6274a93d995 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 20 Mar 2019 10:00:59 +0100 Subject: [PATCH 078/240] Use glibmm-2.62 instead of glibmm-2.60 We have changed the ABI name in glibmm. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 3814bddd..f423edab 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ MM_AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory]) LT_PREREQ([2.2.6]) LT_INIT([dlopen win32-dll disable-static]) -AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.60 >= 2.59.1']) +AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.62 >= 2.61.1']) PKG_CHECK_MODULES([LIBXMLXX], [$LIBXMLXX_MODULES]) AC_LANG([C++]) @@ -45,7 +45,7 @@ LIBXMLXX_CXX_HAS_EXCEPTION_PTR MM_ARG_ENABLE_DOCUMENTATION MM_ARG_WITH_TAGFILE_DOC([libstdc++.tag], [mm-common-libstdc++]) MM_ARG_WITH_TAGFILE_DOC([libsigc++-3.0.tag], [sigc++-3.0]) -MM_ARG_WITH_TAGFILE_DOC([glibmm-2.60.tag], [glibmm-2.60]) +MM_ARG_WITH_TAGFILE_DOC([glibmm-2.62.tag], [glibmm-2.62]) # Evaluate the --enable-warnings=level option. MM_ARG_ENABLE_WARNINGS([LIBXMLXX_WXXFLAGS], From 75bdd19f6c0b217e8f7a6fc5c32c889941b1903b Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 21 Mar 2019 16:24:15 +0100 Subject: [PATCH 079/240] Doxyfile.in: Remove obsolete glibmm configuration constants They have been removed from glibmm. See issue glibmm#22. --- docs/reference/Doxyfile.in | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in index bd291170..c00c367e 100644 --- a/docs/reference/Doxyfile.in +++ b/docs/reference/Doxyfile.in @@ -293,10 +293,6 @@ PREDEFINED = __cplusplus \ "G_GNUC_PURE=" \ "G_GNUC_WARN_UNUSED_RESULT=" \ "G_MODULE_EXPORT=" \ - GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED \ - GLIBMM_EXCEPTIONS_ENABLED \ - GLIBMM_PROPERTIES_ENABLED \ - GLIBMM_VFUNCS_ENABLED \ "LIBXMLXX_API=" EXPAND_AS_DEFINED = LIBXMLXX_MAJOR_VERSION \ LIBXMLXX_MINOR_VERSION \ From 13cfbcd526d713023815d1c54e9510a2af338d57 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 9 Jan 2020 22:09:47 +0100 Subject: [PATCH 080/240] docs: Convert website to github pages Using markdown instead of HTML. --- docs/_config.yml | 1 + docs/index.html | 50 ------------------------------------------------ docs/index.md | 37 +++++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 50 deletions(-) create mode 100644 docs/_config.yml delete mode 100644 docs/index.html create mode 100644 docs/index.md diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 00000000..966d1ac0 --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +name: libsigc++ diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index 6bfba974..00000000 --- a/docs/index.html +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - libxml++ - - - -

-

-libxml++

- -

Introduction

-

-libxml++ is a C++ wrapper for the libxml XML parser library. -

- -

License

-

Libxml++ is released under the LGPL version 2 or above

- -

Download

-

You can download libxml++ from here.

-

Required Libraries

- - -

Documentation

-

The short manual gives an overview of the libxml++ API. You can also browse online the reference documentation. -

- - -

Development

-

Libxml++ uses the GNOME git repository.

-

Bugs and patches are tracked in GNOME's GitLab issue tracker. Here is a list of - open issues. - Add new issues here.

-

Contact

-

Please use the libxmlplusplus-list mailing -list or GitLab. Please do not just email the developers directly.

-

- -*SOURCEFORGE* -

- - diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..c1188db4 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,37 @@ +-- +layout: default +title: libxml++ +-- + +## Introduction + +libxml++ is a C++ wrapper for the [libxml](http://www.xmlsoft.org) XML parser library. + +## License + +Libxml++ is released under the [LGPL](http://www.gnu.org/licenses/lgpl.html#TOC1) version 2 or above + +## Download + +You can download libxml++ from [here](http://ftp.gnome.org/pub/GNOME/sources/libxml++/). + +## Required Libraries + +* [libxml2](http://www.xmlsoft.org/) +* [glibmm-2.4](http://www.gtkmm.org/) (or a subset of it containing at least Glib::ustring) + +## Documentation + +The short [reference documentation](http://library.gnome.org/devel/libxml++-tutorial/stable/) + +The short [manual](http://library.gnome.org/devel/libxml++-tutorial/stable/) gives an overview of the libxml++ API. You can also browse online the [reference documentation](http://library.gnome.org/devel/libxml++/stable/). + +## Development + +Libxml++ uses the GNOME [git repository](https://gitlab.gnome.org/GNOME/libxmlplusplus/). + +Bugs and patches are tracked in GNOME's GitLab issue tracker. Here is a list of [open issues](https://gitlab.gnome.org/GNOME/libxmlplusplus/issues). Add new issues [here](https://gitlab.gnome.org/GNOME/libxmlplusplus/issues/new). + +## Contact + +Please use the [libxmlplusplus-list mailing list](http://mail.gnome.org/mailman/listinfo/libxmlplusplus-list) or GitLab. Please do not just email the developers directly. From 77e626c85d8eb7f5bbb080565265d9ad030ee7ed Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 9 Jan 2020 22:22:33 +0100 Subject: [PATCH 081/240] docs: Slight markdown correction --- docs/index.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/index.md b/docs/index.md index c1188db4..92f5a522 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,8 +1,7 @@ --- +--- layout: default title: libxml++ --- - +--- ## Introduction libxml++ is a C++ wrapper for the [libxml](http://www.xmlsoft.org) XML parser library. From 44a206b00fb62b5954da1c7db16ac6ffbf989aae Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 9 Jan 2020 22:25:40 +0100 Subject: [PATCH 082/240] Website: Update some links --- docs/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/index.md b/docs/index.md index 92f5a522..8affe416 100644 --- a/docs/index.md +++ b/docs/index.md @@ -27,9 +27,9 @@ The short [manual](http://library.gnome.org/devel/libxml++-tutorial/stable/) giv ## Development -Libxml++ uses the GNOME [git repository](https://gitlab.gnome.org/GNOME/libxmlplusplus/). +Libxml++ uses the GitHub [git repository](https://github.com/libxmlplusplus/libxmlplusplus). -Bugs and patches are tracked in GNOME's GitLab issue tracker. Here is a list of [open issues](https://gitlab.gnome.org/GNOME/libxmlplusplus/issues). Add new issues [here](https://gitlab.gnome.org/GNOME/libxmlplusplus/issues/new). +Bugs and patches are tracked in GitHub's [issue tracker](https://github.com/libxmlplusplus/libxmlplusplus/issues). ## Contact From bbc285469ddd0c37b43b075d21fb7335dabac0d3 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Thu, 9 Jan 2020 22:29:34 +0100 Subject: [PATCH 083/240] Website: Add title --- docs/index.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/index.md b/docs/index.md index 8affe416..81e832f7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,6 +2,8 @@ layout: default title: libxml++ --- +# libxml++ + ## Introduction libxml++ is a C++ wrapper for the [libxml](http://www.xmlsoft.org) XML parser library. From c859062ba020077c6738418aae2f1368a62542b3 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 11 Jan 2020 15:39:11 +0100 Subject: [PATCH 084/240] Build/Docs: Change gitlab mentions to GitHub --- configure.ac | 4 ++-- docs/manual/libxml++_without_code.xml | 2 +- libxmlplusplus.doap | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index f423edab..d8a0ec53 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ ## This file is part of libxml++. AC_INIT([libxml++], [3.0.1], - [https://gitlab.gnome.org/GNOME/libxmlplusplus/issues/], - [libxml++], [http://libxmlplusplus.sourceforge.net/]) + [https://github.com/libxmlplusplus/libxmlplusplus/issues], + [libxml++], [https://libxmlplusplus.github.io/libxmlplusplus/]) AC_PREREQ([2.59]) AC_CONFIG_SRCDIR([libxml++/libxml++.h]) diff --git a/docs/manual/libxml++_without_code.xml b/docs/manual/libxml++_without_code.xml index 7dd39939..71ccf50a 100644 --- a/docs/manual/libxml++_without_code.xml +++ b/docs/manual/libxml++_without_code.xml @@ -2,7 +2,7 @@ - + ]> diff --git a/libxmlplusplus.doap b/libxmlplusplus.doap index ac9f8479..7caaa81c 100644 --- a/libxmlplusplus.doap +++ b/libxmlplusplus.doap @@ -12,7 +12,7 @@ the DOM specification. Its API is simpler than the underlying libxml2 C API. - + From cbc653ec5d06e4367a9da3375131fc85aa842407 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 11 Jan 2020 22:22:50 +0100 Subject: [PATCH 085/240] Update NEWS from the libxml++-3-2 branch --- NEWS | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/NEWS b/NEWS index b640e309..9bf51ede 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,19 @@ +3.2.0 (stable): + +* Document, DomParser: Improve XInclude processing: + Document: + Add process_xinclude() overload that takes a fixup_base_uris parameter. + DomParser: + Add set/get_xinclude_options() and add optional XInclude processing to the + parse methods. + (Kjell Ahlstedt) Bug 781566 +* Add explicit keyword to some single-parameter constructors. + (Murray Cumming) +* tests: Don't require C++17 + (Kjell Ahlstedt) +* Build: Fix srcdir != buildir build. + (Kjell Ahlstedt, Murray Cumming) + 3.0.1 (stable): * Element::remove_attribute(): Delete the C++ wrapper From 344970156a37e25d31206a93ef22ae5f79dcedf7 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 11 Jan 2020 23:00:04 +0100 Subject: [PATCH 086/240] configure.ac: Use glibmm-2.26 instead of glibmm-2.24 The unstable glibmm ABI name changed again, to track the glib version number, while waiting for GTK+ 4 to become stable. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index d8a0ec53..2c4af7c0 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ MM_AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory]) LT_PREREQ([2.2.6]) LT_INIT([dlopen win32-dll disable-static]) -AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.62 >= 2.61.1']) +AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.64 >= 2.63.1']) PKG_CHECK_MODULES([LIBXMLXX], [$LIBXMLXX_MODULES]) AC_LANG([C++]) @@ -45,7 +45,7 @@ LIBXMLXX_CXX_HAS_EXCEPTION_PTR MM_ARG_ENABLE_DOCUMENTATION MM_ARG_WITH_TAGFILE_DOC([libstdc++.tag], [mm-common-libstdc++]) MM_ARG_WITH_TAGFILE_DOC([libsigc++-3.0.tag], [sigc++-3.0]) -MM_ARG_WITH_TAGFILE_DOC([glibmm-2.62.tag], [glibmm-2.62]) +MM_ARG_WITH_TAGFILE_DOC([glibmm-2.64.tag], [glibmm-2.64]) # Evaluate the --enable-warnings=level option. MM_ARG_ENABLE_WARNINGS([LIBXMLXX_WXXFLAGS], From 9d1b13f7454d06fdac0d9e3c1c002a6dd4714d37 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 11 Jan 2020 22:37:35 +0100 Subject: [PATCH 087/240] 3.9.1 --- NEWS | 10 ++++++++++ configure.ac | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 9bf51ede..d1fa7dfd 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,13 @@ +3.9.1 (unstable): + +* Change ABI name to libxml++-4.0 + There is also a libxml++-3-2 branch for the libxml++-3.0 ABI, + which still uses glibmm-2.4. +* Build: + - Use glibmm-2.62 instead of glibmm-2.42. + - Require C++17. +* Parser: Make some methods const + 3.2.0 (stable): * Document, DomParser: Improve XInclude processing: diff --git a/configure.ac b/configure.ac index 2c4af7c0..a0f94c55 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [3.0.1], +AC_INIT([libxml++], [3.9.1], [https://github.com/libxmlplusplus/libxmlplusplus/issues], [libxml++], [https://libxmlplusplus.github.io/libxmlplusplus/]) AC_PREREQ([2.59]) From 7daf137251e02669413ae01cb8baec5b902289f6 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 5 Jan 2020 23:26:35 +0100 Subject: [PATCH 088/240] Change API name from libxml++-4.0 to libxml++-5.0 --- README | 2 +- configure.ac | 4 ++-- docs/manual/libxml++_without_code.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README b/README index 8846c382..91342da8 100644 --- a/README +++ b/README @@ -17,5 +17,5 @@ See the examples directory for example code. Use pkg-config to discover the necessary include and linker arguments. For instance, - pkg-config libxml++-4.0 --cflags --libs + pkg-config libxml++-5.0 --cflags --libs Ideally you would use PKG_CHECK_MODULES in your configure.ac file. diff --git a/configure.ac b/configure.ac index a0f94c55..26ebb848 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [3.9.1], +AC_INIT([libxml++], [4.9.1], [https://github.com/libxmlplusplus/libxmlplusplus/issues], [libxml++], [https://libxmlplusplus.github.io/libxmlplusplus/]) AC_PREREQ([2.59]) @@ -18,7 +18,7 @@ AM_MAINTAINER_MODE([disable]) AC_ARG_VAR([ACLOCAL_FLAGS], [aclocal flags, e.g. -I ]) MM_PREREQ([0.9.10]) -MM_INIT_MODULE([libxml++-4.0]) +MM_INIT_MODULE([libxml++-5.0]) # Tell mm-common-prepare to copy the mm-common .pl scripts # and some other files into docs/, and use them from there, diff --git a/docs/manual/libxml++_without_code.xml b/docs/manual/libxml++_without_code.xml index 71ccf50a..4b96b36b 100644 --- a/docs/manual/libxml++_without_code.xml +++ b/docs/manual/libxml++_without_code.xml @@ -44,7 +44,7 @@ url="http://www.gnome.org">GNOME project, of which libxml++ is a part.libxml++ is packaged by major Linux and *BSD distributions and can be installed from source on Linux and Windows, using any modern compiler, such as g++, SUN Forte, or MSVC++.
For instance, to install libxml++ and its documentation on debian, use apt-get or synaptic like so: - # apt-get install libxml++3.0-dev libxml++3.0-doc + # apt-get install libxml++5.0-dev libxml++5.0-doc To check that you have the libxml++ development packages installed, and that your environment is working properly, try pkg-config libxml++-4.0 --modversion. From 9c5b59a4c20f475f03fc9d5f4392a9da39b123bc Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 5 Jan 2020 22:29:34 +0100 Subject: [PATCH 089/240] Remove dependency on glibmm and don't use Glib::ustring For now, the API uses an xmlpp::ustring where it previously used Glib::ustring. --- configure.ac | 4 +- docs/manual/libxml++_without_code.xml | 8 +- examples/Makefile.am | 6 +- examples/dom_build/main.cc | 3 - examples/dom_parse_entities/main.cc | 15 ++-- examples/dom_parser/main.cc | 25 +++--- examples/dom_parser_raw/main.cc | 32 +++---- examples/dom_read_write/main.cc | 4 - examples/dom_update_namespace/main.cc | 5 +- examples/dom_xinclude/main.cc | 6 +- examples/dom_xpath/main.cc | 8 +- examples/dtdvalidation/main.cc | 4 - examples/import_node/main.cc | 5 -- examples/sax_exception/main.cc | 4 - examples/sax_exception/myparser.cc | 14 ++-- examples/sax_exception/myparser.h | 14 ++-- examples/sax_parser/main.cc | 9 +- examples/sax_parser/myparser.cc | 79 ++++-------------- examples/sax_parser/myparser.h | 14 ++-- examples/sax_parser_build_dom/main.cc | 4 - examples/sax_parser_build_dom/svgelement.cc | 4 +- examples/sax_parser_build_dom/svgelement.h | 6 +- examples/sax_parser_build_dom/svgparser.cc | 26 +++--- examples/sax_parser_build_dom/svgparser.h | 18 ++-- examples/sax_parser_build_dom/svgpath.h | 4 +- examples/sax_parser_entities/main.cc | 4 - examples/sax_parser_entities/myparser.cc | 18 ++-- examples/sax_parser_entities/myparser.h | 20 ++--- examples/schemavalidation/main.cc | 6 +- examples/testutilities.cc | 33 -------- examples/testutilities.h | 45 ---------- examples/textreader/main.cc | 4 - libxml++/attribute.h | 4 +- libxml++/attributedeclaration.cc | 2 +- libxml++/attributedeclaration.h | 4 +- libxml++/attributenode.cc | 6 +- libxml++/attributenode.h | 6 +- libxml++/document.cc | 60 +++++++------- libxml++/document.h | 50 +++++------ libxml++/dtd.cc | 14 ++-- libxml++/dtd.h | 14 ++-- libxml++/exceptions/exception.cc | 22 ++--- libxml++/exceptions/exception.h | 14 ++-- libxml++/exceptions/internal_error.cc | 2 +- libxml++/exceptions/internal_error.h | 2 +- libxml++/exceptions/parse_error.cc | 2 +- libxml++/exceptions/parse_error.h | 2 +- libxml++/exceptions/validity_error.cc | 2 +- libxml++/exceptions/validity_error.h | 2 +- libxml++/filelist.am | 1 + libxml++/io/ostreamoutputbuffer.cc | 2 +- libxml++/io/ostreamoutputbuffer.h | 2 +- libxml++/io/outputbuffer.cc | 2 +- libxml++/io/outputbuffer.h | 4 +- libxml++/libxml++.h | 1 + libxml++/nodes/contentnode.cc | 4 +- libxml++/nodes/contentnode.h | 4 +- libxml++/nodes/element.cc | 75 ++++++++--------- libxml++/nodes/element.h | 72 ++++++++-------- libxml++/nodes/entitydeclaration.cc | 4 +- libxml++/nodes/entitydeclaration.h | 4 +- libxml++/nodes/entityreference.cc | 8 +- libxml++/nodes/entityreference.h | 4 +- libxml++/nodes/node.cc | 68 +++++++-------- libxml++/nodes/node.h | 44 +++++----- libxml++/parsers/domparser.cc | 8 +- libxml++/parsers/domparser.h | 2 +- libxml++/parsers/parser.cc | 18 ++-- libxml++/parsers/parser.h | 10 +-- libxml++/parsers/saxparser.cc | 78 ++++++++--------- libxml++/parsers/saxparser.h | 38 ++++----- libxml++/parsers/textreader.cc | 60 +++++++------- libxml++/parsers/textreader.h | 48 +++++------ libxml++/relaxngschema.cc | 4 +- libxml++/relaxngschema.h | 2 +- libxml++/schemabase.h | 8 +- libxml++/ustring.cc | 0 libxml++/ustring.h | 37 +++++++++ libxml++/validators/dtdvalidator.cc | 6 +- libxml++/validators/dtdvalidator.h | 6 +- libxml++/validators/relaxngvalidator.cc | 4 +- libxml++/validators/relaxngvalidator.h | 7 +- libxml++/validators/schemavalidatorbase.h | 7 +- libxml++/validators/validator.cc | 10 +-- libxml++/validators/validator.h | 10 +-- libxml++/validators/xsdvalidator.cc | 6 +- libxml++/validators/xsdvalidator.h | 7 +- libxml++/xsdschema.cc | 4 +- libxml++/xsdschema.h | 2 +- libxml++config.h.in | 2 - .../main.cc | 17 ++-- tests/saxparser_parse_double_free/main.cc | 83 +++++++++---------- .../main.cc | 15 ++-- 93 files changed, 629 insertions(+), 828 deletions(-) delete mode 100644 examples/testutilities.cc delete mode 100644 examples/testutilities.h create mode 100644 libxml++/ustring.cc create mode 100644 libxml++/ustring.h diff --git a/configure.ac b/configure.ac index 26ebb848..3eecda59 100644 --- a/configure.ac +++ b/configure.ac @@ -35,7 +35,7 @@ MM_AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory]) LT_PREREQ([2.2.6]) LT_INIT([dlopen win32-dll disable-static]) -AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7 glibmm-2.64 >= 2.63.1']) +AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7']) PKG_CHECK_MODULES([LIBXMLXX], [$LIBXMLXX_MODULES]) AC_LANG([C++]) @@ -44,8 +44,6 @@ LIBXMLXX_CXX_HAS_EXCEPTION_PTR MM_ARG_ENABLE_DOCUMENTATION MM_ARG_WITH_TAGFILE_DOC([libstdc++.tag], [mm-common-libstdc++]) -MM_ARG_WITH_TAGFILE_DOC([libsigc++-3.0.tag], [sigc++-3.0]) -MM_ARG_WITH_TAGFILE_DOC([glibmm-2.64.tag], [glibmm-2.64]) # Evaluate the --enable-warnings=level option. MM_ARG_ENABLE_WARNINGS([LIBXMLXX_WXXFLAGS], diff --git a/docs/manual/libxml++_without_code.xml b/docs/manual/libxml++_without_code.xml index 4b96b36b..ce7f69b0 100644 --- a/docs/manual/libxml++_without_code.xml +++ b/docs/manual/libxml++_without_code.xml @@ -54,11 +54,9 @@ url="http://libxmlplusplus.sourceforge.net">libxmlplusplus.sourceforge.net - UTF-8 and Glib::ustring + UTF-8 and xmlpp::ustring The libxml++ API takes, and gives, strings in the UTF-8 Unicode encoding, which can support all known languages and locales. This choice was made because, of the encodings that have this capability, UTF-8 is the most commonly accepted choice. UTF-8 is a multi-byte encoding, meaning that some characters use more than 1 byte. But for compatibility, old-fashioned 7-bit ASCII strings are unchanged when encoded as UTF-8, and UTF-8 strings do not contain null bytes which would cause old code to misjudge the number of bytes. For these reasons, you can store a UTF-8 string in a std::string object. However, the std::string API will operate on that string in terms of bytes, instead of characters. - Because Standard C++ has no string class that can fully handle UTF-8, libxml++ uses the Glib::ustring class from the glibmm library. Glib::ustring has almost exactly the same API as std::string, but methods such as length() and operator[] deal with whole UTF-8 characters rather than raw bytes. - There are implicit conversions between std::string and Glib::ustring, so you can use std::string wherever you see a Glib::ustring in the API, if you really don't care about any locale other than English. However, that is unlikely in today's connected world. - glibmm also provides useful API to convert between encodings and locales. + The libxml++ API indicates when a string should be provided as UTF-8, or will be provided as UTF-8, by using the xmlpp::ustring type alias. However, this is really just a std::string, whose operator[] and size() consider bytes, not characters. @@ -80,7 +78,7 @@ url="http://libxmlplusplus.sourceforge.net">libxmlplusplus.sourceforge.net Parsers Like the underlying libxml2 library, libxml++ allows the use of 3 parsers, depending on your needs - the DOM, SAX, and TextReader parsers. The relative advantages and behaviour of these parsers will be explained here. - All of the parsers may parse XML documents directly from disk, a string, or a C++ std::istream. Although the libxml++ API uses only Glib::ustring, and therefore the UTF-8 encoding, libxml++ can parse documents in any encoding, converting to UTF-8 automatically. This conversion will not lose any information because UTF-8 can represent any locale. + All of the parsers may parse XML documents directly from disk, a string, or a C++ std::istream. Although the libxml++ API uses only xmlpp::ustring, indicating the UTF-8 encoding, libxml++ can parse documents in any encoding, converting to UTF-8 automatically. This conversion will not lose any information because UTF-8 can represent any locale. Remember that white space is usually significant in XML documents, so the parsers might provide unexpected text nodes that contain only spaces and new lines. The parser does not know whether you care about these text nodes, but your application may choose to ignore them. diff --git a/examples/Makefile.am b/examples/Makefile.am index 5a6dfe12..6fa20eab 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -58,14 +58,12 @@ check_SCRIPTS = \ TESTS = $(check_SCRIPTS) -xmlpp_test_util = testutilities.h testutilities.cc - dom_build_dom_build_SOURCES = \ dom_build/main.cc dom_parse_entities_dom_parse_entities_SOURCES = \ - dom_parse_entities/main.cc $(xmlpp_test_util) + dom_parse_entities/main.cc dom_parser_dom_parser_SOURCES = \ - dom_parser/main.cc $(xmlpp_test_util) + dom_parser/main.cc dom_parser_raw_dom_parser_raw_SOURCES = \ dom_parser_raw/main.cc dom_read_write_dom_read_write_SOURCES = \ diff --git a/examples/dom_build/main.cc b/examples/dom_build/main.cc index 13e081c1..7cd1478a 100644 --- a/examples/dom_build/main.cc +++ b/examples/dom_build/main.cc @@ -28,9 +28,6 @@ int main(int /* argc */, char** /* argv */) { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); try { diff --git a/examples/dom_parse_entities/main.cc b/examples/dom_parse_entities/main.cc index d7a38700..621fac74 100644 --- a/examples/dom_parse_entities/main.cc +++ b/examples/dom_parse_entities/main.cc @@ -21,7 +21,6 @@ #include #endif -#include "../testutilities.h" #include #include #include @@ -29,7 +28,7 @@ void print_node(const xmlpp::Node* node, bool substitute_entities, unsigned int indentation = 0) { - const Glib::ustring indent(indentation, ' '); + const std::string indent(indentation, ' '); std::cout << std::endl; //Separate nodes by an empty line. if (substitute_entities) @@ -38,7 +37,7 @@ void print_node(const xmlpp::Node* node, bool substitute_entities, unsigned int const auto nodeText = dynamic_cast(node); if (nodeText && !nodeText->is_white_space()) { - std::cout << indent << "text = " << CatchConvertError(nodeText->get_content()) << std::endl; + std::cout << indent << "text = " << nodeText->get_content() << std::endl; } } else @@ -47,9 +46,9 @@ void print_node(const xmlpp::Node* node, bool substitute_entities, unsigned int const auto nodeEntityReference = dynamic_cast(node); if (nodeEntityReference) { - std::cout << indent << "entity reference name = " << CatchConvertError(nodeEntityReference->get_name()) << std::endl; - std::cout << indent << " resolved text = " << CatchConvertError(nodeEntityReference->get_resolved_text()) << std::endl; - std::cout << indent << " original text = " << CatchConvertError(nodeEntityReference->get_original_text()) << std::endl; + std::cout << indent << "entity reference name = " << nodeEntityReference->get_name() << std::endl; + std::cout << indent << " resolved text = " << nodeEntityReference->get_resolved_text() << std::endl; + std::cout << indent << " original text = " << nodeEntityReference->get_original_text() << std::endl; } } // end if (substitute_entities) @@ -66,10 +65,6 @@ void print_node(const xmlpp::Node* node, bool substitute_entities, unsigned int int main(int argc, char* argv[]) { - // Set the global C++ locale to the user-specified locale. Then we can - // hopefully use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - std::string filepath; if(argc > 1 ) filepath = argv[1]; //Allow the user to specify a different XML file to parse. diff --git a/examples/dom_parser/main.cc b/examples/dom_parser/main.cc index 389a7ecd..edb4b0d0 100644 --- a/examples/dom_parser/main.cc +++ b/examples/dom_parser/main.cc @@ -21,14 +21,13 @@ #include #endif -#include "../testutilities.h" #include #include #include void print_node(const xmlpp::Node* node, unsigned int indentation = 0) { - const Glib::ustring indent(indentation, ' '); + const std::string indent(indentation, ' '); std::cout << std::endl; //Separate nodes by an empty line. const auto nodeContent = dynamic_cast(node); @@ -46,8 +45,8 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) std::cout << indent << "Node name = "; if(!namespace_prefix.empty()) - std::cout << CatchConvertError(namespace_prefix) << ":"; - std::cout << CatchConvertError(nodename) << std::endl; + std::cout << namespace_prefix << ":"; + std::cout << nodename << std::endl; } else if(nodeText) //Let's say when it's text. - e.g. let's say what that white space is. { @@ -57,15 +56,15 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) //Treat the various node types differently: if(nodeText) { - std::cout << indent << "text = \"" << CatchConvertError(nodeText->get_content()) << "\"" << std::endl; + std::cout << indent << "text = \"" << nodeText->get_content() << "\"" << std::endl; } else if(nodeComment) { - std::cout << indent << "comment = " << CatchConvertError(nodeComment->get_content()) << std::endl; + std::cout << indent << "comment = " << nodeComment->get_content() << std::endl; } else if(nodeContent) { - std::cout << indent << "content = " << CatchConvertError(nodeContent->get_content()) << std::endl; + std::cout << indent << "content = " << nodeContent->get_content() << std::endl; } else if(const xmlpp::Element* nodeElement = dynamic_cast(node)) { @@ -81,9 +80,9 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) std::cout << indent << " Attribute "; if(!namespace_prefix.empty()) - std::cout << CatchConvertError(namespace_prefix) << ":"; - std::cout << CatchConvertError(attribute->get_name()) << " = " - << CatchConvertError(attribute->get_value()) << std::endl; + std::cout << namespace_prefix << ":"; + std::cout << attribute->get_name() << " = " + << attribute->get_value() << std::endl; } const auto attribute = nodeElement->get_attribute("title"); @@ -94,7 +93,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) std::cout << "AttributeNode "; else if (dynamic_cast(attribute)) std::cout << "AttributeDeclaration "; - std::cout << "title = " << CatchConvertError(attribute->get_value()) << std::endl; + std::cout << "title = " << attribute->get_value() << std::endl; } } @@ -110,10 +109,6 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) int main(int argc, char* argv[]) { - // Set the global C++ locale to the user-specified locale. Then we can - // hopefully use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - bool validate = false; bool set_throw_messages = false; bool throw_messages = false; diff --git a/examples/dom_parser_raw/main.cc b/examples/dom_parser_raw/main.cc index 496bb30f..552490ec 100644 --- a/examples/dom_parser_raw/main.cc +++ b/examples/dom_parser_raw/main.cc @@ -21,7 +21,6 @@ #include #include -#include #include void print_node(const xmlpp::Node* node, unsigned int indentation = 0) @@ -57,10 +56,6 @@ std::string read_from_disk(const std::string& filepath) int main(int argc, char* argv[]) { - // Set the global C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - std::string filepath; if(argc > 1 ) filepath = argv[1]; //Allow the user to specify a different XML file to parse. @@ -77,26 +72,19 @@ int main(int argc, char* argv[]) auto contents = read_from_disk(filepath); std::string contents_ucs2; - try - { - contents_ucs2 = Glib::convert(contents, "UCS-2", "UTF-8"); - } - catch(const Glib::Error& ex) - { - std::cerr << "Glib::convert failed: " << ex.what() << std::endl; - } - - parser.parse_memory_raw((const unsigned char*)contents_ucs2.c_str(), contents_ucs2.size()); + // TODO: Convert to UCS2 (previously we used Glib::convert()) and pass that to parse_memory_raw(). + // //Look at the first few bytes, to see whether it really looks like UCS2. //Because UCS2 uses 2 bytes, we would expect every second byte to be zero for our simple example: - std::cout << "First 10 bytes of the UCS-2 data:" << std::endl; - for(std::string::size_type i = 0; (i < 10) && (i < contents_ucs2.size()); ++i) - { - std::cout << std::hex << (int)contents_ucs2[i] << ", "; - } - std::cout << std::endl; - + // std::cout << "First 10 bytes of the UCS-2 data:" << std::endl; + // for(std::string::size_type i = 0; (i < 10) && (i < contents_ucs2.size()); ++i) + // { + // std::cout << std::hex << (int)contents_ucs2[i] << ", "; + // } + // std::cout << std::endl; + + parser.parse_memory_raw((const unsigned char*)contents.c_str(), contents.size()); if(parser) { //Walk the tree: diff --git a/examples/dom_read_write/main.cc b/examples/dom_read_write/main.cc index 4948af04..1ceeb15c 100644 --- a/examples/dom_read_write/main.cc +++ b/examples/dom_read_write/main.cc @@ -30,10 +30,6 @@ int main(int argc, char* argv[]) { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - //Parse command-line arguments: std::string filepath_in; std::string filepath_out; diff --git a/examples/dom_update_namespace/main.cc b/examples/dom_update_namespace/main.cc index 1e350030..8d1eec07 100644 --- a/examples/dom_update_namespace/main.cc +++ b/examples/dom_update_namespace/main.cc @@ -22,6 +22,7 @@ #include #include +#include #include #include @@ -176,10 +177,6 @@ void Tests::fail(const RefType& reference, const ValueType& value, const std::st int main(int /* argc */, char** /* argv */) { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - TestNamespace tests; try diff --git a/examples/dom_xinclude/main.cc b/examples/dom_xinclude/main.cc index dbf87241..8837836a 100644 --- a/examples/dom_xinclude/main.cc +++ b/examples/dom_xinclude/main.cc @@ -26,7 +26,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) { - const Glib::ustring indent(indentation, ' '); + const std::string indent(indentation, ' '); const auto nodeContent = dynamic_cast(node); const auto nodeText = dynamic_cast(node); @@ -108,10 +108,6 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) int main(int argc, char* argv[]) { - // Set the global C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - bool validate = false; bool set_throw_messages = false; bool throw_messages = false; diff --git a/examples/dom_xpath/main.cc b/examples/dom_xpath/main.cc index 52c0bd80..8003b718 100644 --- a/examples/dom_xpath/main.cc +++ b/examples/dom_xpath/main.cc @@ -25,7 +25,7 @@ #include #include -Glib::ustring result_type_to_ustring(xmlpp::XPathResultType result_type) +std::string result_type_to_ustring(xmlpp::XPathResultType result_type) { switch (result_type) { @@ -40,7 +40,7 @@ Glib::ustring result_type_to_ustring(xmlpp::XPathResultType result_type) } } -bool xpath_test(const xmlpp::Node* node, const Glib::ustring& xpath) +bool xpath_test(const xmlpp::Node* node, const std::string& xpath) { bool result = true; std::cout << std::endl; //Separate tests by an empty line. @@ -103,10 +103,6 @@ bool xpath_test(const xmlpp::Node* node, const Glib::ustring& xpath) int main(int argc, char* argv[]) { - // Set the global C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - std::string filepath; if (argc > 1) filepath = argv[1]; //Allow the user to specify a different XML file to parse. diff --git a/examples/dtdvalidation/main.cc b/examples/dtdvalidation/main.cc index 6c10accc..7ca4aecf 100644 --- a/examples/dtdvalidation/main.cc +++ b/examples/dtdvalidation/main.cc @@ -28,10 +28,6 @@ int main(int argc, char* argv[]) { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - std::string dtdfilepath; if(argc > 1) dtdfilepath = argv[1]; //Allow the user to specify a different dtd file to use. diff --git a/examples/import_node/main.cc b/examples/import_node/main.cc index 726d2ec0..5632ba65 100644 --- a/examples/import_node/main.cc +++ b/examples/import_node/main.cc @@ -1,6 +1,5 @@ #include #include -#include #include #include @@ -9,10 +8,6 @@ using namespace std; int main (int /* argc */, char** /* argv */) { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - try { DomParser example1("example1.xml"); diff --git a/examples/sax_exception/main.cc b/examples/sax_exception/main.cc index ac4ed551..869afa2e 100644 --- a/examples/sax_exception/main.cc +++ b/examples/sax_exception/main.cc @@ -31,10 +31,6 @@ int main(int /* argc */, char** /* argv */) { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - MySaxParser parser; try diff --git a/examples/sax_exception/myparser.cc b/examples/sax_exception/myparser.cc index 70f8bdaf..4c94f124 100644 --- a/examples/sax_exception/myparser.cc +++ b/examples/sax_exception/myparser.cc @@ -66,7 +66,7 @@ void MySaxParser::on_end_document() std::cout << "on_end_document()" << std::endl; } -void MySaxParser::on_start_element(const Glib::ustring& name, +void MySaxParser::on_start_element(const xmlpp::ustring& name, const AttributeList& attributes) { std::cout << "node name=" << name << std::endl; @@ -80,32 +80,32 @@ void MySaxParser::on_start_element(const Glib::ustring& name, throw MyException(); } -void MySaxParser::on_end_element(const Glib::ustring& /* name */) +void MySaxParser::on_end_element(const xmlpp::ustring& /* name */) { std::cout << "on_end_element()" << std::endl; } -void MySaxParser::on_characters(const Glib::ustring& text) +void MySaxParser::on_characters(const xmlpp::ustring& text) { std::cout << "on_characters(): " << text << std::endl; } -void MySaxParser::on_comment(const Glib::ustring& text) +void MySaxParser::on_comment(const xmlpp::ustring& text) { std::cout << "on_comment(): " << text << std::endl; } -void MySaxParser::on_warning(const Glib::ustring& text) +void MySaxParser::on_warning(const xmlpp::ustring& text) { std::cout << "on_warning(): " << text << std::endl; } -void MySaxParser::on_error(const Glib::ustring& text) +void MySaxParser::on_error(const xmlpp::ustring& text) { std::cout << "on_error(): " << text << std::endl; } -void MySaxParser::on_fatal_error(const Glib::ustring& text) +void MySaxParser::on_fatal_error(const xmlpp::ustring& text) { std::cout << "on_fatal_error(): " << text << std::endl; } diff --git a/examples/sax_exception/myparser.h b/examples/sax_exception/myparser.h index 6c2376d3..7ac22901 100644 --- a/examples/sax_exception/myparser.h +++ b/examples/sax_exception/myparser.h @@ -41,14 +41,14 @@ class MySaxParser : public xmlpp::SaxParser //overrides: void on_start_document() override; void on_end_document() override; - void on_start_element(const Glib::ustring& name, + void on_start_element(const xmlpp::ustring& name, const AttributeList &properties) override; - void on_end_element(const Glib::ustring& name) override; - void on_characters(const Glib::ustring& characters) override; - void on_comment(const Glib::ustring& text) override; - void on_warning(const Glib::ustring& text) override; - void on_error(const Glib::ustring& text) override; - void on_fatal_error(const Glib::ustring& text) override; + void on_end_element(const xmlpp::ustring& name) override; + void on_characters(const xmlpp::ustring& characters) override; + void on_comment(const xmlpp::ustring& text) override; + void on_warning(const xmlpp::ustring& text) override; + void on_error(const xmlpp::ustring& text) override; + void on_fatal_error(const xmlpp::ustring& text) override; }; diff --git a/examples/sax_parser/main.cc b/examples/sax_parser/main.cc index be405a5f..1ff2147d 100644 --- a/examples/sax_parser/main.cc +++ b/examples/sax_parser/main.cc @@ -31,10 +31,6 @@ int main(int argc, char* argv[]) { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - std::string filepath; if(argc > 1 ) filepath = argv[1]; //Allow the user to specify a different XML file to parse. @@ -76,10 +72,7 @@ main(int argc, char* argv[]) is.read(buffer, buffer_size-1); if(is.gcount()) { - // We use Glib::ustring::ustring(InputIterator begin, InputIterator end) - // instead of Glib::ustring::ustring( const char*, size_type ) because it - // expects the length of the string in characters, not in bytes. - Glib::ustring input(buffer, buffer+is.gcount()); + xmlpp::ustring input(buffer, buffer+is.gcount()); parser.parse_chunk(input); } } diff --git a/examples/sax_parser/myparser.cc b/examples/sax_parser/myparser.cc index 03c694c5..5c929479 100644 --- a/examples/sax_parser/myparser.cc +++ b/examples/sax_parser/myparser.cc @@ -20,7 +20,6 @@ */ #include "myparser.h" -#include //For Glib::ConvertError #include @@ -43,7 +42,7 @@ void MySaxParser::on_end_document() std::cout << "on_end_document()" << std::endl; } -void MySaxParser::on_start_element(const Glib::ustring& name, +void MySaxParser::on_start_element(const xmlpp::ustring& name, const AttributeList& attributes) { std::cout << "node name=" << name << std::endl; @@ -51,88 +50,38 @@ void MySaxParser::on_start_element(const Glib::ustring& name, // Print attributes: for(const auto& attr_pair : attributes) { - try - { - std::cout << " Attribute name=" << attr_pair.name << std::endl; - } - catch(const Glib::ConvertError& ex) - { - std::cerr << "MySaxParser::on_start_element(): Exception caught while converting name for std::cout: " << ex.what() << std::endl; - } - - try - { - std::cout << " , value= " << attr_pair.value << std::endl; - } - catch(const Glib::ConvertError& ex) - { - std::cerr << "MySaxParser::on_start_element(): Exception caught while converting value for std::cout: " << ex.what() << std::endl; - } + std::cout << " Attribute name=" << attr_pair.name << std::endl; + std::cout << " , value= " << attr_pair.value << std::endl; } } -void MySaxParser::on_end_element(const Glib::ustring& /* name */) +void MySaxParser::on_end_element(const xmlpp::ustring& /* name */) { std::cout << "on_end_element()" << std::endl; } -void MySaxParser::on_characters(const Glib::ustring& text) +void MySaxParser::on_characters(const xmlpp::ustring& text) { - try - { - std::cout << "on_characters(): " << text << std::endl; - } - catch(const Glib::ConvertError& ex) - { - std::cerr << "MySaxParser::on_characters(): Exception caught while converting text for std::cout: " << ex.what() << std::endl; - } + std::cout << "on_characters(): " << text << std::endl; } -void MySaxParser::on_comment(const Glib::ustring& text) +void MySaxParser::on_comment(const xmlpp::ustring& text) { - try - { - std::cout << "on_comment(): " << text << std::endl; - } - catch(const Glib::ConvertError& ex) - { - std::cerr << "MySaxParser::on_comment(): Exception caught while converting text for std::cout: " << ex.what() << std::endl; - } + std::cout << "on_comment(): " << text << std::endl; } -void MySaxParser::on_warning(const Glib::ustring& text) +void MySaxParser::on_warning(const xmlpp::ustring& text) { - try - { - std::cout << "on_warning(): " << text << std::endl; - } - catch(const Glib::ConvertError& ex) - { - std::cerr << "MySaxParser::on_warning(): Exception caught while converting text for std::cout: " << ex.what() << std::endl; - } + std::cout << "on_warning(): " << text << std::endl; } -void MySaxParser::on_error(const Glib::ustring& text) +void MySaxParser::on_error(const xmlpp::ustring& text) { - try - { - std::cout << "on_error(): " << text << std::endl; - } - catch(const Glib::ConvertError& ex) - { - std::cerr << "MySaxParser::on_error(): Exception caught while converting text for std::cout: " << ex.what() << std::endl; - } + std::cout << "on_error(): " << text << std::endl; } -void MySaxParser::on_fatal_error(const Glib::ustring& text) +void MySaxParser::on_fatal_error(const xmlpp::ustring& text) { - try - { - std::cout << "on_fatal_error(): " << text << std::endl; - } - catch(const Glib::ConvertError& ex) - { - std::cerr << "MySaxParser::on_characters(): Exception caught while converting value for std::cout: " << ex.what() << std::endl; - } + std::cout << "on_fatal_error(): " << text << std::endl; } diff --git a/examples/sax_parser/myparser.h b/examples/sax_parser/myparser.h index 34bece82..9dde6643 100644 --- a/examples/sax_parser/myparser.h +++ b/examples/sax_parser/myparser.h @@ -34,14 +34,14 @@ class MySaxParser : public xmlpp::SaxParser //overrides: void on_start_document() override; void on_end_document() override; - void on_start_element(const Glib::ustring& name, + void on_start_element(const xmlpp::ustring& name, const AttributeList& properties) override; - void on_end_element(const Glib::ustring& name) override; - void on_characters(const Glib::ustring& characters) override; - void on_comment(const Glib::ustring& text) override; - void on_warning(const Glib::ustring& text) override; - void on_error(const Glib::ustring& text) override; - void on_fatal_error(const Glib::ustring& text) override; + void on_end_element(const xmlpp::ustring& name) override; + void on_characters(const xmlpp::ustring& characters) override; + void on_comment(const xmlpp::ustring& text) override; + void on_warning(const xmlpp::ustring& text) override; + void on_error(const xmlpp::ustring& text) override; + void on_fatal_error(const xmlpp::ustring& text) override; }; diff --git a/examples/sax_parser_build_dom/main.cc b/examples/sax_parser_build_dom/main.cc index 613d85f1..d6016157 100644 --- a/examples/sax_parser_build_dom/main.cc +++ b/examples/sax_parser_build_dom/main.cc @@ -36,10 +36,6 @@ int main(int argc, char* argv[]) { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - std::string filepath; if(argc > 1 ) filepath = argv[1]; //Allow the user to specify a different XML file to parse. diff --git a/examples/sax_parser_build_dom/svgelement.cc b/examples/sax_parser_build_dom/svgelement.cc index 8a39ced3..de17d4e4 100644 --- a/examples/sax_parser_build_dom/svgelement.cc +++ b/examples/sax_parser_build_dom/svgelement.cc @@ -31,12 +31,12 @@ Element::~Element() {} // example custom methods -void Element::set_style(const Glib::ustring& style) +void Element::set_style(const xmlpp::ustring& style) { set_attribute("style", style); } -const Glib::ustring Element::get_style() const +const xmlpp::ustring Element::get_style() const { return get_attribute("style")->get_value(); } diff --git a/examples/sax_parser_build_dom/svgelement.h b/examples/sax_parser_build_dom/svgelement.h index 963c0f65..362869e6 100644 --- a/examples/sax_parser_build_dom/svgelement.h +++ b/examples/sax_parser_build_dom/svgelement.h @@ -22,7 +22,7 @@ #ifndef __LIBXMLPP_SVGELEMENT_H #define __LIBXMLPP_SVGELEMENT_H -#include +#include "libxml++/ustring.h" #include #include @@ -36,8 +36,8 @@ class Element : public xmlpp::Element ~Element() override; // example custom methods - void set_style(const Glib::ustring& style); - const Glib::ustring get_style() const; + void set_style(const xmlpp::ustring& style); + const xmlpp::ustring get_style() const; // TODO: add custom methods diff --git a/examples/sax_parser_build_dom/svgparser.cc b/examples/sax_parser_build_dom/svgparser.cc index 44bfe91a..89f9e529 100644 --- a/examples/sax_parser_build_dom/svgparser.cc +++ b/examples/sax_parser_build_dom/svgparser.cc @@ -39,7 +39,7 @@ Parser::~Parser() { } -void Parser::on_start_element(const Glib::ustring& name, +void Parser::on_start_element(const xmlpp::ustring& name, const AttributeList& attributes) { //This method replaces the normal libxml++ node @@ -48,10 +48,10 @@ void Parser::on_start_element(const Glib::ustring& name, //work with future versions of libxml++. // Parse namespace prefix and save for later: - Glib::ustring elementPrefix; - Glib::ustring elementName = name; - Glib::ustring::size_type idx = name.find(':'); - if (idx != Glib::ustring::npos) //If the separator was found + xmlpp::ustring elementPrefix; + xmlpp::ustring elementName = name; + xmlpp::ustring::size_type idx = name.find(':'); + if (idx != xmlpp::ustring::npos) //If the separator was found { elementPrefix = name.substr(0, idx); elementName = name.substr(idx + 1); @@ -109,7 +109,7 @@ void Parser::on_start_element(const Glib::ustring& name, const auto attr_name = attr_pair.name; const auto attr_value = attr_pair.value; const auto idx_colon = attr_name.find(':'); - if (idx_colon == Glib::ustring::npos) // If the separator was not found. + if (idx_colon == xmlpp::ustring::npos) // If the separator was not found. { if (attr_name == "xmlns") // This is a namespace declaration. { @@ -146,19 +146,19 @@ void Parser::on_start_element(const Glib::ustring& name, } } -void Parser::on_end_element(const Glib::ustring& /* name */) +void Parser::on_end_element(const xmlpp::ustring& /* name */) { // This causes the next child elements to be added to the sibling, not this node. m_context.pop(); } -void Parser::on_characters(const Glib::ustring& text) +void Parser::on_characters(const xmlpp::ustring& text) { if(!m_context.empty()) m_context.top()->add_child_text(text); } -void Parser::on_comment(const Glib::ustring& text) +void Parser::on_comment(const xmlpp::ustring& text) { if(!m_context.empty()) m_context.top()->add_child_comment(text); @@ -166,22 +166,22 @@ void Parser::on_comment(const Glib::ustring& text) m_doc.add_comment(text); } -void Parser::on_warning(const Glib::ustring& text) +void Parser::on_warning(const xmlpp::ustring& text) { std::cout << "on_warning(): " << text << std::endl; } -void Parser::on_error(const Glib::ustring& text) +void Parser::on_error(const xmlpp::ustring& text) { std::cout << "on_error(): " << text << std::endl; } -void Parser::on_fatal_error(const Glib::ustring& text) +void Parser::on_fatal_error(const xmlpp::ustring& text) { std::cout << "on_fatal_error(): " << text << std::endl; } -void Parser::on_cdata_block(const Glib::ustring& text) +void Parser::on_cdata_block(const xmlpp::ustring& text) { if(!m_context.empty()) m_context.top()->add_child_cdata(text); diff --git a/examples/sax_parser_build_dom/svgparser.h b/examples/sax_parser_build_dom/svgparser.h index 60b591f6..ef28c29a 100644 --- a/examples/sax_parser_build_dom/svgparser.h +++ b/examples/sax_parser_build_dom/svgparser.h @@ -23,7 +23,7 @@ #define __LIBXMLPP_SVGPARSER_H #include -#include +#include "libxml++/ustring.h" #include namespace SVG { @@ -38,15 +38,15 @@ class Parser : public xmlpp::SaxParser // SAX parser callbacks void on_start_document() override {}; void on_end_document() override {}; - void on_start_element(const Glib::ustring& name, + void on_start_element(const xmlpp::ustring& name, const AttributeList& properties) override; - void on_end_element(const Glib::ustring& name) override; - void on_characters(const Glib::ustring& characters) override; - void on_comment(const Glib::ustring& text) override; - void on_warning(const Glib::ustring& text) override; - void on_error(const Glib::ustring& text) override; - void on_fatal_error(const Glib::ustring& text) override; - void on_cdata_block(const Glib::ustring& text) override; + void on_end_element(const xmlpp::ustring& name) override; + void on_characters(const xmlpp::ustring& characters) override; + void on_comment(const xmlpp::ustring& text) override; + void on_warning(const xmlpp::ustring& text) override; + void on_error(const xmlpp::ustring& text) override; + void on_fatal_error(const xmlpp::ustring& text) override; + void on_cdata_block(const xmlpp::ustring& text) override; private: // context is a stack to keep track of parent node while the SAX parser diff --git a/examples/sax_parser_build_dom/svgpath.h b/examples/sax_parser_build_dom/svgpath.h index 9648e204..bc75970a 100644 --- a/examples/sax_parser_build_dom/svgpath.h +++ b/examples/sax_parser_build_dom/svgpath.h @@ -22,7 +22,7 @@ #ifndef __LIBXMLPP_SVGPATH_H #define __LIBXMLPP_SVGPATH_H -#include +#include "libxml++/ustring.h" #include #include "svgelement.h" @@ -35,7 +35,7 @@ class Path : public Element : Element(node) {} - const Glib::ustring get_data() const + const xmlpp::ustring get_data() const { return get_attribute("d")->get_value(); } diff --git a/examples/sax_parser_entities/main.cc b/examples/sax_parser_entities/main.cc index fd19391d..ed372d0d 100644 --- a/examples/sax_parser_entities/main.cc +++ b/examples/sax_parser_entities/main.cc @@ -30,10 +30,6 @@ int main(int argc, char* argv[]) { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - std::string filepath; if(argc > 1 ) filepath = argv[1]; //Allow the user to specify a different XML file to parse. diff --git a/examples/sax_parser_entities/myparser.cc b/examples/sax_parser_entities/myparser.cc index 4ea7145f..a19cdf6e 100644 --- a/examples/sax_parser_entities/myparser.cc +++ b/examples/sax_parser_entities/myparser.cc @@ -40,7 +40,7 @@ void MySaxParser::on_end_document() std::cout << "on_end_document()" << std::endl; } -void MySaxParser::on_start_element(const Glib::ustring& name, +void MySaxParser::on_start_element(const xmlpp::ustring& name, const AttributeList& attributes) { std::cout << "node name=" << name << std::endl; @@ -52,37 +52,37 @@ void MySaxParser::on_start_element(const Glib::ustring& name, } } -void MySaxParser::on_end_element(const Glib::ustring& /* name */) +void MySaxParser::on_end_element(const xmlpp::ustring& /* name */) { std::cout << "on_end_element()" << std::endl; } -void MySaxParser::on_characters(const Glib::ustring& text) +void MySaxParser::on_characters(const xmlpp::ustring& text) { std::cout << "on_characters(): " << text << std::endl; } -void MySaxParser::on_comment(const Glib::ustring& text) +void MySaxParser::on_comment(const xmlpp::ustring& text) { std::cout << "on_comment(): " << text << std::endl; } -void MySaxParser::on_warning(const Glib::ustring& text) +void MySaxParser::on_warning(const xmlpp::ustring& text) { std::cout << "on_warning(): " << text << std::endl; } -void MySaxParser::on_error(const Glib::ustring& text) +void MySaxParser::on_error(const xmlpp::ustring& text) { std::cout << "on_error(): " << text << std::endl; } -void MySaxParser::on_fatal_error(const Glib::ustring& text) +void MySaxParser::on_fatal_error(const xmlpp::ustring& text) { std::cout << "on_fatal_error(): " << text << std::endl; } -_xmlEntity* MySaxParser::on_get_entity(const Glib::ustring& name) +_xmlEntity* MySaxParser::on_get_entity(const xmlpp::ustring& name) { std::cout << "on_get_entity(): " << name << std::endl; @@ -90,7 +90,7 @@ _xmlEntity* MySaxParser::on_get_entity(const Glib::ustring& name) return SaxParser::on_get_entity(name); } -void MySaxParser::on_entity_declaration(const Glib::ustring& name, xmlpp::XmlEntityType type, const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content) +void MySaxParser::on_entity_declaration(const xmlpp::ustring& name, xmlpp::XmlEntityType type, const xmlpp::ustring& publicId, const xmlpp::ustring& systemId, const xmlpp::ustring& content) { std::cout << "on_entity_declaration(): name=" << name << ", publicId=" << publicId << ", systemId=" << systemId << ", content=" << content << std::endl; diff --git a/examples/sax_parser_entities/myparser.h b/examples/sax_parser_entities/myparser.h index 30001095..312667c2 100644 --- a/examples/sax_parser_entities/myparser.h +++ b/examples/sax_parser_entities/myparser.h @@ -32,18 +32,18 @@ class MySaxParser : public xmlpp::SaxParser //overrides: void on_start_document() override; void on_end_document() override; - void on_start_element(const Glib::ustring& name, + void on_start_element(const xmlpp::ustring& name, const AttributeList& properties) override; - void on_end_element(const Glib::ustring& name) override; - void on_characters(const Glib::ustring& characters) override; - void on_comment(const Glib::ustring& text) override; - void on_warning(const Glib::ustring& text) override; - void on_error(const Glib::ustring& text) override; - void on_fatal_error(const Glib::ustring& text) override; + void on_end_element(const xmlpp::ustring& name) override; + void on_characters(const xmlpp::ustring& characters) override; + void on_comment(const xmlpp::ustring& text) override; + void on_warning(const xmlpp::ustring& text) override; + void on_error(const xmlpp::ustring& text) override; + void on_fatal_error(const xmlpp::ustring& text) override; - _xmlEntity* on_get_entity(const Glib::ustring& name) override; - void on_entity_declaration(const Glib::ustring& name, xmlpp::XmlEntityType type, - const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content) override; + _xmlEntity* on_get_entity(const xmlpp::ustring& name) override; + void on_entity_declaration(const xmlpp::ustring& name, xmlpp::XmlEntityType type, + const xmlpp::ustring& publicId, const xmlpp::ustring& systemId, const xmlpp::ustring& content) override; }; #endif //__LIBXMLPP_EXAMPLES_MYPARSER_H diff --git a/examples/schemavalidation/main.cc b/examples/schemavalidation/main.cc index f488bc0e..a5de5e07 100644 --- a/examples/schemavalidation/main.cc +++ b/examples/schemavalidation/main.cc @@ -27,10 +27,6 @@ int main(int argc, char* argv[]) { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - std::string docfilepath("example.xml"); std::string xsdschemafilepath("example.xsd"); std::string rngschemafilepath("example.rng"); @@ -48,7 +44,7 @@ int main(int argc, char* argv[]) rngschemafilepath = argv[3]; } - Glib::ustring phase; + xmlpp::ustring phase; try { phase = "XSD"; diff --git a/examples/testutilities.cc b/examples/testutilities.cc deleted file mode 100644 index 4509e822..00000000 --- a/examples/testutilities.cc +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (C) 2013 The libxml++ development team - * - * This file is part of libxml++. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#include "testutilities.h" -#include - -std::ostream& operator<<(std::ostream& os, const CatchConvertError& utf8_string) -{ - try - { - os << static_cast(utf8_string); - } - catch (const Glib::ConvertError& ex) - { - os << "[Glib::ConvertError: " << ex.what() << "]"; - } - return os; -} diff --git a/examples/testutilities.h b/examples/testutilities.h deleted file mode 100644 index 31576d00..00000000 --- a/examples/testutilities.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (C) 2013 The libxml++ development team - * - * This file is part of libxml++. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library. If not, see . - */ - -#include -#include - -// CatchConvertError is identical to Glib::ustring, except that -// std::ostream& operator<<(std::ostream&, const CatchConvertError&) -// catches Glib::ConvertError, and prints the exception message. -// -// If a printed string contains characters that don't exist in the global -// locale's character set, an exception is thrown, but it's caught locally, -// and the program continues. -// This is particularly useful when the example programs are run by 'make check'. -// If the user-specified locale's character set does not contain all characters -// in the Glib::ustring, operator<<(std::ostream&, const Glib::ustring&) throws -// a Glib::ConvertError exception. That exception is not the result of an error -// in libxml++ or libxml2. -// See also https://bugzilla.gnome.org/show_bug.cgi?id=702136 - -class CatchConvertError : public Glib::ustring -{ -public: - explicit CatchConvertError(const Glib::ustring& str) - : Glib::ustring(str) - { } -}; - -std::ostream& operator<<(std::ostream& os, const CatchConvertError& utf8_string); - diff --git a/examples/textreader/main.cc b/examples/textreader/main.cc index adc78e4b..0d748cad 100644 --- a/examples/textreader/main.cc +++ b/examples/textreader/main.cc @@ -45,10 +45,6 @@ std::ostream & operator<<(std::ostream & o, indent const & in) int main(int /* argc */, char** /* argv */) { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - try { xmlpp::TextReader reader("example.xml"); diff --git a/libxml++/attribute.h b/libxml++/attribute.h index 01c46238..9f939cfe 100644 --- a/libxml++/attribute.h +++ b/libxml++/attribute.h @@ -8,7 +8,7 @@ #define __LIBXMLPP_ATTRIBUTE_H -#include +#include "libxml++/ustring.h" #include @@ -27,7 +27,7 @@ class Attribute : public Node /** Get the value of this attribute. * @returns The attribute's value. */ - virtual Glib::ustring get_value() const = 0; + virtual ustring get_value() const = 0; }; } // namespace xmlpp diff --git a/libxml++/attributedeclaration.cc b/libxml++/attributedeclaration.cc index d1877217..bd30b097 100644 --- a/libxml++/attributedeclaration.cc +++ b/libxml++/attributedeclaration.cc @@ -20,7 +20,7 @@ AttributeDeclaration::~AttributeDeclaration() { } -Glib::ustring AttributeDeclaration::get_value() const +ustring AttributeDeclaration::get_value() const { return (const char*)cobj()->defaultValue; } diff --git a/libxml++/attributedeclaration.h b/libxml++/attributedeclaration.h index 50448966..81d29622 100644 --- a/libxml++/attributedeclaration.h +++ b/libxml++/attributedeclaration.h @@ -7,7 +7,7 @@ #ifndef __LIBXMLPP_ATTRIBUTEDECLARATION_H #define __LIBXMLPP_ATTRIBUTEDECLARATION_H -#include +#include "libxml++/ustring.h" #include @@ -34,7 +34,7 @@ class AttributeDeclaration : public Attribute /** Get the default value of this attribute. * @returns The attribute's default value. */ - Glib::ustring get_value() const override; + ustring get_value() const override; ///Access the underlying libxml implementation. _xmlAttribute* cobj() noexcept; diff --git a/libxml++/attributenode.cc b/libxml++/attributenode.cc index c585c312..2d999fda 100644 --- a/libxml++/attributenode.cc +++ b/libxml++/attributenode.cc @@ -20,7 +20,7 @@ AttributeNode::~AttributeNode() { } -Glib::ustring AttributeNode::get_value() const +ustring AttributeNode::get_value() const { xmlChar* value = nullptr; if (cobj()->ns && cobj()->ns->href) @@ -28,13 +28,13 @@ Glib::ustring AttributeNode::get_value() const else value = xmlGetNoNsProp(cobj()->parent, cobj()->name); - const Glib::ustring retn = value ? (const char*)value : ""; + const ustring retn = value ? (const char*)value : ""; if (value) xmlFree(value); return retn; } -void AttributeNode::set_value(const Glib::ustring& value) +void AttributeNode::set_value(const ustring& value) { if (cobj()->ns) xmlSetNsProp(cobj()->parent, cobj()->ns, cobj()->name, (const xmlChar*)value.c_str()); diff --git a/libxml++/attributenode.h b/libxml++/attributenode.h index af6c4c58..27c63939 100644 --- a/libxml++/attributenode.h +++ b/libxml++/attributenode.h @@ -8,7 +8,7 @@ #define __LIBXMLPP_ATTRIBUTENODE_H -#include +#include "libxml++/ustring.h" #include @@ -35,13 +35,13 @@ class AttributeNode : public Attribute /** Get the value of this attribute. * @returns The attribute's value. */ - Glib::ustring get_value() const override; + ustring get_value() const override; /** Set the value of this attribute. * * @newin{3,0} Replaces Attribute::set_value() */ - void set_value(const Glib::ustring& value); + void set_value(const ustring& value); /** Access the underlying libxml implementation. * diff --git a/libxml++/document.cc b/libxml++/document.cc index 9a5d39b0..be1456ab 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -134,7 +134,7 @@ void remove_found_wrappers(xmlNode* node, NodeMap& node_map) namespace xmlpp { -static const char* get_encoding_or_utf8(const Glib::ustring& encoding) +static const char* get_encoding_or_utf8(const ustring& encoding) { if(encoding.empty()) { @@ -168,7 +168,7 @@ Document::Init::~Init() noexcept Document::Init Document::init_; -Document::Document(const Glib::ustring& version) +Document::Document(const ustring& version) : impl_(xmlNewDoc((const xmlChar*)version.c_str())) { if (!impl_) @@ -191,9 +191,9 @@ Document::~Document() xmlFreeDoc(impl_); } -Glib::ustring Document::get_encoding() const +ustring Document::get_encoding() const { - Glib::ustring encoding; + ustring encoding; if(impl_->encoding) encoding = (const char*)impl_->encoding; @@ -212,9 +212,9 @@ Dtd* Document::get_internal_subset() const return reinterpret_cast(dtd->_private); } -void Document::set_internal_subset(const Glib::ustring& name, - const Glib::ustring& external_id, - const Glib::ustring& system_id) +void Document::set_internal_subset(const ustring& name, + const ustring& external_id, + const ustring& system_id) { auto dtd = xmlCreateIntSubset(impl_, (const xmlChar*)name.c_str(), @@ -242,9 +242,9 @@ const Element* Document::get_root_node() const return const_cast(this)->get_root_node(); } -Element* Document::create_root_node(const Glib::ustring& name, - const Glib::ustring& ns_uri, - const Glib::ustring& ns_prefix) +Element* Document::create_root_node(const ustring& name, + const ustring& ns_uri, + const ustring& ns_prefix) { auto node = xmlNewDocNode(impl_, nullptr, (const xmlChar*)name.c_str(), nullptr); if (!node) @@ -293,7 +293,7 @@ Element* Document::create_root_node_by_import(const Node* node, return get_root_node(); } -CommentNode* Document::add_comment(const Glib::ustring& content) +CommentNode* Document::add_comment(const ustring& content) { auto child = xmlNewComment((const xmlChar*)content.c_str()); @@ -309,7 +309,7 @@ CommentNode* Document::add_comment(const Glib::ustring& content) } ProcessingInstructionNode* Document::add_processing_instruction( - const Glib::ustring& name, const Glib::ustring& content) + const ustring& name, const ustring& content) { auto child = xmlNewDocPI(impl_, (const xmlChar*)name.c_str(), (const xmlChar*)content.c_str()); auto node = xmlAddChild((xmlNode*)impl_, child); @@ -322,39 +322,39 @@ ProcessingInstructionNode* Document::add_processing_instruction( return static_cast(node->_private); } -void Document::write_to_file(const std::string& filename, const Glib::ustring& encoding) +void Document::write_to_file(const std::string& filename, const ustring& encoding) { do_write_to_file(filename, encoding, false); } -void Document::write_to_file_formatted(const std::string& filename, const Glib::ustring& encoding) +void Document::write_to_file_formatted(const std::string& filename, const ustring& encoding) { do_write_to_file(filename, encoding, true); } -Glib::ustring Document::write_to_string(const Glib::ustring& encoding) +ustring Document::write_to_string(const ustring& encoding) { return do_write_to_string(encoding, false); } -Glib::ustring Document::write_to_string_formatted(const Glib::ustring& encoding) +ustring Document::write_to_string_formatted(const ustring& encoding) { return do_write_to_string(encoding, true); } -void Document::write_to_stream(std::ostream& output, const Glib::ustring& encoding) +void Document::write_to_stream(std::ostream& output, const ustring& encoding) { do_write_to_stream(output, encoding.empty()?get_encoding():encoding, false); } -void Document::write_to_stream_formatted(std::ostream& output, const Glib::ustring& encoding) +void Document::write_to_stream_formatted(std::ostream& output, const ustring& encoding) { do_write_to_stream(output, encoding.empty()?get_encoding():encoding, true); } void Document::do_write_to_file( const std::string& filename, - const Glib::ustring& encoding, + const ustring& encoding, bool format) { KeepBlanks k(KeepBlanks::Default); @@ -369,8 +369,8 @@ void Document::do_write_to_file( } } -Glib::ustring Document::do_write_to_string( - const Glib::ustring& encoding, +ustring Document::do_write_to_string( + const ustring& encoding, bool format) { KeepBlanks k(KeepBlanks::Default); @@ -387,12 +387,12 @@ Glib::ustring Document::do_write_to_string( throw exception("do_write_to_string() failed.\n" + format_xml_error()); } - // Create a Glib::ustring copy of the buffer + // Create a ustring copy of the buffer - // Here we force the use of Glib::ustring::ustring( InputIterator begin, InputIterator end ) - // instead of Glib::ustring::ustring( const char*, size_type ) because it + // Here we force the use of ustring::ustring( InputIterator begin, InputIterator end ) + // instead of ustring::ustring( const char*, size_type ) because it // expects the length of the string in characters, not in bytes. - Glib::ustring result( reinterpret_cast(buffer), reinterpret_cast(buffer + length) ); + ustring result( reinterpret_cast(buffer), reinterpret_cast(buffer + length) ); // Deletes the original buffer xmlFree(buffer); @@ -400,7 +400,7 @@ Glib::ustring Document::do_write_to_string( return result; } -void Document::do_write_to_stream(std::ostream& output, const Glib::ustring& encoding, bool format) +void Document::do_write_to_stream(std::ostream& output, const ustring& encoding, bool format) { // TODO assert document encoding is UTF-8 if encoding is different than UTF-8 OStreamOutputBuffer buffer(output, encoding); @@ -414,9 +414,9 @@ void Document::do_write_to_stream(std::ostream& output, const Glib::ustring& enc } } -void Document::set_entity_declaration(const Glib::ustring& name, XmlEntityType type, - const Glib::ustring& publicId, const Glib::ustring& systemId, - const Glib::ustring& content) +void Document::set_entity_declaration(const ustring& name, XmlEntityType type, + const ustring& publicId, const ustring& systemId, + const ustring& content) { auto entity = xmlAddDocEntity(impl_, (const xmlChar*)name.c_str(), static_cast(type), @@ -473,7 +473,7 @@ int Document::process_xinclude(bool generate_xinclude_nodes, bool fixup_base_uri return n_substitutions; } -_xmlEntity* Document::get_entity(const Glib::ustring& name) +_xmlEntity* Document::get_entity(const ustring& name) { return xmlGetDocEntity(impl_, (const xmlChar*) name.c_str()); } diff --git a/libxml++/document.h b/libxml++/document.h index 3bf8eeee..745a193b 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -19,10 +19,10 @@ #include #include -/* std::string or Glib::ustring in function prototypes in libxml++? +/* std::string or ustring in function prototypes in libxml++? * * If it's propagated to a libxml2 function that takes a xmlChar*, it's - * UTF-8 encoded, and Glib::ustring is the right choice. + * UTF-8 encoded, and ustring is the right choice. * * If it's propagated to a libxml2 function that takes a char*, it's not * necessarily UTF-8 encoded, and std::string is usually the right choice. @@ -79,7 +79,7 @@ class Document : public NonCopyable * @param version XML version. * @throws xmlpp::internal_error If memory allocation fails. */ - explicit Document(const Glib::ustring& version = "1.0"); + explicit Document(const ustring& version = "1.0"); /** Create a new C++ wrapper for an xmlDoc struct. * The created xmlpp::Document takes ownership of the xmlDoc. @@ -93,7 +93,7 @@ class Document : public NonCopyable /** @return The encoding used in the source from which the document has been loaded. */ - Glib::ustring get_encoding() const; + ustring get_encoding() const; /** Get the internal subset of this document. * @returns A pointer to the DTD, or nullptr if not found. @@ -106,9 +106,9 @@ class Document : public NonCopyable * @param external_id The external (PUBLIC) ID, or an empty string. * @param system_id The system ID, or an empty string. */ - void set_internal_subset(const Glib::ustring& name, - const Glib::ustring& external_id, - const Glib::ustring& system_id); + void set_internal_subset(const ustring& name, + const ustring& external_id, + const ustring& system_id); /** Return the root node. * This function does @b not create a default root node if it doesn't exist. @@ -134,9 +134,9 @@ class Document : public NonCopyable * @throws xmlpp::internal_error If memory allocation fails. * @throws xmlpp::exception If a new namespace node cannot be created. */ - Element* create_root_node(const Glib::ustring& name, - const Glib::ustring& ns_uri = Glib::ustring(), - const Glib::ustring& ns_prefix = Glib::ustring() ); + Element* create_root_node(const ustring& name, + const ustring& ns_uri = ustring(), + const ustring& ns_prefix = ustring() ); /** Create a root element node by importing the node from another document, * without affecting the source node. @@ -156,7 +156,7 @@ class Document : public NonCopyable * @returns The new comment node. * @throws xmlpp::internal_error */ - CommentNode* add_comment(const Glib::ustring& content); + CommentNode* add_comment(const ustring& content); /** Append a new processing instruction node. * @@ -168,14 +168,14 @@ class Document : public NonCopyable * @throws xmlpp::internal_error */ ProcessingInstructionNode* add_processing_instruction( - const Glib::ustring& name, const Glib::ustring& content); + const ustring& name, const ustring& content); /** Write the document to a file. * @param filename * @param encoding If not provided, UTF-8 is used * @throws xmlpp::exception */ - void write_to_file(const std::string& filename, const Glib::ustring& encoding = Glib::ustring()); + void write_to_file(const std::string& filename, const ustring& encoding = ustring()); /** Write the document to a file. * The output is formatted by inserting whitespaces, which is easier to read for a human, @@ -184,14 +184,14 @@ class Document : public NonCopyable * @param encoding If not provided, UTF-8 is used * @throws xmlpp::exception */ - void write_to_file_formatted(const std::string& filename, const Glib::ustring& encoding = Glib::ustring()); + void write_to_file_formatted(const std::string& filename, const ustring& encoding = ustring()); /** Write the document to the memory. * @param encoding If not provided, UTF-8 is used * @returns The written document. * @throws xmlpp::exception */ - Glib::ustring write_to_string(const Glib::ustring& encoding = Glib::ustring()); + ustring write_to_string(const ustring& encoding = ustring()); /** Write the document to the memory. * The output is formatted by inserting whitespaces, which is easier to read for a human, @@ -200,7 +200,7 @@ class Document : public NonCopyable * @returns The written document. * @throws xmlpp::exception */ - Glib::ustring write_to_string_formatted(const Glib::ustring& encoding = Glib::ustring()); + ustring write_to_string_formatted(const ustring& encoding = ustring()); /** Write the document to a std::ostream. * @param output A reference to the stream in which the document will be written @@ -210,7 +210,7 @@ class Document : public NonCopyable * @warning This method is much less efficient than write_to_string if you want to dump the * document to a buffer or the standard output. Writing to a fstream is almost as fast as write_to_file */ - void write_to_stream(std::ostream& output, const Glib::ustring& encoding = Glib::ustring()); + void write_to_stream(std::ostream& output, const ustring& encoding = ustring()); /** Write the document to a std::ostream. * The output is formatted by inserting whitespaces, which is easier to read for a human, @@ -221,7 +221,7 @@ class Document : public NonCopyable * @throws xmlpp::internal_error * @warning See write_to_stream */ - void write_to_stream_formatted(std::ostream & output, const Glib::ustring& encoding = Glib::ustring()); + void write_to_stream_formatted(std::ostream & output, const ustring& encoding = ustring()); /** Add an Entity declaration to the document. * @param name The name of the entity that will be used in an entity reference. @@ -232,9 +232,9 @@ class Document : public NonCopyable * is the replacement value. * @throws xmlpp::internal_error */ - virtual void set_entity_declaration(const Glib::ustring& name, XmlEntityType type, - const Glib::ustring& publicId, const Glib::ustring& systemId, - const Glib::ustring& content); + virtual void set_entity_declaration(const ustring& name, XmlEntityType type, + const ustring& publicId, const ustring& systemId, + const ustring& content); /** Perform XInclude substitution on the XML document. * XInclude substitution may both add and delete nodes in the document, @@ -269,12 +269,12 @@ class Document : public NonCopyable * @param name The name of the entity to get. * @returns A pointer to the libxml2 entity structure, or nullptr if not found. */ - _xmlEntity* get_entity(const Glib::ustring& name); + _xmlEntity* get_entity(const ustring& name); private: - void do_write_to_file(const std::string& filename, const Glib::ustring& encoding, bool format); - Glib::ustring do_write_to_string(const Glib::ustring& encoding, bool format); - void do_write_to_stream(std::ostream& output, const Glib::ustring& encoding, bool format); + void do_write_to_file(const std::string& filename, const ustring& encoding, bool format); + ustring do_write_to_string(const ustring& encoding, bool format); + void do_write_to_stream(std::ostream& output, const ustring& encoding, bool format); static Init init_; diff --git a/libxml++/dtd.cc b/libxml++/dtd.cc index 586461cd..238b3a03 100644 --- a/libxml++/dtd.cc +++ b/libxml++/dtd.cc @@ -10,6 +10,8 @@ #include +#include + namespace xmlpp { @@ -43,7 +45,7 @@ Dtd::Dtd(const std::string& filename) parse_subset("", filename); } -Dtd::Dtd(const Glib::ustring& external, const Glib::ustring& system) +Dtd::Dtd(const ustring& external, const ustring& system) : pimpl_(new Impl) { parse_subset(external, system); @@ -59,7 +61,7 @@ void Dtd::parse_file(const std::string& filename) parse_subset("", filename); } -void Dtd::parse_subset(const Glib::ustring& external, const Glib::ustring& system) +void Dtd::parse_subset(const ustring& external, const ustring& system) { release_underlying(); // Free any existing dtd. xmlResetLastError(); @@ -78,7 +80,7 @@ void Dtd::parse_subset(const Glib::ustring& external, const Glib::ustring& syste pimpl_->is_dtd_owner = true; } -void Dtd::parse_memory(const Glib::ustring& contents) +void Dtd::parse_memory(const ustring& contents) { // Prepare an istream with buffer std::istringstream is(contents); @@ -105,17 +107,17 @@ void Dtd::parse_stream(std::istream& in) pimpl_->is_dtd_owner = true; } -Glib::ustring Dtd::get_name() const +ustring Dtd::get_name() const { return (pimpl_->dtd && pimpl_->dtd->name) ? (const char*)pimpl_->dtd->name : ""; } -Glib::ustring Dtd::get_external_id() const +ustring Dtd::get_external_id() const { return (pimpl_->dtd && pimpl_->dtd->ExternalID) ? (const char*)pimpl_->dtd->ExternalID : ""; } -Glib::ustring Dtd::get_system_id() const +ustring Dtd::get_system_id() const { return (pimpl_->dtd && pimpl_->dtd->SystemID) ? (const char*)pimpl_->dtd->SystemID : ""; } diff --git a/libxml++/dtd.h b/libxml++/dtd.h index 32ee21b8..7a72cdb9 100644 --- a/libxml++/dtd.h +++ b/libxml++/dtd.h @@ -8,7 +8,7 @@ #define __LIBXMLPP_DTD_H #include -#include +#include "libxml++/ustring.h" #include #include // std::unique_ptr @@ -62,7 +62,7 @@ class Dtd : public NonCopyable * @param system The URL of the DTD. * @throws xmlpp::parse_error */ - Dtd(const Glib::ustring& external, const Glib::ustring& system); + Dtd(const ustring& external, const ustring& system); ~Dtd() override; @@ -87,7 +87,7 @@ class Dtd : public NonCopyable * @param system The URL of the DTD. * @throws xmlpp::parse_error */ - void parse_subset(const Glib::ustring& external, const Glib::ustring& system); + void parse_subset(const ustring& external, const ustring& system); /** Parse a DTD from a string. * If another DTD has been parsed before, that DTD is replaced by the new one @@ -98,7 +98,7 @@ class Dtd : public NonCopyable * @param contents The DTD as a string. * @throws xmlpp::parse_error */ - void parse_memory(const Glib::ustring& contents); + void parse_memory(const ustring& contents); /** Parse a DTD from a stream. * If another DTD has been parsed before, that DTD is replaced by the new one @@ -111,9 +111,9 @@ class Dtd : public NonCopyable */ void parse_stream(std::istream& in); - Glib::ustring get_name() const; - Glib::ustring get_external_id() const; - Glib::ustring get_system_id() const; + ustring get_name() const; + ustring get_external_id() const; + ustring get_system_id() const; /** Access the underlying libxml implementation. */ diff --git a/libxml++/exceptions/exception.cc b/libxml++/exceptions/exception.cc index 99fcfc79..d2ed4943 100644 --- a/libxml++/exceptions/exception.cc +++ b/libxml++/exceptions/exception.cc @@ -6,7 +6,7 @@ namespace xmlpp { -exception::exception(const Glib::ustring& message) +exception::exception(const ustring& message) : message_(message) { } @@ -29,7 +29,7 @@ exception* exception::clone() const return new exception(*this); } -Glib::ustring format_xml_error(const _xmlError* error) +ustring format_xml_error(const _xmlError* error) { if (!error) error = xmlGetLastError(); @@ -37,7 +37,7 @@ Glib::ustring format_xml_error(const _xmlError* error) if (!error || error->code == XML_ERR_OK) return ""; // No error - Glib::ustring str; + ustring str; if (error->file && *error->file != '\0') { @@ -47,9 +47,9 @@ Glib::ustring format_xml_error(const _xmlError* error) if (error->line > 0) { - str += (str.empty() ? "Line " : ", line ") + Glib::ustring::format(error->line); + str += (str.empty() ? "Line " : ", line ") + std::to_string(error->line); if (error->int2 > 0) - str += ", column " + Glib::ustring::format(error->int2); + str += ", column " + std::to_string(error->int2); } const bool two_lines = !str.empty(); @@ -77,7 +77,7 @@ Glib::ustring format_xml_error(const _xmlError* error) if (error->message && *error->message != '\0') str += error->message; else - str += "Error code " + Glib::ustring::format(error->code); + str += "Error code " + std::to_string(error->code); // If the string does not end with end-of-line, append an end-of-line. if (*str.rbegin() != '\n') @@ -86,7 +86,7 @@ Glib::ustring format_xml_error(const _xmlError* error) return str; } -Glib::ustring format_xml_parser_error(const _xmlParserCtxt* parser_context) +ustring format_xml_parser_error(const _xmlParserCtxt* parser_context) { if (!parser_context) return "Error. xmlpp::format_xml_parser_error() called with parser_context == nullptr\n"; @@ -96,7 +96,7 @@ Glib::ustring format_xml_parser_error(const _xmlParserCtxt* parser_context) if (!error) return ""; // No error - Glib::ustring str; + ustring str; if (!parser_context->wellFormed) str += "Document not well-formed.\n"; @@ -104,7 +104,7 @@ Glib::ustring format_xml_parser_error(const _xmlParserCtxt* parser_context) return str + format_xml_error(error); } -Glib::ustring format_printf_message(const char* fmt, va_list args) +ustring format_printf_message(const char* fmt, va_list args) { // This code was inspired by the example at // http://en.cppreference.com/w/cpp/io/c/vfprintf @@ -115,11 +115,11 @@ Glib::ustring format_printf_message(const char* fmt, va_list args) const int nchar = std::vsnprintf(nullptr, 0, fmt, args2); va_end(args2); if (nchar < 0) - return Glib::ustring::format("Error code from std::vsnprintf = ", nchar); + return "Error code from std::vsnprintf = " + std::to_string(nchar); std::vector buf(nchar+1); std::vsnprintf(buf.data(), buf.size(), fmt, args); - return Glib::ustring(buf.data()); + return ustring(buf.data()); } } //namespace xmlpp diff --git a/libxml++/exceptions/exception.h b/libxml++/exceptions/exception.h index 7fbaf1e7..198f4239 100644 --- a/libxml++/exceptions/exception.h +++ b/libxml++/exceptions/exception.h @@ -22,7 +22,7 @@ #include #include // va_list -#include +#include "libxml++/ustring.h" #include @@ -39,7 +39,7 @@ namespace xmlpp class LIBXMLPP_API exception : public std::exception { public: - explicit exception(const Glib::ustring& message); + explicit exception(const ustring& message); ~exception() noexcept override; const char* what() const noexcept override; @@ -48,7 +48,7 @@ class LIBXMLPP_API exception : public std::exception virtual exception* clone() const; private: - Glib::ustring message_; + ustring message_; }; /** Format an _xmlError struct into a text string, suitable for printing. @@ -60,7 +60,7 @@ class LIBXMLPP_API exception : public std::exception * @returns A formatted text string. If the error struct does not contain an * error (error->code == XML_ERR_OK), an empty string is returned. */ -Glib::ustring format_xml_error(const _xmlError* error = nullptr); +ustring format_xml_error(const _xmlError* error = nullptr); /** Format a parser error into a text string, suitable for printing. * @@ -71,7 +71,7 @@ Glib::ustring format_xml_error(const _xmlError* error = nullptr); * error (parser_context->lastError.code == XML_ERR_OK), an empty * string is returned. */ -Glib::ustring format_xml_parser_error(const _xmlParserCtxt* parser_context); +ustring format_xml_parser_error(const _xmlParserCtxt* parser_context); /** Format a message from a function with C-style variadic parameters. * @@ -84,7 +84,7 @@ Glib::ustring format_xml_parser_error(const _xmlParserCtxt* parser_context); * { * va_list args; * va_start(args, fmt); - * Glib::ustring msg = xmlpp::format_printf_message(fmt, args); + * ustring msg = xmlpp::format_printf_message(fmt, args); * va_end(args); * // ... * } @@ -92,7 +92,7 @@ Glib::ustring format_xml_parser_error(const _xmlParserCtxt* parser_context); * * @newin{3,0} */ -Glib::ustring format_printf_message(const char* fmt, va_list args); +ustring format_printf_message(const char* fmt, va_list args); } // namespace xmlpp diff --git a/libxml++/exceptions/internal_error.cc b/libxml++/exceptions/internal_error.cc index 2bdbe1c7..215c2d9e 100644 --- a/libxml++/exceptions/internal_error.cc +++ b/libxml++/exceptions/internal_error.cc @@ -2,7 +2,7 @@ namespace xmlpp { -internal_error::internal_error(const Glib::ustring& message) +internal_error::internal_error(const ustring& message) : exception(message) { } diff --git a/libxml++/exceptions/internal_error.h b/libxml++/exceptions/internal_error.h index d60b0547..21f80b26 100644 --- a/libxml++/exceptions/internal_error.h +++ b/libxml++/exceptions/internal_error.h @@ -27,7 +27,7 @@ namespace xmlpp { class internal_error : public exception { public: - explicit internal_error(const Glib::ustring& message); + explicit internal_error(const ustring& message); ~internal_error() noexcept override; void raise() const override; diff --git a/libxml++/exceptions/parse_error.cc b/libxml++/exceptions/parse_error.cc index a83a3fc5..5708ccf0 100644 --- a/libxml++/exceptions/parse_error.cc +++ b/libxml++/exceptions/parse_error.cc @@ -2,7 +2,7 @@ namespace xmlpp { -parse_error::parse_error(const Glib::ustring& message) +parse_error::parse_error(const ustring& message) : exception(message) { } diff --git a/libxml++/exceptions/parse_error.h b/libxml++/exceptions/parse_error.h index 1abb0916..65f5965c 100644 --- a/libxml++/exceptions/parse_error.h +++ b/libxml++/exceptions/parse_error.h @@ -30,7 +30,7 @@ namespace xmlpp class parse_error : public exception { public: - explicit parse_error(const Glib::ustring& message); + explicit parse_error(const ustring& message); ~parse_error() noexcept override; void raise() const override; diff --git a/libxml++/exceptions/validity_error.cc b/libxml++/exceptions/validity_error.cc index 81006b66..537fe027 100644 --- a/libxml++/exceptions/validity_error.cc +++ b/libxml++/exceptions/validity_error.cc @@ -2,7 +2,7 @@ namespace xmlpp { -validity_error::validity_error(const Glib::ustring& message) +validity_error::validity_error(const ustring& message) : parse_error(message) { } diff --git a/libxml++/exceptions/validity_error.h b/libxml++/exceptions/validity_error.h index e264e4b7..17c5f8a2 100644 --- a/libxml++/exceptions/validity_error.h +++ b/libxml++/exceptions/validity_error.h @@ -30,7 +30,7 @@ namespace xmlpp class validity_error : public parse_error { public: - explicit validity_error(const Glib::ustring& message); + explicit validity_error(const ustring& message); ~validity_error() noexcept override; void raise() const override; diff --git a/libxml++/filelist.am b/libxml++/filelist.am index ee338a84..70fdd270 100644 --- a/libxml++/filelist.am +++ b/libxml++/filelist.am @@ -10,6 +10,7 @@ h_root_sources_public = \ noncopyable.h \ relaxngschema.h \ schemabase.h \ + ustring.h \ xsdschema.h h_exceptions_sources_public = \ exceptions/exception.h \ diff --git a/libxml++/io/ostreamoutputbuffer.cc b/libxml++/io/ostreamoutputbuffer.cc index f8b7a7f0..512b05fe 100644 --- a/libxml++/io/ostreamoutputbuffer.cc +++ b/libxml++/io/ostreamoutputbuffer.cc @@ -13,7 +13,7 @@ namespace xmlpp { OStreamOutputBuffer::OStreamOutputBuffer( std::ostream & output, - const Glib::ustring& encoding) + const ustring& encoding) : OutputBuffer(encoding), output_(output) { } diff --git a/libxml++/io/ostreamoutputbuffer.h b/libxml++/io/ostreamoutputbuffer.h index bef47bc8..ae750f14 100644 --- a/libxml++/io/ostreamoutputbuffer.h +++ b/libxml++/io/ostreamoutputbuffer.h @@ -26,7 +26,7 @@ namespace xmlpp * @param encoding Charset in which data will be encoded before being * sent to the stream */ - OStreamOutputBuffer(std::ostream& output, const Glib::ustring& encoding = Glib::ustring()); + OStreamOutputBuffer(std::ostream& output, const ustring& encoding = ustring()); ~OStreamOutputBuffer() override; private: diff --git a/libxml++/io/outputbuffer.cc b/libxml++/io/outputbuffer.cc index 9f3750bc..a0b4d663 100644 --- a/libxml++/io/outputbuffer.cc +++ b/libxml++/io/outputbuffer.cc @@ -32,7 +32,7 @@ namespace xmlpp OutputBuffer::OutputBuffer( - const Glib::ustring& encoding) + const ustring& encoding) { // we got to initialise the char encoding handler // The code is almost cut/paste from xmlSaveFormatFileEnc diff --git a/libxml++/io/outputbuffer.h b/libxml++/io/outputbuffer.h index e07b1537..90824b27 100644 --- a/libxml++/io/outputbuffer.h +++ b/libxml++/io/outputbuffer.h @@ -10,7 +10,7 @@ #ifndef __LIBXMLPP_OUTPUTBUFFER_H #define __LIBXMLPP_OUTPUTBUFFER_H -#include +#include "libxml++/ustring.h" #include #ifndef DOXYGEN_SHOULD_SKIP_THIS @@ -40,7 +40,7 @@ namespace xmlpp * @warning The encoding is done by libxml. As a consequence, libxml must * have a translator to the target encoding. */ - OutputBuffer(const Glib::ustring& encoding = Glib::ustring()); + OutputBuffer(const ustring& encoding = ustring()); ~OutputBuffer() override; public: diff --git a/libxml++/libxml++.h b/libxml++/libxml++.h index 81d8c8be..1de2bf97 100644 --- a/libxml++/libxml++.h +++ b/libxml++/libxml++.h @@ -74,5 +74,6 @@ #include #include #include +#include #endif //__LIBXMLCPP_H diff --git a/libxml++/nodes/contentnode.cc b/libxml++/nodes/contentnode.cc index 7a0ff57e..2347f479 100644 --- a/libxml++/nodes/contentnode.cc +++ b/libxml++/nodes/contentnode.cc @@ -19,7 +19,7 @@ ContentNode::ContentNode(xmlNode* node) ContentNode::~ContentNode() {} -Glib::ustring ContentNode::get_content() const +ustring ContentNode::get_content() const { if(cobj()->type == XML_ELEMENT_NODE) { @@ -29,7 +29,7 @@ Glib::ustring ContentNode::get_content() const return cobj()->content ? (char*)cobj()->content : ""; } -void ContentNode::set_content(const Glib::ustring& content) +void ContentNode::set_content(const ustring& content) { if(cobj()->type == XML_ELEMENT_NODE) { diff --git a/libxml++/nodes/contentnode.h b/libxml++/nodes/contentnode.h index 20ffaad3..d89e5331 100644 --- a/libxml++/nodes/contentnode.h +++ b/libxml++/nodes/contentnode.h @@ -24,13 +24,13 @@ class ContentNode : public Node * @returns The text. Note that the 5 predefined entities (&, ", <, >, ') * are always resolved, so this content will show their human-readable equivalents. */ - Glib::ustring get_content() const; + ustring get_content() const; /** Set the text of this content node * @param content The text. This must be unescaped, meaning that the predefined entities will be created for you where necessary. * See get_content(). */ - void set_content(const Glib::ustring& content); + void set_content(const ustring& content); /// @returns Whether this node contains only white space, or is empty. bool is_white_space() const; diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc index 979b1db5..ef1b6b03 100644 --- a/libxml++/nodes/element.cc +++ b/libxml++/nodes/element.cc @@ -9,10 +9,11 @@ #include + namespace // anonymous { // Common part of all add_child_element*() methods. -xmlpp::Element* add_child_element_common(const Glib::ustring& name, xmlNode* child, xmlNode* node) +xmlpp::Element* add_child_element_common(const xmlpp::ustring& name, xmlNode* child, xmlNode* node) { if (!node) { @@ -57,12 +58,12 @@ Element::const_AttributeList Element::get_attributes() const return attributes; } -Attribute* Element::get_attribute(const Glib::ustring& name, - const Glib::ustring& ns_prefix) +Attribute* Element::get_attribute(const ustring& name, + const ustring& ns_prefix) { // An empty ns_prefix means "use no namespace". // The default namespace never applies to an attribute. - Glib::ustring ns_uri; + ustring ns_uri; if (!ns_prefix.empty()) { ns_uri = get_namespace_uri_for_prefix(ns_prefix); @@ -85,20 +86,20 @@ Attribute* Element::get_attribute(const Glib::ustring& name, return nullptr; } -const Attribute* Element::get_attribute(const Glib::ustring& name, - const Glib::ustring& ns_prefix) const +const Attribute* Element::get_attribute(const ustring& name, + const ustring& ns_prefix) const { return const_cast(this)->get_attribute(name, ns_prefix); } -Glib::ustring Element::get_attribute_value(const Glib::ustring& name, const Glib::ustring& ns_prefix) const +ustring Element::get_attribute_value(const ustring& name, const ustring& ns_prefix) const { const auto attr = get_attribute(name, ns_prefix); - return attr ? attr->get_value() : Glib::ustring(); + return attr ? attr->get_value() : ustring(); } -Attribute* Element::set_attribute(const Glib::ustring& name, const Glib::ustring& value, - const Glib::ustring& ns_prefix) +Attribute* Element::set_attribute(const ustring& name, const ustring& value, + const ustring& ns_prefix) { xmlAttr* attr = nullptr; @@ -131,7 +132,7 @@ Attribute* Element::set_attribute(const Glib::ustring& name, const Glib::ustring return nullptr; } -void Element::remove_attribute(const Glib::ustring& name, const Glib::ustring& ns_prefix) +void Element::remove_attribute(const ustring& name, const ustring& ns_prefix) { // xmlHasProp() seaches for an attribute with a specified name in any namespace. // Not useful here. @@ -165,8 +166,8 @@ void Element::remove_attribute(const Glib::ustring& name, const Glib::ustring& n } } -Element* Element::add_child_element(const Glib::ustring& name, - const Glib::ustring& ns_prefix) +Element* Element::add_child_element(const ustring& name, + const ustring& ns_prefix) { auto child = create_new_child_element_node(name, ns_prefix); auto node = xmlAddChild(cobj(), child); @@ -174,7 +175,7 @@ Element* Element::add_child_element(const Glib::ustring& name, } Element* Element::add_child_element(xmlpp::Node* previous_sibling, - const Glib::ustring& name, const Glib::ustring& ns_prefix) + const ustring& name, const ustring& ns_prefix) { if (!previous_sibling) return nullptr; @@ -185,7 +186,7 @@ Element* Element::add_child_element(xmlpp::Node* previous_sibling, } Element* Element::add_child_element_before(xmlpp::Node* next_sibling, - const Glib::ustring& name, const Glib::ustring& ns_prefix) + const ustring& name, const ustring& ns_prefix) { if (!next_sibling) return nullptr; @@ -195,8 +196,8 @@ Element* Element::add_child_element_before(xmlpp::Node* next_sibling, return add_child_element_common(name, child, node); } -Element* Element::add_child_element_with_new_ns(const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) +Element* Element::add_child_element_with_new_ns(const ustring& name, + const ustring& ns_uri, const ustring& ns_prefix) { auto child = create_new_child_element_node_with_new_ns(name, ns_uri, ns_prefix); auto node = xmlAddChild(cobj(), child); @@ -204,8 +205,8 @@ Element* Element::add_child_element_with_new_ns(const Glib::ustring& name, } Element* Element::add_child_element_with_new_ns(xmlpp::Node* previous_sibling, - const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) + const ustring& name, + const ustring& ns_uri, const ustring& ns_prefix) { if (!previous_sibling) return nullptr; @@ -216,8 +217,8 @@ Element* Element::add_child_element_with_new_ns(xmlpp::Node* previous_sibling, } Element* Element::add_child_element_before_with_new_ns(xmlpp::Node* next_sibling, - const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) + const ustring& name, + const ustring& ns_uri, const ustring& ns_prefix) { if (!next_sibling) return nullptr; @@ -227,8 +228,8 @@ Element* Element::add_child_element_before_with_new_ns(xmlpp::Node* next_sibling return add_child_element_common(name, child, node); } -_xmlNode* Element::create_new_child_element_node(const Glib::ustring& name, - const Glib::ustring& ns_prefix) +_xmlNode* Element::create_new_child_element_node(const ustring& name, + const ustring& ns_prefix) { xmlNs* ns = nullptr; @@ -251,8 +252,8 @@ _xmlNode* Element::create_new_child_element_node(const Glib::ustring& name, return xmlNewNode(ns, (const xmlChar*)name.c_str()); } -_xmlNode* Element::create_new_child_element_node_with_new_ns(const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) +_xmlNode* Element::create_new_child_element_node_with_new_ns(const ustring& name, + const ustring& ns_uri, const ustring& ns_prefix) { if (cobj()->type != XML_ELEMENT_NODE) throw internal_error("You can only add child nodes to element nodes."); @@ -299,7 +300,7 @@ const TextNode* Element::get_first_child_text() const return const_cast(this)->get_first_child_text(); } -void Element::set_first_child_text(const Glib::ustring& content) +void Element::set_first_child_text(const ustring& content) { auto node = get_first_child_text(); if(node) @@ -308,7 +309,7 @@ void Element::set_first_child_text(const Glib::ustring& content) add_child_text(content); } -TextNode* Element::add_child_text(const Glib::ustring& content) +TextNode* Element::add_child_text(const ustring& content) { if(cobj()->type == XML_ELEMENT_NODE) { @@ -327,7 +328,7 @@ TextNode* Element::add_child_text(const Glib::ustring& content) return nullptr; } -TextNode* Element::add_child_text(xmlpp::Node* previous_sibling, const Glib::ustring& content) +TextNode* Element::add_child_text(xmlpp::Node* previous_sibling, const ustring& content) { if(!previous_sibling) return nullptr; @@ -349,7 +350,7 @@ TextNode* Element::add_child_text(xmlpp::Node* previous_sibling, const Glib::ust return nullptr; } -TextNode* Element::add_child_text_before(xmlpp::Node* next_sibling, const Glib::ustring& content) +TextNode* Element::add_child_text_before(xmlpp::Node* next_sibling, const ustring& content) { if(!next_sibling) return nullptr; @@ -376,7 +377,7 @@ bool Element::has_child_text() const return get_first_child_text() != nullptr; } -void Element::set_namespace_declaration(const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix) +void Element::set_namespace_declaration(const ustring& ns_uri, const ustring& ns_prefix) { //Create a new namespace declaration for this element: auto ns = xmlNewNs(cobj(), (const xmlChar*)(ns_uri.empty() ? nullptr : ns_uri.c_str()), @@ -400,9 +401,9 @@ void Element::set_namespace_declaration(const Glib::ustring& ns_uri, const Glib: //We ignore the returned xmlNs*. It's owned by the XML_ELEMENT_NODE. } -Glib::ustring Element::get_namespace_uri_for_prefix(const Glib::ustring& ns_prefix) const +ustring Element::get_namespace_uri_for_prefix(const ustring& ns_prefix) const { - Glib::ustring result; + ustring result; //Find the namespace: const auto ns = xmlSearchNs( cobj()->doc, const_cast(cobj()), (xmlChar*)ns_prefix.c_str() ); @@ -413,7 +414,7 @@ Glib::ustring Element::get_namespace_uri_for_prefix(const Glib::ustring& ns_pref return result; } -CommentNode* Element::add_child_comment(const Glib::ustring& content) +CommentNode* Element::add_child_comment(const ustring& content) { auto child = xmlNewComment((const xmlChar*)content.c_str()); @@ -428,9 +429,9 @@ CommentNode* Element::add_child_comment(const Glib::ustring& content) return static_cast(node->_private); } -CdataNode* Element::add_child_cdata(const Glib::ustring& content) +CdataNode* Element::add_child_cdata(const ustring& content) { - auto child = xmlNewCDataBlock(cobj()->doc, (const xmlChar*)content.c_str(), content.bytes()); + auto child = xmlNewCDataBlock(cobj()->doc, (const xmlChar*)content.c_str(), content.size()); auto node = xmlAddChild(cobj(), child); if (!node) { @@ -441,7 +442,7 @@ CdataNode* Element::add_child_cdata(const Glib::ustring& content) return static_cast(node->_private); } -EntityReference* Element::add_child_entity_reference(const Glib::ustring& name) +EntityReference* Element::add_child_entity_reference(const ustring& name) { const auto extended_name = name + " "; // This is at least two chars long. int ichar = 0; @@ -466,7 +467,7 @@ EntityReference* Element::add_child_entity_reference(const Glib::ustring& name) } ProcessingInstructionNode* Element::add_child_processing_instruction( - const Glib::ustring& name, const Glib::ustring& content) + const ustring& name, const ustring& content) { auto child = xmlNewDocPI(cobj()->doc, (const xmlChar*)name.c_str(), (const xmlChar*)content.c_str()); auto node = xmlAddChild(cobj(), child); diff --git a/libxml++/nodes/element.h b/libxml++/nodes/element.h index 326df912..6ae0056f 100644 --- a/libxml++/nodes/element.h +++ b/libxml++/nodes/element.h @@ -45,7 +45,7 @@ class Element : public Node * @throws xmlpp::exception If a new namespace node cannot be created, * e.g. because a namespace with the same prefix but another URI already exists. */ - void set_namespace_declaration(const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring()); + void set_namespace_declaration(const ustring& ns_uri, const ustring& ns_prefix = ustring()); /** Obtain the list of explicitly set attributes for this element. * @returns The list of explicitly set attributes. @@ -65,8 +65,8 @@ class Element : public Node * attribute, or an AttributeDeclaration*, pointing to the declaration * of an attribute with a default value. */ - Attribute* get_attribute(const Glib::ustring& name, - const Glib::ustring& ns_prefix = Glib::ustring()); + Attribute* get_attribute(const ustring& name, + const ustring& ns_prefix = ustring()); /** Get the attribute with this name, and optionally with this namespace. * @param name The name of the attribute that will be retrieved. @@ -76,8 +76,8 @@ class Element : public Node * attribute, or an AttributeDeclaration*, pointing to the declaration * of an attribute with a default value. */ - const Attribute* get_attribute(const Glib::ustring& name, - const Glib::ustring& ns_prefix = Glib::ustring()) const; + const Attribute* get_attribute(const ustring& name, + const ustring& ns_prefix = ustring()) const; /** Get the value of the attribute with this name, and optionally with this namespace. * For finer control, you might use get_attribute() and use the methods of the Attribute class. @@ -87,8 +87,8 @@ class Element : public Node * * @newin{2,20} */ - Glib::ustring get_attribute_value(const Glib::ustring& name, - const Glib::ustring& ns_prefix = Glib::ustring()) const; + ustring get_attribute_value(const ustring& name, + const ustring& ns_prefix = ustring()) const; /** Set the value of the attribute with this name, and optionally with this namespace. * A matching attribute will be added if no matching attribute already exists. @@ -99,15 +99,15 @@ class Element : public Node * @return The attribute that was changed, or nullptr is no suitable Attribute was found. * @throws xmlpp::exception */ - Attribute* set_attribute(const Glib::ustring& name, const Glib::ustring& value, - const Glib::ustring& ns_prefix = Glib::ustring()); + Attribute* set_attribute(const ustring& name, const ustring& value, + const ustring& ns_prefix = ustring()); /** Remove the attribute with this name, and optionally with this namespace. * @param name The name of the attribute to be removed * @param ns_prefix Namespace prefix. If specified, the attribute will be removed only if the attribute has this namespace. */ - void remove_attribute(const Glib::ustring& name, - const Glib::ustring& ns_prefix = Glib::ustring()); + void remove_attribute(const ustring& name, + const ustring& ns_prefix = ustring()); /** Add a child element to this node. * @@ -120,8 +120,8 @@ class Element : public Node * @throws xmlpp::internal_error If this node is not an element node, * or the child node cannot be created. */ - Element* add_child_element(const Glib::ustring& name, - const Glib::ustring& ns_prefix = Glib::ustring()); + Element* add_child_element(const ustring& name, + const ustring& ns_prefix = ustring()); /** Add a child element to this node after the specified existing child node. * @@ -135,8 +135,8 @@ class Element : public Node * @throws xmlpp::internal_error If this node is not an element node, * or the child node cannot be created. */ - Element* add_child_element(xmlpp::Node* previous_sibling, const Glib::ustring& name, - const Glib::ustring& ns_prefix = Glib::ustring()); + Element* add_child_element(xmlpp::Node* previous_sibling, const ustring& name, + const ustring& ns_prefix = ustring()); /** Add a child element to this node before the specified existing child node. * @@ -150,8 +150,8 @@ class Element : public Node * @throws xmlpp::internal_error If this node is not an element node, * or the child node cannot be created. */ - Element* add_child_element_before(xmlpp::Node* next_sibling, const Glib::ustring& name, - const Glib::ustring& ns_prefix = Glib::ustring()); + Element* add_child_element_before(xmlpp::Node* next_sibling, const ustring& name, + const ustring& ns_prefix = ustring()); /** Add a child element to this node. * @@ -166,8 +166,8 @@ class Element : public Node * @throws xmlpp::internal_error If this node is not an element node, * or the child node or the namespace node cannot be created. */ - Element* add_child_element_with_new_ns(const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring()); + Element* add_child_element_with_new_ns(const ustring& name, + const ustring& ns_uri, const ustring& ns_prefix = ustring()); /** Add a child element to this node after the specified existing child node. * @@ -183,8 +183,8 @@ class Element : public Node * @throws xmlpp::internal_error If this node is not an element node, * or the child node or the namespace node cannot be created. */ - Element* add_child_element_with_new_ns(xmlpp::Node* previous_sibling, const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring()); + Element* add_child_element_with_new_ns(xmlpp::Node* previous_sibling, const ustring& name, + const ustring& ns_uri, const ustring& ns_prefix = ustring()); /** Add a child element to this node before the specified existing child node. * @@ -200,8 +200,8 @@ class Element : public Node * @throws xmlpp::internal_error If this node is not an element node, * or the child node or the namespace node cannot be created. */ - Element* add_child_element_before_with_new_ns(xmlpp::Node* next_sibling, const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix = Glib::ustring()); + Element* add_child_element_before_with_new_ns(xmlpp::Node* next_sibling, const ustring& name, + const ustring& ns_uri, const ustring& ns_prefix = ustring()); /** Get the first child text content node. * This is a convenience method, meant as an alternative to iterating over all the @@ -226,7 +226,7 @@ class Element : public Node * @returns The new text node. * @throws xmlpp::internal_error */ - TextNode* add_child_text(const Glib::ustring& content = Glib::ustring()); + TextNode* add_child_text(const ustring& content = ustring()); /** Add a new text node after the specified existing child node. * @@ -237,7 +237,7 @@ class Element : public Node * @returns The new text node. * @throws xmlpp::internal_error */ - TextNode* add_child_text(xmlpp::Node* previous_sibling, const Glib::ustring& content = Glib::ustring()); + TextNode* add_child_text(xmlpp::Node* previous_sibling, const ustring& content = ustring()); /** Add a new text node before the specified existing child node. * @@ -248,7 +248,7 @@ class Element : public Node * @returns The new text node. * @throws xmlpp::internal_error */ - TextNode* add_child_text_before(xmlpp::Node* next_sibling, const Glib::ustring& content = Glib::ustring()); + TextNode* add_child_text_before(xmlpp::Node* next_sibling, const ustring& content = ustring()); /** Set the text of the first text node, adding one if necessary. * This is a convenience method, meant as an alternative to iterating over all the @@ -258,7 +258,7 @@ class Element : public Node * * @newin{3,0} Replaces set_child_text(). */ - void set_first_child_text(const Glib::ustring& content); + void set_first_child_text(const ustring& content); /** Discover whether one of the child nodes is a text node. * This is a convenience method, meant as an alternative to iterating over all the child nodes and examining them directly. @@ -271,14 +271,14 @@ class Element : public Node * @returns The new comment node. * @throws xmlpp::internal_error */ - CommentNode* add_child_comment(const Glib::ustring& content); + CommentNode* add_child_comment(const ustring& content); /** Append a new CDATA node. * @param content The raw text. * @returns The new CDATA node. * @throws xmlpp::internal_error */ - CdataNode* add_child_cdata(const Glib::ustring& content); + CdataNode* add_child_cdata(const ustring& content); /** Append a new entity reference node. * The reference can be either an entity reference ("name" or "&name;") or @@ -294,7 +294,7 @@ class Element : public Node * @returns The new entity reference node. * @throws xmlpp::internal_error */ - EntityReference* add_child_entity_reference(const Glib::ustring& name); + EntityReference* add_child_entity_reference(const ustring& name); /** Append a new processing instruction node. * @@ -306,18 +306,18 @@ class Element : public Node * @throws xmlpp::internal_error */ ProcessingInstructionNode* add_child_processing_instruction( - const Glib::ustring& name, const Glib::ustring& content); + const ustring& name, const ustring& content); private: - Glib::ustring get_namespace_uri_for_prefix(const Glib::ustring& ns_prefix) const; + ustring get_namespace_uri_for_prefix(const ustring& ns_prefix) const; ///Create the C instance ready to be added to the parent node. - _xmlNode* create_new_child_element_node(const Glib::ustring& name, - const Glib::ustring& ns_prefix); + _xmlNode* create_new_child_element_node(const ustring& name, + const ustring& ns_prefix); ///Create the C instance ready to be added to the parent node. - _xmlNode* create_new_child_element_node_with_new_ns(const Glib::ustring& name, - const Glib::ustring& ns_uri, const Glib::ustring& ns_prefix); + _xmlNode* create_new_child_element_node_with_new_ns(const ustring& name, + const ustring& ns_uri, const ustring& ns_prefix); }; } // namespace xmlpp diff --git a/libxml++/nodes/entitydeclaration.cc b/libxml++/nodes/entitydeclaration.cc index 3b5c08aa..0a6390e8 100644 --- a/libxml++/nodes/entitydeclaration.cc +++ b/libxml++/nodes/entitydeclaration.cc @@ -17,12 +17,12 @@ EntityDeclaration::EntityDeclaration(xmlNode* node) EntityDeclaration::~EntityDeclaration() {} -Glib::ustring EntityDeclaration::get_resolved_text() const +ustring EntityDeclaration::get_resolved_text() const { return cobj()->content ? (const char*)cobj()->content : ""; } -Glib::ustring EntityDeclaration::get_original_text() const +ustring EntityDeclaration::get_original_text() const { return cobj()->orig ? (const char*)cobj()->orig : ""; } diff --git a/libxml++/nodes/entitydeclaration.h b/libxml++/nodes/entitydeclaration.h index 0cc3f3e7..626c5f15 100644 --- a/libxml++/nodes/entitydeclaration.h +++ b/libxml++/nodes/entitydeclaration.h @@ -35,12 +35,12 @@ class EntityDeclaration : public ContentNode * document had been parsed with Parser::set_substitute_entities(true). * @returns The text with character references unescaped. */ - Glib::ustring get_resolved_text() const; + ustring get_resolved_text() const; /** Get the text as read from the XML or DTD file. * @returns The escaped text. */ - Glib::ustring get_original_text() const; + ustring get_original_text() const; ///Access the underlying libxml implementation. _xmlEntity* cobj() noexcept; diff --git a/libxml++/nodes/entityreference.cc b/libxml++/nodes/entityreference.cc index 3f83c013..19b1b221 100644 --- a/libxml++/nodes/entityreference.cc +++ b/libxml++/nodes/entityreference.cc @@ -18,9 +18,9 @@ EntityReference::EntityReference(xmlNode* node) EntityReference::~EntityReference() {} -Glib::ustring EntityReference::get_resolved_text() const +ustring EntityReference::get_resolved_text() const { - Glib::ustring result; + ustring result; //Get the child xmlEntity node (there should only be 1). auto cChild = cobj()->children; @@ -35,9 +35,9 @@ Glib::ustring EntityReference::get_resolved_text() const return result; } -Glib::ustring EntityReference::get_original_text() const +ustring EntityReference::get_original_text() const { - Glib::ustring result; + ustring result; //Get the child xmlEntity node (there should only be 1). auto cChild = cobj()->children; diff --git a/libxml++/nodes/entityreference.h b/libxml++/nodes/entityreference.h index 7d626acc..58a467a7 100644 --- a/libxml++/nodes/entityreference.h +++ b/libxml++/nodes/entityreference.h @@ -26,12 +26,12 @@ class EntityReference : public Node * if the XML document had been parsed with Parser::set_substitute_entities(true). * @returns The text with character references unescaped. */ - Glib::ustring get_resolved_text() const; + ustring get_resolved_text() const; /** Get the text as read from the XML or DTD file. * @returns The escaped text. */ - Glib::ustring get_original_text() const; + ustring get_original_text() const; }; diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index 3dd47c3b..bc47cc65 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -39,7 +39,7 @@ xmlpp::Node* _convert_node(xmlNode* node) // Common part of const and non-const get_children() template -Tlist get_children_common(const Glib::ustring& name, xmlNode* child) +Tlist get_children_common(const xmlpp::ustring& name, xmlNode* child) { Tlist children; @@ -55,7 +55,7 @@ Tlist get_children_common(const Glib::ustring& name, xmlNode* child) // Common part of all overloaded xmlpp::Node::find() methods. template -Tvector find_common(const Glib::ustring& xpath, +Tvector find_common(const xmlpp::ustring& xpath, const xmlpp::Node::PrefixNsMap* namespaces, xmlNode* node) { auto ctxt = xmlXPathNewContext(node->doc); @@ -129,7 +129,7 @@ Tvector find_common(const Glib::ustring& xpath, } // Common part of xmlpp::Node::eval_to_[boolean|number|string] -xmlXPathObject* eval_common(const Glib::ustring& xpath, +xmlXPathObject* eval_common(const xmlpp::ustring& xpath, const xmlpp::Node::PrefixNsMap* namespaces, xmlpp::XPathResultType* result_type, xmlNode* node) { @@ -175,7 +175,7 @@ xmlXPathObject* eval_common(const Glib::ustring& xpath, } // Common part of all overloaded xmlpp::Node::eval_to_boolean() methods. -bool eval_common_to_boolean(const Glib::ustring& xpath, +bool eval_common_to_boolean(const xmlpp::ustring& xpath, const xmlpp::Node::PrefixNsMap* namespaces, xmlpp::XPathResultType* result_type, xmlNode* node) { @@ -186,7 +186,7 @@ bool eval_common_to_boolean(const Glib::ustring& xpath, } // Common part of all overloaded xmlpp::Node::eval_to_number() methods. -double eval_common_to_number(const Glib::ustring& xpath, +double eval_common_to_number(const xmlpp::ustring& xpath, const xmlpp::Node::PrefixNsMap* namespaces, xmlpp::XPathResultType* result_type, xmlNode* node) { @@ -197,7 +197,7 @@ double eval_common_to_number(const Glib::ustring& xpath, } // Common part of all overloaded xmlpp::Node::eval_to_string() methods. -Glib::ustring eval_common_to_string(const Glib::ustring& xpath, +xmlpp::ustring eval_common_to_string(const xmlpp::ustring& xpath, const xmlpp::Node::PrefixNsMap* namespaces, xmlpp::XPathResultType* result_type, xmlNode* node) { @@ -206,11 +206,11 @@ Glib::ustring eval_common_to_string(const Glib::ustring& xpath, xmlXPathFreeObject(xpath_value); if (result) { - const Glib::ustring uresult(reinterpret_cast(result)); + const xmlpp::ustring uresult(reinterpret_cast(result)); xmlFree(result); return uresult; } - return Glib::ustring(); + return {}; } } // anonymous namespace @@ -272,7 +272,7 @@ Node* Node::get_previous_sibling() return static_cast(cobj()->prev->_private); } -Node* Node::get_first_child(const Glib::ustring& name) +Node* Node::get_first_child(const ustring& name) { auto child = impl_->children; if(!child) @@ -288,17 +288,17 @@ Node* Node::get_first_child(const Glib::ustring& name) return nullptr; } -const Node* Node::get_first_child(const Glib::ustring& name) const +const Node* Node::get_first_child(const ustring& name) const { return const_cast(this)->get_first_child(name); } -Node::NodeList Node::get_children(const Glib::ustring& name) +Node::NodeList Node::get_children(const ustring& name) { return get_children_common(name, impl_->children); } -Node::const_NodeList Node::get_children(const Glib::ustring& name) const +Node::const_NodeList Node::get_children(const ustring& name) const { return get_children_common(name, impl_->children); } @@ -360,12 +360,12 @@ Node* Node::import_node(const Node* node, bool recursive) return static_cast(added_node->_private); } -Glib::ustring Node::get_name() const +ustring Node::get_name() const { return impl_->name ? (const char*)impl_->name : ""; } -void Node::set_name(const Glib::ustring& name) +void Node::set_name(const ustring& name) { xmlNodeSetName( impl_, (const xmlChar *)name.c_str() ); } @@ -386,68 +386,68 @@ const xmlNode* Node::cobj() const noexcept return impl_; } -Glib::ustring Node::get_path() const +ustring Node::get_path() const { xmlChar* path = xmlGetNodePath(impl_); - Glib::ustring retn = path ? (char*)path : ""; + ustring retn = path ? (char*)path : ""; xmlFree(path); return retn; } -Node::NodeSet Node::find(const Glib::ustring& xpath) +Node::NodeSet Node::find(const ustring& xpath) { return find_common(xpath, nullptr, impl_); } -Node::const_NodeSet Node::find(const Glib::ustring& xpath) const +Node::const_NodeSet Node::find(const ustring& xpath) const { return find_common(xpath, nullptr, impl_); } -Node::NodeSet Node::find(const Glib::ustring& xpath, const PrefixNsMap& namespaces) +Node::NodeSet Node::find(const ustring& xpath, const PrefixNsMap& namespaces) { return find_common(xpath, &namespaces, impl_); } -Node::const_NodeSet Node::find(const Glib::ustring& xpath, const PrefixNsMap& namespaces) const +Node::const_NodeSet Node::find(const ustring& xpath, const PrefixNsMap& namespaces) const { return find_common(xpath, &namespaces, impl_); } -bool Node::eval_to_boolean(const Glib::ustring& xpath, XPathResultType* result_type) const +bool Node::eval_to_boolean(const ustring& xpath, XPathResultType* result_type) const { return eval_common_to_boolean(xpath, nullptr, result_type, impl_); } -bool Node::eval_to_boolean(const Glib::ustring& xpath, const PrefixNsMap& namespaces, +bool Node::eval_to_boolean(const ustring& xpath, const PrefixNsMap& namespaces, XPathResultType* result_type) const { return eval_common_to_boolean(xpath, &namespaces, result_type, impl_); } -double Node::eval_to_number(const Glib::ustring& xpath, XPathResultType* result_type) const +double Node::eval_to_number(const ustring& xpath, XPathResultType* result_type) const { return eval_common_to_number(xpath, nullptr, result_type, impl_); } -double Node::eval_to_number(const Glib::ustring& xpath, const PrefixNsMap& namespaces, +double Node::eval_to_number(const ustring& xpath, const PrefixNsMap& namespaces, XPathResultType* result_type) const { return eval_common_to_number(xpath, &namespaces, result_type, impl_); } -Glib::ustring Node::eval_to_string(const Glib::ustring& xpath, XPathResultType* result_type) const +ustring Node::eval_to_string(const ustring& xpath, XPathResultType* result_type) const { return eval_common_to_string(xpath, nullptr, result_type, impl_); } -Glib::ustring Node::eval_to_string(const Glib::ustring& xpath, const PrefixNsMap& namespaces, +ustring Node::eval_to_string(const ustring& xpath, const PrefixNsMap& namespaces, XPathResultType* result_type) const { return eval_common_to_string(xpath, &namespaces, result_type, impl_); } -Glib::ustring Node::get_namespace_prefix() const +ustring Node::get_namespace_prefix() const { if(impl_->type == XML_DOCUMENT_NODE || impl_->type == XML_ENTITY_DECL) { @@ -458,7 +458,7 @@ Glib::ustring Node::get_namespace_prefix() const //This can be an issue when calling this method on a Node returned by Node::find(). //See the TODO comment on Document, suggesting that Document should derive from Node. - return Glib::ustring(); + return ustring(); } else if (impl_->type == XML_ATTRIBUTE_DECL) { @@ -469,10 +469,10 @@ Glib::ustring Node::get_namespace_prefix() const else if(impl_->ns && impl_->ns->prefix) return (char*)impl_->ns->prefix; else - return Glib::ustring(); + return ustring(); } -Glib::ustring Node::get_namespace_uri() const +ustring Node::get_namespace_uri() const { if(impl_->type == XML_DOCUMENT_NODE || impl_->type == XML_ENTITY_DECL || @@ -485,16 +485,16 @@ Glib::ustring Node::get_namespace_uri() const //This can be an issue when calling this method on a Node returned by Node::find(). //See the TODO comment on Document, suggesting that Document should derived from Node. - return Glib::ustring(); + return ustring(); } if(impl_->ns && impl_->ns->href) return (char*)impl_->ns->href; else - return Glib::ustring(); + return ustring(); } -void Node::set_namespace(const Glib::ustring& ns_prefix) +void Node::set_namespace(const ustring& ns_prefix) { if (impl_->type == XML_ATTRIBUTE_DECL) { @@ -599,7 +599,7 @@ void Node::create_wrapper(xmlNode* node) { // good default for release versions node->_private = new xmlpp::Node(node); - std::cerr << G_STRFUNC << " Warning: new node of unknown type created: " + std::cerr << __PRETTY_FUNCTION__ << " Warning: new node of unknown type created: " << node->type << std::endl; break; } diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index e5ac5a01..098e070d 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -9,7 +9,7 @@ #include #include -#include +#include "libxml++/ustring.h" #include #include #include @@ -70,29 +70,29 @@ class Node : public NonCopyable /** Get the name of this node. * @returns The node's name. */ - Glib::ustring get_name() const; + ustring get_name() const; /** Set the name of this node. * @param name The new name for the node. */ - void set_name(const Glib::ustring& name); + void set_name(const ustring& name); /** Set the namespace prefix used by the node. * If no such namespace prefix has been declared then this method will throw an exception. * @param ns_prefix The namespace prefix. * @throws xmlpp::exception */ - void set_namespace(const Glib::ustring& ns_prefix); + void set_namespace(const ustring& ns_prefix); /** Get the namespace prefix of this node. * @returns The node's namespace prefix. Can be an empty string. */ - Glib::ustring get_namespace_prefix() const; + ustring get_namespace_prefix() const; /** Get the namespace URI of this node. * @returns The node's namespace URI. Can be an empty string. */ - Glib::ustring get_namespace_uri() const; + ustring get_namespace_uri() const; /** Discover at what line number this node occurs in the XML file. * @returns The line number. @@ -136,7 +136,7 @@ class Node : public NonCopyable * * @newin{2,36} */ - const Node* get_first_child(const Glib::ustring& name = Glib::ustring()) const; + const Node* get_first_child(const ustring& name = ustring()) const; /** Get the first child of this node. * You may optionally get the first child node which has a certain name. @@ -145,19 +145,19 @@ class Node : public NonCopyable * * @newin{2,36} */ - Node* get_first_child(const Glib::ustring& name = Glib::ustring()); + Node* get_first_child(const ustring& name = ustring()); /** Obtain the list of child nodes. You may optionally obtain a list of only the child nodes which have a certain name. * @param name The names of the child nodes to get. If you do not specify a name, then the list will contain all nodes, regardless of their names. * @returns The list of child nodes. */ - NodeList get_children(const Glib::ustring& name = Glib::ustring()); + NodeList get_children(const ustring& name = ustring()); /** Obtain the list of child nodes. You may optionally obtain a list of only the child nodes which have a certain name. * @param name The names of the child nodes to get. If you do not specify a name, then the list will contain all nodes, regardless of their names. * @returns The list of child nodes. */ - const_NodeList get_children(const Glib::ustring& name = Glib::ustring()) const; + const_NodeList get_children(const ustring& name = ustring()) const; /** Remove a node and its children. * @@ -190,7 +190,7 @@ class Node : public NonCopyable /** Get the XPath of this node. * @result The XPath of the node. */ - Glib::ustring get_path() const; + ustring get_path() const; /** Find nodes from an XPath expression. * @param xpath The XPath of the nodes. @@ -198,7 +198,7 @@ class Node : public NonCopyable * @throws xmlpp::exception If the XPath expression cannot be evaluated. * @throws xmlpp::internal_error If the result type is not nodeset. */ - NodeSet find(const Glib::ustring& xpath); + NodeSet find(const ustring& xpath); /** Find nodes from an XPath expression. * @param xpath The XPath of the nodes. @@ -206,11 +206,11 @@ class Node : public NonCopyable * @throws xmlpp::exception If the XPath expression cannot be evaluated. * @throws xmlpp::internal_error If the result type is not nodeset. */ - const_NodeSet find(const Glib::ustring& xpath) const; + const_NodeSet find(const ustring& xpath) const; /** A map of namespace prefixes to namespace URIs. */ - using PrefixNsMap = std::map; + using PrefixNsMap = std::map; /** Find nodes from an XPath expression. * @param xpath The XPath of the nodes. @@ -219,7 +219,7 @@ class Node : public NonCopyable * @throws xmlpp::exception If the XPath expression cannot be evaluated. * @throws xmlpp::internal_error If the result type is not nodeset. */ - NodeSet find(const Glib::ustring& xpath, const PrefixNsMap& namespaces); + NodeSet find(const ustring& xpath, const PrefixNsMap& namespaces); /** Find nodes from an XPath expression. * @param xpath The XPath of the nodes. @@ -228,7 +228,7 @@ class Node : public NonCopyable * @throws xmlpp::exception If the XPath expression cannot be evaluated. * @throws xmlpp::internal_error If the result type is not nodeset. */ - const_NodeSet find(const Glib::ustring& xpath, const PrefixNsMap& namespaces) const; + const_NodeSet find(const ustring& xpath, const PrefixNsMap& namespaces) const; /** Evaluate an XPath expression. * @param xpath The XPath expression. @@ -241,7 +241,7 @@ class Node : public NonCopyable * * @newin{2,36} */ - bool eval_to_boolean(const Glib::ustring& xpath, XPathResultType* result_type = nullptr) const; + bool eval_to_boolean(const ustring& xpath, XPathResultType* result_type = nullptr) const; /** Evaluate an XPath expression. @@ -256,7 +256,7 @@ class Node : public NonCopyable * * @newin{2,36} */ - bool eval_to_boolean(const Glib::ustring& xpath, const PrefixNsMap& namespaces, + bool eval_to_boolean(const ustring& xpath, const PrefixNsMap& namespaces, XPathResultType* result_type = nullptr) const; /** Evaluate an XPath expression. @@ -270,7 +270,7 @@ class Node : public NonCopyable * * @newin{2,36} */ - double eval_to_number(const Glib::ustring& xpath, XPathResultType* result_type = nullptr) const; + double eval_to_number(const ustring& xpath, XPathResultType* result_type = nullptr) const; /** Evaluate an XPath expression. * @param xpath The XPath expression. @@ -284,7 +284,7 @@ class Node : public NonCopyable * * @newin{2,36} */ - double eval_to_number(const Glib::ustring& xpath, const PrefixNsMap& namespaces, + double eval_to_number(const ustring& xpath, const PrefixNsMap& namespaces, XPathResultType* result_type = nullptr) const; /** Evaluate an XPath expression. @@ -298,7 +298,7 @@ class Node : public NonCopyable * * @newin{2,36} */ - Glib::ustring eval_to_string(const Glib::ustring& xpath, XPathResultType* result_type = nullptr) const; + ustring eval_to_string(const ustring& xpath, XPathResultType* result_type = nullptr) const; /** Evaluate an XPath expression. * @param xpath The XPath expression. @@ -312,7 +312,7 @@ class Node : public NonCopyable * * @newin{2,36} */ - Glib::ustring eval_to_string(const Glib::ustring& xpath, const PrefixNsMap& namespaces, + ustring eval_to_string(const ustring& xpath, const PrefixNsMap& namespaces, XPathResultType* result_type = nullptr) const; ///Access the underlying libxml implementation. diff --git a/libxml++/parsers/domparser.cc b/libxml++/parsers/domparser.cc index 53a78258..ef856362 100644 --- a/libxml++/parsers/domparser.cc +++ b/libxml++/parsers/domparser.cc @@ -100,9 +100,9 @@ void DomParser::parse_memory_raw(const unsigned char* contents, size_type bytes_ parse_context(); } -void DomParser::parse_memory(const Glib::ustring& contents) +void DomParser::parse_memory(const ustring& contents) { - parse_memory_raw((const unsigned char*)contents.c_str(), contents.bytes()); + parse_memory_raw((const unsigned char*)contents.c_str(), contents.size()); } void DomParser::parse_context() @@ -195,7 +195,7 @@ void DomParser::parse_stream(std::istream& in) initialize_context(); - // std::string or Glib::ustring? + // std::string or ustring? // Output from the XML parser is UTF-8 encoded. // But the istream "in" is input, i.e. an XML file. It can use any encoding. // If it's not UTF-8, the file itself must contain information about which @@ -233,7 +233,7 @@ void DomParser::parse_stream(std::istream& in) auto error_str = format_xml_parser_error(context_); if (error_str.empty() && firstParseError != XML_ERR_OK) - error_str = "Error code from xmlParseChunk(): " + Glib::ustring::format(firstParseError); + error_str = "Error code from xmlParseChunk(): " + std::to_string(firstParseError); if(!error_str.empty()) { diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index ddccd24c..699551bf 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -76,7 +76,7 @@ class DomParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - void parse_memory(const Glib::ustring& contents) override; + void parse_memory(const ustring& contents) override; /** Parse an XML document from raw memory. * If the parser already contains a document, that document and all its nodes diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc index 69c859e7..5b5d1684 100644 --- a/libxml++/parsers/parser.cc +++ b/libxml++/parsers/parser.cc @@ -21,10 +21,10 @@ struct Parser::Impl {} // Built gradually - used in an exception at the end of parsing. - Glib::ustring parser_error_; - Glib::ustring parser_warning_; - Glib::ustring validate_error_; - Glib::ustring validate_warning_; + ustring parser_error_; + ustring parser_warning_; + ustring validate_error_; + ustring validate_warning_; bool throw_messages_; bool validate_; @@ -169,24 +169,24 @@ void Parser::release_underlying() } } -void Parser::on_parser_error(const Glib::ustring& message) +void Parser::on_parser_error(const ustring& message) { //Throw an exception later when the whole message has been received: pimpl_->parser_error_ += message; } -void Parser::on_parser_warning(const Glib::ustring& message) +void Parser::on_parser_warning(const ustring& message) { //Throw an exception later when the whole message has been received: pimpl_->parser_warning_ += message; } -void Parser::on_validity_error(const Glib::ustring& message) +void Parser::on_validity_error(const ustring& message) { //Throw an exception later when the whole message has been received: pimpl_->validate_error_ += message; } -void Parser::on_validity_warning(const Glib::ustring& message) +void Parser::on_validity_warning(const ustring& message) { //Throw an exception later when the whole message has been received: pimpl_->validate_warning_ += message; @@ -194,7 +194,7 @@ void Parser::on_validity_warning(const Glib::ustring& message) void Parser::check_for_error_and_warning_messages() { - Glib::ustring msg(exception_ ? exception_->what() : ""); + ustring msg(exception_ ? exception_->what() : ""); bool parser_msg = false; bool validity_msg = false; diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index 4cc92b18..a5970ccd 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -155,7 +155,7 @@ class Parser : public NonCopyable * @throw exception * @param contents The XML document as a string. */ - virtual void parse_memory(const Glib::ustring& contents) = 0; + virtual void parse_memory(const ustring& contents) = 0; /** Parse an XML document from a stream. * @throw exception @@ -169,10 +169,10 @@ class Parser : public NonCopyable virtual void initialize_context(); virtual void release_underlying(); - virtual void on_parser_error(const Glib::ustring& message); - virtual void on_parser_warning(const Glib::ustring& message); - virtual void on_validity_error(const Glib::ustring& message); - virtual void on_validity_warning(const Glib::ustring& message); + virtual void on_parser_error(const ustring& message); + virtual void on_parser_warning(const ustring& message); + virtual void on_validity_error(const ustring& message); + virtual void on_validity_warning(const ustring& message); /// To be called in an exception handler. virtual void handle_exception(); diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index 4ce408be..71674877 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -86,12 +86,12 @@ SaxParser::~SaxParser() release_underlying(); } -xmlEntityPtr SaxParser::on_get_entity(const Glib::ustring& name) +xmlEntityPtr SaxParser::on_get_entity(const ustring& name) { return entity_resolver_doc_->get_entity(name); } -void SaxParser::on_entity_declaration(const Glib::ustring& name, XmlEntityType type, const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content) +void SaxParser::on_entity_declaration(const ustring& name, XmlEntityType type, const ustring& publicId, const ustring& systemId, const ustring& content) { entity_resolver_doc_->set_entity_declaration(name, type, publicId, systemId, content); } @@ -104,43 +104,43 @@ void SaxParser::on_end_document() { } -void SaxParser::on_start_element(const Glib::ustring& /* name */, const AttributeList& /* attributes */) +void SaxParser::on_start_element(const ustring& /* name */, const AttributeList& /* attributes */) { } -void SaxParser::on_end_element(const Glib::ustring& /* name */) +void SaxParser::on_end_element(const ustring& /* name */) { } -void SaxParser::on_characters(const Glib::ustring& /* text */) +void SaxParser::on_characters(const ustring& /* text */) { } -void SaxParser::on_comment(const Glib::ustring& /* text */) +void SaxParser::on_comment(const ustring& /* text */) { } -void SaxParser::on_warning(const Glib::ustring& /* text */) +void SaxParser::on_warning(const ustring& /* text */) { } -void SaxParser::on_error(const Glib::ustring& /* text */) +void SaxParser::on_error(const ustring& /* text */) { } -void SaxParser::on_fatal_error(const Glib::ustring& text) +void SaxParser::on_fatal_error(const ustring& text) { throw parse_error("Fatal error: " + text); } -void SaxParser::on_cdata_block(const Glib::ustring& /* text */) +void SaxParser::on_cdata_block(const ustring& /* text */) { } -void SaxParser::on_internal_subset(const Glib::ustring& name, - const Glib::ustring& publicId, - const Glib::ustring& systemId) +void SaxParser::on_internal_subset(const ustring& name, + const ustring& publicId, + const ustring& systemId) { entity_resolver_doc_->set_internal_subset(name, publicId, systemId); } @@ -204,9 +204,9 @@ void SaxParser::parse_memory_raw(const unsigned char* contents, size_type bytes_ parse(); } -void SaxParser::parse_memory(const Glib::ustring& contents) +void SaxParser::parse_memory(const ustring& contents) { - parse_memory_raw((const unsigned char*)contents.c_str(), contents.bytes()); + parse_memory_raw((const unsigned char*)contents.c_str(), contents.size()); } void SaxParser::parse_stream(std::istream& in) @@ -233,7 +233,7 @@ void SaxParser::parse_stream(std::istream& in) initialize_context(); - // std::string or Glib::ustring? + // std::string or ustring? // Output from the XML parser is UTF-8 encoded. // But the istream "in" is input, i.e. an XML file. It can use any encoding. // If it's not UTF-8, the file itself must contain information about which @@ -267,7 +267,7 @@ void SaxParser::parse_stream(std::istream& in) auto error_str = format_xml_parser_error(context_); if (error_str.empty() && firstParseError != XML_ERR_OK) - error_str = "Error code from xmlParseChunk(): " + Glib::ustring::format(firstParseError); + error_str = "Error code from xmlParseChunk(): " + std::to_string(firstParseError); release_underlying(); // Free context_ @@ -279,9 +279,9 @@ void SaxParser::parse_stream(std::istream& in) } } -void SaxParser::parse_chunk(const Glib::ustring& chunk) +void SaxParser::parse_chunk(const ustring& chunk) { - parse_chunk_raw((const unsigned char*)chunk.c_str(), chunk.bytes()); + parse_chunk_raw((const unsigned char*)chunk.c_str(), chunk.size()); } void SaxParser::parse_chunk_raw(const unsigned char* contents, size_type bytes_count) @@ -315,7 +315,7 @@ void SaxParser::parse_chunk_raw(const unsigned char* contents, size_type bytes_c auto error_str = format_xml_parser_error(context_); if (error_str.empty() && parseError != XML_ERR_OK) - error_str = "Error code from xmlParseChunk(): " + Glib::ustring::format(parseError); + error_str = "Error code from xmlParseChunk(): " + std::to_string(parseError); if(!error_str.empty()) { throw parse_error(error_str); @@ -350,7 +350,7 @@ void SaxParser::finish_chunk_parsing() auto error_str = format_xml_parser_error(context_); if (error_str.empty() && parseError != XML_ERR_OK) - error_str = "Error code from xmlParseChunk(): " + Glib::ustring::format(parseError); + error_str = "Error code from xmlParseChunk(): " + std::to_string(parseError); release_underlying(); // Free context_ @@ -401,11 +401,11 @@ void SaxParserCallback::entity_decl(void* context, const xmlChar* name, int type try { parser->on_entity_declaration( - ( name ? Glib::ustring((const char*)name) : ""), + ( name ? ustring((const char*)name) : ""), static_cast(type), - ( publicId ? Glib::ustring((const char*)publicId) : ""), - ( systemId ? Glib::ustring((const char*)systemId) : ""), - ( content ? Glib::ustring((const char*)content) : "") ); + ( publicId ? ustring((const char*)publicId) : ""), + ( systemId ? ustring((const char*)systemId) : ""), + ( content ? ustring((const char*)content) : "") ); } catch (...) { @@ -462,7 +462,7 @@ void SaxParserCallback::start_element(void* context, try { - parser->on_start_element(Glib::ustring((const char*) name), attributes); + parser->on_start_element(ustring((const char*) name), attributes); } catch (...) { @@ -477,7 +477,7 @@ void SaxParserCallback::end_element(void* context, const xmlChar* name) try { - parser->on_end_element(Glib::ustring((const char*) name)); + parser->on_end_element(ustring((const char*) name)); } catch (...) { @@ -492,11 +492,11 @@ void SaxParserCallback::characters(void * context, const xmlChar* ch, int len) try { - // Here we force the use of Glib::ustring::ustring( InputIterator begin, InputIterator end ) - // instead of Glib::ustring::ustring( const char*, size_type ) because it + // Here we force the use of ustring::ustring( InputIterator begin, InputIterator end ) + // instead of ustring::ustring( const char*, size_type ) because it // expects the length of the string in characters, not in bytes. parser->on_characters( - Glib::ustring( + ustring( reinterpret_cast(ch), reinterpret_cast(ch + len) ) ); } @@ -513,7 +513,7 @@ void SaxParserCallback::comment(void* context, const xmlChar* value) try { - parser->on_comment(Glib::ustring((const char*) value)); + parser->on_comment(ustring((const char*) value)); } catch (...) { @@ -528,7 +528,7 @@ void SaxParserCallback::warning(void* context, const char* fmt, ...) va_list arg; va_start(arg, fmt); - const Glib::ustring buff = format_printf_message(fmt, arg); + const ustring buff = format_printf_message(fmt, arg); va_end(arg); try @@ -551,7 +551,7 @@ void SaxParserCallback::error(void* context, const char* fmt, ...) va_list arg; va_start(arg, fmt); - const Glib::ustring buff = format_printf_message(fmt, arg); + const ustring buff = format_printf_message(fmt, arg); va_end(arg); try @@ -571,7 +571,7 @@ void SaxParserCallback::fatal_error(void* context, const char* fmt, ...) va_list arg; va_start(arg, fmt); - const Glib::ustring buff = format_printf_message(fmt, arg); + const ustring buff = format_printf_message(fmt, arg); va_end(arg); try @@ -591,10 +591,10 @@ void SaxParserCallback::cdata_block(void* context, const xmlChar* value, int len try { - // Here we force the use of Glib::ustring::ustring( InputIterator begin, InputIterator end ) + // Here we force the use of ustring::ustring( InputIterator begin, InputIterator end ) // see comments in SaxParserCallback::characters parser->on_cdata_block( - Glib::ustring( + ustring( reinterpret_cast(value), reinterpret_cast(value + len) ) ); } @@ -612,10 +612,10 @@ void SaxParserCallback::internal_subset(void* context, const xmlChar* name, try { - const auto pid = publicId ? Glib::ustring((const char*) publicId) : ""; - const auto sid = systemId ? Glib::ustring((const char*) systemId) : ""; + const auto pid = publicId ? ustring((const char*) publicId) : ""; + const auto sid = systemId ? ustring((const char*) systemId) : ""; - parser->on_internal_subset( Glib::ustring((const char*) name), pid, sid); + parser->on_internal_subset( ustring((const char*) name), pid, sid); } catch (...) { diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index ba3be62c..d745dbb6 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -40,10 +40,10 @@ class SaxParser : public Parser */ struct Attribute { - Glib::ustring name; - Glib::ustring value; + ustring name; + ustring value; - Attribute(Glib::ustring const & n, Glib::ustring const & v) + Attribute(ustring const & n, ustring const & v) : name(n), value(v) { } @@ -56,15 +56,15 @@ class SaxParser : public Parser * * Example:@n * - * Glib::ustring name = "foo";@n + * ustring name = "foo";@n * AttributeList::const_iterator attribute = std::find_if(attributes.begin(), attributes.end(), AttributeHasName(name)); * */ struct AttributeHasName { - Glib::ustring const & name; + ustring const & name; - AttributeHasName(Glib::ustring const & n) + AttributeHasName(ustring const & n) : name(n) { } @@ -99,7 +99,7 @@ class SaxParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - void parse_memory(const Glib::ustring& contents) override; + void parse_memory(const ustring& contents) override; /** Parse an XML document from raw memory. * @param contents The XML document as an array of bytes. @@ -132,7 +132,7 @@ class SaxParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - void parse_chunk(const Glib::ustring& chunk); + void parse_chunk(const ustring& chunk); /** Parse a chunk of data. * @@ -167,21 +167,21 @@ class SaxParser : public Parser virtual void on_start_document(); virtual void on_end_document(); - virtual void on_start_element(const Glib::ustring& name, const AttributeList& attributes); - virtual void on_end_element(const Glib::ustring& name); - virtual void on_characters(const Glib::ustring& characters); - virtual void on_comment(const Glib::ustring& text); - virtual void on_warning(const Glib::ustring& text); - virtual void on_error(const Glib::ustring& text); + virtual void on_start_element(const ustring& name, const AttributeList& attributes); + virtual void on_end_element(const ustring& name); + virtual void on_characters(const ustring& characters); + virtual void on_comment(const ustring& text); + virtual void on_warning(const ustring& text); + virtual void on_error(const ustring& text); /** @throws xmlpp::parse_error */ - virtual void on_fatal_error(const Glib::ustring& text); - virtual void on_cdata_block(const Glib::ustring& text); + virtual void on_fatal_error(const ustring& text); + virtual void on_cdata_block(const ustring& text); /** Override this to receive information about the document's DTD and any entity declarations. */ - virtual void on_internal_subset(const Glib::ustring& name, const Glib::ustring& publicId, const Glib::ustring& systemId); + virtual void on_internal_subset(const ustring& name, const ustring& publicId, const ustring& systemId); /** Override this method to resolve entities references in your derived parser, instead of using the default entity resolution, * or to be informed when entity references are encountered. @@ -203,7 +203,7 @@ class SaxParser : public Parser * You must include libxml/parser.h in order to use this C struct. * This instance will not be freed by the caller. */ - virtual _xmlEntity* on_get_entity(const Glib::ustring& name); + virtual _xmlEntity* on_get_entity(const ustring& name); /** Override this to receive information about every entity declaration. * If you override this function, and you want normal entity substitution to work, then you must call the base class in your override. @@ -211,7 +211,7 @@ class SaxParser : public Parser * This would be useful when overriding on_get_entity(). * @throws xmlpp::internal_error */ - virtual void on_entity_declaration(const Glib::ustring& name, XmlEntityType type, const Glib::ustring& publicId, const Glib::ustring& systemId, const Glib::ustring& content); + virtual void on_entity_declaration(const ustring& name, XmlEntityType type, const ustring& publicId, const ustring& systemId, const ustring& content); void release_underlying() override; void initialize_context() override; diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc index 75a2c680..7f6f2125 100644 --- a/libxml++/parsers/textreader.cc +++ b/libxml++/parsers/textreader.cc @@ -19,8 +19,8 @@ class TextReader::PropertyReader int Int(int value); bool Bool(int value); char Char(int value); - Glib::ustring String(xmlChar* value, bool free = false); - Glib::ustring String(xmlChar const* value); + ustring String(xmlChar* value, bool free = false); + ustring String(xmlChar const* value); TextReader & owner_; }; @@ -36,7 +36,7 @@ TextReader::TextReader( TextReader::TextReader( const unsigned char* data, size_type size, - const Glib::ustring& uri) + const ustring& uri) : propertyreader(new PropertyReader(*this)), impl_( xmlReaderForMemory ((const char*)data, size, uri.c_str(), nullptr, 0) ), severity_( 0 ) @@ -50,7 +50,7 @@ TextReader::TextReader( } TextReader::TextReader( - const Glib::ustring& URI) + const ustring& URI) : propertyreader(new PropertyReader(*this)), impl_( xmlNewTextReaderFilename(URI.c_str()) ), severity_( 0 ) { @@ -73,19 +73,19 @@ bool TextReader::read() xmlTextReaderRead(impl_)); } -Glib::ustring TextReader::read_inner_xml() +ustring TextReader::read_inner_xml() { return propertyreader->String( xmlTextReaderReadInnerXml(impl_), true); } -Glib::ustring TextReader::read_outer_xml() +ustring TextReader::read_outer_xml() { return propertyreader->String( xmlTextReaderReadOuterXml(impl_), true); } -Glib::ustring TextReader::read_string() +ustring TextReader::read_string() { return propertyreader->String( xmlTextReaderReadString(impl_), true); @@ -103,7 +103,7 @@ int TextReader::get_attribute_count() const xmlTextReaderAttributeCount(impl_)); } -Glib::ustring TextReader::get_base_uri() const +ustring TextReader::get_base_uri() const { return propertyreader->String( xmlTextReaderBaseUri(impl_), true); @@ -139,19 +139,19 @@ bool TextReader::is_empty_element() const xmlTextReaderIsEmptyElement(impl_)); } -Glib::ustring TextReader::get_local_name() const +ustring TextReader::get_local_name() const { return propertyreader->String( xmlTextReaderLocalName(impl_), true); } -Glib::ustring TextReader::get_name() const +ustring TextReader::get_name() const { return propertyreader->String( xmlTextReaderName(impl_), true); } -Glib::ustring TextReader::get_namespace_uri() const +ustring TextReader::get_namespace_uri() const { return propertyreader->String( xmlTextReaderNamespaceUri(impl_), true); @@ -165,7 +165,7 @@ TextReader::NodeType TextReader::get_node_type() const return static_cast(result); } -Glib::ustring TextReader::get_prefix() const +ustring TextReader::get_prefix() const { return propertyreader->String( xmlTextReaderPrefix(impl_), true); @@ -177,13 +177,13 @@ char TextReader::get_quote_char() const xmlTextReaderQuoteChar(impl_)); } -Glib::ustring TextReader::get_value() const +ustring TextReader::get_value() const { return propertyreader->String( xmlTextReaderValue(impl_), true); } -Glib::ustring TextReader::get_xml_lang() const +ustring TextReader::get_xml_lang() const { return propertyreader->String( xmlTextReaderXmlLang(impl_)); @@ -203,29 +203,29 @@ void TextReader::close() check_for_exceptions(); } -Glib::ustring TextReader::get_attribute(int number) const +ustring TextReader::get_attribute(int number) const { return propertyreader->String( xmlTextReaderGetAttributeNo(impl_, number), true); } -Glib::ustring TextReader::get_attribute( - const Glib::ustring& name) const +ustring TextReader::get_attribute( + const ustring& name) const { return propertyreader->String( xmlTextReaderGetAttribute(impl_, (const xmlChar *)name.c_str()), true); } -Glib::ustring TextReader::get_attribute( - const Glib::ustring& localName, - const Glib::ustring& namespaceURI) const +ustring TextReader::get_attribute( + const ustring& localName, + const ustring& namespaceURI) const { return propertyreader->String( xmlTextReaderGetAttributeNs(impl_, (const xmlChar *)localName.c_str(), (const xmlChar *)namespaceURI.c_str()), true); } -Glib::ustring TextReader::lookup_namespace( - const Glib::ustring& prefix) const +ustring TextReader::lookup_namespace( + const ustring& prefix) const { return propertyreader->String( xmlTextReaderLookupNamespace(impl_, (const xmlChar *)prefix.c_str()), true); @@ -238,15 +238,15 @@ bool TextReader::move_to_attribute(int number) } bool TextReader::move_to_attribute( - const Glib::ustring& name) + const ustring& name) { return propertyreader->Bool( xmlTextReaderMoveToAttribute(impl_, (const xmlChar *)name.c_str())); } bool TextReader::move_to_attribute( - const Glib::ustring& localName, - const Glib::ustring& namespaceURI) + const ustring& localName, + const ustring& namespaceURI) { return propertyreader->Bool( xmlTextReaderMoveToAttributeNs(impl_, (const xmlChar *)localName.c_str(), (const xmlChar *)namespaceURI.c_str())); @@ -403,14 +403,14 @@ char TextReader::PropertyReader::Char(int value) return value; } -Glib::ustring TextReader::PropertyReader::String(xmlChar* value, bool free) +ustring TextReader::PropertyReader::String(xmlChar* value, bool free) { owner_.check_for_exceptions(); if (!value) - return Glib::ustring(); + return ustring(); - const Glib::ustring result = (char *)value; + const ustring result = (char *)value; if(free) xmlFree(value); @@ -418,12 +418,12 @@ Glib::ustring TextReader::PropertyReader::String(xmlChar* value, bool free) return result; } -Glib::ustring TextReader::PropertyReader::String(xmlChar const* value) +ustring TextReader::PropertyReader::String(xmlChar const* value) { owner_.check_for_exceptions(); if (!value) - return Glib::ustring(); + return ustring(); return (const char*)value; } diff --git a/libxml++/parsers/textreader.h b/libxml++/parsers/textreader.h index c8b44a73..c98c16ac 100644 --- a/libxml++/parsers/textreader.h +++ b/libxml++/parsers/textreader.h @@ -10,7 +10,7 @@ #include #include -#include +#include "libxml++/ustring.h" #include @@ -92,7 +92,7 @@ class TextReader: public NonCopyable * @param URI The URI to read. * @throws xmlpp::internal_error If an xmlTextReader object cannot be created. */ - TextReader(const Glib::ustring& URI); + TextReader(const ustring& URI); /** * Creates a new TextReader object which parses in memory data. @@ -101,7 +101,7 @@ class TextReader: public NonCopyable * @param uri The base URI to use for the document. * @throws xmlpp::internal_error If an xmlTextReader object cannot be created. */ - TextReader(const unsigned char* data, size_type size, const Glib::ustring& uri = Glib::ustring()); + TextReader(const unsigned char* data, size_type size, const ustring& uri = ustring()); ~TextReader() override; @@ -113,25 +113,25 @@ class TextReader: public NonCopyable bool read(); /** Reads the contents of the current node, including child nodes and markup. - * @return A Glib::ustring containing the XML content, or an empty Glib::ustring if the current node is neither an element nor attribute, or has no child nodes. + * @return A ustring containing the XML content, or an empty ustring if the current node is neither an element nor attribute, or has no child nodes. * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - Glib::ustring read_inner_xml(); + ustring read_inner_xml(); /** Reads the current node and its contents, including child nodes and markup. - * @return A Glib::ustring containing the XML content, or an empty Glib::ustring if the current node is neither an element nor attribute. + * @return A ustring containing the XML content, or an empty ustring if the current node is neither an element nor attribute. * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - Glib::ustring read_outer_xml(); + ustring read_outer_xml(); /** Reads the contents of an element or a text node as a string. - * @return A Glib::ustring containing the contents of the Element or Text node, or an empty Glib::ustring if the reader is positioned on any other type of node. + * @return A ustring containing the contents of the Element or Text node, or an empty ustring if the reader is positioned on any other type of node. * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - Glib::ustring read_string(); + ustring read_string(); /** Parses an attribute value into one or more Text and EntityReference nodes. * @return A bool where true indicates the attribute value was parsed, and false indicates the reader was not positioned on an attribute node or all the attribute values have been read. @@ -149,9 +149,9 @@ class TextReader: public NonCopyable int get_attribute_count() const; /** Gets the base Uniform Resource Identifier (URI) of the current node. - * @return The base URI of the current node or an empty Glib::ustring if not available. + * @return The base URI of the current node or an empty ustring if not available. */ - Glib::ustring get_base_uri() const; + ustring get_base_uri() const; /** Gets the depth of the current node in the XML document. * @return The depth of the current node in the XML document, or -1 in case of error. @@ -178,9 +178,9 @@ class TextReader: public NonCopyable */ bool is_empty_element() const; - Glib::ustring get_local_name() const; - Glib::ustring get_name() const; - Glib::ustring get_namespace_uri() const; + ustring get_local_name() const; + ustring get_name() const; + ustring get_namespace_uri() const; /** Get the node type of the current node. * @returns The xmlpp::TextReader::NodeType of the current node. @@ -194,31 +194,31 @@ class TextReader: public NonCopyable /** Get the namespace prefix associated with the current node. * @returns The namespace prefix, or an empty string if not available. */ - Glib::ustring get_prefix() const; + ustring get_prefix() const; /** Get the quotation mark character used to enclose the value of an attribute. * @returns Returns " or ' and -1 in case of error. */ char get_quote_char() const; - Glib::ustring get_value() const; - Glib::ustring get_xml_lang() const; + ustring get_value() const; + ustring get_xml_lang() const; ReadState get_read_state() const; void close(); - Glib::ustring get_attribute(int number) const; - Glib::ustring get_attribute(const Glib::ustring& name) const; - Glib::ustring get_attribute(const Glib::ustring& local_name, const Glib::ustring& ns_uri) const; + ustring get_attribute(int number) const; + ustring get_attribute(const ustring& name) const; + ustring get_attribute(const ustring& local_name, const ustring& ns_uri) const; // TODO InputBuffer GetRemainder; - Glib::ustring lookup_namespace(const Glib::ustring& prefix) const; + ustring lookup_namespace(const ustring& prefix) const; bool move_to_attribute(int number); - bool move_to_attribute(const Glib::ustring& name); - bool move_to_attribute(const Glib::ustring& local_name, const Glib::ustring& ns_uri); + bool move_to_attribute(const ustring& name); + bool move_to_attribute(const ustring& local_name, const ustring& ns_uri); bool move_to_first_attribute(); bool move_to_next_attribute(); bool move_to_element(); @@ -273,7 +273,7 @@ class TextReader: public NonCopyable std::unique_ptr propertyreader; _xmlTextReader* impl_; int severity_; - Glib::ustring error_; + ustring error_; }; } diff --git a/libxml++/relaxngschema.cc b/libxml++/relaxngschema.cc index 3804f129..20f20efe 100644 --- a/libxml++/relaxngschema.cc +++ b/libxml++/relaxngschema.cc @@ -83,9 +83,9 @@ void RelaxNGSchema::parse_file(const std::string& filename) parse_context(xmlRelaxNGNewParserCtxt(filename.c_str())); } -void RelaxNGSchema::parse_memory(const Glib::ustring& contents) +void RelaxNGSchema::parse_memory(const ustring& contents) { - parse_context(xmlRelaxNGNewMemParserCtxt(contents.c_str(), contents.bytes())); + parse_context(xmlRelaxNGNewMemParserCtxt(contents.c_str(), contents.size())); } void RelaxNGSchema::parse_document(const Document* document) diff --git a/libxml++/relaxngschema.h b/libxml++/relaxngschema.h index b18e3594..b557d9a6 100644 --- a/libxml++/relaxngschema.h +++ b/libxml++/relaxngschema.h @@ -84,7 +84,7 @@ class RelaxNGSchema : public SchemaBase * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ - void parse_memory(const Glib::ustring& contents) override; + void parse_memory(const ustring& contents) override; /** Parse a schema definition from a document. * If another schema has been parsed before, that schema is replaced by the new one. diff --git a/libxml++/schemabase.h b/libxml++/schemabase.h index 6ea2bddb..66c0f6ac 100644 --- a/libxml++/schemabase.h +++ b/libxml++/schemabase.h @@ -20,13 +20,9 @@ #define __LIBXMLPP_SCHEMABASE_H #include +#include #include -namespace Glib -{ -class ustring; -} - namespace xmlpp { class Document; @@ -53,7 +49,7 @@ class SchemaBase : public NonCopyable * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ - virtual void parse_memory(const Glib::ustring& contents) = 0; + virtual void parse_memory(const ustring& contents) = 0; /** Parse a schema definition from a document. * If another schema has been parsed before, that schema is replaced by the new one. diff --git a/libxml++/ustring.cc b/libxml++/ustring.cc new file mode 100644 index 00000000..e69de29b diff --git a/libxml++/ustring.h b/libxml++/ustring.h new file mode 100644 index 00000000..fabb3ffb --- /dev/null +++ b/libxml++/ustring.h @@ -0,0 +1,37 @@ +/* + * Copyright 2020, The libsigc++ Development Team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#ifndef __LIBXMLPP_USTRING_H +#define __LIBXMLPP_USTRING_H + +#include + +namespace xmlpp +{ + +/** This is just an indication to the programmer that the string contains UTF-8. + * On the other hand, when std::string appears in the libxml++ API, the + * encoding of the string may be UTF-8 or may be some other encoding. + */ +using ustring = std::string; + +} // namespace xmlpp + +#endif //__LIBXMLPP_USTRING_H + diff --git a/libxml++/validators/dtdvalidator.cc b/libxml++/validators/dtdvalidator.cc index 7ae5c994..703c2c74 100644 --- a/libxml++/validators/dtdvalidator.cc +++ b/libxml++/validators/dtdvalidator.cc @@ -42,7 +42,7 @@ DtdValidator::DtdValidator(const std::string& filename) parse_file(filename); } -DtdValidator::DtdValidator(const Glib::ustring& external, const Glib::ustring& system) +DtdValidator::DtdValidator(const ustring& external, const ustring& system) : pimpl_(new Impl) { parse_subset(external, system); @@ -64,12 +64,12 @@ void DtdValidator::parse_file(const std::string& filename) set_dtd(new Dtd(filename), true); } -void DtdValidator::parse_subset(const Glib::ustring& external, const Glib::ustring& system) +void DtdValidator::parse_subset(const ustring& external, const ustring& system) { set_dtd(new Dtd(external, system), true); } -void DtdValidator::parse_memory(const Glib::ustring& contents) +void DtdValidator::parse_memory(const ustring& contents) { std::unique_ptr dtd(new Dtd()); dtd->parse_memory(contents); diff --git a/libxml++/validators/dtdvalidator.h b/libxml++/validators/dtdvalidator.h index 69a371fd..599aaf03 100644 --- a/libxml++/validators/dtdvalidator.h +++ b/libxml++/validators/dtdvalidator.h @@ -33,7 +33,7 @@ class DtdValidator : public Validator * @param system The URL of the DTD. * @throws xmlpp::parse_error */ - explicit DtdValidator(const Glib::ustring& external, const Glib::ustring& system); + explicit DtdValidator(const ustring& external, const ustring& system); /** Create a validator. * @@ -64,14 +64,14 @@ class DtdValidator : public Validator * @param system The URL of the DTD. * @throws xmlpp::parse_error */ - void parse_subset(const Glib::ustring& external, const Glib::ustring& system); + void parse_subset(const ustring& external, const ustring& system); /** Parse a DTD from a string. * If the validator already contains a DTD, that DTD is deleted. * @param contents The DTD as a string. * @throws xmlpp::parse_error */ - void parse_memory(const Glib::ustring& contents) override; + void parse_memory(const ustring& contents) override; /** Parse a DTD from a stream. * If the validator already contains a DTD, that DTD is deleted. diff --git a/libxml++/validators/relaxngvalidator.cc b/libxml++/validators/relaxngvalidator.cc index 392a4cf1..dfc42cf1 100644 --- a/libxml++/validators/relaxngvalidator.cc +++ b/libxml++/validators/relaxngvalidator.cc @@ -70,7 +70,7 @@ void RelaxNGValidator::parse_file(const std::string& filename) set_schema(new RelaxNGSchema(filename), true); } -void RelaxNGValidator::parse_memory(const Glib::ustring& contents) +void RelaxNGValidator::parse_memory(const ustring& contents) { std::unique_ptr schema(new RelaxNGSchema()); schema->parse_memory(contents); @@ -154,7 +154,7 @@ void RelaxNGValidator::validate(const Document* document) auto error_str = format_xml_error(); if (error_str.empty()) - error_str = "Error code from xmlRelaxNGValidateDoc(): " + Glib::ustring::format(res); + error_str = "Error code from xmlRelaxNGValidateDoc(): " + std::to_string(res); throw validity_error("Document failed RelaxNG schema validation.\n" + error_str); } } diff --git a/libxml++/validators/relaxngvalidator.h b/libxml++/validators/relaxngvalidator.h index 0e37852b..585d5f90 100644 --- a/libxml++/validators/relaxngvalidator.h +++ b/libxml++/validators/relaxngvalidator.h @@ -24,11 +24,6 @@ #include #include // std::unique_ptr -namespace Glib -{ -class ustring; -} - namespace xmlpp { class Document; @@ -90,7 +85,7 @@ class RelaxNGValidator : public SchemaValidatorBase * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ - void parse_memory(const Glib::ustring& contents) override; + void parse_memory(const ustring& contents) override; /** Parse a schema definition from a document. * If the validator already contains a schema, that schema is released diff --git a/libxml++/validators/schemavalidatorbase.h b/libxml++/validators/schemavalidatorbase.h index 104fda76..dae7b3af 100644 --- a/libxml++/validators/schemavalidatorbase.h +++ b/libxml++/validators/schemavalidatorbase.h @@ -21,11 +21,6 @@ #include -namespace Glib -{ -class ustring; -} - namespace xmlpp { class Document; @@ -54,7 +49,7 @@ class SchemaValidatorBase : public Validator * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ - void parse_memory(const Glib::ustring& contents) override = 0; + void parse_memory(const ustring& contents) override = 0; /** Parse a schema definition from a document. * If the validator already contains a schema, that schema is released diff --git a/libxml++/validators/validator.cc b/libxml++/validators/validator.cc index ec449945..9347b516 100644 --- a/libxml++/validators/validator.cc +++ b/libxml++/validators/validator.cc @@ -36,13 +36,13 @@ void Validator::release_underlying() { } -void Validator::on_validity_error(const Glib::ustring& message) +void Validator::on_validity_error(const ustring& message) { //Throw an exception later when the whole message has been received: validate_error_ += message; } -void Validator::on_validity_warning(const Glib::ustring& message) +void Validator::on_validity_warning(const ustring& message) { //Throw an exception later when the whole message has been received: validate_warning_ += message; @@ -50,7 +50,7 @@ void Validator::on_validity_warning(const Glib::ustring& message) void Validator::check_for_validity_messages() { - Glib::ustring msg(exception_ ? exception_->what() : ""); + ustring msg(exception_ ? exception_->what() : ""); bool validity_msg = false; if (!validate_error_.empty()) @@ -80,7 +80,7 @@ void Validator::callback_validity_error(void* valid_, const char* msg, ...) //Convert the ... to a string: va_list arg; va_start(arg, msg); - const Glib::ustring buff = format_printf_message(msg, arg); + const ustring buff = format_printf_message(msg, arg); va_end(arg); try @@ -103,7 +103,7 @@ void Validator::callback_validity_warning(void* valid_, const char* msg, ...) //Convert the ... to a string: va_list arg; va_start(arg, msg); - const Glib::ustring buff = format_printf_message(msg, arg); + const ustring buff = format_printf_message(msg, arg); va_end(arg); try diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index 32ed3fcc..e0c10334 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -44,7 +44,7 @@ class Validator : public NonCopyable * @param contents The schema definition or the DTD as a string. * @throws xmlpp::parse_error */ - virtual void parse_memory(const Glib::ustring& contents) = 0; + virtual void parse_memory(const ustring& contents) = 0; /** Validate a document, using a previously parsed schema or DTD. * @param document Pointer to the document. @@ -66,8 +66,8 @@ class Validator : public NonCopyable virtual void initialize_context(); virtual void release_underlying(); - virtual void on_validity_error(const Glib::ustring& message); - virtual void on_validity_warning(const Glib::ustring& message); + virtual void on_validity_error(const ustring& message); + virtual void on_validity_warning(const ustring& message); /// To be called in an exception handler. virtual void handle_exception(); @@ -79,8 +79,8 @@ class Validator : public NonCopyable std::unique_ptr exception_; // Built gradually - used in an exception at the end of validation. - Glib::ustring validate_error_; - Glib::ustring validate_warning_; + ustring validate_error_; + ustring validate_warning_; }; } // namespace xmlpp diff --git a/libxml++/validators/xsdvalidator.cc b/libxml++/validators/xsdvalidator.cc index b399db42..1de372fc 100644 --- a/libxml++/validators/xsdvalidator.cc +++ b/libxml++/validators/xsdvalidator.cc @@ -67,7 +67,7 @@ void XsdValidator::parse_file(const std::string& filename) set_schema(new XsdSchema(filename), true); } -void XsdValidator::parse_memory(const Glib::ustring& contents) +void XsdValidator::parse_memory(const ustring& contents) { std::unique_ptr schema(new XsdSchema()); schema->parse_memory(contents); @@ -152,7 +152,7 @@ void XsdValidator::validate(const Document* document) auto error_str = format_xml_error(); if (error_str.empty()) - error_str = "Error code from xmlSchemaValidateDoc(): " + Glib::ustring::format(res); + error_str = "Error code from xmlSchemaValidateDoc(): " + std::to_string(res); throw validity_error("Document failed XSD schema validation.\n" + error_str); } } @@ -179,7 +179,7 @@ void XsdValidator::validate(const std::string& filename) auto error_str = format_xml_error(); if (error_str.empty()) - error_str = "Error code from xmlSchemaValidateFile(): " + Glib::ustring::format(res); + error_str = "Error code from xmlSchemaValidateFile(): " + std::to_string(res); throw validity_error("XML file failed XSD schema validation.\n" + error_str); } } diff --git a/libxml++/validators/xsdvalidator.h b/libxml++/validators/xsdvalidator.h index 71d23cf6..9dac56bc 100644 --- a/libxml++/validators/xsdvalidator.h +++ b/libxml++/validators/xsdvalidator.h @@ -22,11 +22,6 @@ #include #include // std::unique_ptr -namespace Glib -{ -class ustring; -} - namespace xmlpp { class Document; @@ -81,7 +76,7 @@ class XsdValidator : public SchemaValidatorBase * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ - void parse_memory(const Glib::ustring& contents) override; + void parse_memory(const ustring& contents) override; /** Parse a schema definition from a document. * If the validator already contains a schema, that schema is released diff --git a/libxml++/xsdschema.cc b/libxml++/xsdschema.cc index 7e13f2e8..9368fbe9 100644 --- a/libxml++/xsdschema.cc +++ b/libxml++/xsdschema.cc @@ -84,11 +84,11 @@ void XsdSchema::parse_file(const std::string& filename) parse_context(xmlSchemaNewParserCtxt(filename.c_str())); } -void XsdSchema::parse_memory(const Glib::ustring& contents) +void XsdSchema::parse_memory(const ustring& contents) { xmlResetLastError(); release_underlying(); - parse_context(xmlSchemaNewMemParserCtxt(contents.c_str(), contents.bytes())); + parse_context(xmlSchemaNewMemParserCtxt(contents.c_str(), contents.size())); } void XsdSchema::parse_document(const Document* document) diff --git a/libxml++/xsdschema.h b/libxml++/xsdschema.h index 9d865269..3b69f440 100644 --- a/libxml++/xsdschema.h +++ b/libxml++/xsdschema.h @@ -75,7 +75,7 @@ class XsdSchema : public SchemaBase * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ - void parse_memory(const Glib::ustring& contents) override; + void parse_memory(const ustring& contents) override; /** Parse a schema definition from a document. * If another schema has been parsed before, that schema is replaced by the new one. diff --git a/libxml++config.h.in b/libxml++config.h.in index 0a908003..a8d6cce7 100755 --- a/libxml++config.h.in +++ b/libxml++config.h.in @@ -1,8 +1,6 @@ #ifndef _LIBXMLPP_CONFIG_H #define _LIBXMLPP_CONFIG_H -#include - /* Define to omit deprecated API from the library. */ #undef LIBXMLXX_DISABLE_DEPRECATED diff --git a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc index ab44d0bf..b10748fc 100644 --- a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc +++ b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,7 @@ class MySaxParser : public xmlpp::SaxParser { throw std::runtime_error("some custom runtime exception"); } - void on_error(const Glib::ustring& /* text */) override + void on_error(const xmlpp::ustring& /* text */) override { throw std::runtime_error("on_error() called"); } @@ -37,10 +38,6 @@ class MySaxParser : public xmlpp::SaxParser int main() { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - { MySaxParser parser; @@ -57,9 +54,9 @@ int main() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "on_error() called"); + assert(e.what() == xmlpp::ustring("on_error() called")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); // Try parsing a stream now. exceptionThrown = false; @@ -72,7 +69,7 @@ int main() { // An "Attempt to start a second parse while a parse is in progress." parse // error should not have been thrown. - g_assert_not_reached(); + assert(false); } #ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) @@ -81,9 +78,9 @@ int main() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "some custom runtime exception"); + assert(e.what() == xmlpp::ustring("some custom runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); } return EXIT_SUCCESS; diff --git a/tests/saxparser_parse_double_free/main.cc b/tests/saxparser_parse_double_free/main.cc index 09af02e4..bb059491 100644 --- a/tests/saxparser_parse_double_free/main.cc +++ b/tests/saxparser_parse_double_free/main.cc @@ -18,15 +18,16 @@ #include #include +#include #include #include class OnCdataBlockTestParser : public xmlpp::SaxParser { protected: - void on_cdata_block(const Glib::ustring& text) override + void on_cdata_block(const xmlpp::ustring& text) override { - g_assert_cmpstr(text.c_str(), ==, "some CDATA"); + assert(text == xmlpp::ustring("some CDATA")); throw std::runtime_error("on_cdata_block runtime exception"); } }; @@ -46,18 +47,18 @@ void test_on_cdata_block() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "on_cdata_block runtime exception"); + assert(e.what() == xmlpp::ustring("on_cdata_block runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); } class OnCharactersTestParser : public xmlpp::SaxParser { protected: - void on_characters(const Glib::ustring& characters) override + void on_characters(const xmlpp::ustring& characters) override { - g_assert_cmpstr(characters.c_str(), ==, "abc"); + assert(characters == xmlpp::ustring("abc")); throw std::runtime_error("on_characters runtime exception"); } }; @@ -77,18 +78,18 @@ void test_on_characters() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "on_characters runtime exception"); + assert(e.what() == xmlpp::ustring("on_characters runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); } class OnCommentTestParser : public xmlpp::SaxParser { protected: - void on_comment(const Glib::ustring& text) override + void on_comment(const xmlpp::ustring& text) override { - g_assert_cmpstr(text.c_str(), ==, "a comment"); + assert(text == xmlpp::ustring("a comment")); throw std::runtime_error("on_comment runtime exception"); } }; @@ -108,9 +109,9 @@ void test_on_comment() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "on_comment runtime exception"); + assert(e.what() == xmlpp::ustring("on_comment runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); } @@ -138,18 +139,18 @@ void test_on_end_document() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "on_end_document runtime exception"); + assert(e.what() == xmlpp::ustring("on_end_document runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); } class OnEndElementTestParser : public xmlpp::SaxParser { protected: - void on_end_element(const Glib::ustring& name) override + void on_end_element(const xmlpp::ustring& name) override { - g_assert_cmpstr(name.c_str(), ==, "a:root"); + assert(name == xmlpp::ustring("a:root")); throw std::runtime_error("on_end_element runtime exception"); } }; @@ -169,21 +170,21 @@ void test_on_end_element() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "on_end_element runtime exception"); + assert(e.what() == xmlpp::ustring("on_end_element runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); } class OnEntityDeclarationTestParser : public xmlpp::SaxParser { protected: - void on_entity_declaration(const Glib::ustring& name, xmlpp::XmlEntityType /* type */, - const Glib::ustring& /* publicId */, const Glib::ustring& /* systemId */, - const Glib::ustring& content) override + void on_entity_declaration(const xmlpp::ustring& name, xmlpp::XmlEntityType /* type */, + const xmlpp::ustring& /* publicId */, const xmlpp::ustring& /* systemId */, + const xmlpp::ustring& content) override { - g_assert_cmpstr(name.c_str(), ==, "number"); - g_assert_cmpstr(content.c_str(), ==, "42"); + assert(name == xmlpp::ustring("number")); + assert(content.c_str() == xmlpp::ustring("42")); throw std::runtime_error("on_entity_declaration runtime exception"); } }; @@ -203,16 +204,16 @@ void test_on_entity_declaration() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "on_entity_declaration runtime exception"); + assert(e.what() == xmlpp::ustring("on_entity_declaration runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); } class OnErrorTestParser : public xmlpp::SaxParser { protected: - void on_error(const Glib::ustring& /* text */) override + void on_error(const xmlpp::ustring& /* text */) override { throw std::runtime_error("on_error runtime exception"); } @@ -233,9 +234,9 @@ void test_on_error() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "on_error runtime exception"); + assert(e.what() == xmlpp::ustring("on_error runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); } @@ -247,9 +248,9 @@ class OnGetEntityTestParser : public xmlpp::SaxParser { } protected: - _xmlEntity* on_get_entity(const Glib::ustring& name) override + _xmlEntity* on_get_entity(const xmlpp::ustring& name) override { - g_assert_cmpstr(name.c_str(), ==, "number"); + assert(name == xmlpp::ustring("number")); throw std::runtime_error("on_get_entity runtime exception"); } }; @@ -269,9 +270,9 @@ void test_on_get_entity() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "on_get_entity runtime exception"); + assert(e.what() == xmlpp::ustring("on_get_entity runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); } @@ -299,19 +300,19 @@ void test_on_start_document() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "on_start_document runtime exception"); + assert(e.what() == xmlpp::ustring("on_start_document runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); } class OnStartElementTestParser : public xmlpp::SaxParser { protected: - void on_start_element(const Glib::ustring& name, const xmlpp::SaxParser::AttributeList& attributes) override + void on_start_element(const xmlpp::ustring& name, const xmlpp::SaxParser::AttributeList& attributes) override { - g_assert_cmpstr(name.c_str(), ==, "b:root"); - g_assert_cmpint(attributes.size(), ==, 2); + assert(name == xmlpp::ustring("b:root")); + assert(attributes.size() == 2); throw std::runtime_error("on_start_element runtime exception"); } }; @@ -331,18 +332,14 @@ void test_on_start_element() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "on_start_element runtime exception"); + assert(e.what() == xmlpp::ustring("on_start_element runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); } int main() { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - test_on_cdata_block(); test_on_characters(); test_on_comment(); diff --git a/tests/saxparser_parse_stream_inconsistent_state/main.cc b/tests/saxparser_parse_stream_inconsistent_state/main.cc index 6be414ec..b094f25f 100644 --- a/tests/saxparser_parse_stream_inconsistent_state/main.cc +++ b/tests/saxparser_parse_stream_inconsistent_state/main.cc @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -33,10 +34,6 @@ class MySaxParser : public xmlpp::SaxParser int main() { - // Set the global C and C++ locale to the user-configured locale, - // so we can use std::cout with UTF-8, via Glib::ustring, without exceptions. - std::locale::global(std::locale("")); - { MySaxParser parser; @@ -53,9 +50,9 @@ int main() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "some custom runtime exception"); + assert(e.what() == xmlpp::ustring("some custom runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); // Try parsing a different stream. exceptionThrown = false; @@ -68,7 +65,7 @@ int main() { // An "Attempt to start a second parse while a parse is in progress." parse // error should not have been thrown. - g_assert_not_reached(); + assert(false); } #ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch(const std::runtime_error& e) @@ -77,9 +74,9 @@ int main() #endif { exceptionThrown = true; - g_assert_cmpstr(e.what(), ==, "some custom runtime exception"); + assert(e.what() == xmlpp::ustring("some custom runtime exception")); } - g_assert_true(exceptionThrown); + assert(exceptionThrown); } return EXIT_SUCCESS; From 5e97c59417cbf1e2e76aae46ac7a29a249c0d5ee Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sat, 11 Jan 2020 23:29:21 +0100 Subject: [PATCH 090/240] 4.9.1 --- NEWS | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/NEWS b/NEWS index d1fa7dfd..3ef13596 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,14 @@ +4.9.1 (unstable): + +* Change ABI name from libxml++-4.0 to libxml++-5.0 + There is also a libxml++-4-0 branch for the libxml++-4.0 ABI, + which still uses glibmm-2.64. + And there is a libxml++-3-0 branch for the libxml++-3.0 ABI, + which still uses glibmm-2.4. +* Build: Remove dependency on glibmm and don't use Glib::ustring + For now, the API uses an xmlpp::ustring alias of std::string + where it previously used Glib::ustring. + 3.9.1 (unstable): * Change ABI name to libxml++-4.0 From 09de4f27675c9997626b09f46e61c13ceca5413f Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 12 Jan 2020 10:38:17 +0100 Subject: [PATCH 091/240] NEWS: Minor correction --- NEWS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 3ef13596..4b9f719e 100644 --- a/NEWS +++ b/NEWS @@ -15,7 +15,7 @@ There is also a libxml++-3-2 branch for the libxml++-3.0 ABI, which still uses glibmm-2.4. * Build: - - Use glibmm-2.62 instead of glibmm-2.42. + - Use glibmm-2.64 instead of glibmm-2.4. - Require C++17. * Parser: Make some methods const From fb1ce34e3da8679adeff9c8678c04a8648ead4cd Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Thu, 11 Jun 2020 15:27:06 +0800 Subject: [PATCH 092/240] Rename MSVC_Net2010 to MSVC_NMake This initiates the move from the Visual Studio project files to using NMake Makefiles, so that we reduce the likelihood of the MSVC build files becoming outdated, by sharing the autotools build files' source listings. --- {MSVC_Net2010 => MSVC_NMake}/README | 2 +- .../examples/dom_build/dom_build.vcxproj | 0 .../examples/dom_build/dom_build.vcxproj.filters | 0 .../examples/dom_parse_entities/dom_parse_entities.vcxproj | 0 .../dom_parse_entities/dom_parse_entities.vcxproj.filters | 0 .../examples/dom_parser/dom_parser.vcxproj | 0 .../examples/dom_parser/dom_parser.vcxproj.filters | 0 .../examples/dom_parser_raw/dom_parser_raw.vcxproj | 0 .../examples/dom_parser_raw/dom_parser_raw.vcxproj.filters | 0 .../examples/dom_read_write/dom_read_write.vcxproj | 0 .../examples/dom_read_write/dom_read_write.vcxproj.filters | 0 .../examples/dom_xpath/dom_xpath.vcxproj | 0 .../examples/dom_xpath/dom_xpath.vcxproj.filters | 0 .../examples/dtdvalidation/dtdvalidation.vcxproj | 0 .../examples/dtdvalidation/dtdvalidation.vcxproj.filters | 0 .../examples/import_node/import_node.vcxproj | 0 .../examples/import_node/import_node.vcxproj.filters | 0 .../examples/sax_exception/sax_exception.vcxproj | 0 .../examples/sax_exception/sax_exception.vcxproj.filters | 0 .../examples/sax_parser/sax_parser.vcxproj | 0 .../examples/sax_parser/sax_parser.vcxproj.filters | 0 .../sax_parser_build_dom/sax_parser_build_dom.vcxproj | 0 .../sax_parser_build_dom.vcxproj.filters | 0 .../sax_parser_entities/sax_parser_entities.vcxproj | 0 .../sax_parser_entities/sax_parser_entities.vcxproj.filters | 0 .../examples/schemavalidation/schemavalidation.vcxproj | 0 .../schemavalidation/schemavalidation.vcxproj.filters | 0 .../examples/textreader/textreader.vcxproj | 0 .../examples/textreader/textreader.vcxproj.filters | 0 {MSVC_Net2010 => MSVC_NMake}/filelist.am | 0 {MSVC_Net2010 => MSVC_NMake}/gendef/gendef.cc | 0 {MSVC_Net2010 => MSVC_NMake}/gendef/gendef.vcxproj | 0 {MSVC_Net2010 => MSVC_NMake}/gendef/gendef.vcxproj.filters | 0 {MSVC_Net2010 => MSVC_NMake}/libxml++.sln | 0 {MSVC_Net2010 => MSVC_NMake}/libxml++/libxml++.rc.in | 0 {MSVC_Net2010 => MSVC_NMake}/libxml++/libxml++.vcxproj | 0 .../libxml++/libxml++.vcxproj.filters | 0 Makefile.am | 6 +++--- configure.ac | 6 +++--- 39 files changed, 7 insertions(+), 7 deletions(-) rename {MSVC_Net2010 => MSVC_NMake}/README (93%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dom_build/dom_build.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dom_build/dom_build.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dom_parse_entities/dom_parse_entities.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dom_parse_entities/dom_parse_entities.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dom_parser/dom_parser.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dom_parser/dom_parser.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dom_parser_raw/dom_parser_raw.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dom_parser_raw/dom_parser_raw.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dom_read_write/dom_read_write.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dom_read_write/dom_read_write.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dom_xpath/dom_xpath.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dom_xpath/dom_xpath.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dtdvalidation/dtdvalidation.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/dtdvalidation/dtdvalidation.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/import_node/import_node.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/import_node/import_node.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/sax_exception/sax_exception.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/sax_exception/sax_exception.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/sax_parser/sax_parser.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/sax_parser/sax_parser.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/sax_parser_entities/sax_parser_entities.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/sax_parser_entities/sax_parser_entities.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/schemavalidation/schemavalidation.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/schemavalidation/schemavalidation.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/textreader/textreader.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/examples/textreader/textreader.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/filelist.am (100%) rename {MSVC_Net2010 => MSVC_NMake}/gendef/gendef.cc (100%) rename {MSVC_Net2010 => MSVC_NMake}/gendef/gendef.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/gendef/gendef.vcxproj.filters (100%) rename {MSVC_Net2010 => MSVC_NMake}/libxml++.sln (100%) rename {MSVC_Net2010 => MSVC_NMake}/libxml++/libxml++.rc.in (100%) rename {MSVC_Net2010 => MSVC_NMake}/libxml++/libxml++.vcxproj (100%) rename {MSVC_Net2010 => MSVC_NMake}/libxml++/libxml++.vcxproj.filters (100%) diff --git a/MSVC_Net2010/README b/MSVC_NMake/README similarity index 93% rename from MSVC_Net2010/README rename to MSVC_NMake/README index e948c888..4b5058a3 100644 --- a/MSVC_Net2010/README +++ b/MSVC_NMake/README @@ -4,7 +4,7 @@ Building libxml++ with Visual Studio 2010 * Install the latest Win32 GTK+ Development files from ftp://ftp.gnome.org/pub/GNOME/binaries/win32/gtk+/ * Build libsigc++ 2.0.6 and glibmm from source * Add GTK+, libsigc++ and glibmm to the include and lib paths in Visual Studio. -* Load the MSVC_Net2010/libxml++.sln solution. +* Load the MSVC_NMake/libxml++.sln solution. * Build the entire solution. Run the tests. Cedric Gustin diff --git a/MSVC_Net2010/examples/dom_build/dom_build.vcxproj b/MSVC_NMake/examples/dom_build/dom_build.vcxproj similarity index 100% rename from MSVC_Net2010/examples/dom_build/dom_build.vcxproj rename to MSVC_NMake/examples/dom_build/dom_build.vcxproj diff --git a/MSVC_Net2010/examples/dom_build/dom_build.vcxproj.filters b/MSVC_NMake/examples/dom_build/dom_build.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/dom_build/dom_build.vcxproj.filters rename to MSVC_NMake/examples/dom_build/dom_build.vcxproj.filters diff --git a/MSVC_Net2010/examples/dom_parse_entities/dom_parse_entities.vcxproj b/MSVC_NMake/examples/dom_parse_entities/dom_parse_entities.vcxproj similarity index 100% rename from MSVC_Net2010/examples/dom_parse_entities/dom_parse_entities.vcxproj rename to MSVC_NMake/examples/dom_parse_entities/dom_parse_entities.vcxproj diff --git a/MSVC_Net2010/examples/dom_parse_entities/dom_parse_entities.vcxproj.filters b/MSVC_NMake/examples/dom_parse_entities/dom_parse_entities.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/dom_parse_entities/dom_parse_entities.vcxproj.filters rename to MSVC_NMake/examples/dom_parse_entities/dom_parse_entities.vcxproj.filters diff --git a/MSVC_Net2010/examples/dom_parser/dom_parser.vcxproj b/MSVC_NMake/examples/dom_parser/dom_parser.vcxproj similarity index 100% rename from MSVC_Net2010/examples/dom_parser/dom_parser.vcxproj rename to MSVC_NMake/examples/dom_parser/dom_parser.vcxproj diff --git a/MSVC_Net2010/examples/dom_parser/dom_parser.vcxproj.filters b/MSVC_NMake/examples/dom_parser/dom_parser.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/dom_parser/dom_parser.vcxproj.filters rename to MSVC_NMake/examples/dom_parser/dom_parser.vcxproj.filters diff --git a/MSVC_Net2010/examples/dom_parser_raw/dom_parser_raw.vcxproj b/MSVC_NMake/examples/dom_parser_raw/dom_parser_raw.vcxproj similarity index 100% rename from MSVC_Net2010/examples/dom_parser_raw/dom_parser_raw.vcxproj rename to MSVC_NMake/examples/dom_parser_raw/dom_parser_raw.vcxproj diff --git a/MSVC_Net2010/examples/dom_parser_raw/dom_parser_raw.vcxproj.filters b/MSVC_NMake/examples/dom_parser_raw/dom_parser_raw.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/dom_parser_raw/dom_parser_raw.vcxproj.filters rename to MSVC_NMake/examples/dom_parser_raw/dom_parser_raw.vcxproj.filters diff --git a/MSVC_Net2010/examples/dom_read_write/dom_read_write.vcxproj b/MSVC_NMake/examples/dom_read_write/dom_read_write.vcxproj similarity index 100% rename from MSVC_Net2010/examples/dom_read_write/dom_read_write.vcxproj rename to MSVC_NMake/examples/dom_read_write/dom_read_write.vcxproj diff --git a/MSVC_Net2010/examples/dom_read_write/dom_read_write.vcxproj.filters b/MSVC_NMake/examples/dom_read_write/dom_read_write.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/dom_read_write/dom_read_write.vcxproj.filters rename to MSVC_NMake/examples/dom_read_write/dom_read_write.vcxproj.filters diff --git a/MSVC_Net2010/examples/dom_xpath/dom_xpath.vcxproj b/MSVC_NMake/examples/dom_xpath/dom_xpath.vcxproj similarity index 100% rename from MSVC_Net2010/examples/dom_xpath/dom_xpath.vcxproj rename to MSVC_NMake/examples/dom_xpath/dom_xpath.vcxproj diff --git a/MSVC_Net2010/examples/dom_xpath/dom_xpath.vcxproj.filters b/MSVC_NMake/examples/dom_xpath/dom_xpath.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/dom_xpath/dom_xpath.vcxproj.filters rename to MSVC_NMake/examples/dom_xpath/dom_xpath.vcxproj.filters diff --git a/MSVC_Net2010/examples/dtdvalidation/dtdvalidation.vcxproj b/MSVC_NMake/examples/dtdvalidation/dtdvalidation.vcxproj similarity index 100% rename from MSVC_Net2010/examples/dtdvalidation/dtdvalidation.vcxproj rename to MSVC_NMake/examples/dtdvalidation/dtdvalidation.vcxproj diff --git a/MSVC_Net2010/examples/dtdvalidation/dtdvalidation.vcxproj.filters b/MSVC_NMake/examples/dtdvalidation/dtdvalidation.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/dtdvalidation/dtdvalidation.vcxproj.filters rename to MSVC_NMake/examples/dtdvalidation/dtdvalidation.vcxproj.filters diff --git a/MSVC_Net2010/examples/import_node/import_node.vcxproj b/MSVC_NMake/examples/import_node/import_node.vcxproj similarity index 100% rename from MSVC_Net2010/examples/import_node/import_node.vcxproj rename to MSVC_NMake/examples/import_node/import_node.vcxproj diff --git a/MSVC_Net2010/examples/import_node/import_node.vcxproj.filters b/MSVC_NMake/examples/import_node/import_node.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/import_node/import_node.vcxproj.filters rename to MSVC_NMake/examples/import_node/import_node.vcxproj.filters diff --git a/MSVC_Net2010/examples/sax_exception/sax_exception.vcxproj b/MSVC_NMake/examples/sax_exception/sax_exception.vcxproj similarity index 100% rename from MSVC_Net2010/examples/sax_exception/sax_exception.vcxproj rename to MSVC_NMake/examples/sax_exception/sax_exception.vcxproj diff --git a/MSVC_Net2010/examples/sax_exception/sax_exception.vcxproj.filters b/MSVC_NMake/examples/sax_exception/sax_exception.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/sax_exception/sax_exception.vcxproj.filters rename to MSVC_NMake/examples/sax_exception/sax_exception.vcxproj.filters diff --git a/MSVC_Net2010/examples/sax_parser/sax_parser.vcxproj b/MSVC_NMake/examples/sax_parser/sax_parser.vcxproj similarity index 100% rename from MSVC_Net2010/examples/sax_parser/sax_parser.vcxproj rename to MSVC_NMake/examples/sax_parser/sax_parser.vcxproj diff --git a/MSVC_Net2010/examples/sax_parser/sax_parser.vcxproj.filters b/MSVC_NMake/examples/sax_parser/sax_parser.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/sax_parser/sax_parser.vcxproj.filters rename to MSVC_NMake/examples/sax_parser/sax_parser.vcxproj.filters diff --git a/MSVC_Net2010/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj b/MSVC_NMake/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj similarity index 100% rename from MSVC_Net2010/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj rename to MSVC_NMake/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj diff --git a/MSVC_Net2010/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj.filters b/MSVC_NMake/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj.filters rename to MSVC_NMake/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj.filters diff --git a/MSVC_Net2010/examples/sax_parser_entities/sax_parser_entities.vcxproj b/MSVC_NMake/examples/sax_parser_entities/sax_parser_entities.vcxproj similarity index 100% rename from MSVC_Net2010/examples/sax_parser_entities/sax_parser_entities.vcxproj rename to MSVC_NMake/examples/sax_parser_entities/sax_parser_entities.vcxproj diff --git a/MSVC_Net2010/examples/sax_parser_entities/sax_parser_entities.vcxproj.filters b/MSVC_NMake/examples/sax_parser_entities/sax_parser_entities.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/sax_parser_entities/sax_parser_entities.vcxproj.filters rename to MSVC_NMake/examples/sax_parser_entities/sax_parser_entities.vcxproj.filters diff --git a/MSVC_Net2010/examples/schemavalidation/schemavalidation.vcxproj b/MSVC_NMake/examples/schemavalidation/schemavalidation.vcxproj similarity index 100% rename from MSVC_Net2010/examples/schemavalidation/schemavalidation.vcxproj rename to MSVC_NMake/examples/schemavalidation/schemavalidation.vcxproj diff --git a/MSVC_Net2010/examples/schemavalidation/schemavalidation.vcxproj.filters b/MSVC_NMake/examples/schemavalidation/schemavalidation.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/schemavalidation/schemavalidation.vcxproj.filters rename to MSVC_NMake/examples/schemavalidation/schemavalidation.vcxproj.filters diff --git a/MSVC_Net2010/examples/textreader/textreader.vcxproj b/MSVC_NMake/examples/textreader/textreader.vcxproj similarity index 100% rename from MSVC_Net2010/examples/textreader/textreader.vcxproj rename to MSVC_NMake/examples/textreader/textreader.vcxproj diff --git a/MSVC_Net2010/examples/textreader/textreader.vcxproj.filters b/MSVC_NMake/examples/textreader/textreader.vcxproj.filters similarity index 100% rename from MSVC_Net2010/examples/textreader/textreader.vcxproj.filters rename to MSVC_NMake/examples/textreader/textreader.vcxproj.filters diff --git a/MSVC_Net2010/filelist.am b/MSVC_NMake/filelist.am similarity index 100% rename from MSVC_Net2010/filelist.am rename to MSVC_NMake/filelist.am diff --git a/MSVC_Net2010/gendef/gendef.cc b/MSVC_NMake/gendef/gendef.cc similarity index 100% rename from MSVC_Net2010/gendef/gendef.cc rename to MSVC_NMake/gendef/gendef.cc diff --git a/MSVC_Net2010/gendef/gendef.vcxproj b/MSVC_NMake/gendef/gendef.vcxproj similarity index 100% rename from MSVC_Net2010/gendef/gendef.vcxproj rename to MSVC_NMake/gendef/gendef.vcxproj diff --git a/MSVC_Net2010/gendef/gendef.vcxproj.filters b/MSVC_NMake/gendef/gendef.vcxproj.filters similarity index 100% rename from MSVC_Net2010/gendef/gendef.vcxproj.filters rename to MSVC_NMake/gendef/gendef.vcxproj.filters diff --git a/MSVC_Net2010/libxml++.sln b/MSVC_NMake/libxml++.sln similarity index 100% rename from MSVC_Net2010/libxml++.sln rename to MSVC_NMake/libxml++.sln diff --git a/MSVC_Net2010/libxml++/libxml++.rc.in b/MSVC_NMake/libxml++/libxml++.rc.in similarity index 100% rename from MSVC_Net2010/libxml++/libxml++.rc.in rename to MSVC_NMake/libxml++/libxml++.rc.in diff --git a/MSVC_Net2010/libxml++/libxml++.vcxproj b/MSVC_NMake/libxml++/libxml++.vcxproj similarity index 100% rename from MSVC_Net2010/libxml++/libxml++.vcxproj rename to MSVC_NMake/libxml++/libxml++.vcxproj diff --git a/MSVC_Net2010/libxml++/libxml++.vcxproj.filters b/MSVC_NMake/libxml++/libxml++.vcxproj.filters similarity index 100% rename from MSVC_Net2010/libxml++/libxml++.vcxproj.filters rename to MSVC_NMake/libxml++/libxml++.vcxproj.filters diff --git a/Makefile.am b/Makefile.am index 9f02ec44..04e46dcb 100644 --- a/Makefile.am +++ b/Makefile.am @@ -16,13 +16,13 @@ nodist_library_config_HEADERS = libxml++config.h pkgconfigdir = $(libdir)/pkgconfig nodist_pkgconfig_DATA = $(LIBXMLXX_MODULE_NAME).pc -include $(srcdir)/MSVC_Net2010/filelist.am +include $(srcdir)/MSVC_NMake/filelist.am -dist_noinst_DATA = $(addprefix MSVC_Net2010/,$(msvc_net2010_data)) +dist_noinst_DATA = $(addprefix MSVC_NMake/,$(msvc_net2010_data)) dist_noinst_SCRIPTS = autogen.sh -DISTCLEANFILES = MSVC_Net2010/libxml++/libxml++config.h +DISTCLEANFILES = MSVC_NMake/libxml++/libxml++config.h # Optional: auto-generate the ChangeLog file from the git log on make dist include $(top_srcdir)/build/dist-changelog.am diff --git a/configure.ac b/configure.ac index 3eecda59..87edfcdb 100644 --- a/configure.ac +++ b/configure.ac @@ -66,11 +66,11 @@ AC_CONFIG_FILES([Makefile tests/Makefile docs/Makefile docs/reference/Doxyfile - MSVC_Net2010/libxml++/libxml++.rc + MSVC_NMake/libxml++/libxml++.rc ${LIBXMLXX_MODULE_NAME}.pc:libxml++.pc.in]) # Copy the generated configuration headers into the MSVC project directories. -AC_CONFIG_COMMANDS([MSVC_Net2010/libxml++/libxml++config.h], - [cp -f libxml++config.h MSVC_Net2010/libxml++/libxml++config.h]) +AC_CONFIG_COMMANDS([MSVC_NMake/libxml++/libxml++config.h], + [cp -f libxml++config.h MSVC_NMake/libxml++/libxml++config.h]) AC_OUTPUT From 4c2dcb2629b32034d81bfdaea5dfb47690d59d69 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 12 Jun 2020 12:32:36 +0800 Subject: [PATCH 093/240] tests: Don't include config.h The libxml++config.h should already fulfil our needs here. --- tests/saxparser_chunk_parsing_inconsistent_state/main.cc | 1 - tests/saxparser_parse_double_free/main.cc | 1 - tests/saxparser_parse_stream_inconsistent_state/main.cc | 1 - 3 files changed, 3 deletions(-) diff --git a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc index b10748fc..07cc3eff 100644 --- a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc +++ b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc @@ -15,7 +15,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include diff --git a/tests/saxparser_parse_double_free/main.cc b/tests/saxparser_parse_double_free/main.cc index bb059491..75ef6c9d 100644 --- a/tests/saxparser_parse_double_free/main.cc +++ b/tests/saxparser_parse_double_free/main.cc @@ -15,7 +15,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include diff --git a/tests/saxparser_parse_stream_inconsistent_state/main.cc b/tests/saxparser_parse_stream_inconsistent_state/main.cc index b094f25f..795d5848 100644 --- a/tests/saxparser_parse_stream_inconsistent_state/main.cc +++ b/tests/saxparser_parse_stream_inconsistent_state/main.cc @@ -15,7 +15,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include From 35ba7d57915e9e38f732e61158de0438e32ddad1 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Thu, 18 Jun 2020 16:05:56 +0800 Subject: [PATCH 094/240] node.cc: Don't use __PRETTY_FUNCTION__ __PRETTY_FUNCTION__ is actually a GCC-specific macro, so avoid using it here --- libxml++/nodes/node.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index bc47cc65..1f04b556 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -599,7 +599,7 @@ void Node::create_wrapper(xmlNode* node) { // good default for release versions node->_private = new xmlpp::Node(node); - std::cerr << __PRETTY_FUNCTION__ << " Warning: new node of unknown type created: " + std::cerr << "xmlpp::Node::create_wrapper(): Warning: new node of unknown type created: " << node->type << std::endl; break; } From ec5bd243dc1883fd599f9852c6ffe511d0501f17 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 12 Jun 2020 12:33:25 +0800 Subject: [PATCH 095/240] libxml++.rc.in: Fix version info We are now on libxml++-5.0 (5 .x), not -2.6, so fix the version info in here --- MSVC_NMake/libxml++/libxml++.rc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MSVC_NMake/libxml++/libxml++.rc.in b/MSVC_NMake/libxml++/libxml++.rc.in index e9f81f9f..e7cc391c 100644 --- a/MSVC_NMake/libxml++/libxml++.rc.in +++ b/MSVC_NMake/libxml++/libxml++.rc.in @@ -53,7 +53,7 @@ BEGIN VALUE "FileDescription", "The official C++ wrapper for libxml2" VALUE "FileVersion", "@PACKAGE_VERSION@" VALUE "LegalCopyright", "Distribution is under the LGPL (see COPYING)" - VALUE "OriginalFilename", "libxml++-2.6" + VALUE "OriginalFilename", "libxml++-5.0" VALUE "ProductName", "@PACKAGE_NAME@" VALUE "ProductVersion", "@PACKAGE_VERSION@" END From de6e8150fa071f24e770bbfc2ac9a67bb6e0b19c Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 12 Jun 2020 12:34:32 +0800 Subject: [PATCH 096/240] gendef.cc: Skip symbols implemented inline Like in the case of gtkmm, some symbols were implemented inline in the CRT on Visual Studio 2015+ (UCRT), so we don't want to put them in our .def file, otherwise linking will fail. --- MSVC_NMake/gendef/gendef.cc | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/MSVC_NMake/gendef/gendef.cc b/MSVC_NMake/gendef/gendef.cc index f4ced63e..ba5a8dba 100644 --- a/MSVC_NMake/gendef/gendef.cc +++ b/MSVC_NMake/gendef/gendef.cc @@ -76,11 +76,25 @@ int main(int argc,char** argv) while(*e != ' ' && *e != '\t' && *e != '\0' && *e!= '\n') e++; *e = '\0'; +#if (_MSC_VER >= 1900) + /* Filter out these symbols as they are done inline in the + * compiler-shipped headers, so that things can link properly on + * later Visual Studio versions. Unfortunately we can't just + * link to legacy_stdio_definitions.lib, so this list below may + * continue to grow. + */ + if (_stricmp(s, "__local_stdio_printf_options") != 0 && + _stricmp(s, "_vsnprintf_l") != 0 && + _stricmp(s, "_vsprintf_l") != 0) { +#endif if(strchr(s,'?')==0 && s[0]=='_' && strchr(s,'@') == 0 )//this is a C export type: _fct -> fct def_file << " " << (s+1) << endl; else if(strchr(s,'?')!=0 && strncmp(s,"??_G",4)!=0 && strncmp(s,"??_E",4)!=0) { def_file << " " << s << endl; +#if (_MSC_VER >= 1900) + } +#endif } } } From eb152fdf872d7e88f2bc2cb17747cb49cf7204d4 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 12 Jun 2020 12:36:26 +0800 Subject: [PATCH 097/240] Add NMake Makefiles This adds a set of NMake Makefiles that can be used to build libxml++, which will replace the Visual Studio 2010(!) projects that reside in the repository. To be consistent with the rest of the -mm stack that we build with Visual Studio, we will need to separate the output filenames for the resulting .lib and .dll files for Visual Studio 2017 and 2019. A NMake Makefile build option "USE_COMPAT_LIBS" is added if building 'xml++-vc150-x_y.[dll|lib] is still desired. Note that this branch does not rely on glibmm nor libsigc++, so linking against libxml2 built with an older Visual Studio version should work properly, if libxml2 is built with Visual Studio 2015 or later, but again, we are enforcing the Visual Studio toolset versioning policy by default for consistency's sake. --- MSVC_NMake/Makefile.vc | 61 +++++++++++ MSVC_NMake/build-rules-msvc.mak | 105 +++++++++++++++++++ MSVC_NMake/config-msvc.mak | 34 +++++++ MSVC_NMake/create-lists-msvc.mak | 80 +++++++++++++++ MSVC_NMake/create-lists.bat | 42 ++++++++ MSVC_NMake/detectenv-msvc.mak | 169 +++++++++++++++++++++++++++++++ MSVC_NMake/filelist.am | 11 +- MSVC_NMake/generate-msvc.mak | 50 +++++++++ MSVC_NMake/info-msvc.mak | 44 ++++++++ MSVC_NMake/install.mak | 18 ++++ 10 files changed, 613 insertions(+), 1 deletion(-) create mode 100644 MSVC_NMake/Makefile.vc create mode 100644 MSVC_NMake/build-rules-msvc.mak create mode 100644 MSVC_NMake/config-msvc.mak create mode 100644 MSVC_NMake/create-lists-msvc.mak create mode 100644 MSVC_NMake/create-lists.bat create mode 100644 MSVC_NMake/detectenv-msvc.mak create mode 100644 MSVC_NMake/generate-msvc.mak create mode 100644 MSVC_NMake/info-msvc.mak create mode 100644 MSVC_NMake/install.mak diff --git a/MSVC_NMake/Makefile.vc b/MSVC_NMake/Makefile.vc new file mode 100644 index 00000000..75d57941 --- /dev/null +++ b/MSVC_NMake/Makefile.vc @@ -0,0 +1,61 @@ +# NMake Makefile for building libxml++ on Windows using Visual Studio + +# The items below this line should not be changed, unless one is maintaining +# the NMake Makefiles. Customizations can be done in the following NMake Makefile +# portions (please see comments in the these files to see what can be customized): +# +# detectenv-msvc.mak +# config-msvc.mak + +!include detectenv-msvc.mak + +# Include the Makefile portions with the source listings +!include ..\libxml++\filelist.am + +# Include the Makefile portion that enables features based on user input +!include config-msvc.mak + +!if "$(VALID_CFGSET)" == "TRUE" + +# We need Visual Studio 2015 or later +!if $(VSVER) < 14 +VALID_MSC = FALSE +!else +VALID_MSC = TRUE +!endif + +!if "$(VALID_MSC)" == "TRUE" + +all: $(LIBXMLXX_LIB) libxmlxx_examples all-build-info + +# Include the Makefile portion to convert the source and header lists +# into the lists we need for compilation +!include create-lists-msvc.mak + +!ifdef GENERATE_VERSIONED_FILES +!include pkg-ver.mak +!endif + +tests: $(libxmlxx_tests) all-build-info + +libxmlxx_examples: $(libxmlxx_examples) + +# Include the build rules for sources, DLLs and executables +!include generate-msvc.mak +!include build-rules-msvc.mak + +!include install.mak + +!else # "$(VALID_MSC)" == "TRUE" +all: + @echo You need Visual Studio 2015 or later. + +!endif # "$(VALID_MSC)" == "TRUE" + +!else # "$(VALID_CFGSET)" == "TRUE" +all: help + @echo You need to specify a valid configuration, via + @echo CFG=release or CFG=debug +!endif # "$(VALID_CFGSET)" == "TRUE" + +!include info-msvc.mak diff --git a/MSVC_NMake/build-rules-msvc.mak b/MSVC_NMake/build-rules-msvc.mak new file mode 100644 index 00000000..683966b5 --- /dev/null +++ b/MSVC_NMake/build-rules-msvc.mak @@ -0,0 +1,105 @@ +# NMake Makefile portion for compilation rules +# Items in here should not need to be edited unless +# one is maintaining the NMake build files. The format +# of NMake Makefiles here are different from the GNU +# Makefiles. Please see the comments about these formats. + +# Inference rules for compiling the .obj files. +# Used for libs and programs with more than a single source file. +# Format is as follows +# (all dirs must have a trailing '\'): +# +# {$(srcdir)}.$(srcext){$(destdir)}.obj:: +# $(CC)|$(CXX) $(cflags) /Fo$(destdir) /c @<< +# $< +# << + +{..\libxml++\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.obj:: + @if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ md vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx + $(CXX) $(LIBXMLXX_CFLAGS) $(CFLAGS_NOGL) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /c @<< +$< +<< + +{..\libxml++\exceptions\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.obj:: + @if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ md vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx + $(CXX) $(LIBXMLXX_CFLAGS) $(CFLAGS_NOGL) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /c @<< +$< +<< + +{..\libxml++\io\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.obj:: + @if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ md vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx + $(CXX) $(LIBXMLXX_CFLAGS) $(CFLAGS_NOGL) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /c @<< +$< +<< + +{..\libxml++\nodes\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.obj:: + @if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ md vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx + $(CXX) $(LIBXMLXX_CFLAGS) $(CFLAGS_NOGL) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /c @<< +$< +<< + +{..\libxml++\parsers\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.obj:: + @if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ md vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx + $(CXX) $(LIBXMLXX_CFLAGS) $(CFLAGS_NOGL) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /c @<< +$< +<< + +{..\libxml++\validators\}.cc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.obj:: + @if not exist vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ md vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx + $(CXX) $(LIBXMLXX_CFLAGS) $(CFLAGS_NOGL) /Fovs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /Fdvs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\ /c @<< +$< +<< + +{.\libxml++\}.rc{vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\}.res: + @if not exist $(@D)\ md $(@D) + rc /fo$@ $< + +# Rules for building .lib files +$(LIBXMLXX_LIB): $(LIBXMLXX_DLL) + +# Rules for linking DLLs +# Format is as follows (the mt command is needed for MSVC 2005/2008 builds): +# $(dll_name_with_path): $(dependent_libs_files_objects_and_items) +# link /DLL [$(linker_flags)] [$(dependent_libs)] [/def:$(def_file_if_used)] [/implib:$(lib_name_if_needed)] -out:$@ @<< +# $(dependent_objects) +# << +# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2 +$(LIBXMLXX_DLL): $(libxmlxx_OBJS) vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\libxml++.def + link /DLL $(LDFLAGS_NOLTCG) $(LIBXML2_LIBS) /implib:$(LIBXMLXX_LIB) /def:vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\libxml++.def -out:$@ @<< +$(libxmlxx_OBJS) +<< + @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2 + +# Rules for linking Executables +# Format is as follows (the mt command is needed for MSVC 2005/2008 builds): +# $(dll_name_with_path): $(dependent_libs_files_objects_and_items) +# link [$(linker_flags)] [$(dependent_libs)] -out:$@ @<< +# $(dependent_objects) +# << +# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1 +$(GENDEF): gendef\gendef.cc + @if not exist $(@D)\gendef\ md $(@D)\gendef + $(CXX) $(CFLAGS) /Fo$(@D)\gendef\ /Fd$(@D)\gendef\ $** /Fe:$@ /link $(LDFLAGS) -out:$@ + @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1 + +clean: + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.exe + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.dll + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.pdb + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.ilk + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.exp + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.lib + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-tests\*.obj + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-tests\*.pdb + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-examples\*.obj + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-examples\*.pdb + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\*.def + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\*.res + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\*.obj + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\*.pdb + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\gendef\*.obj + @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\gendef\*.pdb + @-rd vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-tests + @-rd vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-examples + @-rd vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx + @-rd vs$(VSVER)\$(CFG)\$(PLAT)\gendef diff --git a/MSVC_NMake/config-msvc.mak b/MSVC_NMake/config-msvc.mak new file mode 100644 index 00000000..0295b281 --- /dev/null +++ b/MSVC_NMake/config-msvc.mak @@ -0,0 +1,34 @@ +# NMake Makefile portion for enabling features for Windows builds + +# These are the base minimum libraries required for building glibmm. +BASE_INCLUDES = /I$(PREFIX)\include + +# Please do not change anything beneath this line unless maintaining the NMake Makefiles +LIBXMLXX_MAJOR_VERSION = 5 +LIBXMLXX_MINOR_VERSION = 0 + +!if "$(CFG)" == "debug" || "$(CFG)" == "Debug" +DEBUG_SUFFIX = -d +!else +DEBUG_SUFFIX = +!endif + +LIBXMLXX_BASE_CFLAGS = \ + /I.\libxml++ /I.. \ + /wd4530 /wd4251 /wd4275 /EHsc \ + /FImsvc_recommended_pragmas.h \ + /std:c++17 + +LIBXMLXX_EXTRA_INCLUDES = /I$(PREFIX)\include\libxml2 + +LIBXMLXX_CFLAGS = /DLIBXMLPP_BUILD $(LIBXMLXX_BASE_CFLAGS) $(LIBXMLXX_EXTRA_INCLUDES) +LIBXMLXX_EX_CFLAGS = $(LIBXMLXX_BASE_CFLAGS) $(LIBXMLXX_EXTRA_INCLUDES) + +# We build xml++-vc$(VSVER_LIB)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).dll or +# xml++-vc$(VSVER_LIB)-d-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).dll at least + +LIBXMLXX_DLL = vs$(VSVER)\$(CFG)\$(PLAT)\xml++-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).dll +LIBXMLXX_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\xml++-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).lib +GENDEF = vs$(VSVER)\$(CFG)\$(PLAT)\gendef.exe + +LIBXML2_LIBS = libxml2.lib diff --git a/MSVC_NMake/create-lists-msvc.mak b/MSVC_NMake/create-lists-msvc.mak new file mode 100644 index 00000000..654a87f7 --- /dev/null +++ b/MSVC_NMake/create-lists-msvc.mak @@ -0,0 +1,80 @@ +# Convert the source listing to object (.obj) listing in +# another NMake Makefile module, include it, and clean it up. +# This is a "fact-of-life" regarding NMake Makefiles... +# This file does not need to be changed unless one is maintaining the NMake Makefiles + +# For those wanting to add things here: +# To add a list, do the following: +# # $(description_of_list) +# if [call create-lists.bat header $(makefile_snippet_file) $(variable_name)] +# endif +# +# if [call create-lists.bat file $(makefile_snippet_file) $(file_name)] +# endif +# +# if [call create-lists.bat footer $(makefile_snippet_file)] +# endif +# ... (repeat the if [call ...] lines in the above order if needed) +# !include $(makefile_snippet_file) +# +# (add the following after checking the entries in $(makefile_snippet_file) is correct) +# (the batch script appends to $(makefile_snippet_file), you will need to clear the file unless the following line is added) +#!if [del /f /q $(makefile_snippet_file)] +#!endif + +# In order to obtain the .obj filename that is needed for NMake Makefiles to build DLLs/static LIBs or EXEs, do the following +# instead when doing 'if [call create-lists.bat file $(makefile_snippet_file) $(file_name)]' +# (repeat if there are multiple $(srcext)'s in $(source_list), ignore any headers): +# !if [for %c in ($(source_list)) do @if "%~xc" == ".$(srcext)" @call create-lists.bat file $(makefile_snippet_file) $(intdir)\%~nc.obj] +# +# $(intdir)\%~nc.obj needs to correspond to the rules added in build-rules-msvc.mak +# %~xc gives the file extension of a given file, %c in this case, so if %c is a.cc, %~xc means .cc +# %~nc gives the file name of a given file without extension, %c in this case, so if %c is a.cc, %~nc means a + +NULL= + +# For libxml++ + +!if [call create-lists.bat header libxmlxx.mak libxmlxx_OBJS] +!endif + +!if [for %c in ($(cc_sources)) do @if "%~xc" == ".cc" @call create-lists.bat file libxmlxx.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\libxmlxx\%~nc.obj] +!endif + +!if [@call create-lists.bat file libxmlxx.mak vs^$(VSVER)\^$(CFG)\^$(PLAT)\libxmlxx\libxml++.res] +!endif + +!if [call create-lists.bat footer libxmlxx.mak] +!endif + +!if [call create-lists.bat header libxmlxx.mak libxmlxx_real_hdrs] +!endif + +!if [for %c in ($(h_sources_public:/=\)) do @call create-lists.bat file libxmlxx.mak ..\libxml++\%c] +!endif + +!if [call create-lists.bat footer libxmlxx.mak] +!endif + +!if [for %d in (examples tests) do @call create-lists.bat header libxmlxx.mak libxmlxx_%d & @(for /f %t in ('dir /ad /b ..\%d') do @call create-lists.bat file libxmlxx.mak vs$(VSVER)\$(CFG)\$(PLAT)\%t.exe) & @call create-lists.bat footer libxmlxx.mak] +!endif + +!if [for %d in (examples tests) do @for /f %t in ('dir /ad /b ..\%d') do @call create-lists.bat header libxmlxx.mak %t_OBJS & @(for %s in (..\%d\%t\*.cc) do @call create-lists.bat file libxmlxx.mak vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-%d\%t-%~ns.obj) & @call create-lists.bat footer libxmlxx.mak] +!endif + +!if [echo.>>libxmlxx.mak] +!endif + +!if [for %d in (examples tests) do @for /f %t in ('dir /ad /b ..\%d') do @for %s in (..\%d\%t\*.cc) do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\libxmlxx-%d\%t-%~ns.obj: %s>>libxmlxx.mak & @echo. if not exist ^$(@D)\ md ^$(@D)>>libxmlxx.mak & @echo. ^$(CXX) ^$(LIBXMLXX_EX_CFLAGS) ^$(CFLAGS) /Fo^$(@D)\%t-%~ns.obj /Fd^$(@D)\ ^$** /c>>libxmlxx.mak & @echo.>>libxmlxx.mak] +!endif + +!if [for %d in (examples tests) do @for /f %t in ('dir /ad /b ..\%d') do @echo vs^$(VSVER)\^$(CFG)\^$(PLAT)\%t.exe: ^$(LIBXMLXX_LIB) ^$(%t_OBJS)>>libxmlxx.mak & @echo. link ^$(LDFLAGS) ^$** ^$(LIBXML2_LIBS) /out:^$@>>libxmlxx.mak & @echo.>>libxmlxx.mak] +!endif + +!if [echo.>>libxmlxx.mak] +!endif + +!include libxmlxx.mak + +!if [del /f /q libxmlxx.mak] +!endif diff --git a/MSVC_NMake/create-lists.bat b/MSVC_NMake/create-lists.bat new file mode 100644 index 00000000..ef60d5ce --- /dev/null +++ b/MSVC_NMake/create-lists.bat @@ -0,0 +1,42 @@ +@echo off +rem Simple .bat script for creating the NMake Makefile snippets. + +if not "%1" == "header" if not "%1" == "file" if not "%1" == "footer" goto :error_cmd +if "%2" == "" goto error_no_destfile + +if "%1" == "header" goto :header +if "%1" == "file" goto :addfile +if "%1" == "footer" goto :footer + +:header +if "%3" == "" goto error_var +echo %3 = \>>%2 +goto done + +:addfile +if "%3" == "" goto error_file +echo. %3 \>>%2 +goto done + +:footer +echo. $(NULL)>>%2 +echo.>>%2 +goto done + +:error_cmd +echo Specified command '%1' was invalid. Valid commands are: header file footer. +goto done + +:error_no_destfile +echo Destination NMake snippet file must be specified +goto done + +:error_var +echo A name must be specified for using '%1'. +goto done + +:error_file +echo A file must be specified for using '%1'. +goto done + +:done \ No newline at end of file diff --git a/MSVC_NMake/detectenv-msvc.mak b/MSVC_NMake/detectenv-msvc.mak new file mode 100644 index 00000000..8005c35f --- /dev/null +++ b/MSVC_NMake/detectenv-msvc.mak @@ -0,0 +1,169 @@ +# Change this (or specify PREFIX= when invoking this NMake Makefile) if +# necessary, so that the libs and headers of the dependent third-party +# libraries can be located. For instance, if building from GLib's +# included Visual Studio projects, this should be able to locate the GLib +# build out-of-the-box if they were not moved. GLib's headers will be +# found in $(GLIB_PREFIX)\include\glib-2.0 and +# $(GLIB_PREFIX)\lib\glib-2.0\include and its import library will be found +# in $(GLIB_PREFIX)\lib. + +!if "$(PREFIX)" == "" +PREFIX = ..\..\vs$(VSVER)\$(PLAT) +!endif + +# Location of the PERL interpreter, for running glib-mkenums. glib-mkenums +# needs to be found in $(PREFIX)\bin. Using either a 32-bit or x64 PERL +# interpreter are supported for either a 32-bit or x64 build. + +!if "$(PERL)" == "" +PERL = perl +!endif + +# Location of the Python interpreter, for building introspection. The complete set +# of Python Modules for introspection (the giscanner Python scripts and the _giscanner.pyd +# compiled module) needs to be found in $(PREFIX)\lib\gobject-introspection\giscanner, and +# the g-ir-scanner Python script and g-ir-compiler utility program needs to be found +# in $(PREFIX)\bin, together with any DLLs they will depend on, if those DLLs are not already +# in your PATH. +# Note that the Python interpreter and the introspection modules and utility progam must +# correspond to the build type (i.e. 32-bit Release for 32-bit Release builds, and so on). +# +# For introspection, currently only Python 2.7.x is supported. This may change when Python 3.x +# support is added upstream in gobject-introspection--when this happens, the _giscanner.pyd must +# be the one that is built against the release series of Python that is used here. + +!if "$(PYTHON)" == "" +PYTHON = python +!endif + +# Location of the pkg-config utility program, for building introspection. It needs to be able +# to find the pkg-config (.pc) files so that the correct libraries and headers for the needed libraries +# can be located, using PKG_CONFIG_PATH. Using either a 32-bit or x64 pkg-config are supported for +# either a 32-bit or x64 build. + +!if "$(PKG_CONFIG)" == "" +PKG_CONFIG = pkg-config +!endif + +# The items below this line should not be changed, unless one is maintaining +# the NMake Makefiles. The exception is for the CFLAGS_ADD line(s) where one +# could use his/her desired compiler optimization flags, if he/she knows what is +# being done. + +# Check to see we are configured to build with MSVC (MSDEVDIR, MSVCDIR or +# VCINSTALLDIR) or with the MS Platform SDK (MSSDK or WindowsSDKDir) +!if !defined(VCINSTALLDIR) && !defined(WINDOWSSDKDIR) +MSG = ^ +This Makefile is only for Visual Studio 2008 and later.^ +You need to ensure that the Visual Studio Environment is properly set up^ +before running this Makefile. +!error $(MSG) +!endif + +ERRNUL = 2>NUL +_HASH=^# + +!if ![echo VCVERSION=_MSC_VER > vercl.x] \ + && ![echo $(_HASH)if defined(_M_IX86) >> vercl.x] \ + && ![echo PLAT=Win32 >> vercl.x] \ + && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \ + && ![echo PLAT=x64 >> vercl.x] \ + && ![echo $(_HASH)endif >> vercl.x] \ + && ![cl -nologo -TC -P vercl.x $(ERRNUL)] +!include vercl.i +!if ![echo VCVER= ^\> vercl.vc] \ + && ![set /a $(VCVERSION) / 100 - 6 >> vercl.vc] +!include vercl.vc +!endif +!endif +!if ![del $(ERRNUL) /q/f vercl.x vercl.i vercl.vc] +!endif + +VSVER = 0 +PDBVER = 0 +VSVER_SUFFIX = 0 + +!if $(VCVERSION) > 1499 && $(VCVERSION) < 1600 +PDBVER = 9 +!elseif $(VCVERSION) > 1599 && $(VCVERSION) < 1700 +PDBVER = 10 +!elseif $(VCVERSION) > 1699 && $(VCVERSION) < 1800 +PDBVER = 11 +!elseif $(VCVERSION) > 1799 && $(VCVERSION) < 1900 +PDBVER = 12 +!elseif $(VCVERSION) > 1899 && $(VCVERSION) < 2000 +PDBVER = 14 +!if $(VCVERSION) > 1909 && $(VCVERSION) < 1920 +VSVER_SUFFIX = 1 +VSVER = 15 +!elseif $(VCVERSION) > 1919 && $(VCVERSION) < 2000 +VSVER_SUFFIX = 2 +VSVER = 16 +!else +VSVER = $(PDBVER) +!endif +!else +VSVER = $(PDBVER) +!endif + +!if $(VSVER) > 14 && "$(USE_COMPAT_LIBS)" != "" +VSVER_LIB = 150 +!else +VSVER_LIB = $(PDBVER)$(VSVER_SUFFIX) +!endif + +!if "$(VSVER)" == "0" +MSG = ^ +This NMake Makefile set supports Visual Studio^ +9 (2008) through 16 (2019). Your Visual Studio^ +version is not supported. +!error $(MSG) +!endif + +VALID_CFGSET = FALSE +!if "$(CFG)" == "release" || "$(CFG)" == "Release" || "$(CFG)" == "debug" || "$(CFG)" == "Debug" +VALID_CFGSET = TRUE +!endif + +# One may change these items, but be sure to test +# the resulting binaries +!if "$(CFG)" == "release" || "$(CFG)" == "Release" +CFLAGS_ADD_NO_GL = /MD /O2 /MP +CFLAGS_ADD = $(CFLAGS_ADD_NO_GL) /GL +!if "$(VSVER)" != "9" +CFLAGS_ADD = $(CFLAGS_ADD) /d2Zi+ +CFLAGS_ADD_NO_GL = $(CFLAGS_ADD_NO_GL) /d2Zi+ +!if $(VSVER) >= 14 +CFLAGS_ADD = $(CFLAGS_ADD) /utf-8 +CFLAGS_ADD_NO_GL = $(CFLAGS_ADD_NO_GL) /utf-8 +!endif +!endif +!else +CFLAGS_ADD = /MDd /Od +CFLAGS_ADD_NO_GL = $(CFLAGS_ADD) +!endif + +!if "$(PLAT)" == "x64" +LDFLAGS_ARCH = /machine:x64 +!else +LDFLAGS_ARCH = /machine:x86 +!endif + +!if "$(VALID_CFGSET)" == "TRUE" +CFLAGS_NOGL = $(CFLAGS_ADD_NO_GL) /W3 /Zi +CFLAGS = $(CFLAGS_ADD) /W3 /Zi + +LDFLAGS_BASE = $(LDFLAGS_ARCH) /libpath:$(PREFIX)\lib /DEBUG + +!if "$(CFG)" == "debug" || "$(CFG)" == "Debug" +ARFLAGS_NOLTCG = $(LDFLAGS_ARCH) +ARFLAGS = $(LDFLAGS_ARCH) +LDFLAGS_NOLTCG = $(LDFLAGS_BASE) +LDFLAGS = $(LDFLAGS_BASE) +!else +ARFLAGS_NOLTCG = $(LDFLAGS_ARCH) /LTCG +ARFLAGS = $(ARFLAGS_NOLTCG) /LTCG +LDFLAGS_NOLTCG = $(LDFLAGS_BASE) /opt:ref +LDFLAGS = $(LDFLAGS_NOLTCG) /LTCG +!endif +!endif diff --git a/MSVC_NMake/filelist.am b/MSVC_NMake/filelist.am index 45506988..ee2e7428 100644 --- a/MSVC_NMake/filelist.am +++ b/MSVC_NMake/filelist.am @@ -37,4 +37,13 @@ msvc_net2010_data = \ examples/schemavalidation/schemavalidation.vcxproj \ examples/schemavalidation/schemavalidation.vcxproj.filters \ examples/textreader/textreader.vcxproj \ - examples/textreader/textreader.vcxproj.filters + examples/textreader/textreader.vcxproj.filters \ + build-rules-msvc.mak \ + config-msvc.mak \ + create-lists-msvc.mak \ + create-lists.bat \ + detectenv-msvc.mak \ + generate-msvc.mak \ + info-msvc.mak \ + install.mak \ + Makefile.vc diff --git a/MSVC_NMake/generate-msvc.mak b/MSVC_NMake/generate-msvc.mak new file mode 100644 index 00000000..a7772e9f --- /dev/null +++ b/MSVC_NMake/generate-msvc.mak @@ -0,0 +1,50 @@ +# NMake Makefile portion for code generation and +# intermediate build directory creation +# Items in here should not need to be edited unless +# one is maintaining the NMake build files. + +# Create the build directories +vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx: + @-md $@ + +# Generate .def file using gendef +vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\libxml++.def: $(libxmlxx_OBJS) $(GENDEF) + $(GENDEF) $@ xml++-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).dll $(libxmlxx_OBJS) + +# Generate pre-generated resources and configuration headers (builds from GIT) +prep-git-build: pkg-ver.mak + +libxml++\libxml++.rc: pkg-ver.mak libxml++\libxml++.rc.in libxml++\libxml++config.h + @echo Generating $@... + @copy "$@.in" "$@" + @$(PERL) -pi.bak -e "s/\@LIBXMLXX_MAJOR_VERSION\@/$(PKG_MAJOR_VERSION)/g" $@ + @$(PERL) -pi.bak -e "s/\@LIBXMLXX_MINOR_VERSION\@/$(PKG_MINOR_VERSION)/g" $@ + @$(PERL) -pi.bak -e "s/\@LIBXMLXX_MICRO_VERSION\@/$(PKG_MICRO_VERSION)/g" $@ + @$(PERL) -pi.bak -e "s/\@PACKAGE_VERSION\@/$(PKG_MAJOR_VERSION).$(PKG_MINOR_VERSION).$(PKG_MICRO_VERSION)/g" $@ + @$(PERL) -pi.bak -e "s/\@PACKAGE_NAME\@/libxml++-$(PKG_MAJOR_VERSION).$(PKG_MINOR_VERSION)/g" $@ + @del $@.bak + +# You may change LIBXMLXX_DISABLE_DEPRECATED if you know what you are doing +libxml++\libxml++config.h: pkg-ver.mak ..\libxml++config.h.in + @echo Generating $@... + @copy "..\$(@F).in" "$@" + @$(PERL) -pi.bak -e "s/\#undef LIBXMLXX_DISABLE_DEPRECATED/\/\* \#undef LIBXMLXX_DISABLE_DEPRECATED \*\//g" $@ + @$(PERL) -pi.bak -e "s/\#undef LIBXMLXX_HAVE_EXCEPTION_PTR/\#define LIBXMLXX_HAVE_EXCEPTION_PTR 1/g" $@ + @$(PERL) -pi.bak -e "s/\#undef LIBXMLXX_MAJOR_VERSION/\#define LIBXMLXX_MAJOR_VERSION $(PKG_MAJOR_VERSION)/g" $@ + @$(PERL) -pi.bak -e "s/\#undef LIBXMLXX_MINOR_VERSION/\#define LIBXMLXX_MINOR_VERSION $(PKG_MINOR_VERSION)/g" $@ + @$(PERL) -pi.bak -e "s/\#undef LIBXMLXX_MICRO_VERSION/\#define LIBXMLXX_MICRO_VERSION $(PKG_MICRO_VERSION)/g" $@ + @del $@.bak + +pkg-ver.mak: ..\configure.ac + @echo Generating version info Makefile Snippet... + @$(PERL) -00 -ne "print if /AC_INIT\(/" $** | \ + $(PERL) -pe "tr/, /\n/s" | \ + $(PERL) -ne "print if 2 .. 2" | \ + $(PERL) -ne "print /\[(.*)\]/" > ver.txt + @echo @echo off>pkg-ver.bat + @echo.>>pkg-ver.bat + @echo set /p libxmlxx_ver=^>pkg-ver.bat + @echo for /f "tokens=1,2,3 delims=." %%%%a IN ("%libxmlxx_ver%") do (echo PKG_MAJOR_VERSION=%%%%a^& echo PKG_MINOR_VERSION=%%%%b^& echo PKG_MICRO_VERSION=%%%%c)^>$@>>pkg-ver.bat + @pkg-ver.bat + @del ver.txt pkg-ver.bat + $(MAKE) /f Makefile.vc CFG=$(CFG) GENERATE_VERSIONED_FILES=1 libxml++\libxml++.rc diff --git a/MSVC_NMake/info-msvc.mak b/MSVC_NMake/info-msvc.mak new file mode 100644 index 00000000..2882de46 --- /dev/null +++ b/MSVC_NMake/info-msvc.mak @@ -0,0 +1,44 @@ +# NMake Makefile portion for displaying config info + +all-build-info: + @echo. + @echo ---------- + @echo Build info + @echo --------- + @echo Build Type: $(CFG) + +help: + @echo. + @echo ============================ + @echo Building glibmm Using NMake + @echo ============================ + @echo nmake /f Makefile.vc CFG=[release^|debug] ^ ^ + @echo. + @echo Where: + @echo ------ + @echo CFG: Required, use CFG=release for an optimized build and CFG=debug + @echo for a debug build. PDB files are generated for all builds. + @echo. + @echo PREFIX: Optional, the path where dependent libraries and tools may be + @echo found, default is ^$(srcrootdir)\..\vs^$(short_vs_ver)\^$(platform), + @echo where ^$(short_vs_ver) is 15 for VS 2017 and so on; and + @echo ^$(platform) is Win32 for 32-bit builds and x64 for x64 builds. + @echo. + @echo ----- + @echo A few options are supported here, namely: + @echo. + @echo USE_COMPAT_LIBS: Use this if you want to use 'vc150' in your DLL and .lib filenames, + @echo instead of using the Visual Studio toolset version. + @echo. + @echo USE_MESON_LIBS: Use DLLs and LIBs of C++ dependencies that are built with Meson, + @echo as applicable. + @echo ====== + @echo A 'clean' target is supported to remove all generated files, intermediate + @echo object files and binaries for the specified configuration. + @echo. + @echo An 'install' target is supported to copy the build (DLLs, utility programs, + @echo LIBs, along with the header files) to appropriate locations under ^$(PREFIX). + @echo. + @echo A 'tests' target is supported to build the test programs. + @echo ====== + @echo. diff --git a/MSVC_NMake/install.mak b/MSVC_NMake/install.mak new file mode 100644 index 00000000..1c282f70 --- /dev/null +++ b/MSVC_NMake/install.mak @@ -0,0 +1,18 @@ +# NMake Makefile snippet for copying the built libraries, utilities and headers to +# a path under $(PREFIX). + +install: all + @if not exist $(PREFIX)\bin\ md $(PREFIX)\bin + @if not exist $(PREFIX)\lib\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\include\ md $(PREFIX)\lib\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\include + @if not exist $(PREFIX)\include\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\libxml++\ @md $(PREFIX)\include\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\libxml++ + @for /f %d in ('dir /ad /b ..\libxml++') do @if not exist $(PREFIX)\include\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\libxml++\%d\ @md $(PREFIX)\include\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\libxml++\%d + @copy /b "$(LIBXMLXX_DLL)" "$(PREFIX)\bin\" + @copy /b "$(LIBXMLXX_DLL:dll=pdb)" "$(PREFIX)\bin\" + @copy /b "$(LIBXMLXX_LIB)" "$(PREFIX)\lib\" + @for %h in (libxml++.h $(h_root_sources_public:/=\)) do @copy "..\libxml++\%h" "$(PREFIX)\include\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\libxml++\" + @for %h in ($(h_exceptions_sources_public:/=\)) do @copy "..\libxml++\%h" "$(PREFIX)\include\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\libxml++\exceptions\" + @for %h in ($(h_io_sources_public:/=\)) do @copy "..\libxml++\%h" "$(PREFIX)\include\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\libxml++\io\" + @for %h in ($(h_nodes_sources_public:/=\)) do @copy "..\libxml++\%h" "$(PREFIX)\include\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\libxml++\nodes\" + @for %h in ($(h_parsers_sources_public:/=\)) do @copy "..\libxml++\%h" "$(PREFIX)\include\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\libxml++\parsers\" + @for %h in ($(h_validators_sources_public:/=\)) do @copy "..\libxml++\%h" "$(PREFIX)\include\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\libxml++\validators\" + @copy ".\libxml++\libxml++config.h" "$(PREFIX)\lib\libxml++-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION)\include\" From 6af45f3912c8a578e7c5f548cf966558d50aa0ad Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 12 Jun 2020 15:42:15 +0800 Subject: [PATCH 098/240] Drop Visual Studio 2010 projects They have been superseded with the NMake Makefiles, so it's time to retire them from the source tree. --- .../examples/dom_build/dom_build.vcxproj | 205 --------- .../dom_build/dom_build.vcxproj.filters | 22 - .../dom_parse_entities.vcxproj | 205 --------- .../dom_parse_entities.vcxproj.filters | 22 - .../examples/dom_parser/dom_parser.vcxproj | 205 --------- .../dom_parser/dom_parser.vcxproj.filters | 22 - .../dom_parser_raw/dom_parser_raw.vcxproj | 205 --------- .../dom_parser_raw.vcxproj.filters | 22 - .../dom_read_write/dom_read_write.vcxproj | 205 --------- .../dom_read_write.vcxproj.filters | 22 - .../examples/dom_xpath/dom_xpath.vcxproj | 205 --------- .../dom_xpath/dom_xpath.vcxproj.filters | 22 - .../dtdvalidation/dtdvalidation.vcxproj | 205 --------- .../dtdvalidation.vcxproj.filters | 22 - .../examples/import_node/import_node.vcxproj | 205 --------- .../import_node/import_node.vcxproj.filters | 22 - .../sax_exception/sax_exception.vcxproj | 209 --------- .../sax_exception.vcxproj.filters | 30 -- .../examples/sax_parser/sax_parser.vcxproj | 209 --------- .../sax_parser/sax_parser.vcxproj.filters | 30 -- .../sax_parser_build_dom.vcxproj | 214 --------- .../sax_parser_build_dom.vcxproj.filters | 45 -- .../sax_parser_entities.vcxproj | 209 --------- .../sax_parser_entities.vcxproj.filters | 30 -- .../schemavalidation/schemavalidation.vcxproj | 205 --------- .../schemavalidation.vcxproj.filters | 22 - .../examples/textreader/textreader.vcxproj | 205 --------- .../textreader/textreader.vcxproj.filters | 22 - MSVC_NMake/filelist.am | 35 +- MSVC_NMake/gendef/gendef.vcxproj | 177 -------- MSVC_NMake/gendef/gendef.vcxproj.filters | 22 - MSVC_NMake/libxml++.sln | 175 -------- MSVC_NMake/libxml++/libxml++.vcxproj | 413 ------------------ MSVC_NMake/libxml++/libxml++.vcxproj.filters | 233 ---------- Makefile.am | 2 +- 35 files changed, 2 insertions(+), 4301 deletions(-) delete mode 100644 MSVC_NMake/examples/dom_build/dom_build.vcxproj delete mode 100644 MSVC_NMake/examples/dom_build/dom_build.vcxproj.filters delete mode 100644 MSVC_NMake/examples/dom_parse_entities/dom_parse_entities.vcxproj delete mode 100644 MSVC_NMake/examples/dom_parse_entities/dom_parse_entities.vcxproj.filters delete mode 100644 MSVC_NMake/examples/dom_parser/dom_parser.vcxproj delete mode 100644 MSVC_NMake/examples/dom_parser/dom_parser.vcxproj.filters delete mode 100644 MSVC_NMake/examples/dom_parser_raw/dom_parser_raw.vcxproj delete mode 100644 MSVC_NMake/examples/dom_parser_raw/dom_parser_raw.vcxproj.filters delete mode 100644 MSVC_NMake/examples/dom_read_write/dom_read_write.vcxproj delete mode 100644 MSVC_NMake/examples/dom_read_write/dom_read_write.vcxproj.filters delete mode 100644 MSVC_NMake/examples/dom_xpath/dom_xpath.vcxproj delete mode 100644 MSVC_NMake/examples/dom_xpath/dom_xpath.vcxproj.filters delete mode 100644 MSVC_NMake/examples/dtdvalidation/dtdvalidation.vcxproj delete mode 100644 MSVC_NMake/examples/dtdvalidation/dtdvalidation.vcxproj.filters delete mode 100644 MSVC_NMake/examples/import_node/import_node.vcxproj delete mode 100644 MSVC_NMake/examples/import_node/import_node.vcxproj.filters delete mode 100644 MSVC_NMake/examples/sax_exception/sax_exception.vcxproj delete mode 100644 MSVC_NMake/examples/sax_exception/sax_exception.vcxproj.filters delete mode 100644 MSVC_NMake/examples/sax_parser/sax_parser.vcxproj delete mode 100644 MSVC_NMake/examples/sax_parser/sax_parser.vcxproj.filters delete mode 100644 MSVC_NMake/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj delete mode 100644 MSVC_NMake/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj.filters delete mode 100644 MSVC_NMake/examples/sax_parser_entities/sax_parser_entities.vcxproj delete mode 100644 MSVC_NMake/examples/sax_parser_entities/sax_parser_entities.vcxproj.filters delete mode 100644 MSVC_NMake/examples/schemavalidation/schemavalidation.vcxproj delete mode 100644 MSVC_NMake/examples/schemavalidation/schemavalidation.vcxproj.filters delete mode 100644 MSVC_NMake/examples/textreader/textreader.vcxproj delete mode 100644 MSVC_NMake/examples/textreader/textreader.vcxproj.filters delete mode 100644 MSVC_NMake/gendef/gendef.vcxproj delete mode 100644 MSVC_NMake/gendef/gendef.vcxproj.filters delete mode 100644 MSVC_NMake/libxml++.sln delete mode 100644 MSVC_NMake/libxml++/libxml++.vcxproj delete mode 100644 MSVC_NMake/libxml++/libxml++.vcxproj.filters diff --git a/MSVC_NMake/examples/dom_build/dom_build.vcxproj b/MSVC_NMake/examples/dom_build/dom_build.vcxproj deleted file mode 100644 index 76bc78a0..00000000 --- a/MSVC_NMake/examples/dom_build/dom_build.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_dom_build - {129ECC08-6D30-4884-B824-4AF96EF0A45C} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - dom_build - dom_build - dom_build - dom_build - - - - /vd2 %(AdditionalOptions) - Disabled - ../../libxml++;../../..;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_build.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../libxml++;../../..;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_build.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../libxml++;../../..;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_build.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../libxml++;../../..;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_build.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dom_build/dom_build.vcxproj.filters b/MSVC_NMake/examples/dom_build/dom_build.vcxproj.filters deleted file mode 100644 index 197dc8bb..00000000 --- a/MSVC_NMake/examples/dom_build/dom_build.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dom_parse_entities/dom_parse_entities.vcxproj b/MSVC_NMake/examples/dom_parse_entities/dom_parse_entities.vcxproj deleted file mode 100644 index f08b0b33..00000000 --- a/MSVC_NMake/examples/dom_parse_entities/dom_parse_entities.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_dom_parse_entities - {E7989806-1E3E-45AA-AE0D-E6C9250EDDF5} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - dom_parse_entities - dom_parse_entities - dom_parse_entities - dom_parse_entities - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_parse_entities.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_parse_entities.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_parse_entities.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_parse_entities.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dom_parse_entities/dom_parse_entities.vcxproj.filters b/MSVC_NMake/examples/dom_parse_entities/dom_parse_entities.vcxproj.filters deleted file mode 100644 index 242a752a..00000000 --- a/MSVC_NMake/examples/dom_parse_entities/dom_parse_entities.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dom_parser/dom_parser.vcxproj b/MSVC_NMake/examples/dom_parser/dom_parser.vcxproj deleted file mode 100644 index 7f8b398b..00000000 --- a/MSVC_NMake/examples/dom_parser/dom_parser.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_dom_parser - {947E2653-58AE-4BCC-8A77-B131850C8206} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - dom_parser - dom_parser - dom_parser - dom_parser - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_parser.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_parser.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_parser.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_parser.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dom_parser/dom_parser.vcxproj.filters b/MSVC_NMake/examples/dom_parser/dom_parser.vcxproj.filters deleted file mode 100644 index 8215e5d6..00000000 --- a/MSVC_NMake/examples/dom_parser/dom_parser.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dom_parser_raw/dom_parser_raw.vcxproj b/MSVC_NMake/examples/dom_parser_raw/dom_parser_raw.vcxproj deleted file mode 100644 index 1cbb1e53..00000000 --- a/MSVC_NMake/examples/dom_parser_raw/dom_parser_raw.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_dom_parser_raw - {D6AC5DAE-FCDD-4B03-93DC-7588AA3F10F0} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - dom_parser_raw - dom_parser_raw - dom_parser_raw - dom_parser_raw - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_parser_raw.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_parser_raw.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_parser_raw.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_parser_raw.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dom_parser_raw/dom_parser_raw.vcxproj.filters b/MSVC_NMake/examples/dom_parser_raw/dom_parser_raw.vcxproj.filters deleted file mode 100644 index dd7cdfd6..00000000 --- a/MSVC_NMake/examples/dom_parser_raw/dom_parser_raw.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dom_read_write/dom_read_write.vcxproj b/MSVC_NMake/examples/dom_read_write/dom_read_write.vcxproj deleted file mode 100644 index 400b2994..00000000 --- a/MSVC_NMake/examples/dom_read_write/dom_read_write.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_dom_read_write - {6058A05F-D9DA-4965-B506-F927BBF37E75} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - dom_read_write - dom_read_write - dom_read_write - dom_read_write - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_read_write.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_read_write.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_read_write.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_read_write.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dom_read_write/dom_read_write.vcxproj.filters b/MSVC_NMake/examples/dom_read_write/dom_read_write.vcxproj.filters deleted file mode 100644 index 94fd44d5..00000000 --- a/MSVC_NMake/examples/dom_read_write/dom_read_write.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dom_xpath/dom_xpath.vcxproj b/MSVC_NMake/examples/dom_xpath/dom_xpath.vcxproj deleted file mode 100644 index fa77ac1d..00000000 --- a/MSVC_NMake/examples/dom_xpath/dom_xpath.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_dom_xpath - {B0C776B1-FC22-4ADE-88E5-482AE826B353} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - dom_xpath - dom_xpath - dom_xpath - dom_xpath - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_xpath.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_xpath.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_xpath.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dom_xpath.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dom_xpath/dom_xpath.vcxproj.filters b/MSVC_NMake/examples/dom_xpath/dom_xpath.vcxproj.filters deleted file mode 100644 index 57bf26ba..00000000 --- a/MSVC_NMake/examples/dom_xpath/dom_xpath.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dtdvalidation/dtdvalidation.vcxproj b/MSVC_NMake/examples/dtdvalidation/dtdvalidation.vcxproj deleted file mode 100644 index b58f0008..00000000 --- a/MSVC_NMake/examples/dtdvalidation/dtdvalidation.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_dtdvalidation - {6C243796-E9A8-4342-AD70-B32FC1885247} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - dtdvalidation - dtdvalidation - dtdvalidation - dtdvalidation - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dtdvalidation.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dtdvalidation.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)dtdvalidation.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)dtdvalidation.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/dtdvalidation/dtdvalidation.vcxproj.filters b/MSVC_NMake/examples/dtdvalidation/dtdvalidation.vcxproj.filters deleted file mode 100644 index 26c95bea..00000000 --- a/MSVC_NMake/examples/dtdvalidation/dtdvalidation.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/import_node/import_node.vcxproj b/MSVC_NMake/examples/import_node/import_node.vcxproj deleted file mode 100644 index 2f9065e2..00000000 --- a/MSVC_NMake/examples/import_node/import_node.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_import_node - {FCEF0A34-7F40-4419-991E-181663D70AC0} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - import_node - import_node - import_node - import_node - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)import_node.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)import_node.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)import_node.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)import_node.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/import_node/import_node.vcxproj.filters b/MSVC_NMake/examples/import_node/import_node.vcxproj.filters deleted file mode 100644 index d34fcc45..00000000 --- a/MSVC_NMake/examples/import_node/import_node.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/sax_exception/sax_exception.vcxproj b/MSVC_NMake/examples/sax_exception/sax_exception.vcxproj deleted file mode 100644 index 5b93fe02..00000000 --- a/MSVC_NMake/examples/sax_exception/sax_exception.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_sax_exception - {1DA79E56-7C9E-4D77-BF66-C8CD03BB2D58} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - sax_exception - sax_exception - sax_exception - sax_exception - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_exception.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_exception.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_exception.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_exception.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/sax_exception/sax_exception.vcxproj.filters b/MSVC_NMake/examples/sax_exception/sax_exception.vcxproj.filters deleted file mode 100644 index 02e093e0..00000000 --- a/MSVC_NMake/examples/sax_exception/sax_exception.vcxproj.filters +++ /dev/null @@ -1,30 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/sax_parser/sax_parser.vcxproj b/MSVC_NMake/examples/sax_parser/sax_parser.vcxproj deleted file mode 100644 index e99aaef9..00000000 --- a/MSVC_NMake/examples/sax_parser/sax_parser.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_sax_parser - {A665E2E3-4148-4389-B5C4-271AFE4BC1B7} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - sax_parser - sax_parser - sax_parser - sax_parser - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_parser.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_parser.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_parser.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_parser.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/sax_parser/sax_parser.vcxproj.filters b/MSVC_NMake/examples/sax_parser/sax_parser.vcxproj.filters deleted file mode 100644 index 6b79fa24..00000000 --- a/MSVC_NMake/examples/sax_parser/sax_parser.vcxproj.filters +++ /dev/null @@ -1,30 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj b/MSVC_NMake/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj deleted file mode 100644 index b275e366..00000000 --- a/MSVC_NMake/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj +++ /dev/null @@ -1,214 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_sax_parser_build_dom - {394D1FAE-F35F-4A20-9192-2FA598A0D295} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - sax_parser_build_dom - sax_parser_build_dom - sax_parser_build_dom - sax_parser_build_dom - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_parser_build_dom.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_parser_build_dom.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_parser_build_dom.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_parser_build_dom.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj.filters b/MSVC_NMake/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj.filters deleted file mode 100644 index 1a056a01..00000000 --- a/MSVC_NMake/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj.filters +++ /dev/null @@ -1,45 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/sax_parser_entities/sax_parser_entities.vcxproj b/MSVC_NMake/examples/sax_parser_entities/sax_parser_entities.vcxproj deleted file mode 100644 index 1e4d13aa..00000000 --- a/MSVC_NMake/examples/sax_parser_entities/sax_parser_entities.vcxproj +++ /dev/null @@ -1,209 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_sax_parser_entities - {C023B6BA-4F3D-4FD4-ACC3-732120ACD2C9} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - sax_parser_entities - sax_parser_entities - sax_parser_entities - sax_parser_entities - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_parser_entities.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_parser_entities.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_parser_entities.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)sax_parser_entities.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/sax_parser_entities/sax_parser_entities.vcxproj.filters b/MSVC_NMake/examples/sax_parser_entities/sax_parser_entities.vcxproj.filters deleted file mode 100644 index dcb2550b..00000000 --- a/MSVC_NMake/examples/sax_parser_entities/sax_parser_entities.vcxproj.filters +++ /dev/null @@ -1,30 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - Source Files - - - - - Header Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/schemavalidation/schemavalidation.vcxproj b/MSVC_NMake/examples/schemavalidation/schemavalidation.vcxproj deleted file mode 100644 index cdd53ad2..00000000 --- a/MSVC_NMake/examples/schemavalidation/schemavalidation.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_schemavalidation - {D8027D51-09B4-496E-B2F4-608277E466C9} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - schemavalidation - schemavalidation - schemavalidation - schemavalidation - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)schemavalidation.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)schemavalidation.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)schemavalidation.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)schemavalidation.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/schemavalidation/schemavalidation.vcxproj.filters b/MSVC_NMake/examples/schemavalidation/schemavalidation.vcxproj.filters deleted file mode 100644 index 02c56e77..00000000 --- a/MSVC_NMake/examples/schemavalidation/schemavalidation.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/textreader/textreader.vcxproj b/MSVC_NMake/examples/textreader/textreader.vcxproj deleted file mode 100644 index 9d588b78..00000000 --- a/MSVC_NMake/examples/textreader/textreader.vcxproj +++ /dev/null @@ -1,205 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - examples_textreader - {AE21B35B-954D-454E-AADC-8374DE3B3B68} - examples_dispatcher - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - textreader - textreader - textreader - textreader - - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - EditAndContinue - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)textreader.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX86 - - - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)textreader.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)textreader.exe - true - $(OutDir)$(TargetName).pdb - Console - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - ../../..;../../libxml++;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - Level3 - ProgramDatabase - - - glibmm-vc90-2_4.lib;%(AdditionalDependencies) - $(OutDir)textreader.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - {58b2b53c-c4ff-47fd-817b-095e45b7f7d4} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/examples/textreader/textreader.vcxproj.filters b/MSVC_NMake/examples/textreader/textreader.vcxproj.filters deleted file mode 100644 index 8e724ad3..00000000 --- a/MSVC_NMake/examples/textreader/textreader.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - \ No newline at end of file diff --git a/MSVC_NMake/filelist.am b/MSVC_NMake/filelist.am index ee2e7428..ea5e6d5d 100644 --- a/MSVC_NMake/filelist.am +++ b/MSVC_NMake/filelist.am @@ -1,43 +1,10 @@ ## This file is part of libxml++. -msvc_net2010_data = \ - libxml++.sln \ +msvc_nmake_data = \ README \ gendef/gendef.cc \ - gendef/gendef.vcxproj \ - gendef/gendef.vcxproj.filters \ libxml++/libxml++.rc \ - libxml++/libxml++.vcxproj \ - libxml++/libxml++.vcxproj.filters \ libxml++/libxml++config.h \ - examples/dom_build/dom_build.vcxproj \ - examples/dom_build/dom_build.vcxproj.filters \ - examples/dom_parse_entities/dom_parse_entities.vcxproj \ - examples/dom_parse_entities/dom_parse_entities.vcxproj.filters \ - examples/dom_parser/dom_parser.vcxproj \ - examples/dom_parser/dom_parser.vcxproj.filters \ - examples/dom_parser_raw/dom_parser_raw.vcxproj \ - examples/dom_parser_raw/dom_parser_raw.vcxproj.filters \ - examples/dom_read_write/dom_read_write.vcxproj \ - examples/dom_read_write/dom_read_write.vcxproj.filters \ - examples/dom_xpath/dom_xpath.vcxproj \ - examples/dom_xpath/dom_xpath.vcxproj.filters \ - examples/dtdvalidation/dtdvalidation.vcxproj \ - examples/dtdvalidation/dtdvalidation.vcxproj.filters \ - examples/import_node/import_node.vcxproj \ - examples/import_node/import_node.vcxproj.filters \ - examples/sax_exception/sax_exception.vcxproj \ - examples/sax_exception/sax_exception.vcxproj.filters \ - examples/sax_parser/sax_parser.vcxproj \ - examples/sax_parser/sax_parser.vcxproj.filters \ - examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj \ - examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj.filters \ - examples/sax_parser_entities/sax_parser_entities.vcxproj \ - examples/sax_parser_entities/sax_parser_entities.vcxproj.filters \ - examples/schemavalidation/schemavalidation.vcxproj \ - examples/schemavalidation/schemavalidation.vcxproj.filters \ - examples/textreader/textreader.vcxproj \ - examples/textreader/textreader.vcxproj.filters \ build-rules-msvc.mak \ config-msvc.mak \ create-lists-msvc.mak \ diff --git a/MSVC_NMake/gendef/gendef.vcxproj b/MSVC_NMake/gendef/gendef.vcxproj deleted file mode 100644 index 6d017604..00000000 --- a/MSVC_NMake/gendef/gendef.vcxproj +++ /dev/null @@ -1,177 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - {07324745-C9BE-4D65-B08A-9C88188C0C28} - Win32Proj - - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - Application - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - false - - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - EditAndContinue - - - $(OutDir)gendef.exe - true - $(OutDir)gendef.pdb - Console - false - - - MachineX86 - - - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - $(OutDir)gendef.exe - true - Console - true - true - false - - - MachineX86 - - - - - X64 - - - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebug - - - Level3 - ProgramDatabase - - - $(OutDir)gendef.exe - true - $(OutDir)gendef.pdb - Console - false - - - MachineX64 - - - - - X64 - - - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - $(OutDir)gendef.exe - true - Console - true - true - false - - - MachineX64 - - - - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/gendef/gendef.vcxproj.filters b/MSVC_NMake/gendef/gendef.vcxproj.filters deleted file mode 100644 index ec3f611d..00000000 --- a/MSVC_NMake/gendef/gendef.vcxproj.filters +++ /dev/null @@ -1,22 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - \ No newline at end of file diff --git a/MSVC_NMake/libxml++.sln b/MSVC_NMake/libxml++.sln deleted file mode 100644 index 8983f669..00000000 --- a/MSVC_NMake/libxml++.sln +++ /dev/null @@ -1,175 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gendef", "gendef\gendef.vcxproj", "{07324745-C9BE-4D65-B08A-9C88188C0C28}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xml++-2.6", "libxml++\libxml++.vcxproj", "{58B2B53C-C4FF-47FD-817B-095E45B7F7D4}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_dom_build", "examples\dom_build\dom_build.vcxproj", "{129ECC08-6D30-4884-B824-4AF96EF0A45C}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_dom_parse_entities", "examples\dom_parse_entities\dom_parse_entities.vcxproj", "{E7989806-1E3E-45AA-AE0D-E6C9250EDDF5}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_dom_parser", "examples\dom_parser\dom_parser.vcxproj", "{947E2653-58AE-4BCC-8A77-B131850C8206}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_dom_read_write", "examples\dom_read_write\dom_read_write.vcxproj", "{6058A05F-D9DA-4965-B506-F927BBF37E75}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_dom_xpath", "examples\dom_xpath\dom_xpath.vcxproj", "{B0C776B1-FC22-4ADE-88E5-482AE826B353}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_dtdvalidation", "examples\dtdvalidation\dtdvalidation.vcxproj", "{6C243796-E9A8-4342-AD70-B32FC1885247}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_import_node", "examples\import_node\import_node.vcxproj", "{FCEF0A34-7F40-4419-991E-181663D70AC0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_sax_exception", "examples\sax_exception\sax_exception.vcxproj", "{1DA79E56-7C9E-4D77-BF66-C8CD03BB2D58}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_sax_parser", "examples\sax_parser\sax_parser.vcxproj", "{A665E2E3-4148-4389-B5C4-271AFE4BC1B7}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_sax_parser_build_dom", "examples\sax_parser_build_dom\sax_parser_build_dom.vcxproj", "{394D1FAE-F35F-4A20-9192-2FA598A0D295}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_sax_parser_entities", "examples\sax_parser_entities\sax_parser_entities.vcxproj", "{C023B6BA-4F3D-4FD4-ACC3-732120ACD2C9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_textreader", "examples\textreader\textreader.vcxproj", "{AE21B35B-954D-454E-AADC-8374DE3B3B68}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_schemavalidation", "examples\schemavalidation\schemavalidation.vcxproj", "{D8027D51-09B4-496E-B2F4-608277E466C9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "examples_dom_parser_raw", "examples\dom_parser_raw\dom_parser_raw.vcxproj", "{D6AC5DAE-FCDD-4B03-93DC-7588AA3F10F0}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {07324745-C9BE-4D65-B08A-9C88188C0C28}.Debug|Win32.ActiveCfg = Debug|Win32 - {07324745-C9BE-4D65-B08A-9C88188C0C28}.Debug|Win32.Build.0 = Debug|Win32 - {07324745-C9BE-4D65-B08A-9C88188C0C28}.Debug|x64.ActiveCfg = Debug|x64 - {07324745-C9BE-4D65-B08A-9C88188C0C28}.Debug|x64.Build.0 = Debug|x64 - {07324745-C9BE-4D65-B08A-9C88188C0C28}.Release|Win32.ActiveCfg = Release|Win32 - {07324745-C9BE-4D65-B08A-9C88188C0C28}.Release|Win32.Build.0 = Release|Win32 - {07324745-C9BE-4D65-B08A-9C88188C0C28}.Release|x64.ActiveCfg = Release|x64 - {07324745-C9BE-4D65-B08A-9C88188C0C28}.Release|x64.Build.0 = Release|x64 - {58B2B53C-C4FF-47FD-817B-095E45B7F7D4}.Debug|Win32.ActiveCfg = Debug|Win32 - {58B2B53C-C4FF-47FD-817B-095E45B7F7D4}.Debug|Win32.Build.0 = Debug|Win32 - {58B2B53C-C4FF-47FD-817B-095E45B7F7D4}.Debug|x64.ActiveCfg = Debug|x64 - {58B2B53C-C4FF-47FD-817B-095E45B7F7D4}.Debug|x64.Build.0 = Debug|x64 - {58B2B53C-C4FF-47FD-817B-095E45B7F7D4}.Release|Win32.ActiveCfg = Release|Win32 - {58B2B53C-C4FF-47FD-817B-095E45B7F7D4}.Release|Win32.Build.0 = Release|Win32 - {58B2B53C-C4FF-47FD-817B-095E45B7F7D4}.Release|x64.ActiveCfg = Release|x64 - {58B2B53C-C4FF-47FD-817B-095E45B7F7D4}.Release|x64.Build.0 = Release|x64 - {129ECC08-6D30-4884-B824-4AF96EF0A45C}.Debug|Win32.ActiveCfg = Debug|Win32 - {129ECC08-6D30-4884-B824-4AF96EF0A45C}.Debug|Win32.Build.0 = Debug|Win32 - {129ECC08-6D30-4884-B824-4AF96EF0A45C}.Debug|x64.ActiveCfg = Debug|x64 - {129ECC08-6D30-4884-B824-4AF96EF0A45C}.Debug|x64.Build.0 = Debug|x64 - {129ECC08-6D30-4884-B824-4AF96EF0A45C}.Release|Win32.ActiveCfg = Release|Win32 - {129ECC08-6D30-4884-B824-4AF96EF0A45C}.Release|Win32.Build.0 = Release|Win32 - {129ECC08-6D30-4884-B824-4AF96EF0A45C}.Release|x64.ActiveCfg = Release|x64 - {129ECC08-6D30-4884-B824-4AF96EF0A45C}.Release|x64.Build.0 = Release|x64 - {E7989806-1E3E-45AA-AE0D-E6C9250EDDF5}.Debug|Win32.ActiveCfg = Debug|Win32 - {E7989806-1E3E-45AA-AE0D-E6C9250EDDF5}.Debug|Win32.Build.0 = Debug|Win32 - {E7989806-1E3E-45AA-AE0D-E6C9250EDDF5}.Debug|x64.ActiveCfg = Debug|x64 - {E7989806-1E3E-45AA-AE0D-E6C9250EDDF5}.Debug|x64.Build.0 = Debug|x64 - {E7989806-1E3E-45AA-AE0D-E6C9250EDDF5}.Release|Win32.ActiveCfg = Release|Win32 - {E7989806-1E3E-45AA-AE0D-E6C9250EDDF5}.Release|Win32.Build.0 = Release|Win32 - {E7989806-1E3E-45AA-AE0D-E6C9250EDDF5}.Release|x64.ActiveCfg = Release|x64 - {E7989806-1E3E-45AA-AE0D-E6C9250EDDF5}.Release|x64.Build.0 = Release|x64 - {947E2653-58AE-4BCC-8A77-B131850C8206}.Debug|Win32.ActiveCfg = Debug|Win32 - {947E2653-58AE-4BCC-8A77-B131850C8206}.Debug|Win32.Build.0 = Debug|Win32 - {947E2653-58AE-4BCC-8A77-B131850C8206}.Debug|x64.ActiveCfg = Debug|x64 - {947E2653-58AE-4BCC-8A77-B131850C8206}.Debug|x64.Build.0 = Debug|x64 - {947E2653-58AE-4BCC-8A77-B131850C8206}.Release|Win32.ActiveCfg = Release|Win32 - {947E2653-58AE-4BCC-8A77-B131850C8206}.Release|Win32.Build.0 = Release|Win32 - {947E2653-58AE-4BCC-8A77-B131850C8206}.Release|x64.ActiveCfg = Release|x64 - {947E2653-58AE-4BCC-8A77-B131850C8206}.Release|x64.Build.0 = Release|x64 - {6058A05F-D9DA-4965-B506-F927BBF37E75}.Debug|Win32.ActiveCfg = Debug|Win32 - {6058A05F-D9DA-4965-B506-F927BBF37E75}.Debug|Win32.Build.0 = Debug|Win32 - {6058A05F-D9DA-4965-B506-F927BBF37E75}.Debug|x64.ActiveCfg = Debug|x64 - {6058A05F-D9DA-4965-B506-F927BBF37E75}.Debug|x64.Build.0 = Debug|x64 - {6058A05F-D9DA-4965-B506-F927BBF37E75}.Release|Win32.ActiveCfg = Release|Win32 - {6058A05F-D9DA-4965-B506-F927BBF37E75}.Release|Win32.Build.0 = Release|Win32 - {6058A05F-D9DA-4965-B506-F927BBF37E75}.Release|x64.ActiveCfg = Release|x64 - {6058A05F-D9DA-4965-B506-F927BBF37E75}.Release|x64.Build.0 = Release|x64 - {B0C776B1-FC22-4ADE-88E5-482AE826B353}.Debug|Win32.ActiveCfg = Debug|Win32 - {B0C776B1-FC22-4ADE-88E5-482AE826B353}.Debug|Win32.Build.0 = Debug|Win32 - {B0C776B1-FC22-4ADE-88E5-482AE826B353}.Debug|x64.ActiveCfg = Debug|x64 - {B0C776B1-FC22-4ADE-88E5-482AE826B353}.Debug|x64.Build.0 = Debug|x64 - {B0C776B1-FC22-4ADE-88E5-482AE826B353}.Release|Win32.ActiveCfg = Release|Win32 - {B0C776B1-FC22-4ADE-88E5-482AE826B353}.Release|Win32.Build.0 = Release|Win32 - {B0C776B1-FC22-4ADE-88E5-482AE826B353}.Release|x64.ActiveCfg = Release|x64 - {B0C776B1-FC22-4ADE-88E5-482AE826B353}.Release|x64.Build.0 = Release|x64 - {6C243796-E9A8-4342-AD70-B32FC1885247}.Debug|Win32.ActiveCfg = Debug|Win32 - {6C243796-E9A8-4342-AD70-B32FC1885247}.Debug|Win32.Build.0 = Debug|Win32 - {6C243796-E9A8-4342-AD70-B32FC1885247}.Debug|x64.ActiveCfg = Debug|x64 - {6C243796-E9A8-4342-AD70-B32FC1885247}.Debug|x64.Build.0 = Debug|x64 - {6C243796-E9A8-4342-AD70-B32FC1885247}.Release|Win32.ActiveCfg = Release|Win32 - {6C243796-E9A8-4342-AD70-B32FC1885247}.Release|Win32.Build.0 = Release|Win32 - {6C243796-E9A8-4342-AD70-B32FC1885247}.Release|x64.ActiveCfg = Release|x64 - {6C243796-E9A8-4342-AD70-B32FC1885247}.Release|x64.Build.0 = Release|x64 - {FCEF0A34-7F40-4419-991E-181663D70AC0}.Debug|Win32.ActiveCfg = Debug|Win32 - {FCEF0A34-7F40-4419-991E-181663D70AC0}.Debug|Win32.Build.0 = Debug|Win32 - {FCEF0A34-7F40-4419-991E-181663D70AC0}.Debug|x64.ActiveCfg = Debug|x64 - {FCEF0A34-7F40-4419-991E-181663D70AC0}.Debug|x64.Build.0 = Debug|x64 - {FCEF0A34-7F40-4419-991E-181663D70AC0}.Release|Win32.ActiveCfg = Release|Win32 - {FCEF0A34-7F40-4419-991E-181663D70AC0}.Release|Win32.Build.0 = Release|Win32 - {FCEF0A34-7F40-4419-991E-181663D70AC0}.Release|x64.ActiveCfg = Release|x64 - {FCEF0A34-7F40-4419-991E-181663D70AC0}.Release|x64.Build.0 = Release|x64 - {1DA79E56-7C9E-4D77-BF66-C8CD03BB2D58}.Debug|Win32.ActiveCfg = Debug|Win32 - {1DA79E56-7C9E-4D77-BF66-C8CD03BB2D58}.Debug|Win32.Build.0 = Debug|Win32 - {1DA79E56-7C9E-4D77-BF66-C8CD03BB2D58}.Debug|x64.ActiveCfg = Debug|x64 - {1DA79E56-7C9E-4D77-BF66-C8CD03BB2D58}.Debug|x64.Build.0 = Debug|x64 - {1DA79E56-7C9E-4D77-BF66-C8CD03BB2D58}.Release|Win32.ActiveCfg = Release|Win32 - {1DA79E56-7C9E-4D77-BF66-C8CD03BB2D58}.Release|Win32.Build.0 = Release|Win32 - {1DA79E56-7C9E-4D77-BF66-C8CD03BB2D58}.Release|x64.ActiveCfg = Release|x64 - {1DA79E56-7C9E-4D77-BF66-C8CD03BB2D58}.Release|x64.Build.0 = Release|x64 - {A665E2E3-4148-4389-B5C4-271AFE4BC1B7}.Debug|Win32.ActiveCfg = Debug|Win32 - {A665E2E3-4148-4389-B5C4-271AFE4BC1B7}.Debug|Win32.Build.0 = Debug|Win32 - {A665E2E3-4148-4389-B5C4-271AFE4BC1B7}.Debug|x64.ActiveCfg = Debug|x64 - {A665E2E3-4148-4389-B5C4-271AFE4BC1B7}.Debug|x64.Build.0 = Debug|x64 - {A665E2E3-4148-4389-B5C4-271AFE4BC1B7}.Release|Win32.ActiveCfg = Release|Win32 - {A665E2E3-4148-4389-B5C4-271AFE4BC1B7}.Release|Win32.Build.0 = Release|Win32 - {A665E2E3-4148-4389-B5C4-271AFE4BC1B7}.Release|x64.ActiveCfg = Release|x64 - {A665E2E3-4148-4389-B5C4-271AFE4BC1B7}.Release|x64.Build.0 = Release|x64 - {394D1FAE-F35F-4A20-9192-2FA598A0D295}.Debug|Win32.ActiveCfg = Debug|Win32 - {394D1FAE-F35F-4A20-9192-2FA598A0D295}.Debug|Win32.Build.0 = Debug|Win32 - {394D1FAE-F35F-4A20-9192-2FA598A0D295}.Debug|x64.ActiveCfg = Debug|x64 - {394D1FAE-F35F-4A20-9192-2FA598A0D295}.Debug|x64.Build.0 = Debug|x64 - {394D1FAE-F35F-4A20-9192-2FA598A0D295}.Release|Win32.ActiveCfg = Release|Win32 - {394D1FAE-F35F-4A20-9192-2FA598A0D295}.Release|Win32.Build.0 = Release|Win32 - {394D1FAE-F35F-4A20-9192-2FA598A0D295}.Release|x64.ActiveCfg = Release|x64 - {394D1FAE-F35F-4A20-9192-2FA598A0D295}.Release|x64.Build.0 = Release|x64 - {C023B6BA-4F3D-4FD4-ACC3-732120ACD2C9}.Debug|Win32.ActiveCfg = Debug|Win32 - {C023B6BA-4F3D-4FD4-ACC3-732120ACD2C9}.Debug|Win32.Build.0 = Debug|Win32 - {C023B6BA-4F3D-4FD4-ACC3-732120ACD2C9}.Debug|x64.ActiveCfg = Debug|x64 - {C023B6BA-4F3D-4FD4-ACC3-732120ACD2C9}.Debug|x64.Build.0 = Debug|x64 - {C023B6BA-4F3D-4FD4-ACC3-732120ACD2C9}.Release|Win32.ActiveCfg = Release|Win32 - {C023B6BA-4F3D-4FD4-ACC3-732120ACD2C9}.Release|Win32.Build.0 = Release|Win32 - {C023B6BA-4F3D-4FD4-ACC3-732120ACD2C9}.Release|x64.ActiveCfg = Release|x64 - {C023B6BA-4F3D-4FD4-ACC3-732120ACD2C9}.Release|x64.Build.0 = Release|x64 - {AE21B35B-954D-454E-AADC-8374DE3B3B68}.Debug|Win32.ActiveCfg = Debug|Win32 - {AE21B35B-954D-454E-AADC-8374DE3B3B68}.Debug|Win32.Build.0 = Debug|Win32 - {AE21B35B-954D-454E-AADC-8374DE3B3B68}.Debug|x64.ActiveCfg = Debug|x64 - {AE21B35B-954D-454E-AADC-8374DE3B3B68}.Debug|x64.Build.0 = Debug|x64 - {AE21B35B-954D-454E-AADC-8374DE3B3B68}.Release|Win32.ActiveCfg = Release|Win32 - {AE21B35B-954D-454E-AADC-8374DE3B3B68}.Release|Win32.Build.0 = Release|Win32 - {AE21B35B-954D-454E-AADC-8374DE3B3B68}.Release|x64.ActiveCfg = Release|x64 - {AE21B35B-954D-454E-AADC-8374DE3B3B68}.Release|x64.Build.0 = Release|x64 - {D8027D51-09B4-496E-B2F4-608277E466C9}.Debug|Win32.ActiveCfg = Debug|Win32 - {D8027D51-09B4-496E-B2F4-608277E466C9}.Debug|Win32.Build.0 = Debug|Win32 - {D8027D51-09B4-496E-B2F4-608277E466C9}.Debug|x64.ActiveCfg = Debug|x64 - {D8027D51-09B4-496E-B2F4-608277E466C9}.Debug|x64.Build.0 = Debug|x64 - {D8027D51-09B4-496E-B2F4-608277E466C9}.Release|Win32.ActiveCfg = Release|Win32 - {D8027D51-09B4-496E-B2F4-608277E466C9}.Release|Win32.Build.0 = Release|Win32 - {D8027D51-09B4-496E-B2F4-608277E466C9}.Release|x64.ActiveCfg = Release|x64 - {D8027D51-09B4-496E-B2F4-608277E466C9}.Release|x64.Build.0 = Release|x64 - {D6AC5DAE-FCDD-4B03-93DC-7588AA3F10F0}.Debug|Win32.ActiveCfg = Debug|Win32 - {D6AC5DAE-FCDD-4B03-93DC-7588AA3F10F0}.Debug|Win32.Build.0 = Debug|Win32 - {D6AC5DAE-FCDD-4B03-93DC-7588AA3F10F0}.Debug|x64.ActiveCfg = Debug|x64 - {D6AC5DAE-FCDD-4B03-93DC-7588AA3F10F0}.Debug|x64.Build.0 = Debug|x64 - {D6AC5DAE-FCDD-4B03-93DC-7588AA3F10F0}.Release|Win32.ActiveCfg = Release|Win32 - {D6AC5DAE-FCDD-4B03-93DC-7588AA3F10F0}.Release|Win32.Build.0 = Release|Win32 - {D6AC5DAE-FCDD-4B03-93DC-7588AA3F10F0}.Release|x64.ActiveCfg = Release|x64 - {D6AC5DAE-FCDD-4B03-93DC-7588AA3F10F0}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/MSVC_NMake/libxml++/libxml++.vcxproj b/MSVC_NMake/libxml++/libxml++.vcxproj deleted file mode 100644 index 37137f48..00000000 --- a/MSVC_NMake/libxml++/libxml++.vcxproj +++ /dev/null @@ -1,413 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - xml++-2.6 - {58B2B53C-C4FF-47FD-817B-095E45B7F7D4} - glibmm - Win32Proj - - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - DynamicLibrary - MultiByte - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - $(Platform)\$(Configuration)\ - $(Platform)\$(Configuration)\ - true - xml++-vc100-d-2_6 - xml++-vc100-d-2_6 - xml++-vc100-2_6 - xml++-vc100-2_6 - - - - /vd2 %(AdditionalOptions) - Disabled - .;../..;%(AdditionalIncludeDirectories) - LIBXMLPP_BUILD;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - $(IntDir) - Level3 - EditAndContinue - - - Generate libxml++ def file - $(SolutionDir)gendef\$(Platform)\$(Configuration)\gendef $(Platform)\$(Configuration)\$(ProjectName).def $(TargetFileName) $(IntDir)*.obj $(IntDir)exceptions\*.obj $(IntDir)io\*.obj $(IntDir)nodes\*.obj $(IntDir)parsers\*.obj $(IntDir)validators\*.obj - - - libxml2.lib;glibmm-vc100-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)xml++-vc100-d-2_6.dll - $(Platform)\$(Configuration)\$(ProjectName).def - true - false - - - - - - - /vd2 %(AdditionalOptions) - .;../..;%(AdditionalIncludeDirectories) - LIBXMLPP_BUILD;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - $(IntDir) - Level3 - ProgramDatabase - - - Generate libxml++ def file - $(SolutionDir)gendef\$(Platform)\$(Configuration)\gendef $(Platform)\$(Configuration)\$(ProjectName).def $(TargetFileName) $(IntDir)*.obj $(IntDir)exceptions\*.obj $(IntDir)io\*.obj $(IntDir)nodes\*.obj $(IntDir)parsers\*.obj $(IntDir)validators\*.obj - - - libxml2.lib;glibmm-vc100-2_4.lib;%(AdditionalDependencies) - $(OutDir)xml++-vc100-2_6.dll - $(Platform)\$(Configuration)\$(ProjectName).def - false - - - - - - - X64 - - - /vd2 %(AdditionalOptions) - Disabled - .;../..;%(AdditionalIncludeDirectories) - LIBXMLPP_BUILD;%(PreprocessorDefinitions) - true - EnableFastChecks - MultiThreadedDebugDLL - true - - - $(IntDir) - Level3 - ProgramDatabase - - - Generate libxml++ def file - $(SolutionDir)gendef\$(Platform)\$(Configuration)\gendef $(Platform)\$(Configuration)\$(ProjectName).def $(TargetFileName) $(IntDir)*.obj $(IntDir)exceptions\*.obj $(IntDir)io\*.obj $(IntDir)nodes\*.obj $(IntDir)parsers\*.obj $(IntDir)validators\*.obj - - - libxml2.lib;glibmm-vc100-d-2_4.lib;%(AdditionalDependencies) - $(OutDir)xml++-vc100-d-2_6.dll - $(Platform)\$(Configuration)\$(ProjectName).def - true - false - - - MachineX64 - - - - - X64 - - - /vd2 %(AdditionalOptions) - .;../..;%(AdditionalIncludeDirectories) - LIBXMLPP_BUILD;%(PreprocessorDefinitions) - MultiThreadedDLL - true - - - $(IntDir) - Level3 - ProgramDatabase - - - Generate libxml++ def file - $(SolutionDir)gendef\$(Platform)\$(Configuration)\gendef $(Platform)\$(Configuration)\$(ProjectName).def $(TargetFileName) $(IntDir)*.obj $(IntDir)exceptions\*.obj $(IntDir)io\*.obj $(IntDir)nodes\*.obj $(IntDir)parsers\*.obj $(IntDir)validators\*.obj - - - libxml2.lib;glibmm-vc100-2_4.lib;%(AdditionalDependencies) - $(OutDir)xml++-vc100-2_6.dll - $(Platform)\$(Configuration)\$(ProjectName).def - false - - - MachineX64 - - - - - $(IntDir) - $(IntDir) - $(IntDir) - $(IntDir) - - - $(IntDir) - $(IntDir) - $(IntDir) - $(IntDir) - - - $(IntDir) - $(IntDir) - $(IntDir) - $(IntDir) - - - $(IntDir) - $(IntDir) - $(IntDir) - $(IntDir) - - - $(IntDir) - $(IntDir) - $(IntDir) - $(IntDir) - - - - $(IntDir)exceptions/ - $(IntDir)exceptions/ - $(IntDir)exceptions/ - $(IntDir)exceptions/ - - - $(IntDir)exceptions/ - $(IntDir)exceptions/ - $(IntDir)exceptions/ - $(IntDir)exceptions/ - - - $(IntDir)exceptions/ - $(IntDir)exceptions/ - $(IntDir)exceptions/ - $(IntDir)exceptions/ - - - $(IntDir)exceptions/ - $(IntDir)exceptions/ - $(IntDir)exceptions/ - $(IntDir)exceptions/ - - - $(IntDir)io/ - $(IntDir)io/ - $(IntDir)io/ - $(IntDir)io/ - - - $(IntDir)io/ - $(IntDir)io/ - $(IntDir)io/ - $(IntDir)io/ - - - $(IntDir)io/ - $(IntDir)io/ - $(IntDir)io/ - $(IntDir)io/ - - - $(IntDir)io/ - $(IntDir)io/ - $(IntDir)io/ - $(IntDir)io/ - - - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - - - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - - - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - - - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - - - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - - - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - - - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - - - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - $(IntDir)nodes/ - - - $(IntDir)parsers/ - $(IntDir)parsers/ - $(IntDir)parsers/ - $(IntDir)parsers/ - - - $(IntDir)parsers/ - $(IntDir)parsers/ - $(IntDir)parsers/ - $(IntDir)parsers/ - - - $(IntDir)parsers/ - $(IntDir)parsers/ - $(IntDir)parsers/ - $(IntDir)parsers/ - - - $(IntDir)parsers/ - $(IntDir)parsers/ - $(IntDir)parsers/ - $(IntDir)parsers/ - - - $(IntDir)validators/ - $(IntDir)validators/ - $(IntDir)validators/ - $(IntDir)validators/ - - - - $(IntDir)validators/ - $(IntDir)validators/ - $(IntDir)validators/ - $(IntDir)validators/ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {07324745-c9be-4d65-b08a-9c88188c0c28} - false - - - - - - \ No newline at end of file diff --git a/MSVC_NMake/libxml++/libxml++.vcxproj.filters b/MSVC_NMake/libxml++/libxml++.vcxproj.filters deleted file mode 100644 index b4212dd0..00000000 --- a/MSVC_NMake/libxml++/libxml++.vcxproj.filters +++ /dev/null @@ -1,233 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {cc96b287-b76c-4e11-aa5c-ff6ac19dd972} - - - {7385d814-0522-4907-82ad-1cd50a85a5d7} - - - {af9f9408-ae6e-45af-81ba-31fe29b59201} - - - {82e6457e-ad05-4d96-a817-2249be8d83b1} - - - {61c1abc9-f870-4d8a-b83f-0ad60fb6fffa} - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {fd96338f-997a-4f3c-ab2f-e8c6e1e2d1b7} - - - {151f1608-6062-4c50-9dfe-3cbc25f91b5c} - - - {b6a1457d-0d4d-4a44-b87f-8df64ca9e959} - - - {ce47077c-1131-4929-b116-616bf6b9d6fd} - - - {da70c9fb-5a3c-4142-9d58-0c8f62b5ae97} - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files\exceptions - - - Source Files\exceptions - - - Source Files\exceptions - - - Source Files\exceptions - - - Source Files\io - - - Source Files\io - - - Source Files\io - - - Source Files\io - - - Source Files\nodes - - - Source Files\nodes - - - Source Files\nodes - - - Source Files\nodes - - - Source Files\nodes - - - Source Files\nodes - - - Source Files\nodes - - - Source Files\nodes - - - Source Files\parsers - - - Source Files\parsers - - - Source Files\parsers - - - Source Files\parsers - - - Source Files\validators - - - Source Files\validators - - - Source Files\validators - - - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files - - - Header Files\exceptions - - - Header Files\exceptions - - - Header Files\exceptions - - - Header Files\exceptions - - - Header Files\io - - - Header Files\io - - - Header Files\io - - - Header Files\io - - - Header Files\nodes - - - Header Files\nodes - - - Header Files\nodes - - - Header Files\nodes - - - Header Files\nodes - - - Header Files\nodes - - - Header Files\nodes - - - Header Files\nodes - - - Header Files\parsers - - - Header Files\parsers - - - Header Files\parsers - - - Header Files\parsers - - - Header Files\validators - - - Header Files\validators - - - Header Files\validators - - - - - Resource Files - - - \ No newline at end of file diff --git a/Makefile.am b/Makefile.am index 04e46dcb..c93fefe6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,7 @@ nodist_pkgconfig_DATA = $(LIBXMLXX_MODULE_NAME).pc include $(srcdir)/MSVC_NMake/filelist.am -dist_noinst_DATA = $(addprefix MSVC_NMake/,$(msvc_net2010_data)) +dist_noinst_DATA = $(addprefix MSVC_NMake/,$(msvc_nmake_data)) dist_noinst_SCRIPTS = autogen.sh From 08dce79b0e13956009fddb328bb5f51d982ab94b Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 12 Jun 2020 15:54:15 +0800 Subject: [PATCH 099/240] Update MSVC_NMake/README Update instructions for building since we moved to using NMake Makefiles, and let people know that the same compiler version is recommended for building libxml++. --- MSVC_NMake/README | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/MSVC_NMake/README b/MSVC_NMake/README index 4b5058a3..b29b6faf 100644 --- a/MSVC_NMake/README +++ b/MSVC_NMake/README @@ -1,14 +1,18 @@ -Building libxml++ with Visual Studio 2010 - -* You will need Visual Studio 2010 (MSVC 10.0). See the MSVC_Net2005/ folder if you want to build libxml++ using Visual Studio .NET 2005 (MSVC 8.0) or the MSVC_Net2008 folder if you want to build libxml++ using Visual Studio .NET 2008 (MSVC 9.0). Earlier versions of the compiler, including 6.0, 7.0 and 7.1 will not work. -* Install the latest Win32 GTK+ Development files from ftp://ftp.gnome.org/pub/GNOME/binaries/win32/gtk+/ -* Build libsigc++ 2.0.6 and glibmm from source -* Add GTK+, libsigc++ and glibmm to the include and lib paths in Visual Studio. -* Load the MSVC_NMake/libxml++.sln solution. -* Build the entire solution. Run the tests. - -Cedric Gustin -01/26/2005 - -Armin Burgmeier -10/03/2010 +Building libxml++ with Visual Studio 2017 or later + +* You will need Visual Studio 2017 (MSVC 15.7) or later, as C++-17 is required and only 15.7 or later had + adequate C++-17 support +* Install libxml2 from https://xmlsoft.org/, either via Windows binaries or building from source. It is + strongly recommended, if building libxml2 from source, that Visual Studio 2015 or later is used +* Add libxml2 to the include and lib paths in Visual Studio. +* Run `nmake /f Makefile.vc CFG=[debug|release]` to buiild libxml++. Run `nmake /f Makefile.vc` without the + `CFG=[debug|release] flag to see which options are supported by the NMake Makefiles + +Cedric Gustin +01/26/2005 + +Armin Burgmeier +10/03/2010 + +Chun-wei Fan +06/12/2020 From 4414a2258cae041d42451b98c27394a898fa1fd3 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 19 Jun 2020 14:13:05 +0800 Subject: [PATCH 100/240] libxml++/*.h: Remove check for old _MSC_VER stuff They aren't applicable anymore, since the newer Visual Studio versions addressed the issues. --- libxml++/keepblanks.h | 4 ---- libxml++/parsers/parser.h | 4 ---- libxml++/validators/validator.h | 4 ---- 3 files changed, 12 deletions(-) diff --git a/libxml++/keepblanks.h b/libxml++/keepblanks.h index 99391a03..e34e0047 100644 --- a/libxml++/keepblanks.h +++ b/libxml++/keepblanks.h @@ -16,11 +16,7 @@ namespace xmlpp */ class KeepBlanks { public: -#if _MSC_VER == 1200 // detect MSVC 6.0 - static const bool Default; -#else static const bool Default = true; -#endif public: KeepBlanks(bool value) noexcept; diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index a5970ccd..63415bc1 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -7,10 +7,6 @@ #ifndef __LIBXMLPP_PARSER_H #define __LIBXMLPP_PARSER_H -#ifdef _MSC_VER //Ignore warnings about the Visual C++ Bug, where we can not do anything -#pragma warning (disable : 4786) -#endif - #include #include #include diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index e0c10334..2ba7a038 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -8,10 +8,6 @@ #ifndef __LIBXMLPP_VALIDATOR_H #define __LIBXMLPP_VALIDATOR_H -#ifdef _MSC_VER //Ignore warnings about the Visual C++ Bug, where we can not do anything -#pragma warning (disable : 4786) -#endif - #include #include #include From de55b83afc0d8bcb6db5de8bb7ba012fd2fdc8d0 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 19 Jun 2020 14:14:56 +0800 Subject: [PATCH 101/240] libxml++ headers: Mark classes and functions with LIBXMLPP_API This prepares us to export and symbols on Visual Studio builds using only compiler directives, and to drop the venerable gendef.cc --- libxml++/attribute.h | 2 +- libxml++/attributedeclaration.h | 2 +- libxml++/attributenode.h | 2 +- libxml++/document.h | 2 +- libxml++/dtd.h | 2 +- libxml++/exceptions/exception.h | 3 +++ libxml++/exceptions/internal_error.h | 2 +- libxml++/exceptions/parse_error.h | 2 +- libxml++/exceptions/validity_error.h | 2 +- libxml++/exceptions/wrapped_exception.h | 2 +- libxml++/io/istreamparserinputbuffer.h | 2 +- libxml++/io/ostreamoutputbuffer.h | 2 +- libxml++/io/outputbuffer.h | 4 ++-- libxml++/io/parserinputbuffer.h | 4 ++-- libxml++/keepblanks.h | 4 +++- libxml++/nodes/cdatanode.h | 2 +- libxml++/nodes/commentnode.h | 2 +- libxml++/nodes/contentnode.h | 2 +- libxml++/nodes/element.h | 2 +- libxml++/nodes/entitydeclaration.h | 2 +- libxml++/nodes/entityreference.h | 2 +- libxml++/nodes/node.h | 4 ++-- libxml++/nodes/processinginstructionnode.h | 2 +- libxml++/nodes/textnode.h | 2 +- libxml++/nodes/xincludeend.h | 2 +- libxml++/nodes/xincludestart.h | 2 +- libxml++/noncopyable.h | 4 +++- libxml++/parsers/domparser.h | 2 +- libxml++/parsers/parser.h | 2 +- libxml++/parsers/saxparser.h | 2 +- libxml++/parsers/textreader.h | 2 +- libxml++/relaxngschema.h | 2 +- libxml++/schemabase.h | 4 ++-- libxml++/validators/dtdvalidator.h | 2 +- libxml++/validators/relaxngvalidator.h | 6 +++--- libxml++/validators/schemavalidatorbase.h | 4 ++-- libxml++/validators/validator.h | 4 ++-- libxml++/validators/xsdvalidator.h | 6 +++--- libxml++/xsdschema.h | 2 +- 39 files changed, 55 insertions(+), 48 deletions(-) diff --git a/libxml++/attribute.h b/libxml++/attribute.h index 9f939cfe..b450ce3e 100644 --- a/libxml++/attribute.h +++ b/libxml++/attribute.h @@ -18,7 +18,7 @@ namespace xmlpp /** Represents an XML attribute node or attribute declaration. * This will be instantiated by the parser. */ -class Attribute : public Node +class LIBXMLPP_API Attribute : public Node { public: explicit Attribute(_xmlNode* node); diff --git a/libxml++/attributedeclaration.h b/libxml++/attributedeclaration.h index 81d29622..0072da77 100644 --- a/libxml++/attributedeclaration.h +++ b/libxml++/attributedeclaration.h @@ -25,7 +25,7 @@ namespace xmlpp * * @newin{2,36} */ -class AttributeDeclaration : public Attribute +class LIBXMLPP_API AttributeDeclaration : public Attribute { public: explicit AttributeDeclaration(_xmlNode* node); diff --git a/libxml++/attributenode.h b/libxml++/attributenode.h index 27c63939..77dcfd92 100644 --- a/libxml++/attributenode.h +++ b/libxml++/attributenode.h @@ -26,7 +26,7 @@ namespace xmlpp * * @newin{2,36} */ -class AttributeNode : public Attribute +class LIBXMLPP_API AttributeNode : public Attribute { public: explicit AttributeNode(_xmlNode* node); diff --git a/libxml++/document.h b/libxml++/document.h index 745a193b..9657b740 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -62,7 +62,7 @@ enum class XmlEntityType /** * Represents an XML document in the DOM model. */ -class Document : public NonCopyable +class LIBXMLPP_API Document : public NonCopyable { //Ensure that libxml is properly initialised: class Init diff --git a/libxml++/dtd.h b/libxml++/dtd.h index 7a72cdb9..789e2ba5 100644 --- a/libxml++/dtd.h +++ b/libxml++/dtd.h @@ -27,7 +27,7 @@ namespace xmlpp /** Represents an XML DTD for validating XML files. * DTD = %Document Type Definition */ -class Dtd : public NonCopyable +class LIBXMLPP_API Dtd : public NonCopyable { public: Dtd(); diff --git a/libxml++/exceptions/exception.h b/libxml++/exceptions/exception.h index 198f4239..8c22262f 100644 --- a/libxml++/exceptions/exception.h +++ b/libxml++/exceptions/exception.h @@ -60,6 +60,7 @@ class LIBXMLPP_API exception : public std::exception * @returns A formatted text string. If the error struct does not contain an * error (error->code == XML_ERR_OK), an empty string is returned. */ +LIBXMLPP_API ustring format_xml_error(const _xmlError* error = nullptr); /** Format a parser error into a text string, suitable for printing. @@ -71,6 +72,7 @@ ustring format_xml_error(const _xmlError* error = nullptr); * error (parser_context->lastError.code == XML_ERR_OK), an empty * string is returned. */ +LIBXMLPP_API ustring format_xml_parser_error(const _xmlParserCtxt* parser_context); /** Format a message from a function with C-style variadic parameters. @@ -92,6 +94,7 @@ ustring format_xml_parser_error(const _xmlParserCtxt* parser_context); * * @newin{3,0} */ +LIBXMLPP_API ustring format_printf_message(const char* fmt, va_list args); } // namespace xmlpp diff --git a/libxml++/exceptions/internal_error.h b/libxml++/exceptions/internal_error.h index 21f80b26..43eaa6c9 100644 --- a/libxml++/exceptions/internal_error.h +++ b/libxml++/exceptions/internal_error.h @@ -24,7 +24,7 @@ namespace xmlpp { -class internal_error : public exception +class LIBXMLPP_API internal_error : public exception { public: explicit internal_error(const ustring& message); diff --git a/libxml++/exceptions/parse_error.h b/libxml++/exceptions/parse_error.h index 65f5965c..d159c3ac 100644 --- a/libxml++/exceptions/parse_error.h +++ b/libxml++/exceptions/parse_error.h @@ -27,7 +27,7 @@ namespace xmlpp /** This exception will be thrown when the parser encounters an error in the XML document. */ -class parse_error : public exception +class LIBXMLPP_API parse_error : public exception { public: explicit parse_error(const ustring& message); diff --git a/libxml++/exceptions/validity_error.h b/libxml++/exceptions/validity_error.h index 17c5f8a2..1f16055e 100644 --- a/libxml++/exceptions/validity_error.h +++ b/libxml++/exceptions/validity_error.h @@ -27,7 +27,7 @@ namespace xmlpp /** This exception will be thrown when the parser encounters a validity error in the XML document. */ -class validity_error : public parse_error +class LIBXMLPP_API validity_error : public parse_error { public: explicit validity_error(const ustring& message); diff --git a/libxml++/exceptions/wrapped_exception.h b/libxml++/exceptions/wrapped_exception.h index ffcafea6..37daf37e 100644 --- a/libxml++/exceptions/wrapped_exception.h +++ b/libxml++/exceptions/wrapped_exception.h @@ -35,7 +35,7 @@ namespace xmlpp * * @newin{2,40} */ -class wrapped_exception : public exception +class LIBXMLPP_API wrapped_exception : public exception { public: explicit wrapped_exception(std::exception_ptr exception_ptr); diff --git a/libxml++/io/istreamparserinputbuffer.h b/libxml++/io/istreamparserinputbuffer.h index 9140fb09..706f917d 100644 --- a/libxml++/io/istreamparserinputbuffer.h +++ b/libxml++/io/istreamparserinputbuffer.h @@ -16,7 +16,7 @@ namespace xmlpp { - class IStreamParserInputBuffer: public ParserInputBuffer + class LIBXMLPP_API IStreamParserInputBuffer: public ParserInputBuffer { public: /** diff --git a/libxml++/io/ostreamoutputbuffer.h b/libxml++/io/ostreamoutputbuffer.h index ae750f14..516d8b6e 100644 --- a/libxml++/io/ostreamoutputbuffer.h +++ b/libxml++/io/ostreamoutputbuffer.h @@ -18,7 +18,7 @@ namespace xmlpp { /** An OutputBuffer implementation that send datas to a std::ostream. */ - class OStreamOutputBuffer: public OutputBuffer + class LIBXMLPP_API OStreamOutputBuffer: public OutputBuffer { public: /** diff --git a/libxml++/io/outputbuffer.h b/libxml++/io/outputbuffer.h index 90824b27..049ef610 100644 --- a/libxml++/io/outputbuffer.h +++ b/libxml++/io/outputbuffer.h @@ -22,7 +22,7 @@ extern "C" namespace xmlpp { - struct OutputBufferCallback; + struct LIBXMLPP_API OutputBufferCallback; /** Base class for xmlOutputBuffer wrapper * @@ -30,7 +30,7 @@ namespace xmlpp * A child class has to override do_write(), and possibly * do_close() if some actions are required before buffer closing. */ - class OutputBuffer: public NonCopyable + class LIBXMLPP_API OutputBuffer: public NonCopyable { public: /** diff --git a/libxml++/io/parserinputbuffer.h b/libxml++/io/parserinputbuffer.h index 54dd6d26..55c52325 100644 --- a/libxml++/io/parserinputbuffer.h +++ b/libxml++/io/parserinputbuffer.h @@ -20,7 +20,7 @@ extern "C" namespace xmlpp { - struct ParserInputBufferCallback; + struct LIBXMLPP_API ParserInputBufferCallback; /** Base class for xmlParserInputBuffer wrapper * @@ -28,7 +28,7 @@ namespace xmlpp * A child class has to override do_write(), and possibly * do_close() if some actions are required before buffer closing. */ - class ParserInputBuffer: public NonCopyable + class LIBXMLPP_API ParserInputBuffer: public NonCopyable { public: ParserInputBuffer(); diff --git a/libxml++/keepblanks.h b/libxml++/keepblanks.h index e34e0047..40bfed59 100644 --- a/libxml++/keepblanks.h +++ b/libxml++/keepblanks.h @@ -8,13 +8,15 @@ #ifndef __LIBXMLPP_KEEPBLANKS_H #define __LIBXMLPP_KEEPBLANKS_H +#include + namespace xmlpp { /** This class sets KeepBlanksDefault and IndentTreeOutput of libxmlpp * and restores their initial values in its destructor. As a consequence * the wanted setting is kept during instance lifetime. */ - class KeepBlanks { + class LIBXMLPP_API KeepBlanks { public: static const bool Default = true; diff --git a/libxml++/nodes/cdatanode.h b/libxml++/nodes/cdatanode.h index cf132694..9160d1aa 100644 --- a/libxml++/nodes/cdatanode.h +++ b/libxml++/nodes/cdatanode.h @@ -15,7 +15,7 @@ namespace xmlpp /** CData node. This will be instantiated by the parser. * */ -class CdataNode : public ContentNode +class LIBXMLPP_API CdataNode : public ContentNode { public: explicit CdataNode(_xmlNode* node); diff --git a/libxml++/nodes/commentnode.h b/libxml++/nodes/commentnode.h index bed857d6..a1172905 100644 --- a/libxml++/nodes/commentnode.h +++ b/libxml++/nodes/commentnode.h @@ -14,7 +14,7 @@ namespace xmlpp /** Comment node. This will be instantiated by the parser. */ -class CommentNode : public ContentNode +class LIBXMLPP_API CommentNode : public ContentNode { public: explicit CommentNode(_xmlNode* node); diff --git a/libxml++/nodes/contentnode.h b/libxml++/nodes/contentnode.h index d89e5331..b14485db 100644 --- a/libxml++/nodes/contentnode.h +++ b/libxml++/nodes/contentnode.h @@ -14,7 +14,7 @@ namespace xmlpp /** Content node. This will be instantiated by the parser. */ -class ContentNode : public Node +class LIBXMLPP_API ContentNode : public Node { public: explicit ContentNode(_xmlNode* node); diff --git a/libxml++/nodes/element.h b/libxml++/nodes/element.h index 6ae0056f..922a26c9 100644 --- a/libxml++/nodes/element.h +++ b/libxml++/nodes/element.h @@ -21,7 +21,7 @@ namespace xmlpp /** %Element nodes have attributes as well as child nodes. * This will be instantiated by the parser. */ -class Element : public Node +class LIBXMLPP_API Element : public Node { public: explicit Element(_xmlNode* node); diff --git a/libxml++/nodes/entitydeclaration.h b/libxml++/nodes/entitydeclaration.h index 626c5f15..30d3df8d 100644 --- a/libxml++/nodes/entitydeclaration.h +++ b/libxml++/nodes/entitydeclaration.h @@ -23,7 +23,7 @@ namespace xmlpp * @newin{2,36} * */ -class EntityDeclaration : public ContentNode +class LIBXMLPP_API EntityDeclaration : public ContentNode { public: explicit EntityDeclaration(_xmlNode* node); diff --git a/libxml++/nodes/entityreference.h b/libxml++/nodes/entityreference.h index 58a467a7..60a64fc7 100644 --- a/libxml++/nodes/entityreference.h +++ b/libxml++/nodes/entityreference.h @@ -14,7 +14,7 @@ namespace xmlpp /** Entity references refer to previously declared entities. This will be instantiated by the parser. */ -class EntityReference : public Node +class LIBXMLPP_API EntityReference : public Node { public: explicit EntityReference(_xmlNode* node); diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index 098e070d..9b4d2b08 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -23,7 +23,7 @@ extern "C" { namespace xmlpp { -class Element; +class LIBXMLPP_API Element; // xmlpp::XPathResultType is similar to xmlXPathObjectType in libxml2. /** An XPath expression is evaluated to yield a result, which @@ -48,7 +48,7 @@ enum class XPathResultType * manage them for you. Furthermore, Document and Element have methods for * adding Nodes to a Document. */ -class Node : public NonCopyable +class LIBXMLPP_API Node : public NonCopyable { public: using NodeList = std::list; diff --git a/libxml++/nodes/processinginstructionnode.h b/libxml++/nodes/processinginstructionnode.h index beb20ee3..69ae17f1 100644 --- a/libxml++/nodes/processinginstructionnode.h +++ b/libxml++/nodes/processinginstructionnode.h @@ -12,7 +12,7 @@ namespace xmlpp { -class ProcessingInstructionNode : public ContentNode +class LIBXMLPP_API ProcessingInstructionNode : public ContentNode { public: explicit ProcessingInstructionNode(_xmlNode* node); diff --git a/libxml++/nodes/textnode.h b/libxml++/nodes/textnode.h index 4348887a..de36ad55 100644 --- a/libxml++/nodes/textnode.h +++ b/libxml++/nodes/textnode.h @@ -14,7 +14,7 @@ namespace xmlpp /** Text node. This will be instantiated by the parser. */ -class TextNode : public ContentNode +class LIBXMLPP_API TextNode : public ContentNode { public: explicit TextNode(_xmlNode* node); diff --git a/libxml++/nodes/xincludeend.h b/libxml++/nodes/xincludeend.h index 2f12a58d..a3951127 100644 --- a/libxml++/nodes/xincludeend.h +++ b/libxml++/nodes/xincludeend.h @@ -29,7 +29,7 @@ namespace xmlpp * * @newin{2,36} */ -class XIncludeEnd : public Node +class LIBXMLPP_API XIncludeEnd : public Node { public: explicit XIncludeEnd(_xmlNode* node); diff --git a/libxml++/nodes/xincludestart.h b/libxml++/nodes/xincludestart.h index f02de808..c97438a3 100644 --- a/libxml++/nodes/xincludestart.h +++ b/libxml++/nodes/xincludestart.h @@ -29,7 +29,7 @@ namespace xmlpp * * @newin{2,36} */ -class XIncludeStart : public Node +class LIBXMLPP_API XIncludeStart : public Node { public: explicit XIncludeStart(_xmlNode* node); diff --git a/libxml++/noncopyable.h b/libxml++/noncopyable.h index 244c7e0e..8a7b6561 100644 --- a/libxml++/noncopyable.h +++ b/libxml++/noncopyable.h @@ -8,12 +8,14 @@ #ifndef __LIBXMLPP_NONCOPYABLE_H #define __LIBXMLPP_NONCOPYABLE_H +#include + namespace xmlpp { /** A base for classes which cannot be copied or moved. */ -class NonCopyable +class LIBXMLPP_API NonCopyable { protected: NonCopyable() noexcept; diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index 699551bf..61fb1d52 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -15,7 +15,7 @@ namespace xmlpp { /** DOM XML parser. * DOM = %Document Object Model */ -class DomParser : public Parser +class LIBXMLPP_API DomParser : public Parser { public: /** Create a parser with an empty document. diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index 63415bc1..20db85b4 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -28,7 +28,7 @@ namespace xmlpp { * * Abstract base class for DOM parser and SAX parser. */ -class Parser : public NonCopyable +class LIBXMLPP_API Parser : public NonCopyable { public: Parser(); diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index d745dbb6..c876ddc8 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -31,7 +31,7 @@ namespace xmlpp { * that exception is replaced by a xmlpp::exception before it is propagated * out of the parse method, such as parse_file(). */ -class SaxParser : public Parser +class LIBXMLPP_API SaxParser : public Parser { public: /** diff --git a/libxml++/parsers/textreader.h b/libxml++/parsers/textreader.h index c98c16ac..e71f7384 100644 --- a/libxml++/parsers/textreader.h +++ b/libxml++/parsers/textreader.h @@ -26,7 +26,7 @@ namespace xmlpp * A reader that provides fast, non-cached, forward-only access to XML data, * in the style of .Net's XmlTextReader class. */ -class TextReader: public NonCopyable +class LIBXMLPP_API TextReader: public NonCopyable { public: // xmlpp::TextReader::NodeType is similar to xmlReaderTypes in libxml2. diff --git a/libxml++/relaxngschema.h b/libxml++/relaxngschema.h index b557d9a6..a5e15f1b 100644 --- a/libxml++/relaxngschema.h +++ b/libxml++/relaxngschema.h @@ -40,7 +40,7 @@ namespace xmlpp * * @newin{2,38} */ -class RelaxNGSchema : public SchemaBase +class LIBXMLPP_API RelaxNGSchema : public SchemaBase { public: RelaxNGSchema(); diff --git a/libxml++/schemabase.h b/libxml++/schemabase.h index 66c0f6ac..0c66c902 100644 --- a/libxml++/schemabase.h +++ b/libxml++/schemabase.h @@ -25,13 +25,13 @@ namespace xmlpp { -class Document; +class LIBXMLPP_API Document; /** Base class for schemas, used for validation of XML files. * * @newin{2,38} */ -class SchemaBase : public NonCopyable +class LIBXMLPP_API SchemaBase : public NonCopyable { public: SchemaBase() noexcept; diff --git a/libxml++/validators/dtdvalidator.h b/libxml++/validators/dtdvalidator.h index 599aaf03..424353b5 100644 --- a/libxml++/validators/dtdvalidator.h +++ b/libxml++/validators/dtdvalidator.h @@ -17,7 +17,7 @@ namespace xmlpp { /** XML DTD validator. * DTD = %Document Type Definition */ -class DtdValidator : public Validator +class LIBXMLPP_API DtdValidator : public Validator { public: DtdValidator(); diff --git a/libxml++/validators/relaxngvalidator.h b/libxml++/validators/relaxngvalidator.h index 585d5f90..daff9eef 100644 --- a/libxml++/validators/relaxngvalidator.h +++ b/libxml++/validators/relaxngvalidator.h @@ -26,15 +26,15 @@ namespace xmlpp { -class Document; -class RelaxNGSchema; +class LIBXMLPP_API Document; +class LIBXMLPP_API RelaxNGSchema; /** RelaxNG schema validator. * RelaxNG = REgular LAnguage for XML Next Generation * * @newin{2,38} */ -class RelaxNGValidator : public SchemaValidatorBase +class LIBXMLPP_API RelaxNGValidator : public SchemaValidatorBase { public: RelaxNGValidator(); diff --git a/libxml++/validators/schemavalidatorbase.h b/libxml++/validators/schemavalidatorbase.h index dae7b3af..2debc26a 100644 --- a/libxml++/validators/schemavalidatorbase.h +++ b/libxml++/validators/schemavalidatorbase.h @@ -23,13 +23,13 @@ namespace xmlpp { -class Document; +class LIBXMLPP_API Document; /** Base class for schema validators. * * @newin{2,38} */ -class SchemaValidatorBase : public Validator +class LIBXMLPP_API SchemaValidatorBase : public Validator { public: SchemaValidatorBase() noexcept; diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index 2ba7a038..cf931965 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -20,11 +20,11 @@ extern "C" { namespace xmlpp { -class Document; +class LIBXMLPP_API Document; /** Base class for XML validators. */ -class Validator : public NonCopyable +class LIBXMLPP_API Validator : public NonCopyable { public: Validator() noexcept; diff --git a/libxml++/validators/xsdvalidator.h b/libxml++/validators/xsdvalidator.h index 9dac56bc..afc062bb 100644 --- a/libxml++/validators/xsdvalidator.h +++ b/libxml++/validators/xsdvalidator.h @@ -24,15 +24,15 @@ namespace xmlpp { -class Document; -class XsdSchema; +class LIBXMLPP_API Document; +class LIBXMLPP_API XsdSchema; /** XSD schema validator. * XSD = XML %Schema Definition, a.k.a. XML %Schema or W3C XML %Schema * * @newin{2,38} */ -class XsdValidator : public SchemaValidatorBase +class LIBXMLPP_API XsdValidator : public SchemaValidatorBase { public: XsdValidator(); diff --git a/libxml++/xsdschema.h b/libxml++/xsdschema.h index 3b69f440..9e180250 100644 --- a/libxml++/xsdschema.h +++ b/libxml++/xsdschema.h @@ -38,7 +38,7 @@ namespace xmlpp * * @newin{2,38} */ -class XsdSchema : public SchemaBase +class LIBXMLPP_API XsdSchema : public SchemaBase { public: XsdSchema(); From 2e48518be05ef1ac329ce244e8cf4f4016a92122 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 19 Jun 2020 14:16:49 +0800 Subject: [PATCH 102/240] libxml++config.h.in: Re-organize LIBXMLPP_API We want to set LIBXMLPP_API to the following: * __declspec(dllexport) when building the libxml++ DLL on Windows * __declspec(dllimport) when using the libxml++ DLL on Windows * if building/using a static or a non-Windows libxml++ build --- libxml++config.h.in | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/libxml++config.h.in b/libxml++config.h.in index a8d6cce7..1422cc4d 100755 --- a/libxml++config.h.in +++ b/libxml++config.h.in @@ -16,17 +16,19 @@ /* Micro version number of libxml++. */ #undef LIBXMLXX_MICRO_VERSION -#ifdef GLIBMM_DLL - #if defined(LIBXMLPP_BUILD) && defined(_WINDLL) - // Do not dllexport as it is handled by gendef on MSVC - #define LIBXMLPP_API - #elif !defined(LIBXMLPP_BUILD) - #define LIBXMLPP_API __declspec(dllimport) +// Enable DLL-specific stuff only when not building a static library +#if !defined(__CYGWIN__) && (defined(__MINGW32__) || defined(_MSC_VER)) && !defined(LIBXMLXX_STATIC) +# define LIBXMLPP_DLL 1 +#endif + +#ifdef LIBXMLPP_DLL + #ifdef LIBXMLPP_BUILD + #define LIBXMLPP_API __declspec(dllexport) #else - /* Build a static library */ - #define LIBXMLPP_API - #endif /* LIBXMLPP_BUILD - _WINDLL */ + #define LIBXMLPP_API __declspec(dllimport) + #endif /* LIBXMLPP_BUILD - DLL */ #else + /* Build a static library or a non-Windows library*/ #define LIBXMLPP_API #endif /* GLIBMM_DLL */ From f04b4cb1021065397b89c912e79d9e0b35db9e72 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 19 Jun 2020 14:19:49 +0800 Subject: [PATCH 103/240] NMake Makefiles: Stop using gendef This updates the NMake Makefiles to stop building and using the gendef tool, since we are now using compiler directives to export symbols for libxml++ builds. Since this branch did not have official and working Visual Studio build files, and it is not API/ABI compatible with the libxml++-2.6 series, gendef.cc will be dropped in the next commit --- MSVC_NMake/build-rules-msvc.mak | 12 ++---------- MSVC_NMake/config-msvc.mak | 1 - MSVC_NMake/generate-msvc.mak | 8 -------- 3 files changed, 2 insertions(+), 19 deletions(-) diff --git a/MSVC_NMake/build-rules-msvc.mak b/MSVC_NMake/build-rules-msvc.mak index 683966b5..0802403a 100644 --- a/MSVC_NMake/build-rules-msvc.mak +++ b/MSVC_NMake/build-rules-msvc.mak @@ -64,8 +64,8 @@ $(LIBXMLXX_LIB): $(LIBXMLXX_DLL) # $(dependent_objects) # << # @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2 -$(LIBXMLXX_DLL): $(libxmlxx_OBJS) vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\libxml++.def - link /DLL $(LDFLAGS_NOLTCG) $(LIBXML2_LIBS) /implib:$(LIBXMLXX_LIB) /def:vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\libxml++.def -out:$@ @<< +$(LIBXMLXX_DLL): $(libxmlxx_OBJS) + link /DLL $(LDFLAGS_NOLTCG) $(LIBXML2_LIBS) /implib:$(LIBXMLXX_LIB) -out:$@ @<< $(libxmlxx_OBJS) << @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;2 @@ -77,10 +77,6 @@ $(libxmlxx_OBJS) # $(dependent_objects) # << # @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1 -$(GENDEF): gendef\gendef.cc - @if not exist $(@D)\gendef\ md $(@D)\gendef - $(CXX) $(CFLAGS) /Fo$(@D)\gendef\ /Fd$(@D)\gendef\ $** /Fe:$@ /link $(LDFLAGS) -out:$@ - @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1 clean: @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\*.exe @@ -93,13 +89,9 @@ clean: @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-tests\*.pdb @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-examples\*.obj @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-examples\*.pdb - @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\*.def @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\*.res @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\*.obj @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\*.pdb - @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\gendef\*.obj - @-del /f /q vs$(VSVER)\$(CFG)\$(PLAT)\gendef\*.pdb @-rd vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-tests @-rd vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx-examples @-rd vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx - @-rd vs$(VSVER)\$(CFG)\$(PLAT)\gendef diff --git a/MSVC_NMake/config-msvc.mak b/MSVC_NMake/config-msvc.mak index 0295b281..0dfe8b9d 100644 --- a/MSVC_NMake/config-msvc.mak +++ b/MSVC_NMake/config-msvc.mak @@ -29,6 +29,5 @@ LIBXMLXX_EX_CFLAGS = $(LIBXMLXX_BASE_CFLAGS) $(LIBXMLXX_EXTRA_INCLUDES) LIBXMLXX_DLL = vs$(VSVER)\$(CFG)\$(PLAT)\xml++-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).dll LIBXMLXX_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\xml++-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).lib -GENDEF = vs$(VSVER)\$(CFG)\$(PLAT)\gendef.exe LIBXML2_LIBS = libxml2.lib diff --git a/MSVC_NMake/generate-msvc.mak b/MSVC_NMake/generate-msvc.mak index a7772e9f..7de46117 100644 --- a/MSVC_NMake/generate-msvc.mak +++ b/MSVC_NMake/generate-msvc.mak @@ -3,14 +3,6 @@ # Items in here should not need to be edited unless # one is maintaining the NMake build files. -# Create the build directories -vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx: - @-md $@ - -# Generate .def file using gendef -vs$(VSVER)\$(CFG)\$(PLAT)\libxmlxx\libxml++.def: $(libxmlxx_OBJS) $(GENDEF) - $(GENDEF) $@ xml++-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).dll $(libxmlxx_OBJS) - # Generate pre-generated resources and configuration headers (builds from GIT) prep-git-build: pkg-ver.mak From 3a701cb34e76d937fc62a91ce1a5e4432dcadb14 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 19 Jun 2020 14:23:23 +0800 Subject: [PATCH 104/240] Drop gendef.cc Since we are now using compiler directives or mechanisms to export symbols from our libxml++ DLL for all Windows dynamic builds, it's time to drop gendef.cc, as it is no longer used --- MSVC_NMake/filelist.am | 1 - MSVC_NMake/gendef/gendef.cc | 108 ------------------------------------ 2 files changed, 109 deletions(-) delete mode 100644 MSVC_NMake/gendef/gendef.cc diff --git a/MSVC_NMake/filelist.am b/MSVC_NMake/filelist.am index ea5e6d5d..4dbe5555 100644 --- a/MSVC_NMake/filelist.am +++ b/MSVC_NMake/filelist.am @@ -2,7 +2,6 @@ msvc_nmake_data = \ README \ - gendef/gendef.cc \ libxml++/libxml++.rc \ libxml++/libxml++config.h \ build-rules-msvc.mak \ diff --git a/MSVC_NMake/gendef/gendef.cc b/MSVC_NMake/gendef/gendef.cc deleted file mode 100644 index ba5a8dba..00000000 --- a/MSVC_NMake/gendef/gendef.cc +++ /dev/null @@ -1,108 +0,0 @@ -/* - * MICO --- an Open Source CORBA implementation - * Copyright (c) 2003 Harald Bhme - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * For more information, visit the MICO Home Page at - * http://www.mico.org/ - */ - -/* Modified by Cedric Gustin on 2006/01/13 : - * Redirect the output of dumpbin to dumpbin.out instead of reading the - * output stream of popen, as it fails with Visual Studio 2005 in - * pre-link build events. - */ - -#include -#include -#include - -using namespace std; - -int main(int argc,char** argv) -{ - if (argc < 4) { - cerr << "Usage: " << argv[0] << " ...." << endl; - return 2; - } - - // CG : Explicitly redirect stdout to dumpbin.out. - string dumpbin = "dumpbin /SYMBOLS /OUT:dumpbin.out"; - int i = 3; - - for(;i= 1900) - /* Filter out these symbols as they are done inline in the - * compiler-shipped headers, so that things can link properly on - * later Visual Studio versions. Unfortunately we can't just - * link to legacy_stdio_definitions.lib, so this list below may - * continue to grow. - */ - if (_stricmp(s, "__local_stdio_printf_options") != 0 && - _stricmp(s, "_vsnprintf_l") != 0 && - _stricmp(s, "_vsprintf_l") != 0) { -#endif - if(strchr(s,'?')==0 && s[0]=='_' && strchr(s,'@') == 0 )//this is a C export type: _fct -> fct - def_file << " " << (s+1) << endl; - else - if(strchr(s,'?')!=0 && strncmp(s,"??_G",4)!=0 && strncmp(s,"??_E",4)!=0) { - def_file << " " << s << endl; -#if (_MSC_VER >= 1900) - } -#endif - } - } - } - } - - // CG : Close dumpbin.out and delete it. - fclose(dump); - remove("dumpbin.out"); - - cout << dumpbin.c_str() << endl; -} From ebc5985c4b9e646a9e8c033840235b7899e639ca Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 28 Jun 2020 13:09:36 +0200 Subject: [PATCH 105/240] docs/reference/Doxyfile.in: Remove PERL_PATH Doxygen since version 1.8.0 does not use PERL_PATH and MSCGEN_PATH. --- docs/reference/Doxyfile.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in index c00c367e..45d9368f 100644 --- a/docs/reference/Doxyfile.in +++ b/docs/reference/Doxyfile.in @@ -306,12 +306,10 @@ GENERATE_TAGFILE = "reference/@LIBXMLXX_MODULE_NAME@.tag" ALLEXTERNALS = NO EXTERNAL_GROUPS = NO EXTERNAL_PAGES = YES -PERL_PATH = @PERL@ #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = YES -MSCGEN_PATH = DIA_PATH = HIDE_UNDOC_RELATIONS = NO HAVE_DOT = YES From 77241ee193d0382565ceade01a653106d8c203f3 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 28 Jun 2020 16:16:23 +0200 Subject: [PATCH 106/240] docs: Fully update to libxml++-5.0 and C++17 * docs/manual/libxml++_without_code.xml: * libxml++/libxml++.h: This is libxml++-5.0 and a C++17-compliant compiler is required. Update such info where it has not already been done. --- docs/manual/libxml++_without_code.xml | 16 ++++++++-------- libxml++/libxml++.h | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/manual/libxml++_without_code.xml b/docs/manual/libxml++_without_code.xml index ce7f69b0..525f6c08 100644 --- a/docs/manual/libxml++_without_code.xml +++ b/docs/manual/libxml++_without_code.xml @@ -32,8 +32,8 @@ Unlike some other C++ parsers, it does not try to avoid the advantages of standard C++ features such as namespaces, STL containers or runtime type identification, and it does not try to conform to standard API specifications meant for Java. Therefore libxml++ requires - a fairly modern C++ compiler such as g++ 4.9 or g++ 5. libxml++ 2.39.1 and later require - a C++11-compliant compiler. + a fairly modern C++ compiler such as g++ 8 or g++ 9. libxml++ 3.9.1 and later require + a C++17-compliant compiler. But libxml++ was created mainly to fill the need for an API-stable and ABI-stable C++ XML parser which could be used as a shared library dependency by C++ applications that are distributed widely in binary form. That means that installed applications will not break when new versions of libxml++ are installed on a user's computer. Gradual improvement of the libxml++ API is still possible via non-breaking API additions, and new independent versions of the ABI that can be installed in parallel with older versions. These are the general techniques and principles followed by the GNOME project, of which libxml++ is a part. Installation - libxml++ is packaged by major Linux and *BSD distributions and can be installed from source on Linux and Windows, using any modern compiler, such as g++, SUN Forte, or MSVC++. - For instance, to install libxml++ and its documentation on debian, use apt-get or synaptic like so: + libxml++ is packaged by major Linux and *BSD distributions and can be installed from source on Linux and Windows, using any modern compiler, such as g++ or MSVC++. + For instance, to install libxml++ and its documentation on Debian, use apt-get or synaptic like so: # apt-get install libxml++5.0-dev libxml++5.0-doc - To check that you have the libxml++ development packages installed, and that your environment is working properly, try pkg-config libxml++-4.0 --modversion. + To check that you have the libxml++ development packages installed, and that your environment is working properly, try pkg-config libxml++-5.0 --modversion. Links for downloading and more documentation can be found at libxmlplusplus.sourceforge.net. libxml++ is licensed under the LGPL, which allows its use via dynamic linking in both open source and closed-source software. The underlying libxml2 library uses the even more generous MIT licence. @@ -62,11 +62,11 @@ url="http://libxmlplusplus.sourceforge.net">libxmlplusplus.sourceforge.net Compilation and Linking To use libxml++ in your application, you must tell the compiler where to find the include headers and where to find the libxml++ library. libxml++ provides a pkg-config .pc file to make this easy. For instance, the following command will provide the necessary compiler options: - pkg-config libxml++-4.0 --cflags --libs + pkg-config libxml++-5.0 --cflags --libs When using autoconf and automake, this is even easier with the PKG_CHECK_MODULES macro in your configure.ac file. For instance: - PKG_CHECK_MODULES(SOMEAPP, libxml++-4.0 >= 4.0.0) + PKG_CHECK_MODULES(SOMEAPP, libxml++-5.0 >= 5.0.0) AC_SUBST(SOMEAPP_CFLAGS) AC_SUBST(SOMEAPP_LIBS) @@ -138,7 +138,7 @@ url="http://libxmlplusplus.sourceforge.net">libxmlplusplus.sourceforge.netSAX Parser The SAX (Simple API for XML) parser presents each node of the XML document in sequence. So when you process one node, you must have already stored information about any relevant previous nodes, and you have no information at that time about subsequent nodes. The SAX parser uses less memory than the DOM parser and it is a suitable abstraction for documents that can be processed sequentially rather than as a whole. - By using the parse_chunk() method instead of parse(), you can even parse parts of the XML document before you have received the whole document. + By using the parse_chunk() method instead of for instance parse_file(), you can even parse parts of the XML document before you have received the whole document. As shown in the example, you should derive your own class from SaxParser and override some of the virtual methods. These "handler" methods will be called while the document is parsed. diff --git a/libxml++/libxml++.h b/libxml++/libxml++.h index 1de2bf97..b337d09e 100644 --- a/libxml++/libxml++.h +++ b/libxml++/libxml++.h @@ -33,14 +33,14 @@ * * If your source file is @c program.cc, you can compile it with: * @code - * g++ program.cc -o program `pkg-config --cflags --libs libxml++-4.0` + * g++ program.cc -o program `pkg-config --cflags --libs libxml++-5.0` * @endcode - * If your version of g++ is not C++11-compliant be default, - * add the @c -std=c++11 or @c -std=c++0x option. + * If your version of g++ is not C++17-compliant be default, + * add the @c -std=c++17 option. * * Alternatively, if using autoconf, use the following in @c configure.ac: * @code - * PKG_CHECK_MODULES([LIBXMLXX], [libxml++-4.0]) + * PKG_CHECK_MODULES([LIBXMLXX], [libxml++-5.0]) * @endcode * Then use the generated @c LIBXMLXX_CFLAGS and @c LIBXMLXX_LIBS variables in * the project @c Makefile.am files. For example: From 44eb33c6baf2dbe14e6e063ac6fb3829a607b6ee Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 28 Jun 2020 17:01:26 +0200 Subject: [PATCH 107/240] Add support for building libxml++ with Meson libxml++-5.0 can be built with either Autotools or Meson. New files have been copied from the libxml++-4-0 branch. Some of them have been slightly changed. --- .gitignore | 6 +- MSVC_NMake/libxml++/meson.build | 17 + Makefile.am | 15 + configure.ac | 5 +- docs/manual/meson.build | 102 ++++++ docs/reference/meson.build | 127 +++++++ examples/meson.build | 61 ++++ libxml++.pc.in | 2 +- libxml++/meson.build | 121 +++++++ libxml++config.h.meson | 36 ++ meson.build | 365 +++++++++++++++++++++ meson_options.txt | 20 ++ tests/meson.build | 33 ++ tools/build_scripts/tutorial-custom-cmd.py | 196 +++++++++++ tools/conf_tests/have_exception_ptr.cc | 20 ++ untracked/README | 35 ++ 16 files changed, 1157 insertions(+), 4 deletions(-) create mode 100644 MSVC_NMake/libxml++/meson.build create mode 100644 docs/manual/meson.build create mode 100644 docs/reference/meson.build create mode 100644 examples/meson.build create mode 100644 libxml++/meson.build create mode 100755 libxml++config.h.meson create mode 100644 meson.build create mode 100644 meson_options.txt create mode 100644 tests/meson.build create mode 100755 tools/build_scripts/tutorial-custom-cmd.py create mode 100644 tools/conf_tests/have_exception_ptr.cc create mode 100644 untracked/README diff --git a/.gitignore b/.gitignore index 66748672..088ff518 100644 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,7 @@ stamp-h? /libtool # MSVC -/MSVC_Net201?/libxml++/libxml++.rc +/MSVC_NMake/libxml++/libxml++.rc # docs /docs/doc-install.pl @@ -70,3 +70,7 @@ stamp-h? /tests/*/test.log /tests/*/test.trs /tests/test-suite.log + +# untracked/ +untracked/build_scripts/ +untracked/docs/ diff --git a/MSVC_NMake/libxml++/meson.build b/MSVC_NMake/libxml++/meson.build new file mode 100644 index 00000000..bbb237e8 --- /dev/null +++ b/MSVC_NMake/libxml++/meson.build @@ -0,0 +1,17 @@ +# MSVC_NMake/libxml++ + +# Input: pkg_conf_data, xmlxxconfig_h +# Output: xmlxx_rc + +xmlxx_rc = configure_file( + input: 'libxml++.rc.in', + output: '@BASENAME@', + configuration: pkg_conf_data, +) + +# Copy the generated configuration header into the MSVC project directory. +configure_file( + input: xmlxxconfig_h, + output: 'libxml++config.h', + copy: true, +) diff --git a/Makefile.am b/Makefile.am index c93fefe6..ede276a8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,5 +24,20 @@ dist_noinst_SCRIPTS = autogen.sh DISTCLEANFILES = MSVC_NMake/libxml++/libxml++config.h +# Distribute files needed when building libxml++ with Meson. +EXTRA_DIST = \ + meson.build \ + meson_options.txt \ + libxml++config.h.meson \ + MSVC_NMake/libxml++/meson.build \ + docs/manual/meson.build \ + docs/reference/meson.build \ + examples/meson.build \ + libxml++/meson.build \ + tests/meson.build \ + tools/build_scripts/tutorial-custom-cmd.py \ + tools/conf_tests/have_exception_ptr.cc \ + untracked/README + # Optional: auto-generate the ChangeLog file from the git log on make dist include $(top_srcdir)/build/dist-changelog.am diff --git a/configure.ac b/configure.ac index 87edfcdb..89c73c82 100644 --- a/configure.ac +++ b/configure.ac @@ -36,6 +36,8 @@ LT_PREREQ([2.2.6]) LT_INIT([dlopen win32-dll disable-static]) AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7']) +AC_SUBST([LIBXML2_LIB_NO_PKGCONFIG], ['']) +AC_SUBST([MSVC_TOOLSET_VER], ['']) PKG_CHECK_MODULES([LIBXMLXX], [$LIBXMLXX_MODULES]) AC_LANG([C++]) @@ -48,8 +50,7 @@ MM_ARG_WITH_TAGFILE_DOC([libstdc++.tag], [mm-common-libstdc++]) # Evaluate the --enable-warnings=level option. MM_ARG_ENABLE_WARNINGS([LIBXMLXX_WXXFLAGS], [-Wall], - [-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow -Wno-long-long], - [G GLIBMM SIGCXX]) + [-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow -Wno-long-long]) # Offer the ability to omit some API from the library. MM_ARG_DISABLE_DEPRECATED_API([LIBXMLXX]) diff --git a/docs/manual/meson.build b/docs/manual/meson.build new file mode 100644 index 00000000..ae5e463f --- /dev/null +++ b/docs/manual/meson.build @@ -0,0 +1,102 @@ +# docs/manual + +# input: install_datadir, xmlxx_pcname, tutorial_custom_cmd_py, python3, +# build_documentation, book_name, perl +# output: can_parse_and_validate, build_pdf_by_default, can_build_pdf, +# install_tutorialdir + +# xsltproc is required by tutorial_custom_cmd_py html. +xsltproc = find_program('xsltproc', required: build_documentation) +xmllint = find_program('xmllint', required: false) + +can_parse_and_validate = xmllint.found() + +validate = get_option('validation') ? 'true' : 'false' + +dblatex = find_program('dblatex', required: false) +can_build_pdf = dblatex.found() or (xmllint.found() and \ + find_program('docbook2pdf', required: false).found()) +build_pdf_by_default = get_option('build-pdf') + +# Installation directories are relative to {prefix}. +install_tutorialdir = install_datadir / 'doc' / book_name / 'manual' + +if not build_documentation + # Documentation shall not be built or installed. + # Return to the calling meson.build file. + subdir_done() +endif + +doc_dist_dir = 'untracked' / 'docs' / 'manual' # Relative to MESON_DIST_ROOT + +# Create a DocBook XML file with the examples' source code included. +xml_manual_docbook = custom_target('libxml++.xml', + input: 'libxml++_without_code.xml', + output: 'libxml++.xml', + command: [ + python3, tutorial_custom_cmd_py, 'insert_example_code', + meson.current_source_dir() / 'insert_example_code.pl', + project_source_root / 'examples', + '@INPUT@', + '@OUTPUT@', + ], + build_by_default: true +) + +# Create an html version of the DocBook. +custom_target('manual_html', + input: xml_manual_docbook, + output: 'html', + command: [ + python3, tutorial_custom_cmd_py, 'html', + meson.current_source_dir() / 'docbook-customisation.xsl', # stylesheet + '@INPUT@', + '@OUTPUT@', + ], + build_by_default: true, + install: true, + install_dir: install_tutorialdir +) + +if can_parse_and_validate + # Parse and possibly validate the DocBook. + custom_target('manual_xmllint', + input: xml_manual_docbook, + output: 'manual_xmllint.stamp', + command: [ + python3, tutorial_custom_cmd_py, 'xmllint', + validate, + '@INPUT@', + '@OUTPUT@' + ], + build_by_default: true, + ) +endif + +if can_build_pdf + # Create a PDF file of the DocBook. + # Prefer dblatex, if both dblatex and docbook2pdf are available. + custom_target('manual_pdf', + input: xml_manual_docbook, + output: 'libxml++.pdf', + command: [ + python3, tutorial_custom_cmd_py, + dblatex.found() ? 'dblatex' : 'docbook2pdf', + '@INPUT@', + '@OUTPUT@' + ], + build_by_default: build_pdf_by_default, + ) +endif + +if not meson.is_subproject() + # Distribute built files. + # (add_dist_script() is not allowed in a subproject) + meson.add_dist_script( + python3.path(), tutorial_custom_cmd_py, 'dist_doc', + doc_dist_dir, + meson.current_build_dir(), + meson.current_build_dir() / 'libxml++.xml', + meson.current_build_dir() / 'libxml++.pdf', + ) +endif diff --git a/docs/reference/meson.build b/docs/reference/meson.build new file mode 100644 index 00000000..ace88053 --- /dev/null +++ b/docs/reference/meson.build @@ -0,0 +1,127 @@ +# docs/reference + +# Input: project_build_root, project_source_root, xmlxx_pcname, +# xmlxx_api_version, build_documentation, source_h_files, +# install_datadir, python3, doc_reference_py +# Output: install_docdir, install_devhelpdir, book_name + +# There are no built source files in libxml++-5.0. + +tag_file_modules = [ + 'mm-common-libstdc++', +] +doxygen_tagfiles = '' +docinstall_flags = [] +foreach module : tag_file_modules + depmod = dependency(module, required: false) + if depmod.found() + doxytagfile = depmod.get_pkgconfig_variable('doxytagfile') + htmlrefpub = depmod.get_pkgconfig_variable('htmlrefpub', default: '') + htmlrefdir = depmod.get_pkgconfig_variable('htmlrefdir', default: '') + if htmlrefpub == '' + htmlrefpub = htmlrefdir + elif htmlrefdir == '' + htmlrefdir = htmlrefpub + endif + doxygen_tagfiles += ' "' + doxytagfile + '=' + htmlrefpub + '"' + + # Doxygen <= 1.8.15 + docinstall_flags += ['-l', doxytagfile.split('/')[-1] + '@' + htmlrefdir] + if htmlrefpub != htmlrefdir + # Doxygen >= 1.8.16 + docinstall_flags += ['-l', 's@' + htmlrefpub + '@' + htmlrefdir] + endif + endif +endforeach + +book_name = xmlxx_pcname +book_title = meson.project_name() + ' Reference Manual' + +# Configuration data for Doxyfile. +doc_conf_data = configuration_data() +doc_conf_data.set('configure_input', + 'docs/reference/Doxyfile. Generated from Doxyfile.in by meson.configure_file().') +doc_conf_data.set('PACKAGE_NAME', meson.project_name()) +doc_conf_data.set('PACKAGE_VERSION', meson.project_version()) +doc_conf_data.set('abs_top_builddir', project_build_root) +doc_conf_data.set('abs_top_srcdir', project_source_root) +doc_conf_data.set('LIBXMLXX_MODULE_NAME', book_name) +doc_conf_data.set('DOXYGEN_TAGFILES', doxygen_tagfiles) + +configure_file( + input: 'Doxyfile.in', + output: '@BASENAME@', + configuration: doc_conf_data, +) + +# Installation directories relative to {prefix}. +install_docdir = install_datadir / 'doc' / book_name +install_reference_docdir = install_docdir / 'reference' +install_devhelpdir = install_datadir / 'devhelp' / 'books' / book_name + +if not build_documentation + # Documentation shall not be built or installed. + # Return to the calling meson.build file. + subdir_done() +endif + +# Input .h files to Doxygen. +src_h_files = [] +foreach file : source_h_files + src_h_files += project_source_root / 'libxml++' / file +endforeach +src_h_files += project_source_root / 'libxml++' / 'libxml++.h' + +doctool_dir = project_source_root / 'untracked' / 'docs' # MMDOCTOOLDIR +doctool_dist_dir = 'untracked' / 'docs' # Relative to MESON_DIST_ROOT + +tag_file = custom_target('html_and_tag', + input: src_h_files, + output: book_name + '.tag', + command: [ + python3, doc_reference_py, 'doxygen', + doctool_dir, + '@OUTPUT@', + '@INPUT@', + ], + build_by_default: build_documentation, + install: true, + install_dir: install_reference_docdir, +) + +devhelp_file = custom_target('devhelp', + input: tag_file, + output: book_name + '.devhelp2', + command: [ + python3, doc_reference_py, 'devhelp', + doctool_dir, + '@INPUT@', + '@OUTPUT@', + book_name, + book_title, + ], + build_by_default: build_documentation, +) + +# Install Devhelp file and html files. +meson.add_install_script( + python3.path(), doc_reference_py, 'install_doc', + doctool_dir, + devhelp_file.full_path(), + install_devhelpdir, + install_reference_docdir / 'html', + docinstall_flags +) + +if not meson.is_subproject() + # Distribute built files and files copied by mm-common-get. + # (add_dist_script() is not allowed in a subproject) + meson.add_dist_script( + python3.path(), doc_reference_py, 'dist_doc', + doctool_dir, + doctool_dist_dir, + meson.current_build_dir(), + tag_file.full_path(), + devhelp_file.full_path(), + ) +endif diff --git a/examples/meson.build b/examples/meson.build new file mode 100644 index 00000000..83ea5e7a --- /dev/null +++ b/examples/meson.build @@ -0,0 +1,61 @@ +# examples + +# Input: xmlxx_dep, build_examples +# Output: - + +example_programs = [ +# [[dir-name], exe-name, [sources], [arguments]] + [['dom_build'], 'example', ['main.cc'], []], + [['dom_parse_entities'], 'example', ['main.cc'], []], + [['dom_parser'], 'example', ['main.cc'], []], + [['dom_parser_raw'], 'example', ['main.cc'], []], + [['dom_read_write'], 'example', ['main.cc'], + ['example.xml', meson.current_build_dir() / 'dom_read_write_example_output.xml']], + [['dom_update_namespace'], 'example', ['main.cc'], []], + [['dom_xinclude'], 'example', ['main.cc'], []], + [['dom_xpath'], 'example', ['main.cc'], []], + [['dtdvalidation'], 'example', ['main.cc'], []], + [['import_node'], 'example', ['main.cc'], []], + [['sax_exception'], 'example', ['main.cc', 'myparser.cc'], []], + [['sax_parser'], 'example', ['main.cc', 'myparser.cc'], []], + [['sax_parser_build_dom'], 'example', ['main.cc', 'svgparser.cc', + 'svgdocument.cc', 'svgelement.cc'], []], + [['sax_parser_entities'], 'example', ['main.cc', 'myparser.cc'], []], + [['schemavalidation'], 'example', ['main.cc'], []], + [['textreader'], 'example', ['main.cc'], []], +] + +foreach ex : example_programs + dir = '' + foreach dir_part : ex[0] + dir = dir / dir_part + endforeach + ex_name = (dir / ex[1]).underscorify() + ex_sources = [] + foreach src : ex[2] + ex_sources += dir / src + endforeach + + exe_file = executable(ex_name, ex_sources, + dependencies: xmlxx_dep, + gui_app: false, + build_by_default: build_examples + ) + + if build_examples + # Some programs can find their input file(s) only if the current directory, + # when they are executed, is the program's own source directory. + # To make these program invocations as consistent as possible, and to avoid + # having to specify parameters for the programs, the programs are executed + # from their own source directory. + # + # dom_read_write shall write its output file in the build directory. + # It's necessary to specify parameters when the input file and the output + # file are located in different directories. + + test(ex_name, exe_file, + workdir: meson.current_source_dir() / dir, + args: ex[3], + ) + endif +endforeach diff --git a/libxml++.pc.in b/libxml++.pc.in index b6189c12..b5348ba5 100644 --- a/libxml++.pc.in +++ b/libxml++.pc.in @@ -15,5 +15,5 @@ Description: C++ wrapper for libxml Version: @PACKAGE_VERSION@ URL: http://libxmlplusplus.sourceforge.net/ Requires: @LIBXMLXX_MODULES@ -Libs: -L${libdir} -lxml++-@LIBXMLXX_API_VERSION@ +Libs: -L${libdir} -lxml++@MSVC_TOOLSET_VER@-@LIBXMLXX_API_VERSION@ @LIBXML2_LIB_NO_PKGCONFIG@ Cflags: -I${includedir}/@LIBXMLXX_MODULE_NAME@ -I${libdir}/@LIBXMLXX_MODULE_NAME@/include diff --git a/libxml++/meson.build b/libxml++/meson.build new file mode 100644 index 00000000..2183157c --- /dev/null +++ b/libxml++/meson.build @@ -0,0 +1,121 @@ +# libxml++ + +# Input: xmlxx_build_dep, xmlxx_pcname, xmlxx_libversion, xmlxx_api_version, +# install_includedir, xmlxx_rc, xmlxx_libname +# Output: source_h_files, xmlxx_dep + +# There are no built source files in libxml++-5.0. + +source_h_files = [] +source_cc_files = [] + +xmlxx_base_h_cc_files = [ + 'attribute', + 'attributedeclaration', + 'attributenode', + 'document', + 'dtd', + 'keepblanks', + 'noncopyable', + 'relaxngschema', + 'schemabase', + 'ustring', + 'xsdschema', +] + +xmlxx_subdir_h_cc_files = [ +# [ dir-name, [files]] + ['exceptions', [ + 'exception', + 'parse_error', + 'validity_error', + 'internal_error', + 'wrapped_exception', + ]], + ['io', [ + 'istreamparserinputbuffer', + 'outputbuffer', + 'ostreamoutputbuffer', + 'parserinputbuffer', + ]], + ['nodes', [ + 'cdatanode', + 'commentnode', + 'contentnode', + 'element', + 'entitydeclaration', + 'entityreference', + 'node', + 'processinginstructionnode', + 'textnode', + 'xincludeend', + 'xincludestart', + ]], + ['parsers', [ + 'parser', + 'saxparser', + 'domparser', + 'textreader', + ]], + ['validators', [ + 'dtdvalidator', + 'relaxngvalidator', + 'schemavalidatorbase', + 'validator', + 'xsdvalidator', + ]], +] + +foreach f : xmlxx_base_h_cc_files + source_h_files += f + '.h' + source_cc_files += f + '.cc' +endforeach + +install_headers('libxml++.h', subdir: xmlxx_pcname / 'libxml++') +install_headers(source_h_files, subdir: xmlxx_pcname / 'libxml++') + +foreach dir_files : xmlxx_subdir_h_cc_files + dir = dir_files[0] + subdir_h_files = [] + foreach f : dir_files[1] + subdir_h_files += dir / f + '.h' + source_cc_files += dir / f + '.cc' + endforeach + source_h_files += subdir_h_files + install_headers(subdir_h_files, subdir: xmlxx_pcname / 'libxml++' / dir) +endforeach + +xmlxx_cpp_args = [ '-DLIBXMLPP_BUILD=1' ] + +# Make sure we are exporting the symbols from the DLL +if is_msvc + xmlxx_cpp_args += ['-D_WINDLL'] +endif + +extra_xmlxx_objects = [] + +# Build the .rc file for Windows builds and link to it +if host_machine.system() == 'windows' + windows = import('windows') + xmlxx_res = windows.compile_resources(xmlxx_rc) + extra_xmlxx_objects += xmlxx_res +endif + +extra_include_dirs = ['..'] +xmlxx_library = library(xmlxx_libname, + source_cc_files, + extra_xmlxx_objects, + version: xmlxx_libversion, + include_directories: extra_include_dirs, + cpp_args: xmlxx_cpp_args, + dependencies: xmlxx_build_dep, + install: true, +) + +# This is useful in the main project when libxml++ is used as a subproject. +# It's also used when building example programs and test programs. +xmlxx_dep = declare_dependency( + link_with: xmlxx_library, + include_directories: extra_include_dirs, + dependencies: xmlxx_build_dep +) diff --git a/libxml++config.h.meson b/libxml++config.h.meson new file mode 100755 index 00000000..e5a6870f --- /dev/null +++ b/libxml++config.h.meson @@ -0,0 +1,36 @@ +#ifndef _LIBXMLPP_CONFIG_H +#define _LIBXMLPP_CONFIG_H + +/* Define to omit deprecated API from the library. */ +#mesondefine LIBXMLXX_DISABLE_DEPRECATED + +/* Defined if the C++ library supports std::exception_ptr. */ +#mesondefine LIBXMLXX_HAVE_EXCEPTION_PTR + +/* Major version number of libxml++. */ +#mesondefine LIBXMLXX_MAJOR_VERSION + +/* Minor version number of libxml++. */ +#mesondefine LIBXMLXX_MINOR_VERSION + +/* Micro version number of libxml++. */ +#mesondefine LIBXMLXX_MICRO_VERSION + +// Enable DLL-specific stuff only when not building a static library +#if !defined(__CYGWIN__) && (defined(__MINGW32__) || defined(_MSC_VER)) && !defined(LIBXMLXX_STATIC) +# define LIBXMLPP_DLL 1 +#endif + +#ifdef LIBXMLPP_DLL + #ifdef LIBXMLPP_BUILD + #define LIBXMLPP_API __declspec(dllexport) + #else + #define LIBXMLPP_API __declspec(dllimport) + #endif /* LIBXMLPP_BUILD - DLL */ +#else + /* Build a static library or a non-Windows library*/ + #define LIBXMLPP_API +#endif /* GLIBMM_DLL */ + +#endif /* _LIBXMLPP_CONFIG_H */ + diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..e591e28b --- /dev/null +++ b/meson.build @@ -0,0 +1,365 @@ +# This file is part of libxml++. + +project('libxml++', 'cpp', + version: '4.9.1', + license: 'LGPLv2.1+', + default_options: [ + 'cpp_std=c++17' + ], + meson_version: '>= 0.50.0', # required for python3.path() +) + +xmlxx_api_version = '5.0' +xmlxx_pcname = meson.project_name() + '-' + xmlxx_api_version + +xmlxx_version_array = meson.project_version().split('.') +xmlxx_major_version = xmlxx_version_array[0].to_int() +xmlxx_minor_version = xmlxx_version_array[1].to_int() +xmlxx_micro_version = xmlxx_version_array[2].to_int() + +# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html +# The relation between libtool's current:revison:age interface versioning +# and the .so filename, .so.x.y.z, is +# x = current - age +# y = age +# z = revision +# If libtool_soversion is updated as described in libtool's documentation, +# x.y.z will usually *not* be equal to meson.project_version(). +libtool_soversion = [1, 0, 0] +xmlxx_libversion = '@0@.@1@.@2@'.format( + libtool_soversion[0] - libtool_soversion[2], + libtool_soversion[2], + libtool_soversion[1]) + +# Use these instead of meson.source_root() and meson.build_root() in subdirectories. +# source_root() and build_root() are not useful, if this is a subproject. +project_source_root = meson.current_source_dir() +project_build_root = meson.current_build_dir() + +cpp_compiler = meson.get_compiler('cpp') +is_msvc = cpp_compiler.get_id() == 'msvc' +python3 = import('python').find_installation('python3') + +python_version = python3.language_version() +python_version_req = '>= 3.5' +if not python_version.version_compare(python_version_req) + error('Requires Python @0@, found @1@.'.format(python_version_req, python_version)) +endif + +# Do we build from a git repository? +# Suppose we do if and only if a '.git' directory or file exists. +cmd_py = ''' +import os +import sys +sys.exit(os.path.isdir("@0@") or os.path.isfile("@0@")) +'''.format(project_source_root / '.git') +is_git_build = run_command(python3, '-c', cmd_py).returncode() != 0 + +# Are we testing a dist tarball while it's being built? +# There ought to be a better way. https://github.com/mesonbuild/meson/issues/6866 +is_dist_check = project_source_root.contains('dist-unpack') and \ + project_build_root.contains('dist-build') + +# Options. +maintainer_mode_opt = get_option('maintainer-mode') +maintainer_mode = maintainer_mode_opt == 'true' or \ + (maintainer_mode_opt == 'if-git-build' and is_git_build) +if is_dist_check + message('Looks like a tarball is being tested. ' + \ + 'Option "dist-warnings" is used instead of "warnings".') + warning_level = get_option('dist-warnings') +else + warning_level = get_option('warnings') +endif +build_deprecated_api = get_option('build-deprecated-api') +build_documentation_opt = get_option('build-documentation') +build_documentation = build_documentation_opt == 'true' or \ + (build_documentation_opt == 'if-maintainer-mode' and maintainer_mode) +build_examples = get_option('build-examples') +build_tests = get_option('build-tests') +use_msvc14x_toolset_ver = get_option('msvc14x-parallel-installable') + +# Installation directories are relative to {prefix}. +install_prefix = get_option('prefix') +install_includedir = get_option('includedir') +install_libdir = get_option('libdir') +install_datadir = get_option('datadir') +install_pkgconfigdir = install_libdir / 'pkgconfig' + +# Dependencies. +# xmlxx_build_dep: Dependencies when building the libxml++ library. +# xmlxx_dep (created in libxml++/meson.build): +# Dependencies when using the libxml++ library. + +# libxml2's Windows-specific Makefiles don't create pkg-config files for us, so +# we may need to look for it manually on Windows +xml2_min_ver = '2.7.7' +xml2_req = '>= @0@'.format(xml2_min_ver) +xml2_dep = dependency('libxml-2.0', version: xml2_req, required: host_machine.system() != 'windows') + +if not xml2_dep.found() + libxml2_lib = 'libxml2' + xml2_dep = cpp_compiler.find_library(libxml2_lib, + has_headers: [ + 'libxml/globals.h', + 'libxml/parser.h', + 'libxml/parserInternals.h', + 'libxml/relaxng.h', + 'libxml/tree.h', + 'libxml/xinclude.h', + 'libxml/xpath.h', + 'libxml/xpathInternals.h', + 'libxml/xmlerror.h', + 'libxml/xmlIO.h', + 'libxml/xmlreader.h', + 'libxml/xmlschemas.h', + ]) + + xml_min_ver_split = xml2_min_ver.split('.') + xml_min_ver_int = xml_min_ver_split[0].to_int() * 10000 + \ + xml_min_ver_split[1].to_int() * 100 + \ + xml_min_ver_split[2].to_int() + + if not cpp_compiler.compiles('''#include + #if LIBXML_VERSION < @0@ + # error libxml2 versions must be @1@ or later + #endif'''.format(xml_min_ver_int.to_string(), xml2_min_ver), + name : 'libxml2 is @0@ or later'.format(xml2_min_ver)) + error('Your libxml2 installation must be @0@ or later'.format(xml2_min_ver)) + endif +endif + +xmlxx_requires = [] +libxml2_lib_pkgconfig = '' + +# Put libxml-2.0 in the 'Requires:' section in the generated pkg-config file if +# we found it by pkg-config +if xml2_dep.type_name() == 'pkgconfig' + xmlxx_requires += ['libxml-2.0', xml2_req] +else + libxml2_lib_pkgconfig = '-l@0@'.format(libxml2_lib) +endif + +xmlxx_requires = ' '.join(xmlxx_requires) + +# Make sure we link to libxml-2.0 +xmlxx_build_dep = [xml2_dep] + +# Some dependencies are required only in maintainer mode and/or if +# reference documentation shall be built. +mm_common_get = find_program('mm-common-get', required: false) +if maintainer_mode and not mm_common_get.found() + error('Maintainer mode requires the \'mm-common-get\' command.\n' + + 'Use \'-Dmaintainer-mode=false\' or install the \'mm-common\' package, version 1.0.0 or higher') +endif +perl = find_program('perl', required: build_documentation) +doxygen = find_program('doxygen', required: build_documentation) +dot = find_program('dot', required: build_documentation) # Used by Doxygen +xsltproc = find_program('xsltproc', required: build_documentation) + +# Script files copied to 'untracked/' by mm-common-get. +script_dir = project_source_root / 'untracked' / 'build_scripts' +doc_reference_py = script_dir / 'doc-reference.py' +dist_changelog_py = script_dir / 'dist-changelog.py' +dist_build_scripts_py = script_dir / 'dist-build-scripts.py' + +if maintainer_mode + # Copy files to untracked/build_scripts and untracked/docs. + run_command(mm_common_get, '--force', script_dir, + project_source_root / 'untracked' / 'docs') +else + cmd_py = ''' +import os +import sys +sys.exit(os.path.isfile("@0@")) +'''.format(doc_reference_py) + file_exists = run_command(python3, '-c', cmd_py).returncode() != 0 + if not file_exists + warning('Missing files in untracked/. ' + \ + 'Enable maintainer-mode if you want to build documentation or create a dist tarball.') + endif +endif + +# xmlxx's own script files. +xmlxx_script_dir = project_source_root / 'tools' / 'build_scripts' +tutorial_custom_cmd_py = xmlxx_script_dir / 'tutorial-custom-cmd.py' + +# Add toolset version in builds done with Visual Studio 2017 or later +msvc14x_toolset_ver = '' + +if is_msvc + add_project_arguments(cpp_compiler.get_supported_arguments([ '/utf-8', '/wd4828']), language: 'cpp') + + if use_msvc14x_toolset_ver + if cpp_compiler.version().version_compare('>=19.20') + msvc14x_toolset_ver = '-vc142' + elif cpp_compiler.version().version_compare('>=19.10') + msvc14x_toolset_ver = '-vc141' + endif + endif +endif + +xmlxx_libname = 'xml++' + msvc14x_toolset_ver + '-' + xmlxx_api_version + +# Set compiler warnings. +warning_flags = [] +if warning_level == 'min' + if is_msvc + warning_flags = ['/W3'] + else + warning_flags = ['-Wall'] + endif +elif warning_level == 'max' or warning_level == 'fatal' + if is_msvc + warning_flags = ['/W4'] + else + warning_flags = '-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow -Wno-long-long'.split() + endif + if warning_level == 'fatal' + if is_msvc + warning_flags += ['/WX'] + else + warning_flags += ['-Werror'] + endif + endif +endif + +warning_flags = cpp_compiler.get_supported_arguments(warning_flags) +add_project_arguments(warning_flags, language: 'cpp') + +# MSVC: Ignore warnings that aren't really harmful, but make those +# that should not be overlooked stand out. +if is_msvc + foreach wd : ['/FImsvc_recommended_pragmas.h', '/wd4267', '/wd4530', '/wd4251', '/wd4273', '/wd4275'] + disabled_warning = cpp_compiler.get_supported_arguments(wd) + add_project_arguments(disabled_warning, language: 'cpp') + endforeach +endif + +# Configure files +pkg_conf_data = configuration_data() +pkg_conf_data.set('prefix', install_prefix) +pkg_conf_data.set('exec_prefix', '${prefix}') +pkg_conf_data.set('libdir', '${exec_prefix}' / install_libdir) +pkg_conf_data.set('datarootdir', '${prefix}' / install_datadir) +pkg_conf_data.set('datadir', '${datarootdir}') +pkg_conf_data.set('includedir', '${prefix}' / install_includedir) +pkg_conf_data.set('PACKAGE_NAME', meson.project_name()) # MSVC_NMake/libxml++/libxml++.rc +pkg_conf_data.set('PACKAGE_TARNAME', meson.project_name()) +pkg_conf_data.set('PACKAGE_VERSION', meson.project_version()) +pkg_conf_data.set('LIBXMLXX_MODULE_NAME', xmlxx_pcname) +pkg_conf_data.set('LIBXMLXX_API_VERSION', xmlxx_api_version) +pkg_conf_data.set('LIBXMLXX_MODULES', xmlxx_requires) +pkg_conf_data.set('LIBXML2_LIB_NO_PKGCONFIG', libxml2_lib_pkgconfig) +pkg_conf_data.set('MSVC_TOOLSET_VER', msvc14x_toolset_ver) + +if not build_deprecated_api + pkg_conf_data.set('LIBXMLXX_DISABLE_DEPRECATED', 1) +endif +pkg_conf_data.set('LIBXMLXX_MAJOR_VERSION', xmlxx_major_version) +pkg_conf_data.set('LIBXMLXX_MINOR_VERSION', xmlxx_minor_version) +pkg_conf_data.set('LIBXMLXX_MICRO_VERSION', xmlxx_micro_version) + +# Configuration test +if cpp_compiler.compiles(files('tools' / 'conf_tests' / 'have_exception_ptr.cc')) + pkg_conf_data.set('LIBXMLXX_HAVE_EXCEPTION_PTR', 1) +endif + +# Static library? +library_build_type = get_option('default_library') + +if cpp_compiler.get_argument_syntax() == 'msvc' + if library_build_type == 'static' or library_build_type == 'both' + error('Static builds are not supported by MSVC-style builds') + endif +endif + +configure_file( + input: 'libxml++.pc.in', + output: xmlxx_pcname + '.pc', + configuration: pkg_conf_data, + install_dir: install_pkgconfigdir, +) + +install_includeconfigdir = install_libdir / xmlxx_pcname / 'include' +xmlxxconfig_h = configure_file( + input: 'libxml++config.h.meson', + output: 'libxml++config.h', + configuration: pkg_conf_data, + install_dir: install_includeconfigdir, +) + +subdir('MSVC_NMake/libxml++') +subdir('libxml++') +subdir('examples') +subdir('tests') +subdir('docs/reference') +subdir('docs/manual') + +if not meson.is_subproject() + # Add a ChangeLog file to the distribution directory. + # (add_dist_script() is not allowed in a subproject) + meson.add_dist_script( + python3.path(), dist_changelog_py, + project_source_root, + ) + # Add build scripts to the distribution directory, and delete .gitignore + # files and an empty $MESON_DIST_ROOT/build/ directory. + meson.add_dist_script( + python3.path(), dist_build_scripts_py, + project_source_root, + 'untracked' / 'build_scripts', + ) +endif + +# Print a summary. +real_maintainer_mode = '' +if maintainer_mode_opt == 'if-git-build' + real_maintainer_mode = ' (@0@)'.format(maintainer_mode) +endif + +real_build_documentation = '' +if build_documentation_opt == 'if-maintainer-mode' + real_build_documentation = ' (@0@)'.format(build_documentation) +endif + +validate = get_option('validation') and can_parse_and_validate +explain_val = '' +if get_option('validation') and not validate + explain_val = ' (requires xmllint)' +endif + +build_pdf = build_pdf_by_default and can_build_pdf +explain_pdf = '' +if build_pdf_by_default and not build_pdf + explain_pdf = ' (requires dblatex or (xmllint and docbook2pdf))' +endif + +summary = [ + '', + '------', + meson.project_name() + ' ' + meson.project_version(), + '', + ' Maintainer mode: @0@@1@'.format(maintainer_mode_opt, real_maintainer_mode), + ' Compiler warnings: @0@'.format(warning_level), + ' Build deprecated API: @0@'.format(build_deprecated_api), + 'Build HTML documentation: @0@@1@'.format(build_documentation_opt, real_build_documentation), + ' XML validation: @0@@1@'.format(validate, explain_val), + ' Build PDF: @0@@1@'.format(build_pdf, explain_pdf), + ' Build example programs: @0@'.format(build_examples), + ' Build test programs: @0@'.format(build_tests), + 'Directories:', + ' prefix: @0@'.format(install_prefix), + ' includedir: @0@'.format(install_prefix / install_includedir), + ' includexmlxxdir: @0@'.format(install_prefix / install_includedir / xmlxx_pcname), + ' libdir: @0@'.format(install_prefix / install_libdir), + ' includeconfigdir: @0@'.format(install_prefix / install_includeconfigdir), + ' pkgconfigdir: @0@'.format(install_prefix / install_pkgconfigdir), + ' datadir: @0@'.format(install_prefix / install_datadir), + ' docdir: @0@'.format(install_prefix / install_docdir), + ' devhelpdir: @0@'.format(install_prefix / install_devhelpdir), + ' tutorialdir: @0@'.format(install_prefix / install_tutorialdir), + '------', +] + +message('\n'.join(summary)) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..f9449898 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,20 @@ +option('maintainer-mode', type: 'combo', choices: ['false', 'if-git-build', 'true'], + value: 'if-git-build', description: 'Let mm-common-get copy some files to untracked/') +option('warnings', type: 'combo', choices: ['no', 'min', 'max', 'fatal'], + value: 'min', description: 'Compiler warning level') +option('dist-warnings', type: 'combo', choices: ['no', 'min', 'max', 'fatal'], + value: 'fatal', description: 'Compiler warning level when a tarball is created') +option('build-deprecated-api', type: 'boolean', value: true, + description: 'Build deprecated API and include it in the library') +option('build-documentation', type: 'combo', choices: ['false', 'if-maintainer-mode', 'true'], + value: 'if-maintainer-mode', description: 'Build and install the documentation') +option('validation', type: 'boolean', value: true, + description: 'Validate the tutorial XML file') +option('build-pdf', type: 'boolean', value: false, + description: 'Build tutorial PDF file') +option('build-examples', type: 'boolean', value: true, + description: 'Build example programs') +option('build-tests', type: 'boolean', value: true, + description: 'Build test programs') +option('msvc14x-parallel-installable', type: 'boolean', value: true, + description: 'Use separate DLL and LIB filenames for Visual Studio 2017 and 2019') diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 00000000..435ea2ac --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,33 @@ +# tests + +# Input: xmlxx_dep, build_tests +# Output: - + +test_programs = [ +# [[dir-name], exe-name, [sources]] + [['saxparser_chunk_parsing_inconsistent_state'], 'test', ['main.cc']], + [['saxparser_parse_double_free'], 'test', ['main.cc']], + [['saxparser_parse_stream_inconsistent_state'], 'test', ['main.cc']], +] + +foreach ex : test_programs + dir = '' + foreach dir_part : ex[0] + dir = dir / dir_part + endforeach + ex_name = (dir / ex[1]).underscorify() + ex_sources = [] + foreach src : ex[2] + ex_sources += dir / src + endforeach + + exe_file = executable(ex_name, ex_sources, + dependencies: xmlxx_dep, + gui_app: false, + build_by_default: build_tests + ) + + if build_tests + test(ex_name, exe_file) + endif +endforeach diff --git a/tools/build_scripts/tutorial-custom-cmd.py b/tools/build_scripts/tutorial-custom-cmd.py new file mode 100755 index 00000000..aa4761e6 --- /dev/null +++ b/tools/build_scripts/tutorial-custom-cmd.py @@ -0,0 +1,196 @@ +#!/usr/bin/env python3 + +# External command, intended to be called with custom_target() in meson.build + +# argv[1] argv[2:] +# tutorial-custom-cmd.py ... + +import os +import sys +import subprocess +from pathlib import Path +import shutil + +subcommand = sys.argv[1] + +def insert_example_code(): + # argv[2] argv[3] argv[4] argv[5] + # + + perl_script_file = sys.argv[2] + examples_dir = sys.argv[3] + input_xml_file = sys.argv[4] + output_xml_file = sys.argv[5] + + cmd = [ + 'perl', + '--', + perl_script_file, + examples_dir, + input_xml_file, + ] + with open(output_xml_file, mode='w') as xml_file: + return subprocess.run(cmd, stdout=xml_file).returncode + +def html(): + # argv[2] argv[3] argv[4] + # + + xslt_stylesheet = sys.argv[2] + input_xml_file = sys.argv[3] + output_html_dir = sys.argv[4] + + # For a list of available parameters, see http://docbook.sourceforge.net/release/xsl/current/doc/html/ + xslt_params = [] + + # Remove old files and create the destination directory. + shutil.rmtree(output_html_dir, ignore_errors=True) + os.makedirs(output_html_dir, exist_ok=True) + + cmd = [ + 'xsltproc', + ] + xslt_params + [ + '-o', output_html_dir + '/', + '--xinclude', + xslt_stylesheet, + input_xml_file, + ] + result = subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, + universal_newlines=True) + # xsltproc prints the names of all written files. Don't print those lines. + for line in result.stdout.splitlines(): + if not line.startswith('Writing '): + print(line) + + return result.returncode + +def xmllint(): + # argv[2] argv[3] argv[4] + # + + validate = sys.argv[2] + input_xml_file = sys.argv[3] + stamp_file_path = sys.argv[4] + + cmd = [ + 'xmllint', + '--noout', + '--noent', + '--xinclude', + ] + if validate == 'true': + cmd += ['--postvalid'] + cmd += [input_xml_file] + result = subprocess.run(cmd) + if result.returncode: + return result.returncode + + Path(stamp_file_path).touch(exist_ok=True) + return 0 + +def dblatex(): + # argv[2] argv[3] + # + # Create a PDF file, using dblatex. + + input_xml_file = sys.argv[2] + output_pdf_file = sys.argv[3] + + # For a list of available parameters, see http://dblatex.sourceforge.net/doc/manual/ + dblatex_params = [ + '-P', 'toc.section.depth=2', + '-P', 'paper.type=a4paper', + ] + + cmd = [ + 'dblatex', + ] + dblatex_params + [ + '-o', output_pdf_file, + '--pdf', input_xml_file, + ] + return subprocess.run(cmd).returncode + +def docbook2pdf(): + # argv[2] argv[3] + # + # Create a PDF file, using docbook2pdf. + + input_xml_file = sys.argv[2] + output_pdf_file = sys.argv[3] + + output_dir = os.path.dirname(output_pdf_file) + if not output_dir: + output_dir = '.' + output_basename = os.path.basename(output_pdf_file) + if output_basename.endswith('.pdf'): + output_basename = output_basename[:-4] + xml_file = os.path.join(output_dir, output_basename + '.xml') + + # We need to produce a full examples XML with all of the XIncludes done. + cmd = [ + 'xmllint', + '--xinclude', + '--postvalid', + '--output', xml_file, + input_xml_file, + ] + result = subprocess.run(cmd) + if result.returncode: + return result.returncode + + cmd = [ + 'docbook2pdf', + '--output', output_dir, + xml_file, + ] + return subprocess.run(cmd).returncode + +# Invoked from meson.add_dist_script(). +def dist_doc(): + # argv[2] argv[3] argv[4] argv[5] + # + + # is a distribution directory, relative to MESON_DIST_ROOT. + # is a relative or absolute path in the build directory. + # is a relative or absolute path in the build directory. + # is a relative or absolute path in the build directory. + doc_dist_dir = os.path.join(os.getenv('MESON_DIST_ROOT'), sys.argv[2]) + doc_build_dir = sys.argv[3] + xml_file = sys.argv[4] + pdf_file = sys.argv[5] + + # Create the distribution directory, if it does not exist. + os.makedirs(doc_dist_dir, exist_ok=True) + + # Distribute built XML file with example code inserted. + shutil.copy(xml_file, doc_dist_dir) + + # Distribute built html files. + shutil.copytree(os.path.join(doc_build_dir, 'html'), + os.path.join(doc_dist_dir, 'html'), + copy_function=shutil.copy) + + # If there is an updated PDF file, distribute it. + if os.path.isfile(pdf_file) and \ + os.stat(pdf_file).st_mtime > os.stat(xml_file).st_mtime: + shutil.copy(pdf_file, doc_dist_dir) + else: + print('--- Info: No updated PDF file found.') + + return 0 + +# ----- Main ----- +if subcommand == 'insert_example_code': + sys.exit(insert_example_code()) +if subcommand == 'html': + sys.exit(html()) +if subcommand == 'xmllint': + sys.exit(xmllint()) +if subcommand == 'dblatex': + sys.exit(dblatex()) +if subcommand == 'docbook2pdf': + sys.exit(docbook2pdf()) +if subcommand == 'dist_doc': + sys.exit(dist_doc()) +print(sys.argv[0], ': illegal subcommand,', subcommand) +sys.exit(1) diff --git a/tools/conf_tests/have_exception_ptr.cc b/tools/conf_tests/have_exception_ptr.cc new file mode 100644 index 00000000..25bed7a4 --- /dev/null +++ b/tools/conf_tests/have_exception_ptr.cc @@ -0,0 +1,20 @@ +// Configuration-time test program, used in Meson build. +// Test whether std::exception_ptr, std::current_exception() and +// std::rethrow_exception() are defined. +// Corresponds to the M4 macro LIBXMLXX_CXX_HAS_EXCEPTION_PTR. + +#include + +int main() +{ + try + { + throw "custom error"; + } + catch (...) + { + std::exception_ptr ep = std::current_exception(); + std::rethrow_exception(ep); + } + return 0; +} diff --git a/untracked/README b/untracked/README new file mode 100644 index 00000000..4ec8d650 --- /dev/null +++ b/untracked/README @@ -0,0 +1,35 @@ +untracked/README + +This directory contains files not tracked by a source code control program, +such as git. (This README file is the exception.) + +The files can have one of two origins. + +1. Copied by the mm-common-get command. +2. Generated when libxml++ is built. + +Files of type 2 exist here only if libxml++ is built with maintainer-mode=false, +or the directory comes from a tarball. +Files of both types exist here only if libxml++ is built with Meson, +or the tarball is created with Meson. + +1. Files copied by mm-common-get +-------------------------------- +untracked/docs/doc-install.pl + doc-postprocess.pl + doxygen-extra.css + tagfile-to-devhelp2.xsl +untracked/build_scripts/dist-build-scripts.py + dist-changelog.py + doc-reference.py + +mm-common-get may copy more files, but they are not used by libxml++. + +2. Generated files +------------------ +untracked/docs/reference/libxml++-5.0.devhelp2 + libxml++-5.0.tag + html/* +untracked/docs/manual/libxml++.pdf (only if build-pdf=true) + libxml++.xml + html/* From 936fcda90c2baddbf8cc4a0b3e631763609ef872 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 28 Jun 2020 17:01:56 +0200 Subject: [PATCH 108/240] README: Update with instructions for building libxml++ --- README | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 98 insertions(+), 9 deletions(-) diff --git a/README b/README index 91342da8..0785f4d3 100644 --- a/README +++ b/README @@ -1,9 +1,9 @@ libxml++ -------------- +-------- -This library provides a C++ interface to XML files. It uses libxml2 to access -the XML files, and in order to configure libxml++ you must have both libxml2 and -pkg-config installed. +libxml++ (a.k.a. libxmlplusplus) provides a C++ interface to XML files. It uses +libxml2 to access the XML files, and in order to configure libxml++ you must +have both libxml2 and pkg-config installed. To get the latest version of libxml++, see http://libxmlplusplus.sourceforge.net/ @@ -11,11 +11,100 @@ To contact the developers, send e-mail to the mailing list at http://mail.gnome.org/mailman/listinfo/libxmlplusplus-list We welcome patches, but it helps to discuss them first. -Read the file 'INSTALL' for instructions to compile and install the library. - See the examples directory for example code. -Use pkg-config to discover the necessary include and linker arguments. For -instance, +Use pkg-config to discover the necessary include and linker arguments. For instance, pkg-config libxml++-5.0 --cflags --libs -Ideally you would use PKG_CHECK_MODULES in your configure.ac file. +If you build with Autotools, ideally you would use PKG_CHECK_MODULES in your +configure.ac file. + + +# Building + +Whenever possible, you should use the official binary packages approved by the +supplier of your operating system, such as your Linux distribution. + +## Building on Windows + +See MSVC_NMake/README + +## Building from a release tarball + +Extract the tarball and go to the extracted directory: + $ tar xf libxml++-@LIBXMLXX_VERSION@.tar.xz + $ cd libxml++-@LIBXMLXX_VERSION@ + +It's easiest to build with Meson, if the tarball was made with Meson, +and to build with Autotools, if the tarball was made with Autotools. +Then you don't have to use maintainer-mode. + +How do you know how the tarball was made? If it was made with Meson, +it contains files in untracked/docs/ and other subdirectories +of untracked/. + +### Building from a tarball with Meson + +Don't call the builddir 'build'. There is a directory called 'build' with +files used by Autotools. + + $ meson --prefix /some_directory --libdir lib your_builddir . + $ cd your_builddir + +If the tarball was made with Autotools, you must enable maintainer-mode: + $ meson configure -Dmaintainer-mode=true + +Then, regardless of how the tarball was made: + $ ninja + $ ninja install +You can run the tests like so: + $ ninja test + +### Building from a tarball with Autotools + +If the tarball was made with Autotools: + $ ./configure --prefix=/some_directory +If the tarball was made with Meson, you must enable maintainer-mode: + $ ./autogen.sh --prefix=/some_directory + +Then, regardless of how the tarball was made: + $ make + $ make install +You can build the examples and tests, and run the tests, like so: + $ make check + +## Building from git + +Building from git can be difficult so you should prefer building from +a release tarball unless you need to work on the libxml++ code itself. + +jhbuild can be a good help + https://gitlab.gnome.org/GNOME/jhbuild + https://wiki.gnome.org/Projects/Jhbuild + +### Building from git with Meson + +Maintainer-mode is enabled by default when you build from a git clone. + +Don't call the builddir 'build'. There is a directory called 'build' with +files used by Autotools. + + $ meson --prefix /some_directory --libdir lib your_builddir . + $ cd your_builddir + $ ninja + $ ninja install +You can run the tests like so: + $ ninja test +You can create a tarball like so: + $ ninja dist + +### Building from git with Autotools + + $ ./autogen.sh --prefix=/some_directory + $ make + $ make install +You can build the examples and tests, and run the tests, like so: + $ make check +You can create a tarball like so: + $ make distcheck +or + $ make dist From 79275832e7f8f0ecf0df3e6d8176719d38b523a3 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 8 Jul 2020 16:07:52 +0800 Subject: [PATCH 109/240] NMake Makefiles: Support ARM64 Windows builds This will make the NMake Makefiles capable of building ARM64 binaries of libxml++, which can be used on Windows 10 on ARM systems. --- MSVC_NMake/detectenv-msvc.mak | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/MSVC_NMake/detectenv-msvc.mak b/MSVC_NMake/detectenv-msvc.mak index 8005c35f..e24a5ae1 100644 --- a/MSVC_NMake/detectenv-msvc.mak +++ b/MSVC_NMake/detectenv-msvc.mak @@ -68,6 +68,8 @@ _HASH=^# && ![echo PLAT=Win32 >> vercl.x] \ && ![echo $(_HASH)elif defined(_M_AMD64) >> vercl.x] \ && ![echo PLAT=x64 >> vercl.x] \ + && ![echo $(_HASH)elif defined(_M_ARM64) >> vercl.x] \ + && ![echo PLAT=arm64 >> vercl.x] \ && ![echo $(_HASH)endif >> vercl.x] \ && ![cl -nologo -TC -P vercl.x $(ERRNUL)] !include vercl.i @@ -145,6 +147,8 @@ CFLAGS_ADD_NO_GL = $(CFLAGS_ADD) !if "$(PLAT)" == "x64" LDFLAGS_ARCH = /machine:x64 +!elseif "$(PLAT)" == "arm64" +LDFLAGS_ARCH = /machine:arm64 !else LDFLAGS_ARCH = /machine:x86 !endif From 5c862ffd2bb997b3988f99bdfda8ee16e7639502 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 8 Jul 2020 16:26:39 +0800 Subject: [PATCH 110/240] NMake Makefiles: Fix default include paths Make sure we also look for headers in $(PREFIX)\include. --- MSVC_NMake/config-msvc.mak | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MSVC_NMake/config-msvc.mak b/MSVC_NMake/config-msvc.mak index 0dfe8b9d..94f07efe 100644 --- a/MSVC_NMake/config-msvc.mak +++ b/MSVC_NMake/config-msvc.mak @@ -19,7 +19,10 @@ LIBXMLXX_BASE_CFLAGS = \ /FImsvc_recommended_pragmas.h \ /std:c++17 -LIBXMLXX_EXTRA_INCLUDES = /I$(PREFIX)\include\libxml2 + +LIBXMLXX_EXTRA_INCLUDES = \ + /I$(PREFIX)\include\libxml2 \ + /I$(PREFIX)\include LIBXMLXX_CFLAGS = /DLIBXMLPP_BUILD $(LIBXMLXX_BASE_CFLAGS) $(LIBXMLXX_EXTRA_INCLUDES) LIBXMLXX_EX_CFLAGS = $(LIBXMLXX_BASE_CFLAGS) $(LIBXMLXX_EXTRA_INCLUDES) From 1bec85f71b255464b231c3a50c271d3a1b5b2d94 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 22 Jul 2020 18:07:00 +0800 Subject: [PATCH 111/240] NMake Makefiles: Fix build from tarballs Update the rules so that we won't attempt to unnecessarily generate libxml++config.h and libxml++.rc in our builds, and make sure that we do indeed generate them with the version info if generating them becomes necessary. Also streamline this process so that it will be part of the 'all' target. --- MSVC_NMake/Makefile.vc | 1 + MSVC_NMake/generate-msvc.mak | 40 ++++++++++++++++++++---------------- 2 files changed, 23 insertions(+), 18 deletions(-) diff --git a/MSVC_NMake/Makefile.vc b/MSVC_NMake/Makefile.vc index 75d57941..bed3c95e 100644 --- a/MSVC_NMake/Makefile.vc +++ b/MSVC_NMake/Makefile.vc @@ -34,6 +34,7 @@ all: $(LIBXMLXX_LIB) libxmlxx_examples all-build-info !ifdef GENERATE_VERSIONED_FILES !include pkg-ver.mak +DO_REAL_GEN = 1 !endif tests: $(libxmlxx_tests) all-build-info diff --git a/MSVC_NMake/generate-msvc.mak b/MSVC_NMake/generate-msvc.mak index 7de46117..80b6d741 100644 --- a/MSVC_NMake/generate-msvc.mak +++ b/MSVC_NMake/generate-msvc.mak @@ -6,26 +6,30 @@ # Generate pre-generated resources and configuration headers (builds from GIT) prep-git-build: pkg-ver.mak -libxml++\libxml++.rc: pkg-ver.mak libxml++\libxml++.rc.in libxml++\libxml++config.h - @echo Generating $@... - @copy "$@.in" "$@" - @$(PERL) -pi.bak -e "s/\@LIBXMLXX_MAJOR_VERSION\@/$(PKG_MAJOR_VERSION)/g" $@ - @$(PERL) -pi.bak -e "s/\@LIBXMLXX_MINOR_VERSION\@/$(PKG_MINOR_VERSION)/g" $@ - @$(PERL) -pi.bak -e "s/\@LIBXMLXX_MICRO_VERSION\@/$(PKG_MICRO_VERSION)/g" $@ - @$(PERL) -pi.bak -e "s/\@PACKAGE_VERSION\@/$(PKG_MAJOR_VERSION).$(PKG_MINOR_VERSION).$(PKG_MICRO_VERSION)/g" $@ - @$(PERL) -pi.bak -e "s/\@PACKAGE_NAME\@/libxml++-$(PKG_MAJOR_VERSION).$(PKG_MINOR_VERSION)/g" $@ - @del $@.bak +libxml++\libxml++.rc: ..\configure.ac libxml++\libxml++.rc.in libxml++\libxml++config.h + @if not "$(DO_REAL_GEN)" == "1" if exist pkg-ver.mak del pkg-ver.mak + @if not exist pkg-ver.mak $(MAKE) /f Makefile.vc CFG=$(CFG) prep-git-build + @if "$(DO_REAL_GEN)" == "1" echo Generating $@... + @if "$(DO_REAL_GEN)" == "1" copy "$@.in" "$@" + @if "$(DO_REAL_GEN)" == "1" $(PERL) -pi.bak -e "s/\@LIBXMLXX_MAJOR_VERSION\@/$(PKG_MAJOR_VERSION)/g" $@ + @if "$(DO_REAL_GEN)" == "1" $(PERL) -pi.bak -e "s/\@LIBXMLXX_MINOR_VERSION\@/$(PKG_MINOR_VERSION)/g" $@ + @if "$(DO_REAL_GEN)" == "1" $(PERL) -pi.bak -e "s/\@LIBXMLXX_MICRO_VERSION\@/$(PKG_MICRO_VERSION)/g" $@ + @if "$(DO_REAL_GEN)" == "1" $(PERL) -pi.bak -e "s/\@PACKAGE_VERSION\@/$(PKG_MAJOR_VERSION).$(PKG_MINOR_VERSION).$(PKG_MICRO_VERSION)/g" $@ + @if "$(DO_REAL_GEN)" == "1" $(PERL) -pi.bak -e "s/\@PACKAGE_NAME\@/libxml++-$(PKG_MAJOR_VERSION).$(PKG_MINOR_VERSION)/g" $@ + @if "$(DO_REAL_GEN)" == "1" del $@.bak # You may change LIBXMLXX_DISABLE_DEPRECATED if you know what you are doing -libxml++\libxml++config.h: pkg-ver.mak ..\libxml++config.h.in - @echo Generating $@... - @copy "..\$(@F).in" "$@" - @$(PERL) -pi.bak -e "s/\#undef LIBXMLXX_DISABLE_DEPRECATED/\/\* \#undef LIBXMLXX_DISABLE_DEPRECATED \*\//g" $@ - @$(PERL) -pi.bak -e "s/\#undef LIBXMLXX_HAVE_EXCEPTION_PTR/\#define LIBXMLXX_HAVE_EXCEPTION_PTR 1/g" $@ - @$(PERL) -pi.bak -e "s/\#undef LIBXMLXX_MAJOR_VERSION/\#define LIBXMLXX_MAJOR_VERSION $(PKG_MAJOR_VERSION)/g" $@ - @$(PERL) -pi.bak -e "s/\#undef LIBXMLXX_MINOR_VERSION/\#define LIBXMLXX_MINOR_VERSION $(PKG_MINOR_VERSION)/g" $@ - @$(PERL) -pi.bak -e "s/\#undef LIBXMLXX_MICRO_VERSION/\#define LIBXMLXX_MICRO_VERSION $(PKG_MICRO_VERSION)/g" $@ - @del $@.bak +libxml++\libxml++config.h: ..\configure.ac ..\libxml++config.h.in + @if not "$(DO_REAL_GEN)" == "1" if exist pkg-ver.mak del pkg-ver.mak + @if not exist pkg-ver.mak $(MAKE) /f Makefile.vc CFG=$(CFG) prep-git-build + @if "$(DO_REAL_GEN)" == "1" echo Generating $@... + @if "$(DO_REAL_GEN)" == "1" copy "..\$(@F).in" "$@" + @if "$(DO_REAL_GEN)" == "1" $(PERL) -pi.bak -e "s/\#undef LIBXMLXX_DISABLE_DEPRECATED/\/\* \#undef LIBXMLXX_DISABLE_DEPRECATED \*\//g" $@ + @if "$(DO_REAL_GEN)" == "1" $(PERL) -pi.bak -e "s/\#undef LIBXMLXX_HAVE_EXCEPTION_PTR/\#define LIBXMLXX_HAVE_EXCEPTION_PTR 1/g" $@ + @if "$(DO_REAL_GEN)" == "1" $(PERL) -pi.bak -e "s/\#undef LIBXMLXX_MAJOR_VERSION/\#define LIBXMLXX_MAJOR_VERSION $(PKG_MAJOR_VERSION)/g" $@ + @if "$(DO_REAL_GEN)" == "1" $(PERL) -pi.bak -e "s/\#undef LIBXMLXX_MINOR_VERSION/\#define LIBXMLXX_MINOR_VERSION $(PKG_MINOR_VERSION)/g" $@ + @if "$(DO_REAL_GEN)" == "1" $(PERL) -pi.bak -e "s/\#undef LIBXMLXX_MICRO_VERSION/\#define LIBXMLXX_MICRO_VERSION $(PKG_MICRO_VERSION)/g" $@ + @if "$(DO_REAL_GEN)" == "1" del $@.bak pkg-ver.mak: ..\configure.ac @echo Generating version info Makefile Snippet... From 86b59fda4f0bf297c66d31426793afc922708d4c Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Thu, 23 Jul 2020 16:12:02 +0800 Subject: [PATCH 112/240] NMake Makefiles: Use Meson-style DLL and .lib naming if requested To make things more consistent and less prone to confusion, if 'USE_MESON_LIBS' is specified in the NMake command line, build the DLLs and .lib's that are named like the Meson counterparts. Binaries built with Meson+Visual Studio and the ones that are built via NMake using 'USE_MESON_LIBS' are interchangeable, provided that they are built with the same Visual Studio version. Also, introduce the 'USE_COMPAT_LIBS' option as well, so that we are more consistent with the other active branches of libxml++. --- MSVC_NMake/config-msvc.mak | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/MSVC_NMake/config-msvc.mak b/MSVC_NMake/config-msvc.mak index 94f07efe..1f6f746f 100644 --- a/MSVC_NMake/config-msvc.mak +++ b/MSVC_NMake/config-msvc.mak @@ -30,7 +30,23 @@ LIBXMLXX_EX_CFLAGS = $(LIBXMLXX_BASE_CFLAGS) $(LIBXMLXX_EXTRA_INCLUDES) # We build xml++-vc$(VSVER_LIB)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).dll or # xml++-vc$(VSVER_LIB)-d-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).dll at least -LIBXMLXX_DLL = vs$(VSVER)\$(CFG)\$(PLAT)\xml++-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).dll -LIBXMLXX_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\xml++-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION).lib +!if "$(USE_COMPAT_LIBS)" != "" +VSVER_LIB = $(VSVER)0 +MSVC_VSVER_LIB = +!else +VSVER_LIB = $(PDBVER)$(VSVER_SUFFIX) +MSVC_VSVER_LIB = -vc$(VSVER_LIB) +!endif + +!ifdef USE_MESON_LIBS +LIBXMLXX_LIBNAME = xml++$(MSVC_VSVER_LIB)-$(LIBXMLXX_MAJOR_VERSION).$(LIBXMLXX_MINOR_VERSION) +LIBXMLXX_DLLNAME = $(LIBXMLXX_LIBNAME)-1 +!else +LIBXMLXX_LIBNAME = xml++-vc$(VSVER_LIB)$(DEBUG_SUFFIX)-$(LIBXMLXX_MAJOR_VERSION)_$(LIBXMLXX_MINOR_VERSION) +LIBXMLXX_DLLNAME = $(LIBXMLXX_LIBNAME) +!endif + +LIBXMLXX_DLL = vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBXMLXX_DLLNAME).dll +LIBXMLXX_LIB = vs$(VSVER)\$(CFG)\$(PLAT)\$(LIBXMLXX_LIBNAME).lib LIBXML2_LIBS = libxml2.lib From f5d6165d93ae13dcf94cc7db5919233db577da22 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 2 Oct 2020 13:17:17 +0200 Subject: [PATCH 113/240] Meson build: Fix versioning on macOS See libsigcplusplus, pull request 65 --- libxml++/meson.build | 3 ++- meson.build | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libxml++/meson.build b/libxml++/meson.build index 2183157c..e73c4f2f 100644 --- a/libxml++/meson.build +++ b/libxml++/meson.build @@ -1,7 +1,7 @@ # libxml++ # Input: xmlxx_build_dep, xmlxx_pcname, xmlxx_libversion, xmlxx_api_version, -# install_includedir, xmlxx_rc, xmlxx_libname +# install_includedir, xmlxx_rc, xmlxx_libname, macos_darwin_versions # Output: source_h_files, xmlxx_dep # There are no built source files in libxml++-5.0. @@ -106,6 +106,7 @@ xmlxx_library = library(xmlxx_libname, source_cc_files, extra_xmlxx_objects, version: xmlxx_libversion, + darwin_versions: macos_darwin_versions, include_directories: extra_include_dirs, cpp_args: xmlxx_cpp_args, dependencies: xmlxx_build_dep, diff --git a/meson.build b/meson.build index e591e28b..d1bc8c59 100644 --- a/meson.build +++ b/meson.build @@ -29,7 +29,12 @@ libtool_soversion = [1, 0, 0] xmlxx_libversion = '@0@.@1@.@2@'.format( libtool_soversion[0] - libtool_soversion[2], libtool_soversion[2], - libtool_soversion[1]) + libtool_soversion[1] +) +macos_darwin_versions = [ + libtool_soversion[0] + 1, + '@0@.@1@'.format(libtool_soversion[0] + 1, libtool_soversion[1]) +] # Use these instead of meson.source_root() and meson.build_root() in subdirectories. # source_root() and build_root() are not useful, if this is a subproject. From f611c14c1f023407e5856891a2ffd7cfebaa5ea5 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 4 Oct 2020 12:12:54 +0200 Subject: [PATCH 114/240] Docs: Change libxml++ webpage mentions to GitHub Change libxmlplusplus.sourceforge.net to libxmlplusplus.github.io/libxmlplusplus. --- AUTHORS | 2 +- README | 2 +- docs/index.md | 5 +---- docs/manual/libxml++_without_code.xml | 4 ++-- examples/dom_parse_entities/example.xml | 2 +- examples/sax_parser/example.xml | 2 +- examples/sax_parser_entities/example.xml | 2 +- libxml++.pc.in | 2 +- libxml++/libxml++.h | 3 ++- libxmlplusplus.doap | 2 +- 10 files changed, 12 insertions(+), 14 deletions(-) diff --git a/AUTHORS b/AUTHORS index e3c5a395..25a25463 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,5 +1,5 @@ Please do not email us directly - use the mailing list. -See http://libxmlplusplus.sourceforge.net +See https://libxmlplusplus.github.io/libxmlplusplus Maintainer ---------- diff --git a/README b/README index 0785f4d3..d037f78f 100644 --- a/README +++ b/README @@ -6,7 +6,7 @@ libxml2 to access the XML files, and in order to configure libxml++ you must have both libxml2 and pkg-config installed. To get the latest version of libxml++, see -http://libxmlplusplus.sourceforge.net/ +https://libxmlplusplus.github.io/libxmlplusplus/ To contact the developers, send e-mail to the mailing list at http://mail.gnome.org/mailman/listinfo/libxmlplusplus-list We welcome patches, but it helps to discuss them first. diff --git a/docs/index.md b/docs/index.md index 81e832f7..3488919d 100644 --- a/docs/index.md +++ b/docs/index.md @@ -19,12 +19,9 @@ You can download libxml++ from [here](http://ftp.gnome.org/pub/GNOME/sources/lib ## Required Libraries * [libxml2](http://www.xmlsoft.org/) -* [glibmm-2.4](http://www.gtkmm.org/) (or a subset of it containing at least Glib::ustring) ## Documentation -The short [reference documentation](http://library.gnome.org/devel/libxml++-tutorial/stable/) - The short [manual](http://library.gnome.org/devel/libxml++-tutorial/stable/) gives an overview of the libxml++ API. You can also browse online the [reference documentation](http://library.gnome.org/devel/libxml++/stable/). ## Development @@ -35,4 +32,4 @@ Bugs and patches are tracked in GitHub's [issue tracker](https://github.com/libx ## Contact -Please use the [libxmlplusplus-list mailing list](http://mail.gnome.org/mailman/listinfo/libxmlplusplus-list) or GitLab. Please do not just email the developers directly. +Please use the [libxmlplusplus-list mailing list](http://mail.gnome.org/mailman/listinfo/libxmlplusplus-list) or GitHub. Please do not just email the developers directly. diff --git a/docs/manual/libxml++_without_code.xml b/docs/manual/libxml++_without_code.xml index 525f6c08..dcb966cb 100644 --- a/docs/manual/libxml++_without_code.xml +++ b/docs/manual/libxml++_without_code.xml @@ -48,8 +48,8 @@ url="http://www.gnome.org">GNOME project, of which libxml++ is a part. To check that you have the libxml++ development packages installed, and that your environment is working properly, try pkg-config libxml++-5.0 --modversion. - Links for downloading and more documentation can be found at libxmlplusplus.sourceforge.net. + Links for downloading and more documentation can be found at + libxmlplusplus.github.io/libxmlplusplus. libxml++ is licensed under the LGPL, which allows its use via dynamic linking in both open source and closed-source software. The underlying libxml2 library uses the even more generous MIT licence. diff --git a/examples/dom_parse_entities/example.xml b/examples/dom_parse_entities/example.xml index 93d4a4c9..cb949986 100644 --- a/examples/dom_parse_entities/example.xml +++ b/examples/dom_parse_entities/example.xml @@ -1,7 +1,7 @@ - + diff --git a/examples/sax_parser/example.xml b/examples/sax_parser/example.xml index daeb29bf..a7cba9ec 100644 --- a/examples/sax_parser/example.xml +++ b/examples/sax_parser/example.xml @@ -1,6 +1,6 @@ + ]> diff --git a/examples/sax_parser_entities/example.xml b/examples/sax_parser_entities/example.xml index daeb29bf..a7cba9ec 100644 --- a/examples/sax_parser_entities/example.xml +++ b/examples/sax_parser_entities/example.xml @@ -1,6 +1,6 @@ + ]> diff --git a/libxml++.pc.in b/libxml++.pc.in index b5348ba5..6c219ae8 100644 --- a/libxml++.pc.in +++ b/libxml++.pc.in @@ -13,7 +13,7 @@ htmlrefpub=http://library.gnome.org/devel/@PACKAGE_TARNAME@/unstable/ Name: libxml++ Description: C++ wrapper for libxml Version: @PACKAGE_VERSION@ -URL: http://libxmlplusplus.sourceforge.net/ +URL: https://libxmlplusplus.github.io/libxmlplusplus/ Requires: @LIBXMLXX_MODULES@ Libs: -L${libdir} -lxml++@MSVC_TOOLSET_VER@-@LIBXMLXX_API_VERSION@ @LIBXML2_LIB_NO_PKGCONFIG@ Cflags: -I${includedir}/@LIBXMLXX_MODULE_NAME@ -I${libdir}/@LIBXMLXX_MODULE_NAME@/include diff --git a/libxml++/libxml++.h b/libxml++/libxml++.h index b337d09e..228195f2 100644 --- a/libxml++/libxml++.h +++ b/libxml++/libxml++.h @@ -14,7 +14,8 @@ * libxml++ is a C++ wrapper for the libxml2 XML parser and builder library. It presents a * simple C++-like API that can achieve common tasks with less code. * - * See also the libxml++ Tutorial and the libxml++ website. + * See also the libxml++ Tutorial + * and the libxml++ website. * * @section features Features * diff --git a/libxmlplusplus.doap b/libxmlplusplus.doap index 7caaa81c..d3f3d637 100644 --- a/libxmlplusplus.doap +++ b/libxmlplusplus.doap @@ -9,7 +9,7 @@ libxmlplusplus (aka libxml++) is a C++ wrapper for the libxml2 XML parser library. It has SAX and DOM-like APIs, but does not attempt to conform exactly to the DOM specification. Its API is simpler than the underlying libxml2 C API. - + From 17ea17d00d3df53e86980bbaf8b0830a8faa3941 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 21 Dec 2020 18:22:48 +0100 Subject: [PATCH 115/240] 5.0.0 --- NEWS | 21 +++++++++++++++++++++ configure.ac | 2 +- meson.build | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 4b9f719e..e19cedcc 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,24 @@ +5.0.0 (stable): + +This is the first stable release in the libxml++-5.0 ABI series. +It is parallel-installable with the libxml++-2.6, libxml++-3.0 +and libxml++-4.0 ABIs. + +The tarball for 5.0.0 has been created with 'meson dist'. +If you build with Autotools from the tarball, please read +the relevant part of the README file. + +Build: +* Add NMake Makefiles + Remove Visual Studio 2010 projects + (Chun-wei Fan) Pull request #10 +* Use __declspec(dllexport) when building on Visual Studio + Stop using gendef.exe + (Chun-wei Fan) Pull request #15 +* Add support for building with Meson + (Kjell Ahlstedt, Chun-wei Fan) Pull request #16, #17, issue #19 + + 4.9.1 (unstable): * Change ABI name from libxml++-4.0 to libxml++-5.0 diff --git a/configure.ac b/configure.ac index 89c73c82..82123322 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [4.9.1], +AC_INIT([libxml++], [5.0.0], [https://github.com/libxmlplusplus/libxmlplusplus/issues], [libxml++], [https://libxmlplusplus.github.io/libxmlplusplus/]) AC_PREREQ([2.59]) diff --git a/meson.build b/meson.build index d1bc8c59..ab35ba34 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ # This file is part of libxml++. project('libxml++', 'cpp', - version: '4.9.1', + version: '5.0.0', license: 'LGPLv2.1+', default_options: [ 'cpp_std=c++17' From bbc31d7646c7727c6487e01d37835c239a7fd0ad Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 23 Dec 2020 13:47:43 +0100 Subject: [PATCH 116/240] docs/index.md: Describe the different libxml++ ABIs The changes are automatically published at libxmlplusplus.github.io/libxmlplusplus. See issue #20 --- docs/index.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/index.md b/docs/index.md index 3488919d..199b7c66 100644 --- a/docs/index.md +++ b/docs/index.md @@ -12,6 +12,19 @@ libxml++ is a C++ wrapper for the [libxml](http://www.xmlsoft.org) XML parser li Libxml++ is released under the [LGPL](http://www.gnu.org/licenses/lgpl.html#TOC1) version 2 or above +## ABI Versions + +There are several ABI (Application Binary Interface) versions of libxml++. +They can be installed in parallel. + +libxml++-2.6: Old ABI, not recommended for new applications. Uses Glib::ustring from the glibmm-2.4 ABI. + +libxml++-3.0: Uses Glib::ustring from the glibmm-2.4 ABI, therefore has methods that handle UTF-8 characters rather than raw bytes. + +libxml++-4.0: Uses Glib::ustring from the newer glibmm-2.68 ABI, therefore has methods that handle UTF-8 characters rather than raw bytes. + +libxml++-5.0: Does not depend on glibmm, is not as good at handling UTF-8 strings, but has fewer dependencies. + ## Download You can download libxml++ from [here](http://ftp.gnome.org/pub/GNOME/sources/libxml++/). @@ -19,6 +32,8 @@ You can download libxml++ from [here](http://ftp.gnome.org/pub/GNOME/sources/lib ## Required Libraries * [libxml2](http://www.xmlsoft.org/) +* libxml++-2.6 and libxml++-3.0: [glibmm-2.4](https://developer.gnome.org/glibmm/2.64/) +* libxml++-4.0: [glibmm-2.68](https://developer.gnome.org/glibmm/2.68/) ## Documentation From a680b5c05bcaec5ff33e4b37f8879df1576fee95 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Sun, 5 Jan 2020 17:46:42 +0100 Subject: [PATCH 117/240] Add GitHub Actions for CI Based on the ones used by libsigcplusplus. --- .github/workflows/autotools-clang-10.yml | 25 ++++++++++++++++++++++++ .github/workflows/autotools-clang-5.yml | 25 ++++++++++++++++++++++++ .github/workflows/autotools-clang-6.yml | 25 ++++++++++++++++++++++++ .github/workflows/autotools-clang-7.yml | 25 ++++++++++++++++++++++++ .github/workflows/autotools-clang-8.yml | 25 ++++++++++++++++++++++++ .github/workflows/autotools-clang-9.yml | 25 ++++++++++++++++++++++++ .github/workflows/autotools-gcc-7.yml | 25 ++++++++++++++++++++++++ .github/workflows/autotools-gcc-8.yml | 25 ++++++++++++++++++++++++ .github/workflows/autotools-gcc-9.yml | 25 ++++++++++++++++++++++++ 9 files changed, 225 insertions(+) create mode 100644 .github/workflows/autotools-clang-10.yml create mode 100644 .github/workflows/autotools-clang-5.yml create mode 100644 .github/workflows/autotools-clang-6.yml create mode 100644 .github/workflows/autotools-clang-7.yml create mode 100644 .github/workflows/autotools-clang-8.yml create mode 100644 .github/workflows/autotools-clang-9.yml create mode 100644 .github/workflows/autotools-gcc-7.yml create mode 100644 .github/workflows/autotools-gcc-8.yml create mode 100644 .github/workflows/autotools-gcc-9.yml diff --git a/.github/workflows/autotools-clang-10.yml b/.github/workflows/autotools-clang-10.yml new file mode 100644 index 00000000..eaba0e3f --- /dev/null +++ b/.github/workflows/autotools-clang-10.yml @@ -0,0 +1,25 @@ +name: "CI: autotools: clang 10" + +on: [push] + +jobs: + build: + + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v1 + - name: Build + run: | + sudo apt update + sudo apt install libxml2-dev mm-common clang-10 + export CXX=clang++-10 + ./autogen.sh --enable-warnings=fatal + make + - name: Test + run: make check + - name: Distcheck + run: | + # distcheck runs configure again so we need to specify CXX again. + export CXX=clang++-10 + make distcheck diff --git a/.github/workflows/autotools-clang-5.yml b/.github/workflows/autotools-clang-5.yml new file mode 100644 index 00000000..772a1505 --- /dev/null +++ b/.github/workflows/autotools-clang-5.yml @@ -0,0 +1,25 @@ +name: "CI: autotools: clang 5" + +on: [push] + +jobs: + build: + + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v1 + - name: Build + run: | + sudo apt update + sudo apt install libxml2-dev mm-common clang-5.0 + export CXX=clang++-5.0 + ./autogen.sh --enable-warnings=fatal + make + - name: Test + run: make check + - name: Distcheck + run: | + # distcheck runs configure again so we need to specify CXX again. + export CXX=clang++-5.0 + make distcheck diff --git a/.github/workflows/autotools-clang-6.yml b/.github/workflows/autotools-clang-6.yml new file mode 100644 index 00000000..8850b66d --- /dev/null +++ b/.github/workflows/autotools-clang-6.yml @@ -0,0 +1,25 @@ +name: "CI: autotools: clang 6" + +on: [push] + +jobs: + build: + + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v1 + - name: Build + run: | + sudo apt update + sudo apt install libxml2-dev mm-common clang-6.0 + export CXX=clang++-6.0 + ./autogen.sh --enable-warnings=fatal + make + - name: Test + run: make check + - name: Distcheck + run: | + # distcheck runs configure again so we need to specify CXX again. + export CXX=clang++-6.0 + make distcheck diff --git a/.github/workflows/autotools-clang-7.yml b/.github/workflows/autotools-clang-7.yml new file mode 100644 index 00000000..15e1fd1f --- /dev/null +++ b/.github/workflows/autotools-clang-7.yml @@ -0,0 +1,25 @@ +name: "CI: autotools: clang 7" + +on: [push] + +jobs: + build: + + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v1 + - name: Build + run: | + sudo apt update + sudo apt install libxml2-dev mm-common clang-7 + export CXX=clang++-7 + ./autogen.sh --enable-warnings=fatal + make + - name: Test + run: make check + - name: Distcheck + run: | + # distcheck runs configure again so we need to specify CXX again. + export CXX=clang++-7 + make distcheck diff --git a/.github/workflows/autotools-clang-8.yml b/.github/workflows/autotools-clang-8.yml new file mode 100644 index 00000000..eb1507f4 --- /dev/null +++ b/.github/workflows/autotools-clang-8.yml @@ -0,0 +1,25 @@ +name: "CI: autotools: clang 8" + +on: [push] + +jobs: + build: + + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v1 + - name: Build + run: | + sudo apt update + sudo apt install libxml2-dev mm-common clang-8 + export CXX=clang++-8 + ./autogen.sh --enable-warnings=fatal + make + - name: Test + run: make check + - name: Distcheck + run: | + # distcheck runs configure again so we need to specify CXX again. + export CXX=clang++-8 + make distcheck diff --git a/.github/workflows/autotools-clang-9.yml b/.github/workflows/autotools-clang-9.yml new file mode 100644 index 00000000..41048a5e --- /dev/null +++ b/.github/workflows/autotools-clang-9.yml @@ -0,0 +1,25 @@ +name: "CI: autotools: clang 9" + +on: [push] + +jobs: + build: + + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v1 + - name: Build + run: | + sudo apt update + sudo apt install libxml2-dev mm-common clang-9 + export CXX=clang++-9 + ./autogen.sh --enable-warnings=fatal + make + - name: Test + run: make check + - name: Distcheck + run: | + # distcheck runs configure again so we need to specify CXX again. + export CXX=clang++-9 + make distcheck diff --git a/.github/workflows/autotools-gcc-7.yml b/.github/workflows/autotools-gcc-7.yml new file mode 100644 index 00000000..ff3d2cbf --- /dev/null +++ b/.github/workflows/autotools-gcc-7.yml @@ -0,0 +1,25 @@ +name: "CI: autotools: gcc 7" + +on: [push] + +jobs: + build: + + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v1 + - name: Build + run: | + sudo apt update + sudo apt install libxml2-dev mm-common g++-7 + export CXX=g++-7 + ./autogen.sh --enable-warnings=fatal + make + - name: Test + run: make check + - name: Distcheck + run: | + # distcheck runs configure again so we need to specify CXX again. + export CXX=g++-7 + make distcheck diff --git a/.github/workflows/autotools-gcc-8.yml b/.github/workflows/autotools-gcc-8.yml new file mode 100644 index 00000000..b5ada569 --- /dev/null +++ b/.github/workflows/autotools-gcc-8.yml @@ -0,0 +1,25 @@ +name: "CI: autotools: gcc 8" + +on: [push] + +jobs: + build: + + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v1 + - name: Build + run: | + sudo apt update + sudo apt install libxml2-dev mm-common g++-8 + export CXX=g++-8 + ./autogen.sh --enable-warnings=fatal + make + - name: Test + run: make check + - name: Distcheck + run: | + # distcheck runs configure again so we need to specify CXX again. + export CXX=g++-8 + make distcheck diff --git a/.github/workflows/autotools-gcc-9.yml b/.github/workflows/autotools-gcc-9.yml new file mode 100644 index 00000000..e3a20864 --- /dev/null +++ b/.github/workflows/autotools-gcc-9.yml @@ -0,0 +1,25 @@ +name: "CI: autotools: gcc 9" + +on: [push] + +jobs: + build: + + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v1 + - name: Build + run: | + sudo apt update + sudo apt install libxml2-dev mm-common g++-9 + export CXX=g++-9 + ./autogen.sh --enable-warnings=fatal + make + - name: Test + run: make check + - name: Distcheck + run: | + # distcheck runs configure again so we need to specify CXX again. + export CXX=g++-9 + make distcheck From 4c61dc05798ce7220c4ccdefe4d7497f1e0cbe93 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 9 Mar 2021 17:18:39 +0800 Subject: [PATCH 118/240] libxml++config.h.*: Don't dllimport on MinGW This will fix warnings when building items using libxml++ with MinGW/GCC. Please see: https://gitlab.gnome.org/GNOME/gtkmm/-/issues/90 --- libxml++config.h.in | 4 +++- libxml++config.h.meson | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libxml++config.h.in b/libxml++config.h.in index 1422cc4d..cfa46e4d 100755 --- a/libxml++config.h.in +++ b/libxml++config.h.in @@ -24,8 +24,10 @@ #ifdef LIBXMLPP_DLL #ifdef LIBXMLPP_BUILD #define LIBXMLPP_API __declspec(dllexport) - #else + #elif !defined (__GNUC__) #define LIBXMLPP_API __declspec(dllimport) + #else /* don't dllimport classes/methods on GCC/MinGW */ + #define LIBXMLPP_API #endif /* LIBXMLPP_BUILD - DLL */ #else /* Build a static library or a non-Windows library*/ diff --git a/libxml++config.h.meson b/libxml++config.h.meson index e5a6870f..2f0264f0 100755 --- a/libxml++config.h.meson +++ b/libxml++config.h.meson @@ -24,8 +24,10 @@ #ifdef LIBXMLPP_DLL #ifdef LIBXMLPP_BUILD #define LIBXMLPP_API __declspec(dllexport) - #else + #elif !defined (__GNUC__) #define LIBXMLPP_API __declspec(dllimport) + #else /* don't dllimport classes/methods on GCC/MinGW */ + #define LIBXMLPP_API #endif /* LIBXMLPP_BUILD - DLL */ #else /* Build a static library or a non-Windows library*/ From b500757449aa3b6303c1ca53c598398b33ed6034 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 26 Mar 2021 13:38:23 +0100 Subject: [PATCH 119/240] docs/reference/Doxyfile.in: Remove obsolete entries --- docs/reference/Doxyfile.in | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in index 45d9368f..9d40dbca 100644 --- a/docs/reference/Doxyfile.in +++ b/docs/reference/Doxyfile.in @@ -34,7 +34,6 @@ SEPARATE_MEMBER_PAGES = NO TAB_SIZE = 8 ALIASES = "newin{2}=\xrefitem since_\1_\2 \"Since @PACKAGE_NAME@ \1.\2\" \"New API in @PACKAGE_NAME@ \1.\2\"" \ "newin{3}=\xrefitem since_\1_\2_\3 \"Since @PACKAGE_NAME@ \1.\2.\3\" \"New API in @PACKAGE_NAME@ \1.\2.\3\"" -TCL_SUBST = OPTIMIZE_OUTPUT_FOR_C = NO OPTIMIZE_OUTPUT_JAVA = NO OPTIMIZE_FOR_FORTRAN = NO @@ -217,7 +216,7 @@ LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO -PAPER_TYPE = a4wide +PAPER_TYPE = a4 EXTRA_PACKAGES = LATEX_HEADER = LATEX_FOOTER = From 03130eca9d10ceab6fa0a4c31ccd7a86af1fa938 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 26 Mar 2021 13:48:59 +0100 Subject: [PATCH 120/240] Meson build: Make it possible to use libxml++ as a subproject mm-common can be a subproject of libxml++. libxml2 can't be a subproject because it can't be built with Meson. --- Makefile.am | 1 + docs/reference/meson.build | 8 ++++---- examples/meson.build | 4 ++-- libxml++/meson.build | 9 +++++---- meson.build | 16 +++++++++++++++- subprojects/mm-common.wrap | 9 +++++++++ tests/meson.build | 4 ++-- 7 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 subprojects/mm-common.wrap diff --git a/Makefile.am b/Makefile.am index ede276a8..ca3334b0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,6 +34,7 @@ EXTRA_DIST = \ docs/reference/meson.build \ examples/meson.build \ libxml++/meson.build \ + subprojects/mm-common.wrap \ tests/meson.build \ tools/build_scripts/tutorial-custom-cmd.py \ tools/conf_tests/have_exception_ptr.cc \ diff --git a/docs/reference/meson.build b/docs/reference/meson.build index ace88053..62256d0b 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -3,7 +3,7 @@ # Input: project_build_root, project_source_root, xmlxx_pcname, # xmlxx_api_version, build_documentation, source_h_files, # install_datadir, python3, doc_reference_py -# Output: install_docdir, install_devhelpdir, book_name +# Output: install_docdir, install_devhelpdir, book_name, tag_file # There are no built source files in libxml++-5.0. @@ -15,9 +15,9 @@ docinstall_flags = [] foreach module : tag_file_modules depmod = dependency(module, required: false) if depmod.found() - doxytagfile = depmod.get_pkgconfig_variable('doxytagfile') - htmlrefpub = depmod.get_pkgconfig_variable('htmlrefpub', default: '') - htmlrefdir = depmod.get_pkgconfig_variable('htmlrefdir', default: '') + doxytagfile = depmod.get_variable(pkgconfig: 'doxytagfile', internal: 'doxytagfile') + htmlrefpub = depmod.get_variable(pkgconfig: 'htmlrefpub', internal: 'htmlrefpub', default_value: '') + htmlrefdir = depmod.get_variable(pkgconfig: 'htmlrefdir', internal: 'htmlrefdir', default_value: '') if htmlrefpub == '' htmlrefpub = htmlrefdir elif htmlrefdir == '' diff --git a/examples/meson.build b/examples/meson.build index 83ea5e7a..2a1928b4 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -1,6 +1,6 @@ # examples -# Input: xmlxx_dep, build_examples +# Input: xmlxx_own_dep, build_examples # Output: - example_programs = [ @@ -37,7 +37,7 @@ foreach ex : example_programs endforeach exe_file = executable(ex_name, ex_sources, - dependencies: xmlxx_dep, + dependencies: xmlxx_own_dep, gui_app: false, build_by_default: build_examples ) diff --git a/libxml++/meson.build b/libxml++/meson.build index e73c4f2f..a3960ff9 100644 --- a/libxml++/meson.build +++ b/libxml++/meson.build @@ -2,7 +2,7 @@ # Input: xmlxx_build_dep, xmlxx_pcname, xmlxx_libversion, xmlxx_api_version, # install_includedir, xmlxx_rc, xmlxx_libname, macos_darwin_versions -# Output: source_h_files, xmlxx_dep +# Output: source_h_files, xmlxx_own_dep # There are no built source files in libxml++-5.0. @@ -107,15 +107,16 @@ xmlxx_library = library(xmlxx_libname, extra_xmlxx_objects, version: xmlxx_libversion, darwin_versions: macos_darwin_versions, + implicit_include_directories: false, include_directories: extra_include_dirs, cpp_args: xmlxx_cpp_args, dependencies: xmlxx_build_dep, install: true, ) -# This is useful in the main project when libxml++ is used as a subproject. -# It's also used when building example programs and test programs. -xmlxx_dep = declare_dependency( +# This is used when building example programs and test programs. +# It's also a part of xmlxx_dep, when libxml++ is a subproject. +xmlxx_own_dep = declare_dependency( link_with: xmlxx_library, include_directories: extra_include_dirs, dependencies: xmlxx_build_dep diff --git a/meson.build b/meson.build index ab35ba34..86b0c704 100644 --- a/meson.build +++ b/meson.build @@ -6,7 +6,8 @@ project('libxml++', 'cpp', default_options: [ 'cpp_std=c++17' ], - meson_version: '>= 0.50.0', # required for python3.path() + meson_version: '>= 0.54.0', # required for meson.override_dependency() + # and dep.get_variable(internal:) ) xmlxx_api_version = '5.0' @@ -315,6 +316,19 @@ if not meson.is_subproject() project_source_root, 'untracked' / 'build_scripts', ) +else + # This is a subproject. + xmlxx_dep = declare_dependency( + dependencies: xmlxx_own_dep, + variables: { + 'doxytagfile': tag_file.full_path(), + 'htmlrefdir': install_prefix / install_docdir / 'reference' / 'html', + 'htmlrefpub': 'http://library.gnome.org/devel/libxml++/unstable/' + } + ) + + # A main project that looks for xmlxx_pcname.pc shall find xmlxx_dep. + meson.override_dependency(xmlxx_pcname, xmlxx_dep) endif # Print a summary. diff --git a/subprojects/mm-common.wrap b/subprojects/mm-common.wrap new file mode 100644 index 00000000..296109fa --- /dev/null +++ b/subprojects/mm-common.wrap @@ -0,0 +1,9 @@ +[wrap-git] +directory=mm-common +url=https://gitlab.gnome.org/GNOME/mm-common.git +revision=master +depth=1 + +[provide] +dependency_names = mm-common-libstdc++ +program_names = mm-common-get diff --git a/tests/meson.build b/tests/meson.build index 435ea2ac..ab48a9b3 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -1,6 +1,6 @@ # tests -# Input: xmlxx_dep, build_tests +# Input: xmlxx_own_dep, build_tests # Output: - test_programs = [ @@ -22,7 +22,7 @@ foreach ex : test_programs endforeach exe_file = executable(ex_name, ex_sources, - dependencies: xmlxx_dep, + dependencies: xmlxx_own_dep, gui_app: false, build_by_default: build_tests ) From d004d828aaedb46eadcdc8dbd0601f87a0de1001 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 7 Apr 2021 13:27:54 +0200 Subject: [PATCH 121/240] Meson build: No implicit_include_directories --- examples/meson.build | 1 + tests/meson.build | 1 + 2 files changed, 2 insertions(+) diff --git a/examples/meson.build b/examples/meson.build index 2a1928b4..fba8521d 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -38,6 +38,7 @@ foreach ex : example_programs exe_file = executable(ex_name, ex_sources, dependencies: xmlxx_own_dep, + implicit_include_directories: false, gui_app: false, build_by_default: build_examples ) diff --git a/tests/meson.build b/tests/meson.build index ab48a9b3..77cece9e 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -23,6 +23,7 @@ foreach ex : test_programs exe_file = executable(ex_name, ex_sources, dependencies: xmlxx_own_dep, + implicit_include_directories: false, gui_app: false, build_by_default: build_tests ) From c09b1c450ea2b00bb3edbbc80fe7ec53a4c15ab8 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 7 May 2021 12:31:32 +0200 Subject: [PATCH 122/240] Subprojects can use meson.add_dist_script() if meson.version() >= 0.58.0 * meson.build: * docs/manual/meson.build: * docs/reference/meson.build: Call add_dist_script() in a subproject, if meson.version() >= 0.58.0. * tools/build_scripts/tutorial-custom-cmd.py: Use MESON_PROJECT_DIST_ROOT if it exists, else MESON_DIST_ROOT. It exists if meson.version() >= 0.58.0. --- docs/manual/meson.build | 5 ++--- docs/reference/meson.build | 5 ++--- meson.build | 13 ++++++++----- tools/build_scripts/tutorial-custom-cmd.py | 7 +++++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/docs/manual/meson.build b/docs/manual/meson.build index ae5e463f..7908a7d6 100644 --- a/docs/manual/meson.build +++ b/docs/manual/meson.build @@ -1,7 +1,7 @@ # docs/manual # input: install_datadir, xmlxx_pcname, tutorial_custom_cmd_py, python3, -# build_documentation, book_name, perl +# build_documentation, book_name, can_add_dist_script # output: can_parse_and_validate, build_pdf_by_default, can_build_pdf, # install_tutorialdir @@ -89,9 +89,8 @@ if can_build_pdf ) endif -if not meson.is_subproject() +if can_add_dist_script # Distribute built files. - # (add_dist_script() is not allowed in a subproject) meson.add_dist_script( python3.path(), tutorial_custom_cmd_py, 'dist_doc', doc_dist_dir, diff --git a/docs/reference/meson.build b/docs/reference/meson.build index 62256d0b..b181acc6 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -2,7 +2,7 @@ # Input: project_build_root, project_source_root, xmlxx_pcname, # xmlxx_api_version, build_documentation, source_h_files, -# install_datadir, python3, doc_reference_py +# install_datadir, python3, doc_reference_py, can_add_dist_script # Output: install_docdir, install_devhelpdir, book_name, tag_file # There are no built source files in libxml++-5.0. @@ -113,9 +113,8 @@ meson.add_install_script( docinstall_flags ) -if not meson.is_subproject() +if can_add_dist_script # Distribute built files and files copied by mm-common-get. - # (add_dist_script() is not allowed in a subproject) meson.add_dist_script( python3.path(), doc_reference_py, 'dist_doc', doctool_dir, diff --git a/meson.build b/meson.build index 86b0c704..5df9c898 100644 --- a/meson.build +++ b/meson.build @@ -295,6 +295,9 @@ xmlxxconfig_h = configure_file( install_dir: install_includeconfigdir, ) +# add_dist_script() is not allowed in a subproject if meson.version() < 0.58.0. +can_add_dist_script = not meson.is_subproject() or meson.version().version_compare('>= 0.58.0') + subdir('MSVC_NMake/libxml++') subdir('libxml++') subdir('examples') @@ -302,22 +305,22 @@ subdir('tests') subdir('docs/reference') subdir('docs/manual') -if not meson.is_subproject() +if can_add_dist_script # Add a ChangeLog file to the distribution directory. - # (add_dist_script() is not allowed in a subproject) meson.add_dist_script( python3.path(), dist_changelog_py, project_source_root, ) # Add build scripts to the distribution directory, and delete .gitignore - # files and an empty $MESON_DIST_ROOT/build/ directory. + # files and an empty $MESON_PROJECT_DIST_ROOT/build/ directory. meson.add_dist_script( python3.path(), dist_build_scripts_py, project_source_root, 'untracked' / 'build_scripts', ) -else - # This is a subproject. +endif + +if meson.is_subproject() xmlxx_dep = declare_dependency( dependencies: xmlxx_own_dep, variables: { diff --git a/tools/build_scripts/tutorial-custom-cmd.py b/tools/build_scripts/tutorial-custom-cmd.py index aa4761e6..015ae8c6 100755 --- a/tools/build_scripts/tutorial-custom-cmd.py +++ b/tools/build_scripts/tutorial-custom-cmd.py @@ -150,11 +150,14 @@ def dist_doc(): # argv[2] argv[3] argv[4] argv[5] # - # is a distribution directory, relative to MESON_DIST_ROOT. + # is a distribution directory, relative to MESON_PROJECT_DIST_ROOT. # is a relative or absolute path in the build directory. # is a relative or absolute path in the build directory. # is a relative or absolute path in the build directory. - doc_dist_dir = os.path.join(os.getenv('MESON_DIST_ROOT'), sys.argv[2]) + + # MESON_PROJECT_DIST_ROOT is set only if meson.version() >= 0.58.0. + project_dist_root = os.getenv('MESON_PROJECT_DIST_ROOT', os.getenv('MESON_DIST_ROOT')) + doc_dist_dir = os.path.join(project_dist_root, sys.argv[2]) doc_build_dir = sys.argv[3] xml_file = sys.argv[4] pdf_file = sys.argv[5] From 665148413e5aaac3d80754c028fc9a3b21c2901c Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 7 May 2021 18:40:03 +0800 Subject: [PATCH 123/240] libxml++: Export classes selectively This will make the code avoid exporting items such that things are tied to a particular Visual Studio and STL version, and eliminate warnings C4251, C4273 and C4275 from the build. --- libxml++/document.h | 42 +++++++++++--- libxml++/dtd.h | 26 +++++---- libxml++/exceptions/exception.h | 11 ++-- libxml++/exceptions/internal_error.h | 9 +-- libxml++/exceptions/parse_error.h | 9 +-- libxml++/exceptions/validity_error.h | 9 +-- libxml++/exceptions/wrapped_exception.h | 9 +-- libxml++/parsers/domparser.h | 19 ++++++- libxml++/parsers/parser.h | 34 +++++++++++- libxml++/parsers/saxparser.h | 29 +++++++++- libxml++/parsers/textreader.h | 68 +++++++++++++++++------ libxml++/relaxngschema.h | 16 +++++- libxml++/schemabase.h | 2 +- libxml++/validators/dtdvalidator.h | 20 ++++++- libxml++/validators/relaxngvalidator.h | 24 ++++++-- libxml++/validators/schemavalidatorbase.h | 16 ++++-- libxml++/validators/validator.h | 21 +++++-- libxml++/validators/xsdvalidator.h | 23 ++++++-- libxml++/xsdschema.h | 18 ++++-- 19 files changed, 310 insertions(+), 95 deletions(-) diff --git a/libxml++/document.h b/libxml++/document.h index 9657b740..648b9121 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -62,23 +62,24 @@ enum class XmlEntityType /** * Represents an XML document in the DOM model. */ -class LIBXMLPP_API Document : public NonCopyable +class Document : public NonCopyable { //Ensure that libxml is properly initialised: - class Init + class LIBXMLPP_API Init { public: Init(); ~Init() noexcept; }; - friend class SaxParser; + friend LIBXMLPP_API class SaxParser; public: /** Create a new document. * @param version XML version. * @throws xmlpp::internal_error If memory allocation fails. */ + LIBXMLPP_API explicit Document(const ustring& version = "1.0"); /** Create a new C++ wrapper for an xmlDoc struct. @@ -87,17 +88,19 @@ class LIBXMLPP_API Document : public NonCopyable * @param doc A pointer to an xmlDoc struct. Must not be nullptr. * @throws xmlpp::internal_error If @a doc is nullptr. */ - explicit Document(_xmlDoc* doc); + LIBXMLPP_API explicit Document(_xmlDoc* doc); - ~Document() override; + LIBXMLPP_API ~Document() override; /** @return The encoding used in the source from which the document has been loaded. */ + LIBXMLPP_API ustring get_encoding() const; /** Get the internal subset of this document. * @returns A pointer to the DTD, or nullptr if not found. */ + LIBXMLPP_API Dtd* get_internal_subset() const; /** Create the internal subset of this document. @@ -106,6 +109,7 @@ class LIBXMLPP_API Document : public NonCopyable * @param external_id The external (PUBLIC) ID, or an empty string. * @param system_id The system ID, or an empty string. */ + LIBXMLPP_API void set_internal_subset(const ustring& name, const ustring& external_id, const ustring& system_id); @@ -114,12 +118,14 @@ class LIBXMLPP_API Document : public NonCopyable * This function does @b not create a default root node if it doesn't exist. * @return A pointer to the root node if it exists, nullptr otherwise. */ + LIBXMLPP_API Element* get_root_node(); /** Return the root node. * This function does @b not create a default root node if it doesn't exist. * @return A pointer to the root node if it exists, nullptr otherwise. */ + LIBXMLPP_API const Element* get_root_node() const; /** Create the root element node. @@ -134,6 +140,7 @@ class LIBXMLPP_API Document : public NonCopyable * @throws xmlpp::internal_error If memory allocation fails. * @throws xmlpp::exception If a new namespace node cannot be created. */ + LIBXMLPP_API Element* create_root_node(const ustring& name, const ustring& ns_uri = ustring(), const ustring& ns_prefix = ustring() ); @@ -148,6 +155,7 @@ class LIBXMLPP_API Document : public NonCopyable * @return A pointer to the new root node * @throws xmlpp::exception If the node can't be copied. */ + LIBXMLPP_API Element* create_root_node_by_import(const Node* node, bool recursive = true); @@ -156,6 +164,7 @@ class LIBXMLPP_API Document : public NonCopyable * @returns The new comment node. * @throws xmlpp::internal_error */ + LIBXMLPP_API CommentNode* add_comment(const ustring& content); /** Append a new processing instruction node. @@ -167,6 +176,7 @@ class LIBXMLPP_API Document : public NonCopyable * @returns The new processing instruction node. * @throws xmlpp::internal_error */ + LIBXMLPP_API ProcessingInstructionNode* add_processing_instruction( const ustring& name, const ustring& content); @@ -175,6 +185,7 @@ class LIBXMLPP_API Document : public NonCopyable * @param encoding If not provided, UTF-8 is used * @throws xmlpp::exception */ + LIBXMLPP_API void write_to_file(const std::string& filename, const ustring& encoding = ustring()); /** Write the document to a file. @@ -184,6 +195,7 @@ class LIBXMLPP_API Document : public NonCopyable * @param encoding If not provided, UTF-8 is used * @throws xmlpp::exception */ + LIBXMLPP_API void write_to_file_formatted(const std::string& filename, const ustring& encoding = ustring()); /** Write the document to the memory. @@ -191,6 +203,7 @@ class LIBXMLPP_API Document : public NonCopyable * @returns The written document. * @throws xmlpp::exception */ + LIBXMLPP_API ustring write_to_string(const ustring& encoding = ustring()); /** Write the document to the memory. @@ -200,6 +213,7 @@ class LIBXMLPP_API Document : public NonCopyable * @returns The written document. * @throws xmlpp::exception */ + LIBXMLPP_API ustring write_to_string_formatted(const ustring& encoding = ustring()); /** Write the document to a std::ostream. @@ -210,6 +224,7 @@ class LIBXMLPP_API Document : public NonCopyable * @warning This method is much less efficient than write_to_string if you want to dump the * document to a buffer or the standard output. Writing to a fstream is almost as fast as write_to_file */ + LIBXMLPP_API void write_to_stream(std::ostream& output, const ustring& encoding = ustring()); /** Write the document to a std::ostream. @@ -221,6 +236,7 @@ class LIBXMLPP_API Document : public NonCopyable * @throws xmlpp::internal_error * @warning See write_to_stream */ + LIBXMLPP_API void write_to_stream_formatted(std::ostream & output, const ustring& encoding = ustring()); /** Add an Entity declaration to the document. @@ -232,8 +248,11 @@ class LIBXMLPP_API Document : public NonCopyable * is the replacement value. * @throws xmlpp::internal_error */ - virtual void set_entity_declaration(const ustring& name, XmlEntityType type, - const ustring& publicId, const ustring& systemId, + LIBXMLPP_API + virtual void set_entity_declaration(const ustring& name, + XmlEntityType type, + const ustring& publicId, + const ustring& systemId, const ustring& content); /** Perform XInclude substitution on the XML document. @@ -255,13 +274,14 @@ class LIBXMLPP_API Document : public NonCopyable * @returns The number of substitutions. * @throws xmlpp::exception */ + LIBXMLPP_API int process_xinclude(bool generate_xinclude_nodes = true, bool fixup_base_uris = true); ///Access the underlying libxml implementation. - _xmlDoc* cobj() noexcept; + LIBXMLPP_API _xmlDoc* cobj() noexcept; ///Access the underlying libxml implementation. - const _xmlDoc* cobj() const noexcept; + LIBXMLPP_API const _xmlDoc* cobj() const noexcept; protected: /** Retrieve an Entity. @@ -269,11 +289,15 @@ class LIBXMLPP_API Document : public NonCopyable * @param name The name of the entity to get. * @returns A pointer to the libxml2 entity structure, or nullptr if not found. */ + LIBXMLPP_API _xmlEntity* get_entity(const ustring& name); private: + LIBXMLPP_API void do_write_to_file(const std::string& filename, const ustring& encoding, bool format); + LIBXMLPP_API ustring do_write_to_string(const ustring& encoding, bool format); + LIBXMLPP_API void do_write_to_stream(std::ostream& output, const ustring& encoding, bool format); static Init init_; diff --git a/libxml++/dtd.h b/libxml++/dtd.h index 789e2ba5..cd9b51a2 100644 --- a/libxml++/dtd.h +++ b/libxml++/dtd.h @@ -27,10 +27,10 @@ namespace xmlpp /** Represents an XML DTD for validating XML files. * DTD = %Document Type Definition */ -class LIBXMLPP_API Dtd : public NonCopyable +class Dtd : public NonCopyable { public: - Dtd(); + LIBXMLPP_API Dtd(); /** Create a Dtd from the underlying libxml DTD element. * @param dtd A pointer to the libxml DTD element. @@ -43,6 +43,7 @@ class LIBXMLPP_API Dtd : public NonCopyable * needed, unless it belongs to a Document, in which case it's deleted * when the Document is deleted. */ + LIBXMLPP_API explicit Dtd(_xmlDtd* dtd, bool take_ownership = false); /** Create a Dtd and parse an external subset (DTD file) immediately. @@ -52,6 +53,7 @@ class LIBXMLPP_API Dtd : public NonCopyable * @param filename The URL of the DTD. * @throws xmlpp::parse_error */ + LIBXMLPP_API explicit Dtd(const std::string& filename); /** Create a Dtd and parse an external subset (DTD file) immediately. @@ -62,9 +64,10 @@ class LIBXMLPP_API Dtd : public NonCopyable * @param system The URL of the DTD. * @throws xmlpp::parse_error */ + LIBXMLPP_API Dtd(const ustring& external, const ustring& system); - ~Dtd() override; + LIBXMLPP_API ~Dtd() override; /** Parse an external subset (DTD file). * If another DTD has been parsed before, that DTD is replaced by the new one @@ -75,6 +78,7 @@ class LIBXMLPP_API Dtd : public NonCopyable * @param filename The URL of the DTD. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_file(const std::string& filename); /** Parse an external subset (DTD file). @@ -87,6 +91,7 @@ class LIBXMLPP_API Dtd : public NonCopyable * @param system The URL of the DTD. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_subset(const ustring& external, const ustring& system); /** Parse a DTD from a string. @@ -98,6 +103,7 @@ class LIBXMLPP_API Dtd : public NonCopyable * @param contents The DTD as a string. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_memory(const ustring& contents); /** Parse a DTD from a stream. @@ -109,22 +115,22 @@ class LIBXMLPP_API Dtd : public NonCopyable * @param in The stream. * @throws xmlpp::parse_error */ - void parse_stream(std::istream& in); + LIBXMLPP_API void parse_stream(std::istream& in); - ustring get_name() const; - ustring get_external_id() const; - ustring get_system_id() const; + LIBXMLPP_API ustring get_name() const; + LIBXMLPP_API ustring get_external_id() const; + LIBXMLPP_API ustring get_system_id() const; /** Access the underlying libxml implementation. */ - _xmlDtd* cobj() noexcept; + LIBXMLPP_API _xmlDtd* cobj() noexcept; /** Access the underlying libxml implementation. */ - const _xmlDtd* cobj() const noexcept; + LIBXMLPP_API const _xmlDtd* cobj() const noexcept; protected: - void release_underlying(); + LIBXMLPP_API void release_underlying(); private: struct Impl; diff --git a/libxml++/exceptions/exception.h b/libxml++/exceptions/exception.h index 8c22262f..e6b3d97a 100644 --- a/libxml++/exceptions/exception.h +++ b/libxml++/exceptions/exception.h @@ -36,16 +36,17 @@ namespace xmlpp /** Base class for all xmlpp exceptions. */ -class LIBXMLPP_API exception : public std::exception +class exception : public std::exception { public: + LIBXMLPP_API explicit exception(const ustring& message); - ~exception() noexcept override; + LIBXMLPP_API ~exception() noexcept override; - const char* what() const noexcept override; + LIBXMLPP_API const char* what() const noexcept override; - virtual void raise() const; - virtual exception* clone() const; + LIBXMLPP_API virtual void raise() const; + LIBXMLPP_API virtual exception* clone() const; private: ustring message_; diff --git a/libxml++/exceptions/internal_error.h b/libxml++/exceptions/internal_error.h index 43eaa6c9..2ad6fe19 100644 --- a/libxml++/exceptions/internal_error.h +++ b/libxml++/exceptions/internal_error.h @@ -24,14 +24,15 @@ namespace xmlpp { -class LIBXMLPP_API internal_error : public exception +class internal_error : public exception { public: + LIBXMLPP_API explicit internal_error(const ustring& message); - ~internal_error() noexcept override; + LIBXMLPP_API ~internal_error() noexcept override; - void raise() const override; - exception* clone() const override; + LIBXMLPP_API void raise() const override; + LIBXMLPP_API exception* clone() const override; }; } // namespace xmlpp diff --git a/libxml++/exceptions/parse_error.h b/libxml++/exceptions/parse_error.h index d159c3ac..50ebc8d6 100644 --- a/libxml++/exceptions/parse_error.h +++ b/libxml++/exceptions/parse_error.h @@ -27,14 +27,15 @@ namespace xmlpp /** This exception will be thrown when the parser encounters an error in the XML document. */ -class LIBXMLPP_API parse_error : public exception +class parse_error : public exception { public: + LIBXMLPP_API explicit parse_error(const ustring& message); - ~parse_error() noexcept override; + LIBXMLPP_API ~parse_error() noexcept override; - void raise() const override; - exception* clone() const override; + LIBXMLPP_API void raise() const override; + LIBXMLPP_API exception* clone() const override; }; } // namespace xmlpp diff --git a/libxml++/exceptions/validity_error.h b/libxml++/exceptions/validity_error.h index 1f16055e..d8831b4f 100644 --- a/libxml++/exceptions/validity_error.h +++ b/libxml++/exceptions/validity_error.h @@ -27,14 +27,15 @@ namespace xmlpp /** This exception will be thrown when the parser encounters a validity error in the XML document. */ -class LIBXMLPP_API validity_error : public parse_error +class validity_error : public parse_error { public: + LIBXMLPP_API explicit validity_error(const ustring& message); - ~validity_error() noexcept override; + LIBXMLPP_API ~validity_error() noexcept override; - void raise() const override; - exception* clone() const override; + LIBXMLPP_API void raise() const override; + LIBXMLPP_API exception* clone() const override; }; } // namespace xmlpp diff --git a/libxml++/exceptions/wrapped_exception.h b/libxml++/exceptions/wrapped_exception.h index 37daf37e..ad60f88e 100644 --- a/libxml++/exceptions/wrapped_exception.h +++ b/libxml++/exceptions/wrapped_exception.h @@ -35,14 +35,15 @@ namespace xmlpp * * @newin{2,40} */ -class LIBXMLPP_API wrapped_exception : public exception +class wrapped_exception : public exception { public: + LIBXMLPP_API explicit wrapped_exception(std::exception_ptr exception_ptr); - ~wrapped_exception() noexcept override; + LIBXMLPP_API ~wrapped_exception() noexcept override; - void raise() const override; - exception* clone() const override; + LIBXMLPP_API void raise() const override; + LIBXMLPP_API exception* clone() const override; private: std::exception_ptr exception_ptr_; diff --git a/libxml++/parsers/domparser.h b/libxml++/parsers/domparser.h index 61fb1d52..6c40ceb4 100644 --- a/libxml++/parsers/domparser.h +++ b/libxml++/parsers/domparser.h @@ -15,13 +15,13 @@ namespace xmlpp { /** DOM XML parser. * DOM = %Document Object Model */ -class LIBXMLPP_API DomParser : public Parser +class DomParser : public Parser { public: /** Create a parser with an empty document. * @throws xmlpp::internal_error If an empty document can't be created. */ - DomParser(); + LIBXMLPP_API DomParser(); /** Instantiate the parser and parse a document immediately. * @param filename The path to the file. @@ -30,8 +30,9 @@ class LIBXMLPP_API DomParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API explicit DomParser(const std::string& filename, bool validate = false); - ~DomParser() override; + LIBXMLPP_API ~DomParser() override; /** Set whether and how the parser will perform XInclude substitution. * @@ -43,6 +44,7 @@ class LIBXMLPP_API DomParser : public Parser * @param fixup_base_uris Add or replace xml:base attributes in included element * nodes, if necessary to preserve the target of relative URIs. */ + LIBXMLPP_API void set_xinclude_options(bool process_xinclude = true, bool generate_xinclude_nodes = true, bool fixup_base_uris = true) noexcept; @@ -55,6 +57,7 @@ class LIBXMLPP_API DomParser : public Parser * @param[out] fixup_base_uris Add or replace xml:base attributes in included element * nodes, if necessary to preserve the target of relative URIs. */ + LIBXMLPP_API void get_xinclude_options(bool& process_xinclude, bool& generate_xinclude_nodes, bool& fixup_base_uris) const noexcept; @@ -66,6 +69,7 @@ class LIBXMLPP_API DomParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void parse_file(const std::string& filename) override; /** Parse an XML document from a string. @@ -76,6 +80,7 @@ class LIBXMLPP_API DomParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void parse_memory(const ustring& contents) override; /** Parse an XML document from raw memory. @@ -87,6 +92,7 @@ class LIBXMLPP_API DomParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void parse_memory_raw(const unsigned char* contents, size_type bytes_count) override; /** Parse an XML document from a stream. @@ -97,26 +103,33 @@ class LIBXMLPP_API DomParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void parse_stream(std::istream& in) override; /** Test whether a document has been parsed. */ + LIBXMLPP_API explicit operator bool() const noexcept; /** Get the parsed document. * @returns A pointer to the parsed document, or nullptr. */ + LIBXMLPP_API Document* get_document() noexcept; /** Get the parsed document. * @returns A pointer to the parsed document, or nullptr. */ + LIBXMLPP_API const Document* get_document() const noexcept; protected: + LIBXMLPP_API void parse_context(); + LIBXMLPP_API void check_xinclude_and_finish_parsing(); + LIBXMLPP_API void release_underlying() override; int xinclude_options_ = 0; diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index 20db85b4..17803f5b 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -28,22 +28,24 @@ namespace xmlpp { * * Abstract base class for DOM parser and SAX parser. */ -class LIBXMLPP_API Parser : public NonCopyable +class Parser : public NonCopyable { public: - Parser(); - ~Parser() override; + LIBXMLPP_API Parser(); + LIBXMLPP_API ~Parser() override; using size_type = unsigned int; /** By default, the parser will not validate the XML file. * @param val Whether the document should be validated. */ + LIBXMLPP_API void set_validate(bool val = true) noexcept; /** See set_validate(). * @returns Whether the parser will validate the XML file. */ + LIBXMLPP_API bool get_validate() const noexcept; /** Set whether the parser will automatically substitute entity references with the text of the entities' definitions. @@ -51,11 +53,13 @@ class LIBXMLPP_API Parser : public NonCopyable * By default, the parser will not substitute entities, so that you do not lose the entity reference information. * @param val Whether entities will be substitued. */ + LIBXMLPP_API void set_substitute_entities(bool val = true) noexcept; /** See set_substitute_entities(). * @returns Whether entities will be substituted during parsing. */ + LIBXMLPP_API bool get_substitute_entities() const noexcept; /** Set whether the parser will collect and throw error and warning messages. @@ -80,6 +84,7 @@ class LIBXMLPP_API Parser : public NonCopyable * * @param val Whether messages will be collected and thrown in an exception. */ + LIBXMLPP_API void set_throw_messages(bool val = true) noexcept; /** See set_throw_messages(). @@ -88,6 +93,7 @@ class LIBXMLPP_API Parser : public NonCopyable * * @returns Whether messages will be collected and thrown in an exception. */ + LIBXMLPP_API bool get_throw_messages() const noexcept; /** Set whether default attribute values from the DTD shall be included in the node tree. @@ -100,6 +106,7 @@ class LIBXMLPP_API Parser : public NonCopyable * * @param val Whether attributes with default values will be included in the node tree. */ + LIBXMLPP_API void set_include_default_attributes(bool val = true) noexcept; /** See set_include_default_attributes(). @@ -108,6 +115,7 @@ class LIBXMLPP_API Parser : public NonCopyable * * @returns Whether attributes with default values will be included in the node tree. */ + LIBXMLPP_API bool get_include_default_attributes() const noexcept; /** Set and/or clear parser option flags. @@ -122,6 +130,7 @@ class LIBXMLPP_API Parser : public NonCopyable * @param clear_options Set bits correspond to flags that shall be cleared during parsing. * Bits that are set in neither @a set_options nor @a clear_options are not affected. */ + LIBXMLPP_API void set_parser_options(int set_options = 0, int clear_options = 0) noexcept; /** See set_parser_options(). @@ -132,12 +141,14 @@ class LIBXMLPP_API Parser : public NonCopyable * @param[out] clear_options Set bits correspond to flags that shall be cleared during parsing. * Bits that are set in neither @a set_options nor @a clear_options are not affected. */ + LIBXMLPP_API void get_parser_options(int& set_options, int& clear_options) const noexcept; /** Parse an XML document from a file. * @throw exception * @param filename The path to the file. */ + LIBXMLPP_API virtual void parse_file(const std::string& filename) = 0; /** Parse an XML document from raw memory. @@ -145,40 +156,56 @@ class LIBXMLPP_API Parser : public NonCopyable * @param contents The XML document as an array of bytes. * @param bytes_count The number of bytes in the @a contents array. */ + LIBXMLPP_API virtual void parse_memory_raw(const unsigned char* contents, size_type bytes_count) = 0; /** Parse an XML document from a string. * @throw exception * @param contents The XML document as a string. */ + LIBXMLPP_API virtual void parse_memory(const ustring& contents) = 0; /** Parse an XML document from a stream. * @throw exception * @param in The stream. */ + LIBXMLPP_API virtual void parse_stream(std::istream& in) = 0; //TODO: Add stop_parser()/stop_parsing(), wrapping xmlStopParser()? protected: + LIBXMLPP_API virtual void initialize_context(); + LIBXMLPP_API virtual void release_underlying(); + LIBXMLPP_API virtual void on_parser_error(const ustring& message); + LIBXMLPP_API virtual void on_parser_warning(const ustring& message); + LIBXMLPP_API virtual void on_validity_error(const ustring& message); + LIBXMLPP_API virtual void on_validity_warning(const ustring& message); /// To be called in an exception handler. + LIBXMLPP_API virtual void handle_exception(); + LIBXMLPP_API virtual void check_for_exception(); + LIBXMLPP_API virtual void check_for_error_and_warning_messages(); + LIBXMLPP_API static void callback_parser_error(void* ctx, const char* msg, ...); + LIBXMLPP_API static void callback_parser_warning(void* ctx, const char* msg, ...); + LIBXMLPP_API static void callback_validity_error(void* ctx, const char* msg, ...); + LIBXMLPP_API static void callback_validity_warning(void* ctx, const char* msg, ...); enum class MsgType @@ -189,6 +216,7 @@ class LIBXMLPP_API Parser : public NonCopyable ValidityWarning }; + LIBXMLPP_API static void callback_error_or_warning(MsgType msg_type, void* ctx, const char* msg, va_list var_args); diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index c876ddc8..13640516 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -31,7 +31,7 @@ namespace xmlpp { * that exception is replaced by a xmlpp::exception before it is propagated * out of the parse method, such as parse_file(). */ -class LIBXMLPP_API SaxParser : public Parser +class SaxParser : public Parser { public: /** @@ -82,7 +82,9 @@ class LIBXMLPP_API SaxParser : public Parser * if you override on_get_entity() might not have the same behaviour as the underlying default * behaviour of libxml, so the libxml implementation is the default here. */ + LIBXMLPP_API SaxParser(bool use_get_entity = false); + LIBXMLPP_API ~SaxParser() override; /** Parse an XML document from a file. @@ -91,6 +93,7 @@ class LIBXMLPP_API SaxParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void parse_file(const std::string& filename) override; /** Parse an XML document from a string. @@ -99,6 +102,7 @@ class LIBXMLPP_API SaxParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void parse_memory(const ustring& contents) override; /** Parse an XML document from raw memory. @@ -108,6 +112,7 @@ class LIBXMLPP_API SaxParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void parse_memory_raw(const unsigned char* contents, size_type bytes_count) override; /** Parse an XML document from a stream. @@ -116,6 +121,7 @@ class LIBXMLPP_API SaxParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void parse_stream(std::istream& in) override; /** Parse a chunk of data. @@ -132,6 +138,7 @@ class LIBXMLPP_API SaxParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void parse_chunk(const ustring& chunk); /** Parse a chunk of data. @@ -151,6 +158,7 @@ class LIBXMLPP_API SaxParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void parse_chunk_raw(const unsigned char* contents, size_type bytes_count); /** Finish a chunk-wise parse. @@ -161,26 +169,38 @@ class LIBXMLPP_API SaxParser : public Parser * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void finish_chunk_parsing(); protected: + LIBXMLPP_API virtual void on_start_document(); + LIBXMLPP_API virtual void on_end_document(); + LIBXMLPP_API virtual void on_start_element(const ustring& name, const AttributeList& attributes); + LIBXMLPP_API virtual void on_end_element(const ustring& name); + LIBXMLPP_API virtual void on_characters(const ustring& characters); + LIBXMLPP_API virtual void on_comment(const ustring& text); + LIBXMLPP_API virtual void on_warning(const ustring& text); + LIBXMLPP_API virtual void on_error(const ustring& text); /** @throws xmlpp::parse_error */ + LIBXMLPP_API virtual void on_fatal_error(const ustring& text); + LIBXMLPP_API virtual void on_cdata_block(const ustring& text); /** Override this to receive information about the document's DTD and any entity declarations. */ + LIBXMLPP_API virtual void on_internal_subset(const ustring& name, const ustring& publicId, const ustring& systemId); /** Override this method to resolve entities references in your derived parser, instead of using the default entity resolution, @@ -203,6 +223,7 @@ class LIBXMLPP_API SaxParser : public Parser * You must include libxml/parser.h in order to use this C struct. * This instance will not be freed by the caller. */ + LIBXMLPP_API virtual _xmlEntity* on_get_entity(const ustring& name); /** Override this to receive information about every entity declaration. @@ -211,12 +232,16 @@ class LIBXMLPP_API SaxParser : public Parser * This would be useful when overriding on_get_entity(). * @throws xmlpp::internal_error */ + LIBXMLPP_API virtual void on_entity_declaration(const ustring& name, XmlEntityType type, const ustring& publicId, const ustring& systemId, const ustring& content); + LIBXMLPP_API void release_underlying() override; + LIBXMLPP_API void initialize_context() override; private: + LIBXMLPP_API void parse(); std::unique_ptr<_xmlSAXHandler> sax_handler_; @@ -225,7 +250,7 @@ class LIBXMLPP_API SaxParser : public Parser // and never seen in the API: std::unique_ptr entity_resolver_doc_; - friend struct SaxParserCallback; + friend LIBXMLPP_API struct SaxParserCallback; }; } // namespace xmlpp diff --git a/libxml++/parsers/textreader.h b/libxml++/parsers/textreader.h index e71f7384..807f3456 100644 --- a/libxml++/parsers/textreader.h +++ b/libxml++/parsers/textreader.h @@ -26,7 +26,7 @@ namespace xmlpp * A reader that provides fast, non-cached, forward-only access to XML data, * in the style of .Net's XmlTextReader class. */ -class LIBXMLPP_API TextReader: public NonCopyable +class TextReader: public NonCopyable { public: // xmlpp::TextReader::NodeType is similar to xmlReaderTypes in libxml2. @@ -85,6 +85,7 @@ class LIBXMLPP_API TextReader: public NonCopyable * takes ownership of cobj. * @param cobj The underlying libxml xmlTextReader object. */ + LIBXMLPP_API TextReader(struct _xmlTextReader* cobj); /** @@ -92,6 +93,7 @@ class LIBXMLPP_API TextReader: public NonCopyable * @param URI The URI to read. * @throws xmlpp::internal_error If an xmlTextReader object cannot be created. */ + LIBXMLPP_API TextReader(const ustring& URI); /** @@ -101,43 +103,45 @@ class LIBXMLPP_API TextReader: public NonCopyable * @param uri The base URI to use for the document. * @throws xmlpp::internal_error If an xmlTextReader object cannot be created. */ + LIBXMLPP_API TextReader(const unsigned char* data, size_type size, const ustring& uri = ustring()); - ~TextReader() override; + LIBXMLPP_API ~TextReader() override; /** Moves the position of the current instance to the next node in the stream, exposing its properties. * @return true if the node was read successfully, false if there are no more nodes to read. * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - bool read(); + LIBXMLPP_API bool read(); /** Reads the contents of the current node, including child nodes and markup. * @return A ustring containing the XML content, or an empty ustring if the current node is neither an element nor attribute, or has no child nodes. * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - ustring read_inner_xml(); + LIBXMLPP_API ustring read_inner_xml(); /** Reads the current node and its contents, including child nodes and markup. * @return A ustring containing the XML content, or an empty ustring if the current node is neither an element nor attribute. * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - ustring read_outer_xml(); + LIBXMLPP_API ustring read_outer_xml(); /** Reads the contents of an element or a text node as a string. * @return A ustring containing the contents of the Element or Text node, or an empty ustring if the reader is positioned on any other type of node. * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - ustring read_string(); + LIBXMLPP_API ustring read_string(); /** Parses an attribute value into one or more Text and EntityReference nodes. * @return A bool where true indicates the attribute value was parsed, and false indicates the reader was not positioned on an attribute node or all the attribute values have been read. * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API bool read_attribute_value(); /** Gets the number of attributes on the current node. @@ -146,41 +150,47 @@ class LIBXMLPP_API TextReader: public NonCopyable * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API int get_attribute_count() const; /** Gets the base Uniform Resource Identifier (URI) of the current node. * @return The base URI of the current node or an empty ustring if not available. */ - ustring get_base_uri() const; + LIBXMLPP_API ustring get_base_uri() const; /** Gets the depth of the current node in the XML document. * @return The depth of the current node in the XML document, or -1 in case of error. */ + LIBXMLPP_API int get_depth() const; /** Gets a value indicating whether the current node has any attributes. * @return true if the current has attributes, false otherwise. */ + LIBXMLPP_API bool has_attributes() const; /** Whether the node can have a text value. * @return true if the current node can have an associated text value, false otherwise. */ + LIBXMLPP_API bool has_value() const; /** Whether an Attribute node was generated from the default value defined in the DTD or schema. * @return true if defaulted, false otherwise. */ + LIBXMLPP_API bool is_default() const; /** Check if the current node is empty * @return true if empty, false otherwise. */ + LIBXMLPP_API bool is_empty_element() const; - ustring get_local_name() const; - ustring get_name() const; - ustring get_namespace_uri() const; + LIBXMLPP_API ustring get_local_name() const; + LIBXMLPP_API ustring get_name() const; + LIBXMLPP_API ustring get_namespace_uri() const; /** Get the node type of the current node. * @returns The xmlpp::TextReader::NodeType of the current node. @@ -189,44 +199,61 @@ class LIBXMLPP_API TextReader: public NonCopyable * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API NodeType get_node_type() const; /** Get the namespace prefix associated with the current node. * @returns The namespace prefix, or an empty string if not available. */ - ustring get_prefix() const; + LIBXMLPP_API ustring get_prefix() const; /** Get the quotation mark character used to enclose the value of an attribute. * @returns Returns " or ' and -1 in case of error. */ + LIBXMLPP_API char get_quote_char() const; - ustring get_value() const; - ustring get_xml_lang() const; + LIBXMLPP_API ustring get_value() const; + LIBXMLPP_API ustring get_xml_lang() const; + LIBXMLPP_API ReadState get_read_state() const; - void close(); + LIBXMLPP_API void close(); + LIBXMLPP_API ustring get_attribute(int number) const; + LIBXMLPP_API ustring get_attribute(const ustring& name) const; + LIBXMLPP_API ustring get_attribute(const ustring& local_name, const ustring& ns_uri) const; // TODO InputBuffer GetRemainder; + LIBXMLPP_API ustring lookup_namespace(const ustring& prefix) const; + LIBXMLPP_API bool move_to_attribute(int number); + LIBXMLPP_API bool move_to_attribute(const ustring& name); + LIBXMLPP_API bool move_to_attribute(const ustring& local_name, const ustring& ns_uri); + LIBXMLPP_API bool move_to_first_attribute(); + LIBXMLPP_API bool move_to_next_attribute(); + LIBXMLPP_API bool move_to_element(); + LIBXMLPP_API bool get_normalization() const; + LIBXMLPP_API void set_normalization(bool value); + LIBXMLPP_API bool get_parser_property(ParserProperties property) const; + LIBXMLPP_API void set_parser_property(ParserProperties property, bool value); /** Get a pointer to the current node. @@ -236,12 +263,14 @@ class LIBXMLPP_API TextReader: public NonCopyable * called by the application. * @returns A pointer to the current node, or nullptr in case of error. */ + LIBXMLPP_API Node* get_current_node(); /** Get a pointer to the current node. * @warning See the non-const get_current_node(). * @returns A pointer to the current node, or nullptr in case of error. */ + LIBXMLPP_API const Node* get_current_node() const; // Document* CurrentDocument(); @@ -256,18 +285,21 @@ class LIBXMLPP_API TextReader: public NonCopyable * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ - Node* expand(); + LIBXMLPP_API Node* expand(); - bool next(); - bool is_valid() const; + LIBXMLPP_API bool next(); + LIBXMLPP_API bool is_valid() const; private: class PropertyReader; - friend class PropertyReader; + friend LIBXMLPP_API class PropertyReader; + LIBXMLPP_API void setup_exceptions(); + LIBXMLPP_API static void on_libxml_error(void * arg, const char *msg, int severity, void * locator); + LIBXMLPP_API void check_for_exceptions() const; std::unique_ptr propertyreader; diff --git a/libxml++/relaxngschema.h b/libxml++/relaxngschema.h index a5e15f1b..ffa00792 100644 --- a/libxml++/relaxngschema.h +++ b/libxml++/relaxngschema.h @@ -40,15 +40,16 @@ namespace xmlpp * * @newin{2,38} */ -class LIBXMLPP_API RelaxNGSchema : public SchemaBase +class RelaxNGSchema : public SchemaBase { public: - RelaxNGSchema(); + LIBXMLPP_API RelaxNGSchema(); /** Create a schema from the underlying libxml schema element. * @param schema A pointer to the libxml schema element. The RelaxNGSchema takes * ownership of the _xmlRelaxNG. The caller must not deallocate it. */ + LIBXMLPP_API explicit RelaxNGSchema(_xmlRelaxNG* schema); /** Create a schema from a schema definition file. @@ -57,15 +58,17 @@ class LIBXMLPP_API RelaxNGSchema : public SchemaBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ + LIBXMLPP_API explicit RelaxNGSchema(const std::string& filename); /** Create a schema from an XML document. * @param document A preparsed document tree, containing the schema definition. * @throws xmlpp::parse_error */ + LIBXMLPP_API explicit RelaxNGSchema(const Document* document); - ~RelaxNGSchema() override; + LIBXMLPP_API ~RelaxNGSchema() override; /** Parse a schema definition file. * The schema must be defined with XML syntax (.rng file). The compact syntax @@ -75,6 +78,7 @@ class LIBXMLPP_API RelaxNGSchema : public SchemaBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_file(const std::string& filename) override; /** Parse a schema definition from a string. @@ -84,6 +88,7 @@ class LIBXMLPP_API RelaxNGSchema : public SchemaBase * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_memory(const ustring& contents) override; /** Parse a schema definition from a document. @@ -91,16 +96,21 @@ class LIBXMLPP_API RelaxNGSchema : public SchemaBase * @param document A preparsed document tree, containing the schema definition. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_document(const Document* document) override; /** Access the underlying libxml implementation. */ + LIBXMLPP_API _xmlRelaxNG* cobj() noexcept; /** Access the underlying libxml implementation. */ + LIBXMLPP_API const _xmlRelaxNG* cobj() const noexcept; protected: + LIBXMLPP_API void release_underlying(); + LIBXMLPP_API void parse_context(_xmlRelaxNGParserCtxt* context); private: diff --git a/libxml++/schemabase.h b/libxml++/schemabase.h index 0c66c902..690327ef 100644 --- a/libxml++/schemabase.h +++ b/libxml++/schemabase.h @@ -25,7 +25,7 @@ namespace xmlpp { -class LIBXMLPP_API Document; +class Document; /** Base class for schemas, used for validation of XML files. * diff --git a/libxml++/validators/dtdvalidator.h b/libxml++/validators/dtdvalidator.h index 424353b5..4e713c8e 100644 --- a/libxml++/validators/dtdvalidator.h +++ b/libxml++/validators/dtdvalidator.h @@ -17,15 +17,16 @@ namespace xmlpp { /** XML DTD validator. * DTD = %Document Type Definition */ -class LIBXMLPP_API DtdValidator : public Validator +class DtdValidator : public Validator { public: - DtdValidator(); + LIBXMLPP_API DtdValidator(); /** Create a validator and parse an external subset (DTD file) immediately. * @param filename The URL of the DTD. * @throws xmlpp::parse_error */ + LIBXMLPP_API explicit DtdValidator(const std::string& filename); /** Create a validator and parse an external subset (DTD file) immediately. @@ -33,6 +34,7 @@ class LIBXMLPP_API DtdValidator : public Validator * @param system The URL of the DTD. * @throws xmlpp::parse_error */ + LIBXMLPP_API explicit DtdValidator(const ustring& external, const ustring& system); /** Create a validator. @@ -47,15 +49,17 @@ class LIBXMLPP_API DtdValidator : public Validator * validator keeps a pointer to it. The caller is responsible for * deleting the DTD when it's no longer needed. */ + LIBXMLPP_API explicit DtdValidator(Dtd* dtd, bool take_ownership); - ~DtdValidator() override; + LIBXMLPP_API ~DtdValidator() override; /** Parse an external subset (DTD file). * If the validator already contains a DTD, that DTD is deleted. * @param filename The URL of the DTD. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_file(const std::string& filename) override; /** Parse an external subset (DTD file). @@ -64,6 +68,7 @@ class LIBXMLPP_API DtdValidator : public Validator * @param system The URL of the DTD. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_subset(const ustring& external, const ustring& system); /** Parse a DTD from a string. @@ -71,6 +76,7 @@ class LIBXMLPP_API DtdValidator : public Validator * @param contents The DTD as a string. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_memory(const ustring& contents) override; /** Parse a DTD from a stream. @@ -78,6 +84,7 @@ class LIBXMLPP_API DtdValidator : public Validator * @param in The stream. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_stream(std::istream& in); /** Set a DTD. @@ -91,6 +98,7 @@ class LIBXMLPP_API DtdValidator : public Validator * validator keeps a pointer to it. The caller is responsible for * deleting the DTD when it's no longer needed. */ + LIBXMLPP_API void set_dtd(Dtd* dtd, bool take_ownership); /** Test whether a DTD has been parsed. @@ -100,16 +108,19 @@ class LIBXMLPP_API DtdValidator : public Validator * do_something(); * @endcode */ + LIBXMLPP_API explicit operator bool() const noexcept override; /** Get the parsed DTD. * @returns A pointer to the parsed DTD, or nullptr. */ + LIBXMLPP_API Dtd* get_dtd() noexcept; /** Get the parsed DTD. * @returns A pointer to the parsed DTD, or nullptr. */ + LIBXMLPP_API const Dtd* get_dtd() const noexcept; /** Validate a document, using a previously parsed DTD. @@ -119,10 +130,13 @@ class LIBXMLPP_API DtdValidator : public Validator * @throws xmlpp::internal_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void validate(const Document* document) override; protected: + LIBXMLPP_API void initialize_context() override; + LIBXMLPP_API void release_underlying() override; private: diff --git a/libxml++/validators/relaxngvalidator.h b/libxml++/validators/relaxngvalidator.h index daff9eef..1f117dcc 100644 --- a/libxml++/validators/relaxngvalidator.h +++ b/libxml++/validators/relaxngvalidator.h @@ -26,18 +26,18 @@ namespace xmlpp { -class LIBXMLPP_API Document; -class LIBXMLPP_API RelaxNGSchema; +class Document; +class RelaxNGSchema; /** RelaxNG schema validator. * RelaxNG = REgular LAnguage for XML Next Generation * * @newin{2,38} */ -class LIBXMLPP_API RelaxNGValidator : public SchemaValidatorBase +class RelaxNGValidator : public SchemaValidatorBase { public: - RelaxNGValidator(); + LIBXMLPP_API RelaxNGValidator(); /** Create a validator and parse a schema definition file. * The schema must be defined with XML syntax (.rng file). The compact syntax @@ -45,12 +45,14 @@ class LIBXMLPP_API RelaxNGValidator : public SchemaValidatorBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ + LIBXMLPP_API explicit RelaxNGValidator(const std::string& filename); /** Create a validator and parse a schema definition document. * @param document A preparsed document tree, containing the schema definition. * @throws xmlpp::parse_error */ + LIBXMLPP_API explicit RelaxNGValidator(const Document* document); /** Create a validator. @@ -62,9 +64,10 @@ class LIBXMLPP_API RelaxNGValidator : public SchemaValidatorBase * validator keeps a pointer to it. The caller is responsible for * deleting the schema when it's no longer needed. */ + LIBXMLPP_API explicit RelaxNGValidator(RelaxNGSchema* schema, bool take_ownership); - ~RelaxNGValidator() override; + LIBXMLPP_API ~RelaxNGValidator() override; /** Parse a schema definition file. * The schema must be defined with XML syntax (.rng file). The compact syntax @@ -75,6 +78,7 @@ class LIBXMLPP_API RelaxNGValidator : public SchemaValidatorBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_file(const std::string& filename) override; /** Parse a schema definition from a string. @@ -85,6 +89,7 @@ class LIBXMLPP_API RelaxNGValidator : public SchemaValidatorBase * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_memory(const ustring& contents) override; /** Parse a schema definition from a document. @@ -93,6 +98,7 @@ class LIBXMLPP_API RelaxNGValidator : public SchemaValidatorBase * @param document A preparsed document tree, containing the schema definition. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_document(const Document* document) override; /** Set a schema. @@ -106,6 +112,7 @@ class LIBXMLPP_API RelaxNGValidator : public SchemaValidatorBase * validator keeps a pointer to it. The caller is responsible for * deleting the schema when it's no longer needed. */ + LIBXMLPP_API void set_schema(RelaxNGSchema* schema, bool take_ownership); /** Test whether a schema has been parsed. @@ -115,16 +122,19 @@ class LIBXMLPP_API RelaxNGValidator : public SchemaValidatorBase * do_something(); * @endcode */ + LIBXMLPP_API explicit operator bool() const noexcept override; /** Get the schema. * @returns A pointer to the schema, or nullptr. */ + LIBXMLPP_API RelaxNGSchema* get_schema() noexcept; /** Get the schema. * @returns A pointer to the schema, or nullptr. */ + LIBXMLPP_API const RelaxNGSchema* get_schema() const noexcept; /** Validate a document, using a previously parsed schema. @@ -132,6 +142,7 @@ class LIBXMLPP_API RelaxNGValidator : public SchemaValidatorBase * @throws xmlpp::internal_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void validate(const Document* document) override; /** Validate an XML file, using a previously parsed schema. @@ -140,10 +151,13 @@ class LIBXMLPP_API RelaxNGValidator : public SchemaValidatorBase * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void validate(const std::string& filename) override; protected: + LIBXMLPP_API void initialize_context() override; + LIBXMLPP_API void release_underlying() override; private: diff --git a/libxml++/validators/schemavalidatorbase.h b/libxml++/validators/schemavalidatorbase.h index 2debc26a..382e8b88 100644 --- a/libxml++/validators/schemavalidatorbase.h +++ b/libxml++/validators/schemavalidatorbase.h @@ -23,17 +23,17 @@ namespace xmlpp { -class LIBXMLPP_API Document; +class Document; /** Base class for schema validators. * * @newin{2,38} */ -class LIBXMLPP_API SchemaValidatorBase : public Validator +class SchemaValidatorBase : public Validator { public: - SchemaValidatorBase() noexcept; - ~SchemaValidatorBase() override; + LIBXMLPP_API SchemaValidatorBase() noexcept; + LIBXMLPP_API ~SchemaValidatorBase() override; /** Parse a schema definition file. * If the validator already contains a schema, that schema is released @@ -41,6 +41,7 @@ class LIBXMLPP_API SchemaValidatorBase : public Validator * @param filename The URL of the schema. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_file(const std::string& filename) override = 0; /** Parse a schema definition from a string. @@ -49,6 +50,7 @@ class LIBXMLPP_API SchemaValidatorBase : public Validator * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_memory(const ustring& contents) override = 0; /** Parse a schema definition from a document. @@ -57,6 +59,7 @@ class LIBXMLPP_API SchemaValidatorBase : public Validator * @param document A preparsed document tree, containing the schema definition. * @throws xmlpp::parse_error */ + LIBXMLPP_API virtual void parse_document(const Document* document) = 0; /** Test whether a schema has been parsed. @@ -66,6 +69,7 @@ class LIBXMLPP_API SchemaValidatorBase : public Validator * do_something(); * @endcode */ + LIBXMLPP_API explicit virtual operator bool() const noexcept override = 0; /** Validate a document, using a previously parsed schema. @@ -73,6 +77,7 @@ class LIBXMLPP_API SchemaValidatorBase : public Validator * @throws xmlpp::internal_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void validate(const Document* document) override = 0; /** Validate an XML file, using a previously parsed schema. @@ -81,10 +86,13 @@ class LIBXMLPP_API SchemaValidatorBase : public Validator * @throws xmlpp::parse_error * @throws xmlpp::validity_error */ + LIBXMLPP_API virtual void validate(const std::string& filename) = 0; protected: + LIBXMLPP_API void initialize_context() override; + LIBXMLPP_API void release_underlying() override; }; diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index cf931965..f8d7882f 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -20,26 +20,28 @@ extern "C" { namespace xmlpp { -class LIBXMLPP_API Document; +class Document; /** Base class for XML validators. */ -class LIBXMLPP_API Validator : public NonCopyable +class Validator : public NonCopyable { public: - Validator() noexcept; - ~Validator() override; + LIBXMLPP_API Validator() noexcept; + LIBXMLPP_API ~Validator() override; /** Parse a schema definition file or an external subset (DTD file). * @param filename The URL of the schema or the DTD. * @throws xmlpp::parse_error */ + LIBXMLPP_API virtual void parse_file(const std::string& filename) = 0; /** Parse a schema definition or a DTD from a string. * @param contents The schema definition or the DTD as a string. * @throws xmlpp::parse_error */ + LIBXMLPP_API virtual void parse_memory(const ustring& contents) = 0; /** Validate a document, using a previously parsed schema or DTD. @@ -47,6 +49,7 @@ class LIBXMLPP_API Validator : public NonCopyable * @throws xmlpp::internal_error * @throws xmlpp::validity_error */ + LIBXMLPP_API virtual void validate(const Document* document) = 0; /** Test whether a schema or a DTD has been parsed. @@ -56,21 +59,31 @@ class LIBXMLPP_API Validator : public NonCopyable * do_something(); * @endcode */ + LIBXMLPP_API explicit virtual operator bool() const noexcept = 0; protected: + LIBXMLPP_API virtual void initialize_context(); + LIBXMLPP_API virtual void release_underlying(); + LIBXMLPP_API virtual void on_validity_error(const ustring& message); + LIBXMLPP_API virtual void on_validity_warning(const ustring& message); /// To be called in an exception handler. + LIBXMLPP_API virtual void handle_exception(); + LIBXMLPP_API virtual void check_for_exception(); + LIBXMLPP_API virtual void check_for_validity_messages(); + LIBXMLPP_API static void callback_validity_error(void* ctx, const char* msg, ...); + LIBXMLPP_API static void callback_validity_warning(void* ctx, const char* msg, ...); std::unique_ptr exception_; diff --git a/libxml++/validators/xsdvalidator.h b/libxml++/validators/xsdvalidator.h index afc062bb..47c55369 100644 --- a/libxml++/validators/xsdvalidator.h +++ b/libxml++/validators/xsdvalidator.h @@ -24,29 +24,31 @@ namespace xmlpp { -class LIBXMLPP_API Document; -class LIBXMLPP_API XsdSchema; +class Document; +class XsdSchema; /** XSD schema validator. * XSD = XML %Schema Definition, a.k.a. XML %Schema or W3C XML %Schema * * @newin{2,38} */ -class LIBXMLPP_API XsdValidator : public SchemaValidatorBase +class XsdValidator : public SchemaValidatorBase { public: - XsdValidator(); + LIBXMLPP_API XsdValidator(); /** Create a validator and parse a schema definition file. * @param filename The URL of the schema. * @throws xmlpp::parse_error */ + LIBXMLPP_API explicit XsdValidator(const std::string& filename); /** Create a validator and parse a schema definition document. * @param document A preparsed document tree, containing the schema definition. * @throws xmlpp::parse_error */ + LIBXMLPP_API explicit XsdValidator(const Document* document); /** Create a validator. @@ -58,8 +60,10 @@ class LIBXMLPP_API XsdValidator : public SchemaValidatorBase * validator keeps a pointer to it. The caller is responsible for * deleting the schema when it's no longer needed. */ + LIBXMLPP_API explicit XsdValidator(XsdSchema* schema, bool take_ownership); + LIBXMLPP_API ~XsdValidator() override; /** Parse a schema definition file. @@ -68,6 +72,7 @@ class LIBXMLPP_API XsdValidator : public SchemaValidatorBase * @param filename The URL of the schema. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_file(const std::string& filename) override; /** Parse a schema definition from a string. @@ -76,6 +81,7 @@ class LIBXMLPP_API XsdValidator : public SchemaValidatorBase * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_memory(const ustring& contents) override; /** Parse a schema definition from a document. @@ -84,6 +90,7 @@ class LIBXMLPP_API XsdValidator : public SchemaValidatorBase * @param document A preparsed document tree, containing the schema definition. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_document(const Document* document) override; /** Set a schema. @@ -97,6 +104,7 @@ class LIBXMLPP_API XsdValidator : public SchemaValidatorBase * validator keeps a pointer to it. The caller is responsible for * deleting the schema when it's no longer needed. */ + LIBXMLPP_API void set_schema(XsdSchema* schema, bool take_ownership); /** Test whether a schema has been parsed. @@ -106,16 +114,19 @@ class LIBXMLPP_API XsdValidator : public SchemaValidatorBase * do_something(); * @endcode */ + LIBXMLPP_API explicit operator bool() const noexcept override; /** Get the schema. * @returns A pointer to the schema, or nullptr. */ + LIBXMLPP_API XsdSchema* get_schema() noexcept; /** Get the schema. * @returns A pointer to the schema, or nullptr. */ + LIBXMLPP_API const XsdSchema* get_schema() const noexcept; /** Validate a document, using a previously parsed schema. @@ -123,6 +134,7 @@ class LIBXMLPP_API XsdValidator : public SchemaValidatorBase * @throws xmlpp::internal_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void validate(const Document* document) override; /** Validate an XML file, using a previously parsed schema. @@ -130,10 +142,13 @@ class LIBXMLPP_API XsdValidator : public SchemaValidatorBase * @throws xmlpp::internal_error * @throws xmlpp::validity_error */ + LIBXMLPP_API void validate(const std::string& filename) override; protected: + LIBXMLPP_API void initialize_context() override; + LIBXMLPP_API void release_underlying() override; private: diff --git a/libxml++/xsdschema.h b/libxml++/xsdschema.h index 9e180250..a82123a2 100644 --- a/libxml++/xsdschema.h +++ b/libxml++/xsdschema.h @@ -38,36 +38,40 @@ namespace xmlpp * * @newin{2,38} */ -class LIBXMLPP_API XsdSchema : public SchemaBase +class XsdSchema : public SchemaBase { public: - XsdSchema(); + LIBXMLPP_API XsdSchema(); /** Create a schema from the underlying libxml schema element. * @param schema A pointer to the libxml schema element. The XsdSchema takes * ownership of the _xmlSchema. The caller must not deallocate it. */ + LIBXMLPP_API explicit XsdSchema(_xmlSchema* schema); /** Create a schema from a schema definition file. * @param filename The URL of the schema. * @throws xmlpp::parse_error */ + LIBXMLPP_API explicit XsdSchema(const std::string& filename); /** Create a schema from an XML document. * @param document A preparsed document tree, containing the schema definition. * @throws xmlpp::parse_error */ + LIBXMLPP_API explicit XsdSchema(const Document* document); - ~XsdSchema() override; + LIBXMLPP_API ~XsdSchema() override; /** Parse a schema definition file. * If another schema has been parsed before, that schema is replaced by the new one. * @param filename The URL of the schema. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_file(const std::string& filename) override; /** Parse a schema definition from a string. @@ -75,6 +79,7 @@ class LIBXMLPP_API XsdSchema : public SchemaBase * @param contents The schema definition as a string. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_memory(const ustring& contents) override; /** Parse a schema definition from a document. @@ -82,16 +87,19 @@ class LIBXMLPP_API XsdSchema : public SchemaBase * @param document A preparsed document tree, containing the schema definition. * @throws xmlpp::parse_error */ + LIBXMLPP_API void parse_document(const Document* document) override; /** Access the underlying libxml implementation. */ - _xmlSchema* cobj() noexcept; + LIBXMLPP_API _xmlSchema* cobj() noexcept; /** Access the underlying libxml implementation. */ - const _xmlSchema* cobj() const noexcept; + LIBXMLPP_API const _xmlSchema* cobj() const noexcept; protected: + LIBXMLPP_API void release_underlying(); + LIBXMLPP_API void parse_context(_xmlSchemaParserCtxt* context); private: From 685e66507d74a142308f0d67ab4d61a21c33e4a1 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 7 May 2021 18:51:23 +0800 Subject: [PATCH 124/240] Clean up Visual Studio build files We no longer need to ignore warnings C4251, C4273 and C4275, and we will now use /EHsc, so we also no longer need to ignore warning C4530. --- MSVC_NMake/config-msvc.mak | 3 +-- meson.build | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/MSVC_NMake/config-msvc.mak b/MSVC_NMake/config-msvc.mak index 1f6f746f..75e78977 100644 --- a/MSVC_NMake/config-msvc.mak +++ b/MSVC_NMake/config-msvc.mak @@ -14,8 +14,7 @@ DEBUG_SUFFIX = !endif LIBXMLXX_BASE_CFLAGS = \ - /I.\libxml++ /I.. \ - /wd4530 /wd4251 /wd4275 /EHsc \ + /I.\libxml++ /I.. /EHsc \ /FImsvc_recommended_pragmas.h \ /std:c++17 diff --git a/meson.build b/meson.build index 5df9c898..53fc4570 100644 --- a/meson.build +++ b/meson.build @@ -236,7 +236,7 @@ add_project_arguments(warning_flags, language: 'cpp') # MSVC: Ignore warnings that aren't really harmful, but make those # that should not be overlooked stand out. if is_msvc - foreach wd : ['/FImsvc_recommended_pragmas.h', '/wd4267', '/wd4530', '/wd4251', '/wd4273', '/wd4275'] + foreach wd : ['/FImsvc_recommended_pragmas.h', '/wd4267', '/EHsc' ] disabled_warning = cpp_compiler.get_supported_arguments(wd) add_project_arguments(disabled_warning, language: 'cpp') endforeach From c71105b304e27f8294783553faed98dbf9c3c061 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 16 May 2021 12:34:49 +0200 Subject: [PATCH 125/240] Fix build as subproject without building documentation * meson.build: If mm-common-get is not found in maintainer-mode with 'required: false', try with 'required: true'. Don't try to use tag_file, if documentation is not built. * docs/reference/meson.build: Don't use variables from modules that don't define doxytagfile. These are subprojects that don't build their documentation. --- docs/reference/meson.build | 33 ++++++++++++++++++--------------- meson.build | 20 +++++++++++++------- 2 files changed, 31 insertions(+), 22 deletions(-) diff --git a/docs/reference/meson.build b/docs/reference/meson.build index b181acc6..c11dcfba 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -3,7 +3,8 @@ # Input: project_build_root, project_source_root, xmlxx_pcname, # xmlxx_api_version, build_documentation, source_h_files, # install_datadir, python3, doc_reference_py, can_add_dist_script -# Output: install_docdir, install_devhelpdir, book_name, tag_file +# Output: install_docdir, install_devhelpdir, book_name, +# if build_documentation: tag_file # There are no built source files in libxml++-5.0. @@ -15,21 +16,23 @@ docinstall_flags = [] foreach module : tag_file_modules depmod = dependency(module, required: false) if depmod.found() - doxytagfile = depmod.get_variable(pkgconfig: 'doxytagfile', internal: 'doxytagfile') - htmlrefpub = depmod.get_variable(pkgconfig: 'htmlrefpub', internal: 'htmlrefpub', default_value: '') - htmlrefdir = depmod.get_variable(pkgconfig: 'htmlrefdir', internal: 'htmlrefdir', default_value: '') - if htmlrefpub == '' - htmlrefpub = htmlrefdir - elif htmlrefdir == '' - htmlrefdir = htmlrefpub - endif - doxygen_tagfiles += ' "' + doxytagfile + '=' + htmlrefpub + '"' + doxytagfile = depmod.get_variable(pkgconfig: 'doxytagfile', internal: 'doxytagfile', default_value: '') + if doxytagfile != '' + htmlrefpub = depmod.get_variable(pkgconfig: 'htmlrefpub', internal: 'htmlrefpub', default_value: '') + htmlrefdir = depmod.get_variable(pkgconfig: 'htmlrefdir', internal: 'htmlrefdir', default_value: '') + if htmlrefpub == '' + htmlrefpub = htmlrefdir + elif htmlrefdir == '' + htmlrefdir = htmlrefpub + endif + doxygen_tagfiles += ' "' + doxytagfile + '=' + htmlrefpub + '"' - # Doxygen <= 1.8.15 - docinstall_flags += ['-l', doxytagfile.split('/')[-1] + '@' + htmlrefdir] - if htmlrefpub != htmlrefdir - # Doxygen >= 1.8.16 - docinstall_flags += ['-l', 's@' + htmlrefpub + '@' + htmlrefdir] + # Doxygen <= 1.8.15 + docinstall_flags += ['-l', doxytagfile.split('/')[-1] + '@' + htmlrefdir] + if htmlrefpub != htmlrefdir + # Doxygen >= 1.8.16 + docinstall_flags += ['-l', 's@' + htmlrefpub + '@' + htmlrefdir] + endif endif endif endforeach diff --git a/meson.build b/meson.build index 53fc4570..c9ca55b1 100644 --- a/meson.build +++ b/meson.build @@ -155,8 +155,11 @@ xmlxx_build_dep = [xml2_dep] # reference documentation shall be built. mm_common_get = find_program('mm-common-get', required: false) if maintainer_mode and not mm_common_get.found() - error('Maintainer mode requires the \'mm-common-get\' command.\n' + - 'Use \'-Dmaintainer-mode=false\' or install the \'mm-common\' package, version 1.0.0 or higher') + message('Maintainer mode requires the \'mm-common-get\' command. If it is not found,\n' + + 'use \'-Dmaintainer-mode=false\' or install the \'mm-common\' package, version 1.0.0 or higher.') + # If meson --wrap-mode != forcefallback, Meson falls back to the mm-common + # subproject only if mm-common-get is required. + mm_common_get = find_program('mm-common-get', required: true) endif perl = find_program('perl', required: build_documentation) doxygen = find_program('doxygen', required: build_documentation) @@ -321,13 +324,16 @@ if can_add_dist_script endif if meson.is_subproject() + pkgconfig_vars = { + 'htmlrefdir': install_prefix / install_docdir / 'reference' / 'html', + 'htmlrefpub': 'http://library.gnome.org/devel/libxml++/unstable/' + } + if build_documentation + pkgconfig_vars += {'doxytagfile': tag_file.full_path()} + endif xmlxx_dep = declare_dependency( dependencies: xmlxx_own_dep, - variables: { - 'doxytagfile': tag_file.full_path(), - 'htmlrefdir': install_prefix / install_docdir / 'reference' / 'html', - 'htmlrefpub': 'http://library.gnome.org/devel/libxml++/unstable/' - } + variables: pkgconfig_vars, ) # A main project that looks for xmlxx_pcname.pc shall find xmlxx_dep. From 465ea8ca5f7a11dd5ca0b0ce5c6f7d3a19367ec8 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 18 May 2021 11:50:56 +0200 Subject: [PATCH 126/240] Add dependencies to Doxygen tag files in subprojects Doxygen in a main project shall not be called before tag files have been created or updated in subprojects. --- docs/reference/meson.build | 13 ++++++++++++- meson.build | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/reference/meson.build b/docs/reference/meson.build index c11dcfba..0178ffab 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -12,12 +12,21 @@ tag_file_modules = [ 'mm-common-libstdc++', ] doxygen_tagfiles = '' +doxygen_tag_targets = [] docinstall_flags = [] foreach module : tag_file_modules depmod = dependency(module, required: false) if depmod.found() doxytagfile = depmod.get_variable(pkgconfig: 'doxytagfile', internal: 'doxytagfile', default_value: '') if doxytagfile != '' + if depmod.type_name() == 'internal' + # Subprojects must build their tag files before doxygen is called. + if module.startswith('mm-common') + doxygen_tag_targets += subproject('mm-common').get_variable('global_tag_file_target') + else + doxygen_tag_targets += subproject(module).get_variable('global_tag_file_target') + endif + endif htmlrefpub = depmod.get_variable(pkgconfig: 'htmlrefpub', internal: 'htmlrefpub', default_value: '') htmlrefdir = depmod.get_variable(pkgconfig: 'htmlrefdir', internal: 'htmlrefdir', default_value: '') if htmlrefpub == '' @@ -51,7 +60,7 @@ doc_conf_data.set('abs_top_srcdir', project_source_root) doc_conf_data.set('LIBXMLXX_MODULE_NAME', book_name) doc_conf_data.set('DOXYGEN_TAGFILES', doxygen_tagfiles) -configure_file( +doxyfile = configure_file( input: 'Doxyfile.in', output: '@BASENAME@', configuration: doc_conf_data, @@ -87,6 +96,8 @@ tag_file = custom_target('html_and_tag', '@OUTPUT@', '@INPUT@', ], + depend_files: doxyfile, + depends: doxygen_tag_targets, build_by_default: build_documentation, install: true, install_dir: install_reference_docdir, diff --git a/meson.build b/meson.build index c9ca55b1..a123b96b 100644 --- a/meson.build +++ b/meson.build @@ -330,6 +330,8 @@ if meson.is_subproject() } if build_documentation pkgconfig_vars += {'doxytagfile': tag_file.full_path()} + # May be used in a main project. + global_tag_file_target = tag_file endif xmlxx_dep = declare_dependency( dependencies: xmlxx_own_dep, From 6a175d48c6ec58622300c797e74b2745b33bef80 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 19 May 2021 16:22:25 +0200 Subject: [PATCH 127/240] Website: Update some links Don't link to the latest version of library.gnome.org/devel/libxml++ and library.gnome.org/devel/libxml++-tutorial. --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 199b7c66..11e7d103 100644 --- a/docs/index.md +++ b/docs/index.md @@ -37,7 +37,7 @@ You can download libxml++ from [here](http://ftp.gnome.org/pub/GNOME/sources/lib ## Documentation -The short [manual](http://library.gnome.org/devel/libxml++-tutorial/stable/) gives an overview of the libxml++ API. You can also browse online the [reference documentation](http://library.gnome.org/devel/libxml++/stable/). +The short [manual](http://library.gnome.org/devel/libxml++-tutorial/) gives an overview of the libxml++ API. You can also browse online the [reference documentation](http://library.gnome.org/devel/libxml++/). ## Development From 4caece92ce2d09cfb6fbc87180ec768ccf3bf718 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 27 May 2021 12:35:28 +0200 Subject: [PATCH 128/240] 5.0.1 --- NEWS | 17 +++++++++++++++++ configure.ac | 2 +- meson.build | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index e19cedcc..0a7da1cf 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,20 @@ +5.0.1 (stable): + +Build: +* libxml++config.h.*: Don't dllimport on MinGW + (Chun-wei Fan) Issue gtkmm#90 (Lukas K.) +* Meson build: Make it possible to use libxml++ as a subproject + (Kjell Ahlstedt) +* Meson build: No implicit_include_directories + (Kjell Ahlstedt) +* MSVC build: Export classes selectively + (Chun-wei Fan) + +Documentation: +* docs/index.md: Describe the different libxml++ ABIs + (Kjell Ahlstedt) Issue #20 (Tom Schoonjans) + + 5.0.0 (stable): This is the first stable release in the libxml++-5.0 ABI series. diff --git a/configure.ac b/configure.ac index 82123322..67893d62 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [5.0.0], +AC_INIT([libxml++], [5.0.1], [https://github.com/libxmlplusplus/libxmlplusplus/issues], [libxml++], [https://libxmlplusplus.github.io/libxmlplusplus/]) AC_PREREQ([2.59]) diff --git a/meson.build b/meson.build index a123b96b..6e86ca31 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ # This file is part of libxml++. project('libxml++', 'cpp', - version: '5.0.0', + version: '5.0.1', license: 'LGPLv2.1+', default_options: [ 'cpp_std=c++17' From f23e0ff9828cd4036870ed8f2c8249cad7b3089a Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 9 Jun 2021 15:46:01 +0200 Subject: [PATCH 129/240] Document, Node: Recognize HTML documents Documents created with htmlReadDoc() have xmlElementType == XML_HTML_DOCUMENT_NODE. Handle that type like the XML_DOCUMENT_NODE type. htmlDoc* is an alias for xmlDoc*. Fixes #23 --- libxml++/document.cc | 3 +++ libxml++/nodes/node.cc | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libxml++/document.cc b/libxml++/document.cc index be1456ab..da0a8f52 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -56,6 +56,7 @@ void find_wrappers(xmlNode* node, NodeMap& node_map) case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: has_attributes = false; break; default: @@ -102,6 +103,7 @@ void remove_found_wrappers(xmlNode* node, NodeMap& node_map) case XML_ATTRIBUTE_DECL: case XML_ENTITY_DECL: case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: has_attributes = false; break; default: @@ -457,6 +459,7 @@ int Document::process_xinclude(bool generate_xinclude_nodes, bool fixup_base_uri delete reinterpret_cast(node); break; case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: delete reinterpret_cast(node); break; default: diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index 1f04b556..15680ea8 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -449,7 +449,9 @@ ustring Node::eval_to_string(const ustring& xpath, const PrefixNsMap& namespaces ustring Node::get_namespace_prefix() const { - if(impl_->type == XML_DOCUMENT_NODE || impl_->type == XML_ENTITY_DECL) + if(impl_->type == XML_DOCUMENT_NODE || + impl_->type == XML_HTML_DOCUMENT_NODE || + impl_->type == XML_ENTITY_DECL) { //impl_ is actually of type xmlDoc or xmlEntity, instead of just xmlNode. //libxml does not always use GObject-style inheritance, so xmlDoc and @@ -475,6 +477,7 @@ ustring Node::get_namespace_prefix() const ustring Node::get_namespace_uri() const { if(impl_->type == XML_DOCUMENT_NODE || + impl_->type == XML_HTML_DOCUMENT_NODE || impl_->type == XML_ENTITY_DECL || impl_->type == XML_ATTRIBUTE_DECL) { @@ -591,6 +594,7 @@ void Node::create_wrapper(xmlNode* node) break; } case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: { // do nothing. For Documents it's the wrapper that is the owner. break; @@ -639,6 +643,7 @@ void Node::free_wrappers(xmlNode* node) node->_private = nullptr; return; case XML_DOCUMENT_NODE: + case XML_HTML_DOCUMENT_NODE: //Do not free now. The Document is usually the one who owns the caller. return; default: From 9933bbb448ebf7e93d2f360096a8f496204585fa Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 2 Jul 2021 17:12:07 +0200 Subject: [PATCH 130/240] Meson build: Add insert_example_code.py * docs/manual/insert_example_code.py: New Python file, equivalent to the insert_example_code.pl Perl file. The Perl file is still used when building with Autotools. --- .gitignore | 2 +- Makefile.am | 1 + docs/manual/insert_example_code.py | 68 ++++++++++++++++++++++ docs/manual/meson.build | 2 +- tools/build_scripts/tutorial-custom-cmd.py | 28 ++++----- 5 files changed, 81 insertions(+), 20 deletions(-) create mode 100755 docs/manual/insert_example_code.py diff --git a/.gitignore b/.gitignore index 088ff518..4ffe2322 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ # wildcard patterns *.[ao] *.l[ao] -*~ Makefile Makefile.in .deps/ @@ -34,6 +33,7 @@ stamp-h? /docs/doxygen.css /docs/doxygen-extra.css /docs/tagfile-to-devhelp2.xsl +/docs/manual/__pycache__/ /docs/manual/html/ /docs/manual/libxml++.xml /docs/reference/Doxyfile diff --git a/Makefile.am b/Makefile.am index ca3334b0..10911c4e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,6 +30,7 @@ EXTRA_DIST = \ meson_options.txt \ libxml++config.h.meson \ MSVC_NMake/libxml++/meson.build \ + docs/manual/insert_example_code.py \ docs/manual/meson.build \ docs/reference/meson.build \ examples/meson.build \ diff --git a/docs/manual/insert_example_code.py b/docs/manual/insert_example_code.py new file mode 100755 index 00000000..98c5bd36 --- /dev/null +++ b/docs/manual/insert_example_code.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python3 + +# argv[1] argv[2:-1] argv[-1] +# insert_example_code.py ... + +import os +import sys +import re +import glob +import shutil + +# Where to insert example code. +source_include_pattern = re.compile( + r'\s*Source Code') + +# First line not part of leading comment in a source code file. +# The comment typically consists of copyright and license text. +start_of_source_pattern = re.compile(r'[#\w]') + +def process_source_file(source_directory, source_basename, outfile): + source_filename = os.path.join(source_directory, source_basename) + with open(source_filename, mode='r') as srcfile: + outfile.write('File: ' + source_basename + '\n') + outfile.write('\n\n') + +def insert_example_code(examples_base_dir, input_xml_files, output_xml_file): + if not isinstance(input_xml_files, list): + input_xml_files = [input_xml_files] + + with open(output_xml_file, mode='w') as outfile: + for input_xml_file in input_xml_files: + with open(input_xml_file, mode='r') as infile: + for line in infile: + # Print the line. + outfile.write(line) + + # Look for + # Source Code + source_include_match = source_include_pattern.match(line) + if source_include_match: + # List all the source files in the examples directory. + source_directory = os.path.join(examples_base_dir, source_include_match.group(1)) + outfile.write('\n') + for source_filename in glob.glob(os.path.join(source_directory, '*.h')) + \ + glob.glob(os.path.join(source_directory, '*.cc')): + source_basename = os.path.basename(source_filename) + process_source_file(source_directory, source_basename, outfile) + outfile.write('\n') + return 0 + +# ----- Main ----- +if __name__ == '__main__': + if len(sys.argv) < 4: + print('Usage: ' + sys.argv[0] + ' ... ') + sys.exit(1) + + sys.exit(insert_example_code(sys.argv[1], sys.argv[2:-1], sys.argv[-1])) diff --git a/docs/manual/meson.build b/docs/manual/meson.build index 7908a7d6..ded0229d 100644 --- a/docs/manual/meson.build +++ b/docs/manual/meson.build @@ -35,7 +35,7 @@ xml_manual_docbook = custom_target('libxml++.xml', output: 'libxml++.xml', command: [ python3, tutorial_custom_cmd_py, 'insert_example_code', - meson.current_source_dir() / 'insert_example_code.pl', + meson.current_source_dir(), project_source_root / 'examples', '@INPUT@', '@OUTPUT@', diff --git a/tools/build_scripts/tutorial-custom-cmd.py b/tools/build_scripts/tutorial-custom-cmd.py index 015ae8c6..b6a4d84c 100755 --- a/tools/build_scripts/tutorial-custom-cmd.py +++ b/tools/build_scripts/tutorial-custom-cmd.py @@ -8,29 +8,19 @@ import os import sys import subprocess -from pathlib import Path import shutil subcommand = sys.argv[1] -def insert_example_code(): - # argv[2] argv[3] argv[4] argv[5] - # +def insert_ex_code(): + # argv[2] argv[3] argv[4] argv[5] + # - perl_script_file = sys.argv[2] - examples_dir = sys.argv[3] - input_xml_file = sys.argv[4] - output_xml_file = sys.argv[5] + # Search for insert_example_code.py first in . + sys.path.insert(0, sys.argv[2]) + from insert_example_code import insert_example_code - cmd = [ - 'perl', - '--', - perl_script_file, - examples_dir, - input_xml_file, - ] - with open(output_xml_file, mode='w') as xml_file: - return subprocess.run(cmd, stdout=xml_file).returncode + return insert_example_code(sys.argv[3], sys.argv[4], sys.argv[5]) def html(): # argv[2] argv[3] argv[4] @@ -65,6 +55,8 @@ def html(): return result.returncode def xmllint(): + from pathlib import Path + # argv[2] argv[3] argv[4] # @@ -184,7 +176,7 @@ def dist_doc(): # ----- Main ----- if subcommand == 'insert_example_code': - sys.exit(insert_example_code()) + sys.exit(insert_ex_code()) if subcommand == 'html': sys.exit(html()) if subcommand == 'xmllint': From c6d957c571c4d434400041d0a7a61f9a184e7415 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 2 Jul 2021 17:12:40 +0200 Subject: [PATCH 131/240] docs/reference/Doxyfile.in: Remove obsolete COLS_IN_ALPHA_INDEX --- docs/reference/Doxyfile.in | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in index 9d40dbca..91accf57 100644 --- a/docs/reference/Doxyfile.in +++ b/docs/reference/Doxyfile.in @@ -148,7 +148,6 @@ CLANG_OPTIONS = # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = YES -COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the HTML output From f5185ab58d4b2147091d92372fa88863f667502b Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 2 Jul 2021 17:13:08 +0200 Subject: [PATCH 132/240] docs/manual/libxml++_without_code.xml: Add id on elements --- docs/manual/libxml++_without_code.xml | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/docs/manual/libxml++_without_code.xml b/docs/manual/libxml++_without_code.xml index dcb966cb..2646f2a2 100644 --- a/docs/manual/libxml++_without_code.xml +++ b/docs/manual/libxml++_without_code.xml @@ -39,7 +39,7 @@ But libxml++ was created mainly to fill the need for an API-stable and ABI-stable C++ XML parser which could be used as a shared library dependency by C++ applications that are distributed widely in binary form. That means that installed applications will not break when new versions of libxml++ are installed on a user's computer. Gradual improvement of the libxml++ API is still possible via non-breaking API additions, and new independent versions of the ABI that can be installed in parallel with older versions. These are the general techniques and principles followed by the GNOME project, of which libxml++ is a part. - + Installation libxml++ is packaged by major Linux and *BSD distributions and can be installed from source on Linux and Windows, using any modern compiler, such as g++ or MSVC++. For instance, to install libxml++ and its documentation on Debian, use apt-get or synaptic like so: @@ -53,13 +53,13 @@ url="http://www.gnome.org">GNOME project, of which libxml++ is a part. - + UTF-8 and xmlpp::ustring The libxml++ API takes, and gives, strings in the UTF-8 Unicode encoding, which can support all known languages and locales. This choice was made because, of the encodings that have this capability, UTF-8 is the most commonly accepted choice. UTF-8 is a multi-byte encoding, meaning that some characters use more than 1 byte. But for compatibility, old-fashioned 7-bit ASCII strings are unchanged when encoded as UTF-8, and UTF-8 strings do not contain null bytes which would cause old code to misjudge the number of bytes. For these reasons, you can store a UTF-8 string in a std::string object. However, the std::string API will operate on that string in terms of bytes, instead of characters. The libxml++ API indicates when a string should be provided as UTF-8, or will be provided as UTF-8, by using the xmlpp::ustring type alias. However, this is really just a std::string, whose operator[] and size() consider bytes, not characters. - + Compilation and Linking To use libxml++ in your application, you must tell the compiler where to find the include headers and where to find the libxml++ library. libxml++ provides a pkg-config .pc file to make this easy. For instance, the following command will provide the necessary compiler options: pkg-config libxml++-5.0 --cflags --libs @@ -81,7 +81,7 @@ url="http://www.gnome.org">GNOME project, of which libxml++ is a part.All of the parsers may parse XML documents directly from disk, a string, or a C++ std::istream. Although the libxml++ API uses only xmlpp::ustring, indicating the UTF-8 encoding, libxml++ can parse documents in any encoding, converting to UTF-8 automatically. This conversion will not lose any information because UTF-8 can represent any locale. Remember that white space is usually significant in XML documents, so the parsers might provide unexpected text nodes that contain only spaces and new lines. The parser does not know whether you care about these text nodes, but your application may choose to ignore them. - + DOM Parser The DOM (Document Object Model) parser parses the whole document at once and stores the structure in memory, available via DomParser::get_document(). With methods such as Document::get_root_node() and Node::get_children(), you may then navigate into the hierarchy of XML nodes without restriction, jumping forwards or backwards in the document based on the information that you encounter. Therefore the DOM parser uses a relatively large amount of memory. You should use C++ RTTI (via dynamic_cast<>) to identify the specific node type and to perform actions which are not possible with all node types. For instance, only Elements have attributes. Here is the inheritance hierarchy of node types: @@ -124,17 +124,14 @@ url="http://www.gnome.org">GNOME project, of which libxml++ is a part.Although you may obtain pointers to the Nodes, these Nodes are always owned by their parent Node. In most cases that means that the Node will exist, and your pointer will be valid, as long as the Document instance exists. There are also several methods which can create new child Nodes. By using these, and one of the Document::write_*() methods, you can use libxml++ to build a new XML document. - + Example This example looks in the document for expected elements and then examines them. All these examples are included in the libxml++ source distribution. Source Code - - - - + SAX Parser The SAX (Simple API for XML) parser presents each node of the XML document in sequence. So when you process one node, you must have already stored information about any relevant previous nodes, and you have no information at that time about subsequent nodes. The SAX parser uses less memory than the DOM parser and it is a suitable abstraction for documents that can be processed sequentially rather than as a whole. @@ -142,30 +139,25 @@ url="http://www.gnome.org">GNOME project, of which libxml++ is a part.As shown in the example, you should derive your own class from SaxParser and override some of the virtual methods. These "handler" methods will be called while the document is parsed. - + Example This example shows how the handler methods are called during parsing. Source Code - - + TextReader Parser Like the SAX parser, the TextReader parser is suitable for sequential parsing, but instead of implementing handlers for specific parts of the document, it allows you to detect the current node type, process the node accordingly, and skip forward in the document as much as necessary. Unlike the DOM parser, you may not move backwards in the XML document. And unlike the SAX parser, you must not waste time processing nodes that do not interest you. All methods are on the single parser instance, but their result depends on the current context. For instance, use read() to move to the next node, and move_to_element() to navigate to child nodes. These methods will return false when no more nodes are available. Then use methods such as get_name() and get_value() to examine the elements and their attributes. - + Example This example examines each node in turn, then moves to the next node. Source Code - - - - From d9319e4724a52afa609ff3f0affa6a1a76334bc4 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 16 Jul 2021 15:21:42 +0200 Subject: [PATCH 133/240] insert-example-code.py: Specify file encoding The default file encoding is platform dependent in Python. Better tell which encoding is expected. --- docs/manual/insert_example_code.py | 10 +++++++--- tools/build_scripts/tutorial-custom-cmd.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/manual/insert_example_code.py b/docs/manual/insert_example_code.py index 98c5bd36..a97ac014 100755 --- a/docs/manual/insert_example_code.py +++ b/docs/manual/insert_example_code.py @@ -19,7 +19,7 @@ def process_source_file(source_directory, source_basename, outfile): source_filename = os.path.join(source_directory, source_basename) - with open(source_filename, mode='r') as srcfile: + with open(source_filename, mode='r', encoding='utf-8', errors='surrogateescape') as srcfile: outfile.write('File: ' + source_basename + '\n') outfile.write('\n + # argv[2] argv[3] argv[4] argv[5] + # # Search for insert_example_code.py first in . sys.path.insert(0, sys.argv[2]) From 0923202ee3a823c12f0340928105f300c60c85e4 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 18 Aug 2021 09:02:57 +0200 Subject: [PATCH 134/240] meson.build: Check if Perl is required for building documentation New versions of mm-common use the Python scripts doc_postprocess.py and doc_install.py instead of the Perl scripts doc-postprocess.pl and doc-install.pl when documentation is built. --- meson.build | 17 +++++++++++++---- untracked/README | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 6e86ca31..d3666fe9 100644 --- a/meson.build +++ b/meson.build @@ -161,7 +161,6 @@ if maintainer_mode and not mm_common_get.found() # subproject only if mm-common-get is required. mm_common_get = find_program('mm-common-get', required: true) endif -perl = find_program('perl', required: build_documentation) doxygen = find_program('doxygen', required: build_documentation) dot = find_program('dot', required: build_documentation) # Used by Doxygen xsltproc = find_program('xsltproc', required: build_documentation) @@ -172,6 +171,10 @@ doc_reference_py = script_dir / 'doc-reference.py' dist_changelog_py = script_dir / 'dist-changelog.py' dist_build_scripts_py = script_dir / 'dist-build-scripts.py' +# xmlxx's own script files. +xmlxx_script_dir = project_source_root / 'tools' / 'build_scripts' +tutorial_custom_cmd_py = xmlxx_script_dir / 'tutorial-custom-cmd.py' + if maintainer_mode # Copy files to untracked/build_scripts and untracked/docs. run_command(mm_common_get, '--force', script_dir, @@ -189,9 +192,15 @@ sys.exit(os.path.isfile("@0@")) endif endif -# xmlxx's own script files. -xmlxx_script_dir = project_source_root / 'tools' / 'build_scripts' -tutorial_custom_cmd_py = xmlxx_script_dir / 'tutorial-custom-cmd.py' +# Check if perl is required and available. +doc_perl_prop = run_command( + python3, doc_reference_py, 'get_script_property', + '', # MMDOCTOOLDIR is not used + 'requires_perl') +if not (doc_perl_prop.returncode() == 0 and doc_perl_prop.stdout() == 'false') + # Perl is required, if documentation shall be built. + perl = find_program('perl', required: build_documentation) +endif # Add toolset version in builds done with Visual Studio 2017 or later msvc14x_toolset_ver = '' diff --git a/untracked/README b/untracked/README index 4ec8d650..a36b08f0 100644 --- a/untracked/README +++ b/untracked/README @@ -15,8 +15,8 @@ or the tarball is created with Meson. 1. Files copied by mm-common-get -------------------------------- -untracked/docs/doc-install.pl - doc-postprocess.pl +untracked/docs/doc_install.py or doc-install.pl + doc_postprocess.py or doc-postprocess.pl doxygen-extra.css tagfile-to-devhelp2.xsl untracked/build_scripts/dist-build-scripts.py From 12a56478007ac570cfb04f79c1f73f4dda3eea17 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 29 Aug 2021 16:30:06 +0200 Subject: [PATCH 135/240] CI: Add builds with Meson, remove some old Autotools builds --- .github/workflows/autotools-clang-5.yml | 25 ----------------- .github/workflows/autotools-clang-6.yml | 25 ----------------- .github/workflows/autotools-clang-7.yml | 25 ----------------- .github/workflows/autotools-gcc-7.yml | 25 ----------------- .github/workflows/meson-clang-10.yml | 37 +++++++++++++++++++++++++ .github/workflows/meson-gcc-10.yml | 37 +++++++++++++++++++++++++ 6 files changed, 74 insertions(+), 100 deletions(-) delete mode 100644 .github/workflows/autotools-clang-5.yml delete mode 100644 .github/workflows/autotools-clang-6.yml delete mode 100644 .github/workflows/autotools-clang-7.yml delete mode 100644 .github/workflows/autotools-gcc-7.yml create mode 100644 .github/workflows/meson-clang-10.yml create mode 100644 .github/workflows/meson-gcc-10.yml diff --git a/.github/workflows/autotools-clang-5.yml b/.github/workflows/autotools-clang-5.yml deleted file mode 100644 index 772a1505..00000000 --- a/.github/workflows/autotools-clang-5.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "CI: autotools: clang 5" - -on: [push] - -jobs: - build: - - runs-on: ubuntu-18.04 - - steps: - - uses: actions/checkout@v1 - - name: Build - run: | - sudo apt update - sudo apt install libxml2-dev mm-common clang-5.0 - export CXX=clang++-5.0 - ./autogen.sh --enable-warnings=fatal - make - - name: Test - run: make check - - name: Distcheck - run: | - # distcheck runs configure again so we need to specify CXX again. - export CXX=clang++-5.0 - make distcheck diff --git a/.github/workflows/autotools-clang-6.yml b/.github/workflows/autotools-clang-6.yml deleted file mode 100644 index 8850b66d..00000000 --- a/.github/workflows/autotools-clang-6.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "CI: autotools: clang 6" - -on: [push] - -jobs: - build: - - runs-on: ubuntu-18.04 - - steps: - - uses: actions/checkout@v1 - - name: Build - run: | - sudo apt update - sudo apt install libxml2-dev mm-common clang-6.0 - export CXX=clang++-6.0 - ./autogen.sh --enable-warnings=fatal - make - - name: Test - run: make check - - name: Distcheck - run: | - # distcheck runs configure again so we need to specify CXX again. - export CXX=clang++-6.0 - make distcheck diff --git a/.github/workflows/autotools-clang-7.yml b/.github/workflows/autotools-clang-7.yml deleted file mode 100644 index 15e1fd1f..00000000 --- a/.github/workflows/autotools-clang-7.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "CI: autotools: clang 7" - -on: [push] - -jobs: - build: - - runs-on: ubuntu-18.04 - - steps: - - uses: actions/checkout@v1 - - name: Build - run: | - sudo apt update - sudo apt install libxml2-dev mm-common clang-7 - export CXX=clang++-7 - ./autogen.sh --enable-warnings=fatal - make - - name: Test - run: make check - - name: Distcheck - run: | - # distcheck runs configure again so we need to specify CXX again. - export CXX=clang++-7 - make distcheck diff --git a/.github/workflows/autotools-gcc-7.yml b/.github/workflows/autotools-gcc-7.yml deleted file mode 100644 index ff3d2cbf..00000000 --- a/.github/workflows/autotools-gcc-7.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "CI: autotools: gcc 7" - -on: [push] - -jobs: - build: - - runs-on: ubuntu-18.04 - - steps: - - uses: actions/checkout@v1 - - name: Build - run: | - sudo apt update - sudo apt install libxml2-dev mm-common g++-7 - export CXX=g++-7 - ./autogen.sh --enable-warnings=fatal - make - - name: Test - run: make check - - name: Distcheck - run: | - # distcheck runs configure again so we need to specify CXX again. - export CXX=g++-7 - make distcheck diff --git a/.github/workflows/meson-clang-10.yml b/.github/workflows/meson-clang-10.yml new file mode 100644 index 00000000..7ed01429 --- /dev/null +++ b/.github/workflows/meson-clang-10.yml @@ -0,0 +1,37 @@ +name: "meson: clang 10" + +on: [push] + +jobs: + build: + + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v1 + - name: Build + run: | + # Prevent blocking apt install on a question during configuring of tzdata. + export DEBIAN_FRONTEND=noninteractive + sudo apt update + sudo apt install libxml2-dev mm-common clang-10 ninja-build python3-setuptools python3-pip --yes + # Ubuntu 20.04 contains meson 0.53.2, but libxml++ requires meson >= 0.54.0. + # Install it with pip3 instead of apt. + sudo pip3 install "meson>=0.54.0" + export CC=clang-10 + export CXX=clang++-10 + meson -Dwarnings=fatal _build + cd _build + meson compile + - name: Test + run: | + cd _build + meson test + - name: Dist + run: | + sudo apt install git --yes + # dist runs setup again so we need to specify CC and CXX again. + export CC=clang-10 + export CXX=clang++-10 + cd _build + meson dist diff --git a/.github/workflows/meson-gcc-10.yml b/.github/workflows/meson-gcc-10.yml new file mode 100644 index 00000000..4bd76ca0 --- /dev/null +++ b/.github/workflows/meson-gcc-10.yml @@ -0,0 +1,37 @@ +name: "meson: gcc 10" + +on: [push] + +jobs: + build: + + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v1 + - name: Build + run: | + # Prevent blocking apt install on a question during configuring of tzdata. + export DEBIAN_FRONTEND=noninteractive + sudo apt update + sudo apt install libxml2-dev mm-common g++-10 ninja-build python3-setuptools python3-pip --yes + # Ubuntu 20.04 contains meson 0.53.2, but libxml++ requires meson >= 0.54.0. + # Install it with pip3 instead of apt. + sudo pip3 install "meson>=0.54.0" + export CC=gcc-10 + export CXX=g++-10 + meson -Dwarnings=fatal _build + cd _build + meson compile + - name: Test + run: | + cd _build + meson test + - name: Dist + run: | + sudo apt install git --yes + # dist runs setup again so we need to specify CC and CXX again. + export CC=gcc-10 + export CXX=g++-10 + cd _build + meson dist From 8705545d089906d1aa593cd5aa1c7330d93ce980 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 19 Sep 2021 16:08:09 +0200 Subject: [PATCH 136/240] docs/manual: Upgrade from DocBook 4.1 to DocBook 5.0 --- docs/manual/insert_example_code.pl | 4 +- docs/manual/insert_example_code.py | 4 +- docs/manual/libxml++_without_code.xml | 122 +++++++++++---------- docs/manual/meson.build | 13 +-- meson.build | 2 +- tools/build_scripts/tutorial-custom-cmd.py | 84 +++++++++----- 6 files changed, 132 insertions(+), 97 deletions(-) diff --git a/docs/manual/insert_example_code.pl b/docs/manual/insert_example_code.pl index 85aef6b9..8d18f319 100755 --- a/docs/manual/insert_example_code.pl +++ b/docs/manual/insert_example_code.pl @@ -16,9 +16,9 @@ #Beginning of comment: # Look for - # Source Code + # Source Code - if(/Source Code<\/ulink><\/para>/) + if(/Source Code<\/link><\/para>/) { #List all the source files in that directory: my $directory = $examples_base . $1; diff --git a/docs/manual/insert_example_code.py b/docs/manual/insert_example_code.py index a97ac014..49417c2c 100755 --- a/docs/manual/insert_example_code.py +++ b/docs/manual/insert_example_code.py @@ -11,7 +11,7 @@ # Where to insert example code. source_include_pattern = re.compile( - r'\s*Source Code') + r'\s*Source Code') # First line not part of leading comment in a source code file. # The comment typically consists of copyright and license text. @@ -50,7 +50,7 @@ def insert_example_code(examples_base_dir, input_xml_files, output_xml_file): outfile.write(line) # Look for - # Source Code + # Source Code source_include_match = source_include_pattern.match(line) if source_include_match: # List all the source files in the examples directory. diff --git a/docs/manual/libxml++_without_code.xml b/docs/manual/libxml++_without_code.xml index 2646f2a2..7a921edf 100644 --- a/docs/manual/libxml++_without_code.xml +++ b/docs/manual/libxml++_without_code.xml @@ -1,16 +1,18 @@ - - + ]> - - - + + libxml++ - An XML Parser for C++ - Murray - Cumming + + Murray + Cumming +
murrayc@murrayc.com
@@ -19,11 +21,13 @@ This is an introduction to libxml2's C++ binding, with simple examples. -
- - libxml++ + + + + libxml++ + - libxml++ is a C++ API for the popular libxml2 XML parser, written in C. + libxml++ is a C++ API for the popular libxml2 XML parser, written in C. libxml2 is famous for its high performance and compliance to standard specifications, but its C API is quite difficult even for common tasks. @@ -36,11 +40,12 @@ a C++17-compliant compiler.
- But libxml++ was created mainly to fill the need for an API-stable and ABI-stable C++ XML parser which could be used as a shared library dependency by C++ applications that are distributed widely in binary form. That means that installed applications will not break when new versions of libxml++ are installed on a user's computer. Gradual improvement of the libxml++ API is still possible via non-breaking API additions, and new independent versions of the ABI that can be installed in parallel with older versions. These are the general techniques and principles followed by the GNOME project, of which libxml++ is a part. + But libxml++ was created mainly to fill the need for an API-stable and ABI-stable C++ XML parser which could be used as a shared library dependency by C++ applications that are distributed widely in binary form. That means that installed applications will not break when new versions of libxml++ are installed on a user's computer. Gradual improvement of the libxml++ API is still possible via non-breaking API additions, and new independent versions of the ABI that can be installed in parallel with older versions. These are the general techniques and principles followed by the + GNOME project, of which libxml++ is a part. + +
+ Installation - - Installation libxml++ is packaged by major Linux and *BSD distributions and can be installed from source on Linux and Windows, using any modern compiler, such as g++ or MSVC++. For instance, to install libxml++ and its documentation on Debian, use apt-get or synaptic like so: @@ -49,40 +54,43 @@ url="http://www.gnome.org">GNOME project, of which libxml++ is a part. To check that you have the libxml++ development packages installed, and that your environment is working properly, try pkg-config libxml++-5.0 --modversion. Links for downloading and more documentation can be found at - libxmlplusplus.github.io/libxmlplusplus. + libxmlplusplus.github.io/libxmlplusplus. libxml++ is licensed under the LGPL, which allows its use via dynamic linking in both open source and closed-source software. The underlying libxml2 library uses the even more generous MIT licence. - +
+ +
+ UTF-8 and xmlpp::ustring - - UTF-8 and xmlpp::ustring The libxml++ API takes, and gives, strings in the UTF-8 Unicode encoding, which can support all known languages and locales. This choice was made because, of the encodings that have this capability, UTF-8 is the most commonly accepted choice. UTF-8 is a multi-byte encoding, meaning that some characters use more than 1 byte. But for compatibility, old-fashioned 7-bit ASCII strings are unchanged when encoded as UTF-8, and UTF-8 strings do not contain null bytes which would cause old code to misjudge the number of bytes. For these reasons, you can store a UTF-8 string in a std::string object. However, the std::string API will operate on that string in terms of bytes, instead of characters. The libxml++ API indicates when a string should be provided as UTF-8, or will be provided as UTF-8, by using the xmlpp::ustring type alias. However, this is really just a std::string, whose operator[] and size() consider bytes, not characters. - +
+ +
+ Compilation and Linking - - Compilation and Linking To use libxml++ in your application, you must tell the compiler where to find the include headers and where to find the libxml++ library. libxml++ provides a pkg-config .pc file to make this easy. For instance, the following command will provide the necessary compiler options: pkg-config libxml++-5.0 --cflags --libs When using autoconf and automake, this is even easier with the PKG_CHECK_MODULES macro in your configure.ac file. For instance: - PKG_CHECK_MODULES(SOMEAPP, libxml++-5.0 >= 5.0.0) + PKG_CHECK_MODULES(SOMEAPP, libxml++-5.0 >= 5.0.0) AC_SUBST(SOMEAPP_CFLAGS) AC_SUBST(SOMEAPP_LIBS) - +
+ - + + Parsers - - Parsers Like the underlying libxml2 library, libxml++ allows the use of 3 parsers, depending on your needs - the DOM, SAX, and TextReader parsers. The relative advantages and behaviour of these parsers will be explained here. All of the parsers may parse XML documents directly from disk, a string, or a C++ std::istream. Although the libxml++ API uses only xmlpp::ustring, indicating the UTF-8 encoding, libxml++ can parse documents in any encoding, converting to UTF-8 automatically. This conversion will not lose any information because UTF-8 can represent any locale. - Remember that white space is usually significant in XML documents, so the parsers might provide unexpected text nodes that contain only spaces and new lines. The parser does not know whether you care about these text nodes, but your application may choose to ignore them. - - - DOM Parser + Remember that white space is usually significant in XML documents, so the parsers might provide unexpected text nodes that contain only spaces and new lines. The parser does not know whether you care about these text nodes, but your application may choose to ignore them. + +
+ DOM Parser + The DOM (Document Object Model) parser parses the whole document at once and stores the structure in memory, available via DomParser::get_document(). With methods such as Document::get_root_node() and Node::get_children(), you may then navigate into the hierarchy of XML nodes without restriction, jumping forwards or backwards in the document based on the information that you encounter. Therefore the DOM parser uses a relatively large amount of memory. You should use C++ RTTI (via dynamic_cast<>) to identify the specific node type and to perform actions which are not possible with all node types. For instance, only Elements have attributes. Here is the inheritance hierarchy of node types: @@ -111,7 +119,6 @@ url="http://www.gnome.org">GNOME project, of which libxml++ is a part.xmlpp::XIncludeStart - @@ -124,39 +131,44 @@ url="http://www.gnome.org">GNOME project, of which libxml++ is a part.Although you may obtain pointers to the Nodes, these Nodes are always owned by their parent Node. In most cases that means that the Node will exist, and your pointer will be valid, as long as the Document instance exists. There are also several methods which can create new child Nodes. By using these, and one of the Document::write_*() methods, you can use libxml++ to build a new XML document. - -Example +
+Example + This example looks in the document for expected elements and then examines them. All these examples are included in the libxml++ source distribution. -Source Code - - +Source Code +
+
+ +
+ SAX Parser - - SAX Parser The SAX (Simple API for XML) parser presents each node of the XML document in sequence. So when you process one node, you must have already stored information about any relevant previous nodes, and you have no information at that time about subsequent nodes. The SAX parser uses less memory than the DOM parser and it is a suitable abstraction for documents that can be processed sequentially rather than as a whole. By using the parse_chunk() method instead of for instance parse_file(), you can even parse parts of the XML document before you have received the whole document. - As shown in the example, you should derive your own class from SaxParser and override some of the virtual methods. These "handler" methods will be called while the document is parsed. - - -Example + As shown in the example, you should derive your own class from SaxParser and override some of the virtual methods. These "handler" methods will be called while the document is parsed. + +
+Example + This example shows how the handler methods are called during parsing. -Source Code - - +Source Code +
+
+ +
+ TextReader Parser - - TextReader Parser Like the SAX parser, the TextReader parser is suitable for sequential parsing, but instead of implementing handlers for specific parts of the document, it allows you to detect the current node type, process the node accordingly, and skip forward in the document as much as necessary. Unlike the DOM parser, you may not move backwards in the XML document. And unlike the SAX parser, you must not waste time processing nodes that do not interest you. - All methods are on the single parser instance, but their result depends on the current context. For instance, use read() to move to the next node, and move_to_element() to navigate to child nodes. These methods will return false when no more nodes are available. Then use methods such as get_name() and get_value() to examine the elements and their attributes. + All methods are on the single parser instance, but their result depends on the current context. For instance, use read() to move to the next node, and move_to_element() to navigate to child nodes. These methods will return false when no more nodes are available. Then use methods such as get_name() and get_value() to examine the elements and their attributes. + +
+Example - -Example This example examines each node in turn, then moves to the next node. -Source Code - - +Source Code +
+
diff --git a/docs/manual/meson.build b/docs/manual/meson.build index ded0229d..4d915081 100644 --- a/docs/manual/meson.build +++ b/docs/manual/meson.build @@ -1,12 +1,10 @@ # docs/manual # input: install_datadir, xmlxx_pcname, tutorial_custom_cmd_py, python3, -# build_documentation, book_name, can_add_dist_script +# build_documentation, book_name, can_add_dist_script, xsltproc # output: can_parse_and_validate, build_pdf_by_default, can_build_pdf, # install_tutorialdir -# xsltproc is required by tutorial_custom_cmd_py html. -xsltproc = find_program('xsltproc', required: build_documentation) xmllint = find_program('xmllint', required: false) can_parse_and_validate = xmllint.found() @@ -14,8 +12,8 @@ can_parse_and_validate = xmllint.found() validate = get_option('validation') ? 'true' : 'false' dblatex = find_program('dblatex', required: false) -can_build_pdf = dblatex.found() or (xmllint.found() and \ - find_program('docbook2pdf', required: false).found()) +can_build_pdf = dblatex.found() or (xsltproc.found() and \ + find_program('fop', required: false).found()) build_pdf_by_default = get_option('build-pdf') # Installation directories are relative to {prefix}. @@ -49,7 +47,6 @@ custom_target('manual_html', output: 'html', command: [ python3, tutorial_custom_cmd_py, 'html', - meson.current_source_dir() / 'docbook-customisation.xsl', # stylesheet '@INPUT@', '@OUTPUT@', ], @@ -75,13 +72,13 @@ endif if can_build_pdf # Create a PDF file of the DocBook. - # Prefer dblatex, if both dblatex and docbook2pdf are available. + # Prefer dblatex, if both dblatex and fop are available. custom_target('manual_pdf', input: xml_manual_docbook, output: 'libxml++.pdf', command: [ python3, tutorial_custom_cmd_py, - dblatex.found() ? 'dblatex' : 'docbook2pdf', + dblatex.found() ? 'dblatex' : 'fop', '@INPUT@', '@OUTPUT@' ], diff --git a/meson.build b/meson.build index d3666fe9..a67e99cd 100644 --- a/meson.build +++ b/meson.build @@ -371,7 +371,7 @@ endif build_pdf = build_pdf_by_default and can_build_pdf explain_pdf = '' if build_pdf_by_default and not build_pdf - explain_pdf = ' (requires dblatex or (xmllint and docbook2pdf))' + explain_pdf = ' (requires dblatex or (xsltproc and fop))' endif summary = [ diff --git a/tools/build_scripts/tutorial-custom-cmd.py b/tools/build_scripts/tutorial-custom-cmd.py index a1e24110..3ebb78e8 100755 --- a/tools/build_scripts/tutorial-custom-cmd.py +++ b/tools/build_scripts/tutorial-custom-cmd.py @@ -23,15 +23,25 @@ def insert_ex_code(): return insert_example_code(sys.argv[3], sys.argv[4], sys.argv[5]) def html(): - # argv[2] argv[3] argv[4] - # + # argv[2] argv[3] + # - xslt_stylesheet = sys.argv[2] - input_xml_file = sys.argv[3] - output_html_dir = sys.argv[4] + input_xml_file = sys.argv[2] + output_html_dir = sys.argv[3] + # Set the use.id.as.filename param so that we don't use the chapter / section + # number as the filename, otherwise the url will change every time anything is + # re-ordered or inserted in the documentation. # For a list of available parameters, see http://docbook.sourceforge.net/release/xsl/current/doc/html/ - xslt_params = [] + xslt_params = [ + '--param', 'toc.section.depth', '1', + '--stringparam', 'chunker.output.indent', 'yes', + '--stringparam', 'chunker.output.encoding', 'UTF-8', + '--stringparam', 'toc.list.type', 'ul', + '--param', 'use.id.as.filename', '1', + ] + + xslt_stylesheet = 'http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl' # Remove old files and create the destination directory. shutil.rmtree(output_html_dir, ignore_errors=True) @@ -64,6 +74,8 @@ def xmllint(): input_xml_file = sys.argv[3] stamp_file_path = sys.argv[4] + relax_ng_schema = 'http://docbook.org/xml/5.0/rng/docbook.rng' + cmd = [ 'xmllint', '--noout', @@ -71,7 +83,7 @@ def xmllint(): '--xinclude', ] if validate == 'true': - cmd += ['--postvalid'] + cmd += ['--relaxng', relax_ng_schema] cmd += [input_xml_file] result = subprocess.run(cmd) if result.returncode: @@ -80,8 +92,11 @@ def xmllint(): Path(stamp_file_path).touch(exist_ok=True) return 0 +# dblatex and xsltproc+fop generate a PDF file. +# docbook2pdf can generate PDF files from DocBook4 files, but not from DocBook5 files. +# xsltproc+xmlroff (version 0.6.3) does not seem to work acceptably. def dblatex(): - # argv[2] argv[3] + # argv[2] argv[3] # # Create a PDF file, using dblatex. @@ -90,40 +105,51 @@ def dblatex(): # For a list of available parameters, see http://dblatex.sourceforge.net/doc/manual/ dblatex_params = [ - '-P', 'toc.section.depth=2', + '-P', 'toc.section.depth=1', '-P', 'paper.type=a4paper', + '-P', 'doc.collab.show=1', + '-P', 'latex.output.revhistory=0', ] cmd = [ 'dblatex', ] + dblatex_params + [ '-o', output_pdf_file, - '--pdf', input_xml_file, + '--pdf', + input_xml_file, ] return subprocess.run(cmd).returncode -def docbook2pdf(): - # argv[2] argv[3] +def fop(): + # argv[2] argv[3] # - # Create a PDF file, using docbook2pdf. + # Create a PDF file, using fop. input_xml_file = sys.argv[2] output_pdf_file = sys.argv[3] - output_dir = os.path.dirname(output_pdf_file) - if not output_dir: - output_dir = '.' - output_basename = os.path.basename(output_pdf_file) - if output_basename.endswith('.pdf'): - output_basename = output_basename[:-4] - xml_file = os.path.join(output_dir, output_basename + '.xml') + fo_file = os.path.splitext(output_pdf_file)[0] + '.fo' - # We need to produce a full examples XML with all of the XIncludes done. + # For a list of available parameters, see http://docbook.sourceforge.net/release/xsl/current/doc/fo/ + # For a list of available paper types, see the description of the page.width.portrait parameter. + xslt_params = [ + '--param', 'toc.section.depth', '1', + '--stringparam', 'fop1.extensions', '1', + '--stringparam', 'page.orientation', 'portrait', + '--stringparam', 'paper.type', 'A4', + ] + + xslt_stylesheet = 'http://docbook.sourceforge.net/release/xsl/current/fo/docbook.xsl' + + # Generate a .fo (formatting object) file. + # fop can take an xslt stylesheet parameter, but it can only read local files. + # xsltproc is necessary if you want to read the stylesheet from the internet. cmd = [ - 'xmllint', + 'xsltproc', + ] + xslt_params + [ + '-o', fo_file, '--xinclude', - '--postvalid', - '--output', xml_file, + xslt_stylesheet, input_xml_file, ] result = subprocess.run(cmd) @@ -131,9 +157,9 @@ def docbook2pdf(): return result.returncode cmd = [ - 'docbook2pdf', - '--output', output_dir, - xml_file, + 'fop', + '-fo', fo_file, + '-pdf', output_pdf_file, ] return subprocess.run(cmd).returncode @@ -183,8 +209,8 @@ def dist_doc(): sys.exit(xmllint()) if subcommand == 'dblatex': sys.exit(dblatex()) -if subcommand == 'docbook2pdf': - sys.exit(docbook2pdf()) +if subcommand == 'fop': + sys.exit(fop()) if subcommand == 'dist_doc': sys.exit(dist_doc()) print(sys.argv[0], ': illegal subcommand,', subcommand) From 3ddf3ae758d4f237a96c49003c856e1fd335e650 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 24 Sep 2021 18:35:13 +0200 Subject: [PATCH 137/240] CI, Meson build: Install packages for validating XML file libxml2-utils and docbook5-xml are necessary in order to validate the XML file in docs/manual/. --- .github/workflows/meson-clang-10.yml | 2 +- .github/workflows/meson-gcc-10.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/meson-clang-10.yml b/.github/workflows/meson-clang-10.yml index 7ed01429..cbb192b0 100644 --- a/.github/workflows/meson-clang-10.yml +++ b/.github/workflows/meson-clang-10.yml @@ -14,7 +14,7 @@ jobs: # Prevent blocking apt install on a question during configuring of tzdata. export DEBIAN_FRONTEND=noninteractive sudo apt update - sudo apt install libxml2-dev mm-common clang-10 ninja-build python3-setuptools python3-pip --yes + sudo apt install libxml2-dev libxml2-utils docbook5-xml mm-common clang-10 ninja-build python3-setuptools python3-pip --yes # Ubuntu 20.04 contains meson 0.53.2, but libxml++ requires meson >= 0.54.0. # Install it with pip3 instead of apt. sudo pip3 install "meson>=0.54.0" diff --git a/.github/workflows/meson-gcc-10.yml b/.github/workflows/meson-gcc-10.yml index 4bd76ca0..0b4003bc 100644 --- a/.github/workflows/meson-gcc-10.yml +++ b/.github/workflows/meson-gcc-10.yml @@ -14,7 +14,7 @@ jobs: # Prevent blocking apt install on a question during configuring of tzdata. export DEBIAN_FRONTEND=noninteractive sudo apt update - sudo apt install libxml2-dev mm-common g++-10 ninja-build python3-setuptools python3-pip --yes + sudo apt install libxml2-dev libxml2-utils docbook5-xml mm-common g++-10 ninja-build python3-setuptools python3-pip --yes # Ubuntu 20.04 contains meson 0.53.2, but libxml++ requires meson >= 0.54.0. # Install it with pip3 instead of apt. sudo pip3 install "meson>=0.54.0" From b49f738e8c97863f37772895e7582c81ad5b276c Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 27 Sep 2021 10:45:32 +0200 Subject: [PATCH 138/240] docs/manual, Meson config: Check if xmllint can be used --- Makefile.am | 1 + docs/manual/can_use_xmllint.xml | 15 +++++++++++++++ docs/manual/meson.build | 18 ++++++++++++++++++ meson.build | 2 +- tools/build_scripts/tutorial-custom-cmd.py | 12 +++++++++++- 5 files changed, 46 insertions(+), 2 deletions(-) create mode 100644 docs/manual/can_use_xmllint.xml diff --git a/Makefile.am b/Makefile.am index 10911c4e..c38f0442 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,6 +30,7 @@ EXTRA_DIST = \ meson_options.txt \ libxml++config.h.meson \ MSVC_NMake/libxml++/meson.build \ + docs/manual/can_use_xmllint.xml \ docs/manual/insert_example_code.py \ docs/manual/meson.build \ docs/reference/meson.build \ diff --git a/docs/manual/can_use_xmllint.xml b/docs/manual/can_use_xmllint.xml new file mode 100644 index 00000000..8ff1b0d4 --- /dev/null +++ b/docs/manual/can_use_xmllint.xml @@ -0,0 +1,15 @@ + + + +xmllint test + + +Introduction + + This is a short DocBook V5.0 document. It can be used for testing if the installed + version of xmllint or a similar program can validate a DocBook V5.0 document. + + + + diff --git a/docs/manual/meson.build b/docs/manual/meson.build index 4d915081..b6072ed3 100644 --- a/docs/manual/meson.build +++ b/docs/manual/meson.build @@ -25,6 +25,24 @@ if not build_documentation subdir_done() endif +# Check if xmllint can be used. +if xmllint.found() + can_parse_and_validate = run_command( + python3, tutorial_custom_cmd_py, 'xmllint', + validate, + meson.current_source_dir() / 'can_use_xmllint.xml', + meson.current_build_dir() / 'can_use_xmllint.stamp', + ).returncode() == 0 + if not can_parse_and_validate + # The DocBook V5.0 package is called docbook5-xml in Ubuntu, + # docbook5-schemas in Fedora. It may have other names in other distros. + warning('Can\'t validate XML file.\n' + + 'xmllint does not support Relax NG schemas and DocBook V5.0.\n' + + 'DocBook V5.0 support may require docbook5-xml, docbook5-schemas or a similar package.' + ) + endif +endif + doc_dist_dir = 'untracked' / 'docs' / 'manual' # Relative to MESON_DIST_ROOT # Create a DocBook XML file with the examples' source code included. diff --git a/meson.build b/meson.build index a67e99cd..073f1a43 100644 --- a/meson.build +++ b/meson.build @@ -365,7 +365,7 @@ endif validate = get_option('validation') and can_parse_and_validate explain_val = '' if get_option('validation') and not validate - explain_val = ' (requires xmllint)' + explain_val = ' (requires xmllint with Relax NG and DocBook V5.0 support)' endif build_pdf = build_pdf_by_default and can_build_pdf diff --git a/tools/build_scripts/tutorial-custom-cmd.py b/tools/build_scripts/tutorial-custom-cmd.py index 3ebb78e8..e69e074f 100755 --- a/tools/build_scripts/tutorial-custom-cmd.py +++ b/tools/build_scripts/tutorial-custom-cmd.py @@ -75,6 +75,13 @@ def xmllint(): stamp_file_path = sys.argv[4] relax_ng_schema = 'http://docbook.org/xml/5.0/rng/docbook.rng' + # schematron_schema = 'http://docbook.org/xml/5.0/sch/docbook.sch' + + # Validation against the Schematron schema does not work on Ubuntu 21.04: + # file:///usr/share/xml/docbook/schema/schematron/5.0/docbook.sch:6: element rule: + # Schemas parser error : Failed to compile context expression db:firstterm[@linkend] + # ..... + # Schematron schema http://docbook.org/xml/5.0/sch/docbook.sch failed to compile cmd = [ 'xmllint', @@ -83,7 +90,10 @@ def xmllint(): '--xinclude', ] if validate == 'true': - cmd += ['--relaxng', relax_ng_schema] + cmd += [ + '--relaxng', relax_ng_schema, + #'--schematron', schematron_schema, + ] cmd += [input_xml_file] result = subprocess.run(cmd) if result.returncode: From bfa579c874f846b450286b4e071da361a294f682 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 14 Oct 2021 14:40:55 +0200 Subject: [PATCH 139/240] docs/index.md: Update links on the web site --- docs/_config.yml | 2 +- docs/index.md | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/_config.yml b/docs/_config.yml index 966d1ac0..d163e0a4 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1 +1 @@ -name: libsigc++ +name: libxml++ diff --git a/docs/index.md b/docs/index.md index 11e7d103..0eae0a44 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,7 +6,7 @@ title: libxml++ ## Introduction -libxml++ is a C++ wrapper for the [libxml](http://www.xmlsoft.org) XML parser library. +libxml++ is a C++ wrapper for the [libxml2](http://www.xmlsoft.org) XML parser library. ## License @@ -27,7 +27,7 @@ libxml++-5.0: Does not depend on glibmm, is not as good at handling UTF-8 string ## Download -You can download libxml++ from [here](http://ftp.gnome.org/pub/GNOME/sources/libxml++/). +You can download libxml++ from [here](https://download.gnome.org/sources/libxml++/). ## Required Libraries @@ -37,7 +37,8 @@ You can download libxml++ from [here](http://ftp.gnome.org/pub/GNOME/sources/lib ## Documentation -The short [manual](http://library.gnome.org/devel/libxml++-tutorial/) gives an overview of the libxml++ API. You can also browse online the [reference documentation](http://library.gnome.org/devel/libxml++/). +The short [manual](https://developer-old.gnome.org/libxml++-tutorial/) gives an overview of the libxml++ API. +You can also browse online the [reference documentation](https://developer-old.gnome.org/libxml++/). ## Development From 18fd70ca53b468c4d8f96949afd0f38a81496fb1 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 10 Nov 2021 15:07:39 +0800 Subject: [PATCH 140/240] Win32: Don't include afxres.h in resources We can save people from a large download and a large disk footprint for the MFC/ATL items as those items are only optionally installed for later (2017+) Visual Studio versions, by including winresrc.h instead, which is always present in a Visual Studio installation. --- MSVC_NMake/libxml++/libxml++.rc.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MSVC_NMake/libxml++/libxml++.rc.in b/MSVC_NMake/libxml++/libxml++.rc.in index e7cc391c..7f623429 100644 --- a/MSVC_NMake/libxml++/libxml++.rc.in +++ b/MSVC_NMake/libxml++/libxml++.rc.in @@ -1,7 +1,7 @@ #define APSTUDIO_READONLY_SYMBOLS -#include "afxres.h" +#include "winresrc.h" #undef APSTUDIO_READONLY_SYMBOLS @@ -20,7 +20,7 @@ END 2 TEXTINCLUDE BEGIN - "#include ""afxres.h""\r\n" + "#include ""winresrc.h""\r\n" "\0" END From 09798df29ec633c5eb0f969de454d848a1e589b8 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 10 Nov 2021 15:13:04 +0800 Subject: [PATCH 141/240] build: Support Visual Studio 2022 Make these builds distinct from Visual Studio 2019 builds. --- MSVC_NMake/detectenv-msvc.mak | 5 ++++- meson.build | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/MSVC_NMake/detectenv-msvc.mak b/MSVC_NMake/detectenv-msvc.mak index e24a5ae1..789677ca 100644 --- a/MSVC_NMake/detectenv-msvc.mak +++ b/MSVC_NMake/detectenv-msvc.mak @@ -98,9 +98,12 @@ PDBVER = 14 !if $(VCVERSION) > 1909 && $(VCVERSION) < 1920 VSVER_SUFFIX = 1 VSVER = 15 -!elseif $(VCVERSION) > 1919 && $(VCVERSION) < 2000 +!elseif $(VCVERSION) > 1919 && $(VCVERSION) < 1930 VSVER_SUFFIX = 2 VSVER = 16 +!elseif $(VCVERSION) > 1929 && $(VCVERSION) < 2000 +VSVER_SUFFIX = 3 +VSVER = 17 !else VSVER = $(PDBVER) !endif diff --git a/meson.build b/meson.build index 073f1a43..25f29db2 100644 --- a/meson.build +++ b/meson.build @@ -209,7 +209,9 @@ if is_msvc add_project_arguments(cpp_compiler.get_supported_arguments([ '/utf-8', '/wd4828']), language: 'cpp') if use_msvc14x_toolset_ver - if cpp_compiler.version().version_compare('>=19.20') + if cpp_compiler.version().version_compare('>=19.30') + msvc14x_toolset_ver = '-vc143' + elif cpp_compiler.version().version_compare('>=19.20') msvc14x_toolset_ver = '-vc142' elif cpp_compiler.version().version_compare('>=19.10') msvc14x_toolset_ver = '-vc141' From 3edfc6f14d9e40632374f65a4bec1c2389475100 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 9 Jan 2022 10:00:12 +0100 Subject: [PATCH 142/240] CI: Install docbook-xsl If docbook-xsl is installed, the xsltproc command reads stylesheets from local files instead of from http://docbook.sourceforge.net. Faster and safer. Reading from docbook.sourceforge.net sometimes fails. --- .github/workflows/autotools-clang-10.yml | 2 +- .github/workflows/autotools-clang-8.yml | 2 +- .github/workflows/autotools-clang-9.yml | 2 +- .github/workflows/autotools-gcc-8.yml | 2 +- .github/workflows/autotools-gcc-9.yml | 2 +- .github/workflows/meson-clang-10.yml | 2 +- .github/workflows/meson-gcc-10.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/autotools-clang-10.yml b/.github/workflows/autotools-clang-10.yml index eaba0e3f..9ab425d4 100644 --- a/.github/workflows/autotools-clang-10.yml +++ b/.github/workflows/autotools-clang-10.yml @@ -12,7 +12,7 @@ jobs: - name: Build run: | sudo apt update - sudo apt install libxml2-dev mm-common clang-10 + sudo apt install libxml2-dev mm-common clang-10 docbook-xsl export CXX=clang++-10 ./autogen.sh --enable-warnings=fatal make diff --git a/.github/workflows/autotools-clang-8.yml b/.github/workflows/autotools-clang-8.yml index eb1507f4..d460684d 100644 --- a/.github/workflows/autotools-clang-8.yml +++ b/.github/workflows/autotools-clang-8.yml @@ -12,7 +12,7 @@ jobs: - name: Build run: | sudo apt update - sudo apt install libxml2-dev mm-common clang-8 + sudo apt install libxml2-dev mm-common clang-8 docbook-xsl export CXX=clang++-8 ./autogen.sh --enable-warnings=fatal make diff --git a/.github/workflows/autotools-clang-9.yml b/.github/workflows/autotools-clang-9.yml index 41048a5e..4ea2c11f 100644 --- a/.github/workflows/autotools-clang-9.yml +++ b/.github/workflows/autotools-clang-9.yml @@ -12,7 +12,7 @@ jobs: - name: Build run: | sudo apt update - sudo apt install libxml2-dev mm-common clang-9 + sudo apt install libxml2-dev mm-common clang-9 docbook-xsl export CXX=clang++-9 ./autogen.sh --enable-warnings=fatal make diff --git a/.github/workflows/autotools-gcc-8.yml b/.github/workflows/autotools-gcc-8.yml index b5ada569..b68aaaaa 100644 --- a/.github/workflows/autotools-gcc-8.yml +++ b/.github/workflows/autotools-gcc-8.yml @@ -12,7 +12,7 @@ jobs: - name: Build run: | sudo apt update - sudo apt install libxml2-dev mm-common g++-8 + sudo apt install libxml2-dev mm-common g++-8 docbook-xsl export CXX=g++-8 ./autogen.sh --enable-warnings=fatal make diff --git a/.github/workflows/autotools-gcc-9.yml b/.github/workflows/autotools-gcc-9.yml index e3a20864..5b24a14d 100644 --- a/.github/workflows/autotools-gcc-9.yml +++ b/.github/workflows/autotools-gcc-9.yml @@ -12,7 +12,7 @@ jobs: - name: Build run: | sudo apt update - sudo apt install libxml2-dev mm-common g++-9 + sudo apt install libxml2-dev mm-common g++-9 docbook-xsl export CXX=g++-9 ./autogen.sh --enable-warnings=fatal make diff --git a/.github/workflows/meson-clang-10.yml b/.github/workflows/meson-clang-10.yml index cbb192b0..828974df 100644 --- a/.github/workflows/meson-clang-10.yml +++ b/.github/workflows/meson-clang-10.yml @@ -14,7 +14,7 @@ jobs: # Prevent blocking apt install on a question during configuring of tzdata. export DEBIAN_FRONTEND=noninteractive sudo apt update - sudo apt install libxml2-dev libxml2-utils docbook5-xml mm-common clang-10 ninja-build python3-setuptools python3-pip --yes + sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common clang-10 ninja-build python3-setuptools python3-pip --yes # Ubuntu 20.04 contains meson 0.53.2, but libxml++ requires meson >= 0.54.0. # Install it with pip3 instead of apt. sudo pip3 install "meson>=0.54.0" diff --git a/.github/workflows/meson-gcc-10.yml b/.github/workflows/meson-gcc-10.yml index 0b4003bc..4deec56f 100644 --- a/.github/workflows/meson-gcc-10.yml +++ b/.github/workflows/meson-gcc-10.yml @@ -14,7 +14,7 @@ jobs: # Prevent blocking apt install on a question during configuring of tzdata. export DEBIAN_FRONTEND=noninteractive sudo apt update - sudo apt install libxml2-dev libxml2-utils docbook5-xml mm-common g++-10 ninja-build python3-setuptools python3-pip --yes + sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common g++-10 ninja-build python3-setuptools python3-pip --yes # Ubuntu 20.04 contains meson 0.53.2, but libxml++ requires meson >= 0.54.0. # Install it with pip3 instead of apt. sudo pip3 install "meson>=0.54.0" From ce64e8bab2827965a86c4e0d9b9a192bbb141c61 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 13 Feb 2022 16:40:06 +0100 Subject: [PATCH 143/240] meson.build: Specify 'check' option in run_command() The default value will be changed in future Meson releases. Don't use deprecated python3.path() and execute(..., gui_app: ...). Let import('python').find_installation() always find the python installation used to run Meson. Don't distribute .github/. --- .github/workflows/meson-clang-10.yml | 4 ++-- .github/workflows/meson-gcc-10.yml | 4 ++-- docs/manual/meson.build | 3 ++- docs/reference/meson.build | 4 ++-- examples/meson.build | 1 - meson.build | 28 +++++++++++++++++++--------- tests/meson.build | 1 - 7 files changed, 27 insertions(+), 18 deletions(-) diff --git a/.github/workflows/meson-clang-10.yml b/.github/workflows/meson-clang-10.yml index 828974df..ad0da5fa 100644 --- a/.github/workflows/meson-clang-10.yml +++ b/.github/workflows/meson-clang-10.yml @@ -15,9 +15,9 @@ jobs: export DEBIAN_FRONTEND=noninteractive sudo apt update sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common clang-10 ninja-build python3-setuptools python3-pip --yes - # Ubuntu 20.04 contains meson 0.53.2, but libxml++ requires meson >= 0.54.0. + # Ubuntu 20.04 contains meson 0.53.2, but libxml++ requires meson >= 0.55.0. # Install it with pip3 instead of apt. - sudo pip3 install "meson>=0.54.0" + sudo pip3 install "meson>=0.55.0" export CC=clang-10 export CXX=clang++-10 meson -Dwarnings=fatal _build diff --git a/.github/workflows/meson-gcc-10.yml b/.github/workflows/meson-gcc-10.yml index 4deec56f..074fc4d0 100644 --- a/.github/workflows/meson-gcc-10.yml +++ b/.github/workflows/meson-gcc-10.yml @@ -15,9 +15,9 @@ jobs: export DEBIAN_FRONTEND=noninteractive sudo apt update sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common g++-10 ninja-build python3-setuptools python3-pip --yes - # Ubuntu 20.04 contains meson 0.53.2, but libxml++ requires meson >= 0.54.0. + # Ubuntu 20.04 contains meson 0.53.2, but libxml++ requires meson >= 0.55.0. # Install it with pip3 instead of apt. - sudo pip3 install "meson>=0.54.0" + sudo pip3 install "meson>=0.55.0" export CC=gcc-10 export CXX=g++-10 meson -Dwarnings=fatal _build diff --git a/docs/manual/meson.build b/docs/manual/meson.build index b6072ed3..b61271f8 100644 --- a/docs/manual/meson.build +++ b/docs/manual/meson.build @@ -32,6 +32,7 @@ if xmllint.found() validate, meson.current_source_dir() / 'can_use_xmllint.xml', meson.current_build_dir() / 'can_use_xmllint.stamp', + check: false, ).returncode() == 0 if not can_parse_and_validate # The DocBook V5.0 package is called docbook5-xml in Ubuntu, @@ -107,7 +108,7 @@ endif if can_add_dist_script # Distribute built files. meson.add_dist_script( - python3.path(), tutorial_custom_cmd_py, 'dist_doc', + python3, tutorial_custom_cmd_py, 'dist_doc', doc_dist_dir, meson.current_build_dir(), meson.current_build_dir() / 'libxml++.xml', diff --git a/docs/reference/meson.build b/docs/reference/meson.build index 0178ffab..cda283c4 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -119,7 +119,7 @@ devhelp_file = custom_target('devhelp', # Install Devhelp file and html files. meson.add_install_script( - python3.path(), doc_reference_py, 'install_doc', + python3, doc_reference_py, 'install_doc', doctool_dir, devhelp_file.full_path(), install_devhelpdir, @@ -130,7 +130,7 @@ meson.add_install_script( if can_add_dist_script # Distribute built files and files copied by mm-common-get. meson.add_dist_script( - python3.path(), doc_reference_py, 'dist_doc', + python3, doc_reference_py, 'dist_doc', doctool_dir, doctool_dist_dir, meson.current_build_dir(), diff --git a/examples/meson.build b/examples/meson.build index fba8521d..938e1c03 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -39,7 +39,6 @@ foreach ex : example_programs exe_file = executable(ex_name, ex_sources, dependencies: xmlxx_own_dep, implicit_include_directories: false, - gui_app: false, build_by_default: build_examples ) diff --git a/meson.build b/meson.build index 25f29db2..9e52010c 100644 --- a/meson.build +++ b/meson.build @@ -6,8 +6,8 @@ project('libxml++', 'cpp', default_options: [ 'cpp_std=c++17' ], - meson_version: '>= 0.54.0', # required for meson.override_dependency() - # and dep.get_variable(internal:) + meson_version: '>= 0.55.0', # required for meson.add_dist_script(python3, ...) + # and meson.add_install_script(python3, ...) ) xmlxx_api_version = '5.0' @@ -44,7 +44,7 @@ project_build_root = meson.current_build_dir() cpp_compiler = meson.get_compiler('cpp') is_msvc = cpp_compiler.get_id() == 'msvc' -python3 = import('python').find_installation('python3') +python3 = import('python').find_installation() python_version = python3.language_version() python_version_req = '>= 3.5' @@ -59,7 +59,7 @@ import os import sys sys.exit(os.path.isdir("@0@") or os.path.isfile("@0@")) '''.format(project_source_root / '.git') -is_git_build = run_command(python3, '-c', cmd_py).returncode() != 0 +is_git_build = run_command(python3, '-c', cmd_py, check: false).returncode() != 0 # Are we testing a dist tarball while it's being built? # There ought to be a better way. https://github.com/mesonbuild/meson/issues/6866 @@ -178,14 +178,16 @@ tutorial_custom_cmd_py = xmlxx_script_dir / 'tutorial-custom-cmd.py' if maintainer_mode # Copy files to untracked/build_scripts and untracked/docs. run_command(mm_common_get, '--force', script_dir, - project_source_root / 'untracked' / 'docs') + project_source_root / 'untracked' / 'docs', + check: true, + ) else cmd_py = ''' import os import sys sys.exit(os.path.isfile("@0@")) '''.format(doc_reference_py) - file_exists = run_command(python3, '-c', cmd_py).returncode() != 0 + file_exists = run_command(python3, '-c', cmd_py, check: false).returncode() != 0 if not file_exists warning('Missing files in untracked/. ' + \ 'Enable maintainer-mode if you want to build documentation or create a dist tarball.') @@ -196,7 +198,9 @@ endif doc_perl_prop = run_command( python3, doc_reference_py, 'get_script_property', '', # MMDOCTOOLDIR is not used - 'requires_perl') + 'requires_perl', + check: false, +) if not (doc_perl_prop.returncode() == 0 and doc_perl_prop.stdout() == 'false') # Perl is required, if documentation shall be built. perl = find_program('perl', required: build_documentation) @@ -322,15 +326,21 @@ subdir('docs/manual') if can_add_dist_script # Add a ChangeLog file to the distribution directory. meson.add_dist_script( - python3.path(), dist_changelog_py, + python3, dist_changelog_py, project_source_root, ) + + # Don't distribute these files and directories. + dont_distribute = [ + '.github', + ] # Add build scripts to the distribution directory, and delete .gitignore # files and an empty $MESON_PROJECT_DIST_ROOT/build/ directory. meson.add_dist_script( - python3.path(), dist_build_scripts_py, + python3, dist_build_scripts_py, project_source_root, 'untracked' / 'build_scripts', + dont_distribute, ) endif diff --git a/tests/meson.build b/tests/meson.build index 77cece9e..f62e73be 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -24,7 +24,6 @@ foreach ex : test_programs exe_file = executable(ex_name, ex_sources, dependencies: xmlxx_own_dep, implicit_include_directories: false, - gui_app: false, build_by_default: build_tests ) From 686547f3715b5a485c5f0df61b55a2120b228f28 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 31 Mar 2022 12:07:33 +0200 Subject: [PATCH 144/240] libxml++/libxml++.h: Update the link to the tutorial --- libxml++/libxml++.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxml++/libxml++.h b/libxml++/libxml++.h index 228195f2..e844a0e0 100644 --- a/libxml++/libxml++.h +++ b/libxml++/libxml++.h @@ -14,7 +14,7 @@ * libxml++ is a C++ wrapper for the libxml2 XML parser and builder library. It presents a * simple C++-like API that can achieve common tasks with less code. * - * See also the libxml++ Tutorial + * See also the libxml++ Tutorial * and the libxml++ website. * * @section features Features From 8cbfa14242e2db7125e8c172553dec14bc359d58 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 22 Apr 2022 16:30:56 -0700 Subject: [PATCH 145/240] remove min warning level This can be done using warning_level=1. Fixes meson warning. --- meson.build | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/meson.build b/meson.build index 9e52010c..e9267430 100644 --- a/meson.build +++ b/meson.build @@ -4,6 +4,7 @@ project('libxml++', 'cpp', version: '5.0.1', license: 'LGPLv2.1+', default_options: [ + 'warning_level=1' 'cpp_std=c++17' ], meson_version: '>= 0.55.0', # required for meson.add_dist_script(python3, ...) @@ -227,13 +228,7 @@ xmlxx_libname = 'xml++' + msvc14x_toolset_ver + '-' + xmlxx_api_version # Set compiler warnings. warning_flags = [] -if warning_level == 'min' - if is_msvc - warning_flags = ['/W3'] - else - warning_flags = ['-Wall'] - endif -elif warning_level == 'max' or warning_level == 'fatal' +if warning_level == 'max' or warning_level == 'fatal' if is_msvc warning_flags = ['/W4'] else From 164be664cf121703b7aa67da764fd311c0e6bf75 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sat, 30 Apr 2022 09:51:16 +0200 Subject: [PATCH 146/240] meson.build: Add a necessary comma --- meson.build | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index e9267430..ca76c7ec 100644 --- a/meson.build +++ b/meson.build @@ -4,8 +4,8 @@ project('libxml++', 'cpp', version: '5.0.1', license: 'LGPLv2.1+', default_options: [ - 'warning_level=1' - 'cpp_std=c++17' + 'warning_level=1', + 'cpp_std=c++17', ], meson_version: '>= 0.55.0', # required for meson.add_dist_script(python3, ...) # and meson.add_install_script(python3, ...) From 5fd04f33fb2d5724fea9522b87bc39d05d32cbb6 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 2 May 2022 10:01:31 +0200 Subject: [PATCH 147/240] meson.build: Avoid configuration warnings --- .github/workflows/meson-clang-10.yml | 2 +- .github/workflows/meson-gcc-10.yml | 2 +- meson.build | 38 +++++++++++++++++++++------- 3 files changed, 31 insertions(+), 11 deletions(-) diff --git a/.github/workflows/meson-clang-10.yml b/.github/workflows/meson-clang-10.yml index ad0da5fa..3f521d8a 100644 --- a/.github/workflows/meson-clang-10.yml +++ b/.github/workflows/meson-clang-10.yml @@ -20,7 +20,7 @@ jobs: sudo pip3 install "meson>=0.55.0" export CC=clang-10 export CXX=clang++-10 - meson -Dwarnings=fatal _build + meson -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true _build cd _build meson compile - name: Test diff --git a/.github/workflows/meson-gcc-10.yml b/.github/workflows/meson-gcc-10.yml index 074fc4d0..4e704937 100644 --- a/.github/workflows/meson-gcc-10.yml +++ b/.github/workflows/meson-gcc-10.yml @@ -20,7 +20,7 @@ jobs: sudo pip3 install "meson>=0.55.0" export CC=gcc-10 export CXX=g++-10 - meson -Dwarnings=fatal _build + meson -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true _build cd _build meson compile - name: Test diff --git a/meson.build b/meson.build index ca76c7ec..743052b8 100644 --- a/meson.build +++ b/meson.build @@ -74,10 +74,12 @@ maintainer_mode = maintainer_mode_opt == 'true' or \ if is_dist_check message('Looks like a tarball is being tested. ' + \ 'Option "dist-warnings" is used instead of "warnings".') - warning_level = get_option('dist-warnings') + cpp_warnings = get_option('dist-warnings') else - warning_level = get_option('warnings') + cpp_warnings = get_option('warnings') endif +warning_level = get_option('warning_level').to_int() +werror = get_option('werror') build_deprecated_api = get_option('build-deprecated-api') build_documentation_opt = get_option('build-documentation') build_documentation = build_documentation_opt == 'true' or \ @@ -227,14 +229,31 @@ endif xmlxx_libname = 'xml++' + msvc14x_toolset_ver + '-' + xmlxx_api_version # Set compiler warnings. +# Meson warns if any of the /W1, /W2, /W3, /W4, /Wall, -Wall, -Wextra, -Werror +# compiler options are added with add_project_arguments(). +# Avoid such warnings, when possible. +# See _warn_about_builtin_args() in meson/mesonbuild/interpreter/interpreter.py. warning_flags = [] -if warning_level == 'max' or warning_level == 'fatal' - if is_msvc - warning_flags = ['/W4'] - else - warning_flags = '-pedantic -Wall -Wextra -Wformat-security -Wsuggest-override -Wshadow -Wno-long-long'.split() +if cpp_warnings == 'min' + if warning_level == 0 + if is_msvc + warning_flags = ['/W2'] + else + warning_flags = ['-Wall'] + endif + endif +elif cpp_warnings == 'max' or cpp_warnings == 'fatal' + if warning_level < 3 + if is_msvc + warning_flags = ['/W4'] + else + warning_flags = ['-pedantic', '-Wall', '-Wextra'] + endif + endif + if not is_msvc + warning_flags += '-Wformat-security -Wsuggest-override -Wshadow -Wno-long-long'.split() endif - if warning_level == 'fatal' + if cpp_warnings == 'fatal' and not werror if is_msvc warning_flags += ['/WX'] else @@ -387,7 +406,8 @@ summary = [ meson.project_name() + ' ' + meson.project_version(), '', ' Maintainer mode: @0@@1@'.format(maintainer_mode_opt, real_maintainer_mode), - ' Compiler warnings: @0@'.format(warning_level), + ' Compiler warnings: @0@ (warning_level: @1@, werror: @2@)'. \ + format(cpp_warnings, warning_level, werror), ' Build deprecated API: @0@'.format(build_deprecated_api), 'Build HTML documentation: @0@@1@'.format(build_documentation_opt, real_build_documentation), ' XML validation: @0@@1@'.format(validate, explain_val), From 35db47668c3cb90ece21468dbcfce5a1a7e56c1c Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 6 May 2022 15:05:55 +0200 Subject: [PATCH 148/240] docs/manual: Sort example file lists so that docs/manual/libxml++.xml builds in a reproducible way. See https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/merge_requests/15 by Bernhard M. Wiedemann. --- docs/manual/insert_example_code.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/manual/insert_example_code.py b/docs/manual/insert_example_code.py index 49417c2c..e8985d71 100755 --- a/docs/manual/insert_example_code.py +++ b/docs/manual/insert_example_code.py @@ -56,8 +56,8 @@ def insert_example_code(examples_base_dir, input_xml_files, output_xml_file): # List all the source files in the examples directory. source_directory = os.path.join(examples_base_dir, source_include_match.group(1)) outfile.write('\n') - for source_filename in glob.glob(os.path.join(source_directory, '*.h')) + \ - glob.glob(os.path.join(source_directory, '*.cc')): + for source_filename in sorted(glob.glob(os.path.join(source_directory, '*.h'))) + \ + sorted(glob.glob(os.path.join(source_directory, '*.cc'))): source_basename = os.path.basename(source_filename) process_source_file(source_directory, source_basename, outfile) outfile.write('\n') From f985ee9cafdbf9b981ab2d29f7b28f7fdb1cd157 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 23 May 2022 18:04:00 +0800 Subject: [PATCH 149/240] Meson: Some minor cleanups We don't actually need to check for the /wd4828 compiler flag here, so stop checking for that. Move the '/utf-8' compiler flag check to be together with the other warning- related compiler flag checks. --- meson.build | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/meson.build b/meson.build index 743052b8..52bf45da 100644 --- a/meson.build +++ b/meson.build @@ -213,8 +213,6 @@ endif msvc14x_toolset_ver = '' if is_msvc - add_project_arguments(cpp_compiler.get_supported_arguments([ '/utf-8', '/wd4828']), language: 'cpp') - if use_msvc14x_toolset_ver if cpp_compiler.version().version_compare('>=19.30') msvc14x_toolset_ver = '-vc143' @@ -268,7 +266,7 @@ add_project_arguments(warning_flags, language: 'cpp') # MSVC: Ignore warnings that aren't really harmful, but make those # that should not be overlooked stand out. if is_msvc - foreach wd : ['/FImsvc_recommended_pragmas.h', '/wd4267', '/EHsc' ] + foreach wd : ['/FImsvc_recommended_pragmas.h', '/utf-8', '/wd4267', '/EHsc' ] disabled_warning = cpp_compiler.get_supported_arguments(wd) add_project_arguments(disabled_warning, language: 'cpp') endforeach From ffcefeccc0186cc51683592a1466b2acd4ab2f53 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 23 May 2022 18:07:40 +0800 Subject: [PATCH 150/240] meson/MSVC: Re-organize warning-related compiler flags Add a short description for each of the warning-related compiler flags that we apply globally. Also, apply '/wd4267' only when we are building a 64-bit build, as that warning should only be related to 64-bit builds. --- meson.build | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index 52bf45da..15081ab9 100644 --- a/meson.build +++ b/meson.build @@ -266,10 +266,20 @@ add_project_arguments(warning_flags, language: 'cpp') # MSVC: Ignore warnings that aren't really harmful, but make those # that should not be overlooked stand out. if is_msvc - foreach wd : ['/FImsvc_recommended_pragmas.h', '/utf-8', '/wd4267', '/EHsc' ] - disabled_warning = cpp_compiler.get_supported_arguments(wd) - add_project_arguments(disabled_warning, language: 'cpp') - endforeach + disable_warnings_list = [ + '/FImsvc_recommended_pragmas.h', # Turn off harmless warnings but make potentially + # dangerous ones glaring, distributed with GLib + '/EHsc', # avoid warnings caused by exception handling model used + '/utf-8', # Avoid C4819 unicode conversion warnings when building on CJK locales + ] + if host_machine.cpu_family() == 'x86_64' or host_machine.cpu_family() == 'aarch64' + # 'var' : conversion from 'size_t' to 'type', possible loss of data (applies on 64-bit builds) + disable_warnings_list += '/wd4267' + endif + add_project_arguments( + cpp_compiler.get_supported_arguments(disable_warnings_list), + language: 'cpp' + ) endif # Configure files From 36d88bfbd7f401c6bf93b61c31a4b5955eec73e4 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 23 May 2022 18:09:28 +0800 Subject: [PATCH 151/240] Meson/MSVC: Ignore warning C4706 ... which means "assignment within conditional expression". We don't really need to worry too much about this warning here. --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index 15081ab9..6980b3a8 100644 --- a/meson.build +++ b/meson.build @@ -271,6 +271,7 @@ if is_msvc # dangerous ones glaring, distributed with GLib '/EHsc', # avoid warnings caused by exception handling model used '/utf-8', # Avoid C4819 unicode conversion warnings when building on CJK locales + '/wd4706', # assignment within conditional expression ] if host_machine.cpu_family() == 'x86_64' or host_machine.cpu_family() == 'aarch64' # 'var' : conversion from 'size_t' to 'type', possible loss of data (applies on 64-bit builds) From cc48aae0532d34975c1c596caabfcdeaf9be7e20 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Mon, 23 May 2022 18:20:40 +0800 Subject: [PATCH 152/240] Meson: Compensate for the lack of msvc_recommended_pragmas.h libxml++-5.x and later no longer depends on glibmm (hence GLib), so msvc_recommended_pragmas.h may not be available. If it isn't, disable warnings C4244 and C4101 to compensate for it. --- meson.build | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index 6980b3a8..259069ab 100644 --- a/meson.build +++ b/meson.build @@ -267,12 +267,23 @@ add_project_arguments(warning_flags, language: 'cpp') # that should not be overlooked stand out. if is_msvc disable_warnings_list = [ - '/FImsvc_recommended_pragmas.h', # Turn off harmless warnings but make potentially - # dangerous ones glaring, distributed with GLib '/EHsc', # avoid warnings caused by exception handling model used '/utf-8', # Avoid C4819 unicode conversion warnings when building on CJK locales '/wd4706', # assignment within conditional expression ] + + # Turn off harmless warnings but make potentially dangerous ones glaring, + # distributed with GLib, if available + use_recommended_pragmas = cpp_compiler.get_supported_arguments('/FImsvc_recommended_pragmas.h') + if use_recommended_pragmas.length() > 0 + add_project_arguments(use_recommended_pragmas, language: 'cpp') + else + disable_warnings_list += [ + '/wd4244', # 'conversion' conversion from 'type1' to 'type2', possible loss of data + '/wd4101', # unreferenced local variable + ] + endif + if host_machine.cpu_family() == 'x86_64' or host_machine.cpu_family() == 'aarch64' # 'var' : conversion from 'size_t' to 'type', possible loss of data (applies on 64-bit builds) disable_warnings_list += '/wd4267' From be2f824c23ca68acbc22f9526546ad4c466278ff Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Fri, 10 Jun 2022 20:31:06 -0700 Subject: [PATCH 153/240] parsers: Avoid std::getline for istream inputs For streambuf implementations that can't set a public get area, getline falls back to a character-by-character implementation. Instead we can pass the stream to xmlCreateIOParserCtxt(). This simplifies the parse stream methods and brings them nearly identical to the other parse methods. --- libxml++/parsers/domparser.cc | 80 +++++------------ libxml++/parsers/saxparser.cc | 78 +++++------------ tests/istream_ioparser/main.cc | 152 +++++++++++++++++++++++++++++++++ tests/meson.build | 1 + 4 files changed, 196 insertions(+), 115 deletions(-) create mode 100644 tests/istream_ioparser/main.cc diff --git a/libxml++/parsers/domparser.cc b/libxml++/parsers/domparser.cc index ef856362..ad4c9608 100644 --- a/libxml++/parsers/domparser.cc +++ b/libxml++/parsers/domparser.cc @@ -153,8 +153,8 @@ void DomParser::check_xinclude_and_finish_parsing() int options = xinclude_options_; // Turn on/off any xinclude options. options |= set_options; - options &= ~clear_options; - + options &= ~clear_options; + if (options & XML_PARSE_XINCLUDE) { const int n_substitutions = xmlXIncludeProcessFlags(context_->myDoc, options); @@ -174,6 +174,19 @@ void DomParser::check_xinclude_and_finish_parsing() Parser::release_underlying(); } +namespace { + extern "C" { + static int _io_read_callback(void * context, + char * buffer, + int len) + { + std::istream *in = static_cast(context); + in->read(buffer, len); + return in->gcount(); + } + } +} + void DomParser::parse_stream(std::istream& in) { release_underlying(); //Free any existing document. @@ -181,67 +194,20 @@ void DomParser::parse_stream(std::istream& in) KeepBlanks k(KeepBlanks::Default); xmlResetLastError(); - context_ = xmlCreatePushParserCtxt( - nullptr, // Setting those two parameters to nullptr force the parser - nullptr, // to create a document while parsing. - nullptr, // chunk - 0, // size - nullptr); // no filename for fetching external entities + context_ = xmlCreateIOParserCtxt( + nullptr, // Setting those two parameters to nullptr force the parser + nullptr, // to create a document while parsing. + _io_read_callback, + nullptr, // inputCloseCallback + &in, + XML_CHAR_ENCODING_NONE); if(!context_) { throw internal_error("Could not create parser context\n" + format_xml_error()); } - initialize_context(); - - // std::string or ustring? - // Output from the XML parser is UTF-8 encoded. - // But the istream "in" is input, i.e. an XML file. It can use any encoding. - // If it's not UTF-8, the file itself must contain information about which - // encoding it uses. See the XML specification. Thus use std::string. - int firstParseError = XML_ERR_OK; - std::string line; - while(std::getline(in, line)) - { - // since getline does not get the line separator, we have to add it since the parser cares - // about layout in certain cases. - line += '\n'; - - const int parseError = xmlParseChunk(context_, line.c_str(), - line.size() /* This is a std::string, not a ustring, so this is the number of bytes. */, 0); - - // Save the first error code if any, but read on. - // More errors might be reported and then thrown by check_for_exception(). - if (parseError != XML_ERR_OK && firstParseError == XML_ERR_OK) - firstParseError = parseError; - } - - const int parseError = xmlParseChunk(context_, nullptr, 0, 1 /* last chunk */); - if (parseError != XML_ERR_OK && firstParseError == XML_ERR_OK) - firstParseError = parseError; - - try - { - check_for_exception(); - } - catch (...) - { - release_underlying(); //Free doc_ and context_ - throw; // re-throw exception - } - - auto error_str = format_xml_parser_error(context_); - if (error_str.empty() && firstParseError != XML_ERR_OK) - error_str = "Error code from xmlParseChunk(): " + std::to_string(firstParseError); - - if(!error_str.empty()) - { - release_underlying(); //Free doc_ and context_ - throw parse_error(error_str); - } - - check_xinclude_and_finish_parsing(); + parse_context(); } void DomParser::release_underlying() diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index 71674877..4fbf2d10 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -209,6 +209,19 @@ void SaxParser::parse_memory(const ustring& contents) parse_memory_raw((const unsigned char*)contents.c_str(), contents.size()); } +namespace { + extern "C" { + static int _io_read_callback(void * context, + char * buffer, + int len) + { + std::istream *in = static_cast(context); + in->read(buffer, len); + return in->gcount(); + } + } +} + void SaxParser::parse_stream(std::istream& in) { if(context_) @@ -217,66 +230,15 @@ void SaxParser::parse_stream(std::istream& in) } KeepBlanks k(KeepBlanks::Default); - xmlResetLastError(); - context_ = xmlCreatePushParserCtxt( + context_ = xmlCreateIOParserCtxt( sax_handler_.get(), - nullptr, // user_data - nullptr, // chunk - 0, // size - nullptr); // no filename for fetching external entities - - if(!context_) - { - throw internal_error("Could not create parser context\n" + format_xml_error()); - } - - initialize_context(); - - // std::string or ustring? - // Output from the XML parser is UTF-8 encoded. - // But the istream "in" is input, i.e. an XML file. It can use any encoding. - // If it's not UTF-8, the file itself must contain information about which - // encoding it uses. See the XML specification. Thus use std::string. - int firstParseError = XML_ERR_OK; - std::string line; - while (!exception_ && std::getline(in, line)) - { - // since getline does not get the line separator, we have to add it since the parser care - // about layout in certain cases. - line += '\n'; - - const int parseError = xmlParseChunk(context_, line.c_str(), - line.size() /* This is a std::string, not a ustring, so this is the number of bytes. */, - 0 /* don't terminate */); - - // Save the first error code if any, but read on. - // More errors might be reported and then thrown by check_for_exception(). - if (parseError != XML_ERR_OK && firstParseError == XML_ERR_OK) - firstParseError = parseError; - } - - if (!exception_) - { - //This is called just to terminate parsing. - const int parseError = xmlParseChunk(context_, nullptr /* chunk */, 0 /* size */, 1 /* terminate (1 or 0) */); - - if (parseError != XML_ERR_OK && firstParseError == XML_ERR_OK) - firstParseError = parseError; - } - - auto error_str = format_xml_parser_error(context_); - if (error_str.empty() && firstParseError != XML_ERR_OK) - error_str = "Error code from xmlParseChunk(): " + std::to_string(firstParseError); - - release_underlying(); // Free context_ - - check_for_exception(); - - if(!error_str.empty()) - { - throw parse_error(error_str); - } + nullptr, // user_data + _io_read_callback, + nullptr, // inputCloseCallback + &in, + XML_CHAR_ENCODING_NONE); + parse(); } void SaxParser::parse_chunk(const ustring& chunk) diff --git a/tests/istream_ioparser/main.cc b/tests/istream_ioparser/main.cc new file mode 100644 index 00000000..89821adb --- /dev/null +++ b/tests/istream_ioparser/main.cc @@ -0,0 +1,152 @@ +/* Copyright (C) 2022 The libxml++ development team + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include + +#include +#include +#include +#include + +class test_streambuf : public std::streambuf +{ +public: + test_streambuf() : + uflow_calls(0), + underflow_calls(0), + ofs(0), + buf("\n") + { + } + +protected: + /* Simulate some kind of streambuf impl that doesn't setg() */ + virtual int_type underflow() override final + { + ++underflow_calls; + if (ofs >= (sizeof(buf)-1)) + return traits_type::eof(); + return traits_type::to_int_type(buf[ofs]); + } + + virtual int_type uflow() override final + { + ++uflow_calls; + if (ofs >= (sizeof(buf)-1)) + return traits_type::eof(); + return traits_type::to_int_type(buf[ofs++]); + } + + virtual std::streamsize showmanyc() override final + { + if (ofs >= (sizeof(buf)-1)) + return traits_type::eof(); + return sizeof(buf)-1-ofs; + } + + virtual std::streamsize xsgetn(char_type* s, std::streamsize count) override final + { + auto n = std::min(count, static_cast(sizeof(buf)-1-ofs)); + memcpy(s, buf + ofs, n); + ofs += n; + return n; + } + +public: + int uflow_calls; + int underflow_calls; + +private: + size_t ofs; + char buf[15]; +}; + +class MySaxParser : public xmlpp::SaxParser { +public: + bool saw_root = false; +protected: + virtual void on_start_document() override final + { + saw_root = false; + } + virtual void on_end_element(const xmlpp::ustring &name) override final + { + if (name == "root") + saw_root = true; + } +}; + +int main() +{ + { // Check DomParser works well with normal and custom istreams + xmlpp::DomParser parser; + try + { + std::stringstream ss(""); + parser.parse_stream(ss); + } + catch(...) + { + assert(false); + } + + { + auto doc = parser.get_document(); + assert(doc->get_root_node()->get_name() == "root"); + } + + { + test_streambuf buf; + try { + std::istream is(&buf); + parser.parse_stream(is); + } catch (...) { + assert(false); + } + assert(buf.underflow_calls + buf.uflow_calls < 3); + auto doc = parser.get_document(); + assert(doc->get_root_node()->get_name() == "root"); + } + } + { // Check SaxParser works well with normal and custom istreams. + MySaxParser parser; + try + { + std::stringstream ss(""); + parser.parse_stream(ss); + } + catch(...) + { + assert(false); + } + assert(parser.saw_root); + + { + test_streambuf buf; + try { + std::istream is(&buf); + parser.parse_stream(is); + } catch (...) { + assert(false); + } + assert(buf.underflow_calls + buf.uflow_calls < 3); + assert(parser.saw_root); + } + } + assert(true); + return EXIT_SUCCESS; +} diff --git a/tests/meson.build b/tests/meson.build index f62e73be..9e7948d1 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -8,6 +8,7 @@ test_programs = [ [['saxparser_chunk_parsing_inconsistent_state'], 'test', ['main.cc']], [['saxparser_parse_double_free'], 'test', ['main.cc']], [['saxparser_parse_stream_inconsistent_state'], 'test', ['main.cc']], + [['istream_ioparser'], 'test', ['main.cc']], ] foreach ex : test_programs From 3585d90b9b346d71c815e11c94e20f454b63c448 Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Fri, 10 Jun 2022 22:45:47 -0700 Subject: [PATCH 154/240] Add test to autotools build --- tests/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 96bfe237..ad58ba03 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -21,10 +21,12 @@ LDADD = $(top_builddir)/libxml++/libxml++-$(LIBXMLXX_API_VERSION).la $(LIBXMLXX_ check_PROGRAMS = \ saxparser_chunk_parsing_inconsistent_state/test \ saxparser_parse_double_free/test \ - saxparser_parse_stream_inconsistent_state/test + saxparser_parse_stream_inconsistent_state/test \ + istream_ioparser/test TESTS = $(check_PROGRAMS) saxparser_chunk_parsing_inconsistent_state_test_SOURCES = saxparser_chunk_parsing_inconsistent_state/main.cc saxparser_parse_double_free_test_SOURCES = saxparser_parse_double_free/main.cc saxparser_parse_stream_inconsistent_state_test_SOURCES = saxparser_parse_stream_inconsistent_state/main.cc +istream_ioparser_test_SOURCES = istream_ioparser/main.cc From 2a2825c67a30ea34f3514659bfd91111db8e009d Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Wed, 22 Jun 2022 10:03:54 -0700 Subject: [PATCH 155/240] meson: enable static building on windows --- libxml++config.h.meson | 2 ++ meson.build | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libxml++config.h.meson b/libxml++config.h.meson index 2f0264f0..2a5f03b2 100755 --- a/libxml++config.h.meson +++ b/libxml++config.h.meson @@ -16,6 +16,8 @@ /* Micro version number of libxml++. */ #mesondefine LIBXMLXX_MICRO_VERSION +#mesondefine LIBXMLXX_STATIC + // Enable DLL-specific stuff only when not building a static library #if !defined(__CYGWIN__) && (defined(__MINGW32__) || defined(_MSC_VER)) && !defined(LIBXMLXX_STATIC) # define LIBXMLPP_DLL 1 diff --git a/meson.build b/meson.build index 259069ab..c9441449 100644 --- a/meson.build +++ b/meson.build @@ -325,10 +325,12 @@ endif # Static library? library_build_type = get_option('default_library') +pkg_conf_data.set('LIBXMLXX_STATIC', library_build_type == 'static') + if cpp_compiler.get_argument_syntax() == 'msvc' - if library_build_type == 'static' or library_build_type == 'both' - error('Static builds are not supported by MSVC-style builds') + if library_build_type == 'both' + error('Dynamic+Static builds are not supported by MSVC-style builds') endif endif From 5ca94a59e979a5cb43728166cb638089ac647f8e Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Wed, 22 Jun 2022 13:32:08 -0700 Subject: [PATCH 156/240] meson: no _WINDLL when static --- libxml++/meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxml++/meson.build b/libxml++/meson.build index a3960ff9..27269559 100644 --- a/libxml++/meson.build +++ b/libxml++/meson.build @@ -88,7 +88,7 @@ endforeach xmlxx_cpp_args = [ '-DLIBXMLPP_BUILD=1' ] # Make sure we are exporting the symbols from the DLL -if is_msvc +if is_msvc and get_option('default_library') != 'static' xmlxx_cpp_args += ['-D_WINDLL'] endif From ac10f92ec63a2a0c5f50cda4835ea20781caff75 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Thu, 23 Jun 2022 15:31:18 +0800 Subject: [PATCH 157/240] istream_ioparser test: Include algorithm header Some Visual Studio releases require it to be included to use std::min(). --- tests/istream_ioparser/main.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/istream_ioparser/main.cc b/tests/istream_ioparser/main.cc index 89821adb..f5b167c3 100644 --- a/tests/istream_ioparser/main.cc +++ b/tests/istream_ioparser/main.cc @@ -17,6 +17,7 @@ #include +#include #include #include #include From bd5fe958bd0bd60bd78765533efe27af93446e58 Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Wed, 22 Jun 2022 10:28:42 -0700 Subject: [PATCH 158/240] meson: Add libxml2 cmake wrap --- libxml++/meson.build | 8 +++- meson.build | 68 ++++++++++++++++++++++++++-------- subprojects/libxml2_cmake.wrap | 4 ++ 3 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 subprojects/libxml2_cmake.wrap diff --git a/libxml++/meson.build b/libxml++/meson.build index 27269559..d51378e4 100644 --- a/libxml++/meson.build +++ b/libxml++/meson.build @@ -92,6 +92,8 @@ if is_msvc and get_option('default_library') != 'static' xmlxx_cpp_args += ['-D_WINDLL'] endif +xmlxx_all_deps = [xmlxx_build_dep] + extra_xmlxx_objects = [] # Build the .rc file for Windows builds and link to it @@ -99,6 +101,10 @@ if host_machine.system() == 'windows' windows = import('windows') xmlxx_res = windows.compile_resources(xmlxx_rc) extra_xmlxx_objects += xmlxx_res + + if xml2_is_subproject + xmlxx_all_deps += [winsock_dep] + endif endif extra_include_dirs = ['..'] @@ -119,5 +125,5 @@ xmlxx_library = library(xmlxx_libname, xmlxx_own_dep = declare_dependency( link_with: xmlxx_library, include_directories: extra_include_dirs, - dependencies: xmlxx_build_dep + dependencies: xmlxx_all_deps ) diff --git a/meson.build b/meson.build index c9441449..c46e12fd 100644 --- a/meson.build +++ b/meson.build @@ -7,8 +7,7 @@ project('libxml++', 'cpp', 'warning_level=1', 'cpp_std=c++17', ], - meson_version: '>= 0.55.0', # required for meson.add_dist_script(python3, ...) - # and meson.add_install_script(python3, ...) + meson_version: '>= 0.60.0', # required for dependency('iconv') ) xmlxx_api_version = '5.0' @@ -105,9 +104,12 @@ install_pkgconfigdir = install_libdir / 'pkgconfig' xml2_min_ver = '2.7.7' xml2_req = '>= @0@'.format(xml2_min_ver) xml2_dep = dependency('libxml-2.0', version: xml2_req, required: host_machine.system() != 'windows') +xml2_is_subproject = false +libxml2_lib_set = false if not xml2_dep.found() libxml2_lib = 'libxml2' + libxml2_lib_set = true xml2_dep = cpp_compiler.find_library(libxml2_lib, has_headers: [ 'libxml/globals.h', @@ -122,19 +124,51 @@ if not xml2_dep.found() 'libxml/xmlIO.h', 'libxml/xmlreader.h', 'libxml/xmlschemas.h', - ]) - - xml_min_ver_split = xml2_min_ver.split('.') - xml_min_ver_int = xml_min_ver_split[0].to_int() * 10000 + \ - xml_min_ver_split[1].to_int() * 100 + \ - xml_min_ver_split[2].to_int() - - if not cpp_compiler.compiles('''#include - #if LIBXML_VERSION < @0@ - # error libxml2 versions must be @1@ or later - #endif'''.format(xml_min_ver_int.to_string(), xml2_min_ver), - name : 'libxml2 is @0@ or later'.format(xml2_min_ver)) - error('Your libxml2 installation must be @0@ or later'.format(xml2_min_ver)) + ], + required: false) + if xml2_dep.found() + xml_min_ver_split = xml2_min_ver.split('.') + xml_min_ver_int = xml_min_ver_split[0].to_int() * 10000 + \ + xml_min_ver_split[1].to_int() * 100 + \ + xml_min_ver_split[2].to_int() + + if not cpp_compiler.compiles('''#include + #if LIBXML_VERSION < @0@ + # error libxml2 versions must be @1@ or later + #endif'''.format(xml_min_ver_int.to_string(), xml2_min_ver), + name : 'libxml2 is @0@ or later'.format(xml2_min_ver)) + error('Your libxml2 installation must be @0@ or later'.format(xml2_min_ver)) + endif + else + cmake = import('cmake') + opt_var = cmake.subproject_options() + build_shared = get_option('default_library') != 'static' + iconv_dep = dependency('iconv', required: false) + icu_i18n_dep = dependency('icu-i18n', required: false) + icu_uc_dep = dependency('icu-uc', required: false) + lzma_dep = dependency('liblzma', required: false) + thread_dep = dependency('threads', required: false) + zlib_dep = dependency('zlib', required: false) + winsock_dep = cpp_compiler.find_library('ws2_32', required: false) + opt_var.add_cmake_defines({'BUILD_SHARED_LIBS': build_shared, + 'LIBXML2_WITH_HTTP': host_machine.system() != 'windows' or winsock_dep.found(), + 'LIBXML2_WITH_ICONV': iconv_dep.found(), + 'LIBXML2_WITH_ICU': icu_i18n_dep.found() and icu_uc_dep.found(), + 'LIBXML2_WITH_LZMA': lzma_dep.found(), + 'LIBXML2_WITH_PYTHON': false, + 'LIBXML2_WITH_TESTS': build_tests, + 'LIBXML2_WITH_THREADS': thread_dep.found(), + 'LIBXML2_WITH_ZLIB': zlib_dep.found(), + }) + + xml2_sp = cmake.subproject('libxml2_cmake', options: opt_var) + xml2_dep = xml2_sp.dependency('LibXml2') + xml2_is_subproject = true + + if build_tests + test('testchar', xml2_sp.target('testchar')) + test('testdict', xml2_sp.target('testdict')) + endif endif endif @@ -146,7 +180,9 @@ libxml2_lib_pkgconfig = '' if xml2_dep.type_name() == 'pkgconfig' xmlxx_requires += ['libxml-2.0', xml2_req] else - libxml2_lib_pkgconfig = '-l@0@'.format(libxml2_lib) + if libxml2_lib_set + libxml2_lib_pkgconfig = '-l@0@'.format(libxml2_lib) + endif endif xmlxx_requires = ' '.join(xmlxx_requires) diff --git a/subprojects/libxml2_cmake.wrap b/subprojects/libxml2_cmake.wrap new file mode 100644 index 00000000..a6f60f33 --- /dev/null +++ b/subprojects/libxml2_cmake.wrap @@ -0,0 +1,4 @@ +[wrap-git] +url = https://gitlab.gnome.org/GNOME/libxml2.git +revision = master +depth = 1 From 1c972d3a90e066701e5cbe77324f1dd776dea1f1 Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Thu, 23 Jun 2022 10:14:01 -0700 Subject: [PATCH 159/240] meson: Don't override meson's cpp_eh option From meson 0.51.0, cpp_eh defaults to /EHsc on windows. Passing it to add_program_arguments() means downstream projects using cpp_eh=a will get warnings. --- meson.build | 1 - 1 file changed, 1 deletion(-) diff --git a/meson.build b/meson.build index c46e12fd..c855957f 100644 --- a/meson.build +++ b/meson.build @@ -303,7 +303,6 @@ add_project_arguments(warning_flags, language: 'cpp') # that should not be overlooked stand out. if is_msvc disable_warnings_list = [ - '/EHsc', # avoid warnings caused by exception handling model used '/utf-8', # Avoid C4819 unicode conversion warnings when building on CJK locales '/wd4706', # assignment within conditional expression ] From 43acb9c656bbf11c66bbf1ad4cebbb9150c74d92 Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Thu, 23 Jun 2022 21:48:19 -0700 Subject: [PATCH 160/240] meson: Clear CMAKE C FLAGS for subproject --- meson.build | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/meson.build b/meson.build index c855957f..8d0f7826 100644 --- a/meson.build +++ b/meson.build @@ -150,7 +150,22 @@ if not xml2_dep.found() thread_dep = dependency('threads', required: false) zlib_dep = dependency('zlib', required: false) winsock_dep = cpp_compiler.find_library('ws2_32', required: false) + cmake_build_type = get_option('buildtype') + if get_option('buildtype') == 'debugoptimized' + cmake_build_type = 'RelWithDebInfo' + elif get_option('buildtype') == 'minsize' + cmake_build_type = 'MinSizeRel' + elif get_option('buildtype') == 'plain' + cmake_build_type = '' + endif opt_var.add_cmake_defines({'BUILD_SHARED_LIBS': build_shared, + 'CMAKE_BUILD_TYPE': cmake_build_type, + 'CMAKE_MSVC_RUNTIME_LIBRARY': '', + 'CMAKE_C_FLAGS_INIT': '', + 'CMAKE_C_FLAGS_DEBUG': '', + 'CMAKE_C_FLAGS_RELEASE': '', + 'CMAKE_C_FLAGS_RELWITHDEBINFO': '', + 'CMAKE_C_FLAGS_MINSIZEREL': '', 'LIBXML2_WITH_HTTP': host_machine.system() != 'windows' or winsock_dep.found(), 'LIBXML2_WITH_ICONV': iconv_dep.found(), 'LIBXML2_WITH_ICU': icu_i18n_dep.found() and icu_uc_dep.found(), From 178a7e5127dc74f8c2c4cab68bdb929517cc8683 Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Wed, 15 Jun 2022 00:53:55 -0700 Subject: [PATCH 161/240] github: add windows workflow --- .github/workflows/meson-windows-2022.yml | 38 ++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .github/workflows/meson-windows-2022.yml diff --git a/.github/workflows/meson-windows-2022.yml b/.github/workflows/meson-windows-2022.yml new file mode 100644 index 00000000..27a924b7 --- /dev/null +++ b/.github/workflows/meson-windows-2022.yml @@ -0,0 +1,38 @@ +name: "meson: windows 2022" + +on: [push, workflow_dispatch] + +jobs: + build: + + runs-on: windows-2022 + + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.x' + - run: pip install meson ninja + + - name: Prepare MSVC + uses: bus1/cabuild/action/msdevshell@v1 + with: + architecture: x64 + + - name: Configure + run: meson setup --warnlevel 3 --werror -Dlibxml2_cmake:werror=false -Dmaintainer-mode=false _build + + - name: Compile + run: ninja -C _build + + - name: Test + run: meson test -C _build + + - name: Configure static + run: meson setup --warnlevel 3 --werror -Dlibxml2_cmake:werror=false --default-library static -Dmaintainer-mode=false _build_static + + - name: Compile static + run: ninja -C _build_static + + - name: Test static + run: meson test -C _build_static From 76823176d6ce8f3871fa603f4336dd50d59e1fb2 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 1 Jul 2022 20:57:58 -0700 Subject: [PATCH 162/240] clang-tidy: use make_unique Found with modernize-make-unique Signed-off-by: Rosen Penev --- libxml++/parsers/parser.cc | 6 +++--- libxml++/parsers/saxparser.cc | 2 +- libxml++/validators/validator.cc | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc index 5b5d1684..cfe6addc 100644 --- a/libxml++/parsers/parser.cc +++ b/libxml++/parsers/parser.cc @@ -227,9 +227,9 @@ void Parser::check_for_error_and_warning_messages() } if (validity_msg) - exception_.reset(new validity_error(msg)); + exception_ = std::make_unique(msg); else if (parser_msg) - exception_.reset(new parse_error(msg)); + exception_ = std::make_unique(msg); } //static @@ -331,7 +331,7 @@ void Parser::handle_exception() #ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch (...) { - exception_.reset(new wrapped_exception(std::current_exception())); + exception_ = std::make_unique(std::current_exception()); } #else catch (const std::exception& e) diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index 4fbf2d10..0cf60a5f 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -333,7 +333,7 @@ void SaxParser::initialize_context() { Parser::initialize_context(); // Start with an empty Document for entity resolution. - entity_resolver_doc_.reset(new Document); + entity_resolver_doc_ = std::make_unique(); } diff --git a/libxml++/validators/validator.cc b/libxml++/validators/validator.cc index 9347b516..fa9f7b18 100644 --- a/libxml++/validators/validator.cc +++ b/libxml++/validators/validator.cc @@ -68,7 +68,7 @@ void Validator::check_for_validity_messages() } if (validity_msg) - exception_.reset(new validity_error(msg)); + exception_ = std::make_unique(msg); } void Validator::callback_validity_error(void* valid_, const char* msg, ...) @@ -130,17 +130,17 @@ void Validator::handle_exception() #ifdef LIBXMLXX_HAVE_EXCEPTION_PTR catch (...) { - exception_.reset(new wrapped_exception(std::current_exception())); + exception_ = std::make_unique(std::current_exception()); } #else catch (const std::exception& e) { - exception_.reset(new exception(e.what())); + exception_ = std::make_unique(e.what()); } catch (...) { - exception_.reset(new exception("An exception was thrown that is not derived from std::exception or xmlpp::exception.\n" - "It could not be caught and rethrown because this platform does not support std::exception_ptr.")); + exception_ = std::make_unique("An exception was thrown that is not derived from std::exception or xmlpp::exception.\n" + "It could not be caught and rethrown because this platform does not support std::exception_ptr."); } #endif From 9e9ae240c6fe0753c026436258e90d4d4f049d28 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 1 Jul 2022 20:47:50 -0700 Subject: [PATCH 163/240] clang-tidy: make deleted functions public Found with modernize-use-equals-delete Signed-off-by: Rosen Penev --- libxml++/noncopyable.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libxml++/noncopyable.h b/libxml++/noncopyable.h index 8a7b6561..667fe371 100644 --- a/libxml++/noncopyable.h +++ b/libxml++/noncopyable.h @@ -17,14 +17,15 @@ namespace xmlpp */ class LIBXMLPP_API NonCopyable { -protected: - NonCopyable() noexcept; - virtual ~NonCopyable(); - +public: NonCopyable(const NonCopyable&) = delete; NonCopyable& operator=(const NonCopyable&) = delete; NonCopyable(NonCopyable&&) = delete; NonCopyable& operator=(NonCopyable&&) = delete; + +protected: + NonCopyable() noexcept; + virtual ~NonCopyable(); }; } // namespace xmlpp From 6170fd15e4a060b6aeacaea43dc2bf1840621de7 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 1 Jul 2022 21:24:35 -0700 Subject: [PATCH 164/240] clang-tidy: remove pessimising const Found with performance-no-automatic-move Signed-off-by: Rosen Penev --- libxml++/attributenode.cc | 2 +- libxml++/nodes/node.cc | 2 +- libxml++/parsers/textreader.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libxml++/attributenode.cc b/libxml++/attributenode.cc index 2d999fda..cd48554c 100644 --- a/libxml++/attributenode.cc +++ b/libxml++/attributenode.cc @@ -28,7 +28,7 @@ ustring AttributeNode::get_value() const else value = xmlGetNoNsProp(cobj()->parent, cobj()->name); - const ustring retn = value ? (const char*)value : ""; + ustring retn = value ? (const char*)value : ""; if (value) xmlFree(value); return retn; diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index 15680ea8..c9426e9f 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -206,7 +206,7 @@ xmlpp::ustring eval_common_to_string(const xmlpp::ustring& xpath, xmlXPathFreeObject(xpath_value); if (result) { - const xmlpp::ustring uresult(reinterpret_cast(result)); + xmlpp::ustring uresult(reinterpret_cast(result)); xmlFree(result); return uresult; } diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc index 7f6f2125..88f7ecd9 100644 --- a/libxml++/parsers/textreader.cc +++ b/libxml++/parsers/textreader.cc @@ -410,7 +410,7 @@ ustring TextReader::PropertyReader::String(xmlChar* value, bool free) if (!value) return ustring(); - const ustring result = (char *)value; + ustring result = (char *)value; if(free) xmlFree(value); From 77becea7593aa3b632490c1fd1e37c1691e232ea Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 1 Jul 2022 21:32:39 -0700 Subject: [PATCH 165/240] clang-tidy: use range loops Found with modernize-loop-convert Signed-off-by: Rosen Penev --- libxml++/nodes/node.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index c9426e9f..ca39e236 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -65,11 +65,10 @@ Tvector find_common(const xmlpp::ustring& xpath, if (namespaces) { - for (xmlpp::Node::PrefixNsMap::const_iterator it = namespaces->begin(); - it != namespaces->end(); ++it) + for (const auto& [prefix, ns_uri] : *namespaces) xmlXPathRegisterNs(ctxt, - reinterpret_cast(it->first.c_str()), - reinterpret_cast(it->second.c_str())); + reinterpret_cast(prefix.c_str()), + reinterpret_cast(ns_uri.c_str())); } auto result = xmlXPathEval((const xmlChar*)xpath.c_str(), ctxt); @@ -140,11 +139,10 @@ xmlXPathObject* eval_common(const xmlpp::ustring& xpath, if (namespaces) { - for (xmlpp::Node::PrefixNsMap::const_iterator it = namespaces->begin(); - it != namespaces->end(); ++it) + for (const auto& [prefix, ns_uri] : *namespaces) xmlXPathRegisterNs(ctxt, - reinterpret_cast(it->first.c_str()), - reinterpret_cast(it->second.c_str())); + reinterpret_cast(prefix.c_str()), + reinterpret_cast(ns_uri.c_str())); } auto xpath_value = xmlXPathEvalExpression( From e1cf8e743f2ac8dc84dcf09907fbda3bd8d31e42 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 1 Jul 2022 21:35:44 -0700 Subject: [PATCH 166/240] clang-tidy: replace throw() with noexcept Found with modernize-use-noexcept Signed-off-by: Rosen Penev --- examples/sax_exception/myparser.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/sax_exception/myparser.cc b/examples/sax_exception/myparser.cc index 4c94f124..5004b251 100644 --- a/examples/sax_exception/myparser.cc +++ b/examples/sax_exception/myparser.cc @@ -30,9 +30,7 @@ MyException::MyException() { } -MyException::~MyException() throw () -{ -} +MyException::~MyException() noexcept = default; void MyException::raise() const { From 8ac95788f567ee6f3d15ac8b49c139c1488bb1b4 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 1 Jul 2022 20:49:06 -0700 Subject: [PATCH 167/240] clang-tidy: use override Found with modernize-use-override Signed-off-by: Rosen Penev --- libxml++/validators/schemavalidatorbase.h | 2 +- tests/istream_ioparser/main.cc | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libxml++/validators/schemavalidatorbase.h b/libxml++/validators/schemavalidatorbase.h index 382e8b88..a7f1a508 100644 --- a/libxml++/validators/schemavalidatorbase.h +++ b/libxml++/validators/schemavalidatorbase.h @@ -70,7 +70,7 @@ class SchemaValidatorBase : public Validator * @endcode */ LIBXMLPP_API - explicit virtual operator bool() const noexcept override = 0; + explicit operator bool() const noexcept override = 0; /** Validate a document, using a previously parsed schema. * @param document Pointer to the document. diff --git a/tests/istream_ioparser/main.cc b/tests/istream_ioparser/main.cc index f5b167c3..9fbbca97 100644 --- a/tests/istream_ioparser/main.cc +++ b/tests/istream_ioparser/main.cc @@ -36,7 +36,7 @@ class test_streambuf : public std::streambuf protected: /* Simulate some kind of streambuf impl that doesn't setg() */ - virtual int_type underflow() override final + int_type underflow() final { ++underflow_calls; if (ofs >= (sizeof(buf)-1)) @@ -44,7 +44,7 @@ class test_streambuf : public std::streambuf return traits_type::to_int_type(buf[ofs]); } - virtual int_type uflow() override final + int_type uflow() final { ++uflow_calls; if (ofs >= (sizeof(buf)-1)) @@ -52,14 +52,14 @@ class test_streambuf : public std::streambuf return traits_type::to_int_type(buf[ofs++]); } - virtual std::streamsize showmanyc() override final + std::streamsize showmanyc() final { if (ofs >= (sizeof(buf)-1)) return traits_type::eof(); return sizeof(buf)-1-ofs; } - virtual std::streamsize xsgetn(char_type* s, std::streamsize count) override final + std::streamsize xsgetn(char_type* s, std::streamsize count) final { auto n = std::min(count, static_cast(sizeof(buf)-1-ofs)); memcpy(s, buf + ofs, n); @@ -80,11 +80,11 @@ class MySaxParser : public xmlpp::SaxParser { public: bool saw_root = false; protected: - virtual void on_start_document() override final + void on_start_document() final { saw_root = false; } - virtual void on_end_element(const xmlpp::ustring &name) override final + void on_end_element(const xmlpp::ustring &name) final { if (name == "root") saw_root = true; From 44ae82b731a258d1a604030d60e4eabbe4670748 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 5 Jul 2022 17:26:28 +0200 Subject: [PATCH 168/240] tests/istream_ioparser/main.cc: Replace final by override gcc 8 does not understand that final implies override. --- tests/istream_ioparser/main.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/istream_ioparser/main.cc b/tests/istream_ioparser/main.cc index 9fbbca97..b94dc825 100644 --- a/tests/istream_ioparser/main.cc +++ b/tests/istream_ioparser/main.cc @@ -36,7 +36,7 @@ class test_streambuf : public std::streambuf protected: /* Simulate some kind of streambuf impl that doesn't setg() */ - int_type underflow() final + int_type underflow() override { ++underflow_calls; if (ofs >= (sizeof(buf)-1)) @@ -44,7 +44,7 @@ class test_streambuf : public std::streambuf return traits_type::to_int_type(buf[ofs]); } - int_type uflow() final + int_type uflow() override { ++uflow_calls; if (ofs >= (sizeof(buf)-1)) @@ -52,14 +52,14 @@ class test_streambuf : public std::streambuf return traits_type::to_int_type(buf[ofs++]); } - std::streamsize showmanyc() final + std::streamsize showmanyc() override { if (ofs >= (sizeof(buf)-1)) return traits_type::eof(); return sizeof(buf)-1-ofs; } - std::streamsize xsgetn(char_type* s, std::streamsize count) final + std::streamsize xsgetn(char_type* s, std::streamsize count) override { auto n = std::min(count, static_cast(sizeof(buf)-1-ofs)); memcpy(s, buf + ofs, n); @@ -80,11 +80,11 @@ class MySaxParser : public xmlpp::SaxParser { public: bool saw_root = false; protected: - void on_start_document() final + void on_start_document() override { saw_root = false; } - void on_end_element(const xmlpp::ustring &name) final + void on_end_element(const xmlpp::ustring &name) override { if (name == "root") saw_root = true; From 57f26597b1faaf19b1ef81ca3a1f89ecd0d70e59 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Tue, 5 Jul 2022 16:15:57 -0700 Subject: [PATCH 169/240] clang-tidy: add missing move avoids copying Signed-off-by: Rosen Penev --- libxml++/exceptions/wrapped_exception.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxml++/exceptions/wrapped_exception.cc b/libxml++/exceptions/wrapped_exception.cc index 062dbebc..00cdc37f 100644 --- a/libxml++/exceptions/wrapped_exception.cc +++ b/libxml++/exceptions/wrapped_exception.cc @@ -23,7 +23,7 @@ namespace xmlpp #ifdef LIBXMLXX_HAVE_EXCEPTION_PTR wrapped_exception::wrapped_exception(std::exception_ptr exception_ptr) - : exception("Wrapped exception"), exception_ptr_(exception_ptr) + : exception("Wrapped exception"), exception_ptr_(std::move(exception_ptr)) { } From 2f3c5af897e59719cb3226a84f42ed3ab65cab7f Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 1 Jul 2022 21:21:02 -0700 Subject: [PATCH 170/240] clang-tidy: use C++ headers Found with modernize-deprecated-headers Signed-off-by: Rosen Penev --- examples/dom_build/main.cc | 4 ++-- examples/dom_parser_raw/main.cc | 4 ++-- examples/dom_read_write/main.cc | 4 ++-- examples/dom_xinclude/main.cc | 4 ++-- examples/dom_xpath/main.cc | 4 ++-- examples/dtdvalidation/main.cc | 4 ++-- examples/sax_exception/main.cc | 2 +- examples/sax_parser/main.cc | 4 ++-- examples/sax_parser_build_dom/main.cc | 2 +- examples/sax_parser_entities/main.cc | 2 +- examples/textreader/main.cc | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/examples/dom_build/main.cc b/examples/dom_build/main.cc index 7cd1478a..eadc98d0 100644 --- a/examples/dom_build/main.cc +++ b/examples/dom_build/main.cc @@ -21,9 +21,9 @@ #include #endif -#include +#include #include -#include +#include int main(int /* argc */, char** /* argv */) diff --git a/examples/dom_parser_raw/main.cc b/examples/dom_parser_raw/main.cc index 552490ec..653128ca 100644 --- a/examples/dom_parser_raw/main.cc +++ b/examples/dom_parser_raw/main.cc @@ -19,9 +19,9 @@ #include -#include +#include #include -#include +#include void print_node(const xmlpp::Node* node, unsigned int indentation = 0) { diff --git a/examples/dom_read_write/main.cc b/examples/dom_read_write/main.cc index 1ceeb15c..3cdba11f 100644 --- a/examples/dom_read_write/main.cc +++ b/examples/dom_read_write/main.cc @@ -23,9 +23,9 @@ #include #endif -#include +#include #include -#include +#include int main(int argc, char* argv[]) diff --git a/examples/dom_xinclude/main.cc b/examples/dom_xinclude/main.cc index 8837836a..8603a268 100644 --- a/examples/dom_xinclude/main.cc +++ b/examples/dom_xinclude/main.cc @@ -20,9 +20,9 @@ #include #endif -#include +#include #include -#include +#include void print_node(const xmlpp::Node* node, unsigned int indentation = 0) { diff --git a/examples/dom_xpath/main.cc b/examples/dom_xpath/main.cc index 8003b718..8c15b60e 100644 --- a/examples/dom_xpath/main.cc +++ b/examples/dom_xpath/main.cc @@ -21,9 +21,9 @@ #include #endif -#include -#include +#include #include +#include std::string result_type_to_ustring(xmlpp::XPathResultType result_type) { diff --git a/examples/dtdvalidation/main.cc b/examples/dtdvalidation/main.cc index 7ca4aecf..8ac0a314 100644 --- a/examples/dtdvalidation/main.cc +++ b/examples/dtdvalidation/main.cc @@ -22,9 +22,9 @@ #include #endif -#include +#include #include -#include +#include int main(int argc, char* argv[]) { diff --git a/examples/sax_exception/main.cc b/examples/sax_exception/main.cc index 869afa2e..2b5407ed 100644 --- a/examples/sax_exception/main.cc +++ b/examples/sax_exception/main.cc @@ -26,8 +26,8 @@ #endif #include "myparser.h" +#include #include -#include int main(int /* argc */, char** /* argv */) { diff --git a/examples/sax_parser/main.cc b/examples/sax_parser/main.cc index 1ff2147d..0cb5adc0 100644 --- a/examples/sax_parser/main.cc +++ b/examples/sax_parser/main.cc @@ -21,10 +21,10 @@ #include #endif +#include +#include // std::memset() #include #include -#include -#include // std::memset() #include "myparser.h" diff --git a/examples/sax_parser_build_dom/main.cc b/examples/sax_parser_build_dom/main.cc index d6016157..2bf67596 100644 --- a/examples/sax_parser_build_dom/main.cc +++ b/examples/sax_parser_build_dom/main.cc @@ -23,9 +23,9 @@ #include #endif +#include #include #include -#include #include "svgparser.h" #include "svgdocument.h" diff --git a/examples/sax_parser_entities/main.cc b/examples/sax_parser_entities/main.cc index ed372d0d..97948873 100644 --- a/examples/sax_parser_entities/main.cc +++ b/examples/sax_parser_entities/main.cc @@ -21,9 +21,9 @@ #include #endif +#include #include #include -#include #include "myparser.h" diff --git a/examples/textreader/main.cc b/examples/textreader/main.cc index 0d748cad..87129f69 100644 --- a/examples/textreader/main.cc +++ b/examples/textreader/main.cc @@ -26,8 +26,8 @@ #include #include +#include #include -#include struct indent { int depth_; From dc6e3b4887bd541154760a0dd5156fc711c731ae Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 1 Jul 2022 21:34:27 -0700 Subject: [PATCH 171/240] clang-tidy: use auto Found with modernize-use-auto Signed-off-by: Rosen Penev --- examples/dom_parser/main.cc | 2 +- examples/dom_xinclude/main.cc | 2 +- libxml++/nodes/node.cc | 2 +- libxml++/parsers/domparser.cc | 2 +- libxml++/parsers/saxparser.cc | 2 +- libxml++/validators/dtdvalidator.cc | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/dom_parser/main.cc b/examples/dom_parser/main.cc index edb4b0d0..ae78b733 100644 --- a/examples/dom_parser/main.cc +++ b/examples/dom_parser/main.cc @@ -66,7 +66,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) { std::cout << indent << "content = " << nodeContent->get_content() << std::endl; } - else if(const xmlpp::Element* nodeElement = dynamic_cast(node)) + else if(auto nodeElement = dynamic_cast(node)) { //A normal Element node: diff --git a/examples/dom_xinclude/main.cc b/examples/dom_xinclude/main.cc index 8603a268..8017e0b6 100644 --- a/examples/dom_xinclude/main.cc +++ b/examples/dom_xinclude/main.cc @@ -65,7 +65,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) { std::cout << indent << "content = " << nodeContent->get_content() << std::endl; } - else if (const xmlpp::Element* nodeElement = dynamic_cast(node)) + else if (auto nodeElement = dynamic_cast(node)) { //A normal Element node: std::cout << indent << " Element line = " << node->get_line() << std::endl; diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index ca39e236..c6ce949b 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -463,7 +463,7 @@ ustring Node::get_namespace_prefix() const else if (impl_->type == XML_ATTRIBUTE_DECL) { //impl_ is actually of type xmlAttribute, instead of just xmlNode. - const xmlAttribute* const attr = reinterpret_cast(impl_); + auto attr = reinterpret_cast(impl_); return attr->prefix ? (const char*)attr->prefix : ""; } else if(impl_->ns && impl_->ns->prefix) diff --git a/libxml++/parsers/domparser.cc b/libxml++/parsers/domparser.cc index ad4c9608..e2eeb9a3 100644 --- a/libxml++/parsers/domparser.cc +++ b/libxml++/parsers/domparser.cc @@ -180,7 +180,7 @@ namespace { char * buffer, int len) { - std::istream *in = static_cast(context); + auto in = static_cast(context); in->read(buffer, len); return in->gcount(); } diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index 0cf60a5f..328bbcb5 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -215,7 +215,7 @@ namespace { char * buffer, int len) { - std::istream *in = static_cast(context); + auto in = static_cast(context); in->read(buffer, len); return in->gcount(); } diff --git a/libxml++/validators/dtdvalidator.cc b/libxml++/validators/dtdvalidator.cc index 703c2c74..f456f1e7 100644 --- a/libxml++/validators/dtdvalidator.cc +++ b/libxml++/validators/dtdvalidator.cc @@ -164,7 +164,7 @@ void DtdValidator::validate(const Document* document) xmlResetLastError(); initialize_context(); - const bool res = (bool)xmlValidateDtd(pimpl_->context, (xmlDoc*)document->cobj(), + const auto res = (bool)xmlValidateDtd(pimpl_->context, (xmlDoc*)document->cobj(), pimpl_->dtd->cobj()); if (!res) From a5f95c4c45e08ca8111d524391a9c0c5b0221fda Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 16 Aug 2022 23:28:30 +0800 Subject: [PATCH 172/240] NMake Makefiles: Remove dependency on msvc_recommended_pragmas.h We don't depend on glibmm for libxml++-5.x, so drop the forced include. Mishap when migrating the NMake Makefiles for libxml++-4.x, which does depend on glibmm. --- MSVC_NMake/config-msvc.mak | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/MSVC_NMake/config-msvc.mak b/MSVC_NMake/config-msvc.mak index 75e78977..749f2f73 100644 --- a/MSVC_NMake/config-msvc.mak +++ b/MSVC_NMake/config-msvc.mak @@ -15,10 +15,9 @@ DEBUG_SUFFIX = LIBXMLXX_BASE_CFLAGS = \ /I.\libxml++ /I.. /EHsc \ - /FImsvc_recommended_pragmas.h \ + /wd4244 /wd4101 \ /std:c++17 - LIBXMLXX_EXTRA_INCLUDES = \ /I$(PREFIX)\include\libxml2 \ /I$(PREFIX)\include From 99e6ed1b1aff0b4df2de59d8335bc42e17400cc8 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 16 Aug 2022 23:44:01 +0800 Subject: [PATCH 173/240] NMake Makefiles: Make things more configurable Add the INCLUDEDIR and LIBDIR options, so that we can set where we find dependent headers and libraries, if they are not in %INCLUDE% and/or %LIB% and are not in $(PREFIX)\include and $(PREFIX)\lib. Also mention about the PREFIX and PERL options, so that one can use them when necessary. --- MSVC_NMake/config-msvc.mak | 13 ++++++++++--- MSVC_NMake/detectenv-msvc.mak | 2 +- MSVC_NMake/info-msvc.mak | 13 +++++++++++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/MSVC_NMake/config-msvc.mak b/MSVC_NMake/config-msvc.mak index 749f2f73..03ac22c7 100644 --- a/MSVC_NMake/config-msvc.mak +++ b/MSVC_NMake/config-msvc.mak @@ -1,7 +1,14 @@ # NMake Makefile portion for enabling features for Windows builds # These are the base minimum libraries required for building glibmm. -BASE_INCLUDES = /I$(PREFIX)\include +!ifndef INCLUDEDIR +INCLUDEDIR = $(PREFIX)\include +!endif +!ifndef LIBDIR +LIBDIR = $(PREFIX)\lib +!endif + +BASE_INCLUDES = /I$(INCLUDEDIR) # Please do not change anything beneath this line unless maintaining the NMake Makefiles LIBXMLXX_MAJOR_VERSION = 5 @@ -19,8 +26,8 @@ LIBXMLXX_BASE_CFLAGS = \ /std:c++17 LIBXMLXX_EXTRA_INCLUDES = \ - /I$(PREFIX)\include\libxml2 \ - /I$(PREFIX)\include + /I$(INCLUDEDIR)\libxml2 \ + /I$(INCLUDEDIR) LIBXMLXX_CFLAGS = /DLIBXMLPP_BUILD $(LIBXMLXX_BASE_CFLAGS) $(LIBXMLXX_EXTRA_INCLUDES) LIBXMLXX_EX_CFLAGS = $(LIBXMLXX_BASE_CFLAGS) $(LIBXMLXX_EXTRA_INCLUDES) diff --git a/MSVC_NMake/detectenv-msvc.mak b/MSVC_NMake/detectenv-msvc.mak index 789677ca..ae7c4ba2 100644 --- a/MSVC_NMake/detectenv-msvc.mak +++ b/MSVC_NMake/detectenv-msvc.mak @@ -160,7 +160,7 @@ LDFLAGS_ARCH = /machine:x86 CFLAGS_NOGL = $(CFLAGS_ADD_NO_GL) /W3 /Zi CFLAGS = $(CFLAGS_ADD) /W3 /Zi -LDFLAGS_BASE = $(LDFLAGS_ARCH) /libpath:$(PREFIX)\lib /DEBUG +LDFLAGS_BASE = $(LDFLAGS_ARCH) /libpath:$(LIBDIR) /DEBUG !if "$(CFG)" == "debug" || "$(CFG)" == "Debug" ARFLAGS_NOLTCG = $(LDFLAGS_ARCH) diff --git a/MSVC_NMake/info-msvc.mak b/MSVC_NMake/info-msvc.mak index 2882de46..14205058 100644 --- a/MSVC_NMake/info-msvc.mak +++ b/MSVC_NMake/info-msvc.mak @@ -32,6 +32,19 @@ help: @echo. @echo USE_MESON_LIBS: Use DLLs and LIBs of C++ dependencies that are built with Meson, @echo as applicable. + @echo. + @echo PERL: Full path to PERL interpreter, if not already in PATH, needed to generate + @echo libxml++config.h and libxml++.rc if not already present in .\libxml++. + @echo. + @echo PREFIX: Base directory to look for dependencies and location for where the + @echo build results are copied, default is in ..\..\^$(short_vs_ver)\^$(platform) + @echo. + @echo INCLUDEDIR: Base include directory to look for dependenct headers, + @echo such as libxml2, default is in ^$(PREFIX)\include. + @echo. + @echo LIBDIR: Base directory to look for dependent libraries, such as libxml2, + @echo default is in ^$(PREFIX)\lib. + @echo. @echo ====== @echo A 'clean' target is supported to remove all generated files, intermediate @echo object files and binaries for the specified configuration. From 524861b255576afabf28bcd1a145f2893d477e80 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 17 Aug 2022 11:43:18 +0800 Subject: [PATCH 174/240] MSVC_NMake/README: Document dependency placement ... so that it is easier for people to build libxml++ with less need to tinker with the build files or the %INCLUDE% and %LIB% envvars. --- MSVC_NMake/README | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/MSVC_NMake/README b/MSVC_NMake/README index b29b6faf..3e0b0a44 100644 --- a/MSVC_NMake/README +++ b/MSVC_NMake/README @@ -8,6 +8,23 @@ Building libxml++ with Visual Studio 2017 or later * Run `nmake /f Makefile.vc CFG=[debug|release]` to buiild libxml++. Run `nmake /f Makefile.vc` without the `CFG=[debug|release] flag to see which options are supported by the NMake Makefiles +* It is recommended that the dependent items is to be placed like the following, or be placed in paths + indicated by %INCLUDE% and %LIB% respectively for the headers and .lib's: + +\include + | + -libxml2 (and items in its subdir(s)) + | + -(any dependent headers of libraries enabled by libxml2) + +\lib + | + -libxml2.lib + + Fine-tune by passing in PREFIX=..., INCLUDEDIR=... (default:$(PREFIX)\include, example would be + INCLUDEDIR=\include) and LIBDIR=... (default: $(PREFIX)\lib, example would be + LIBDIR=\lib) as needed. + Cedric Gustin 01/26/2005 From 649c5ee6cf519a2b4c0da3c260ce963c66481dcf Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 6 Sep 2022 08:58:38 +0200 Subject: [PATCH 175/240] DomParser, SaxParser: Move anonymous namespace out of namespace xmlpp --- libxml++/parsers/domparser.cc | 26 +++++++++++++------------- libxml++/parsers/saxparser.cc | 26 +++++++++++++------------- tests/meson.build | 2 +- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/libxml++/parsers/domparser.cc b/libxml++/parsers/domparser.cc index e2eeb9a3..e3f03ec3 100644 --- a/libxml++/parsers/domparser.cc +++ b/libxml++/parsers/domparser.cc @@ -17,6 +17,19 @@ #include #include +namespace { + extern "C" { + static int _io_read_callback(void * context, + char * buffer, + int len) + { + auto in = static_cast(context); + in->read(buffer, len); + return in->gcount(); + } + } +} + namespace xmlpp { @@ -174,19 +187,6 @@ void DomParser::check_xinclude_and_finish_parsing() Parser::release_underlying(); } -namespace { - extern "C" { - static int _io_read_callback(void * context, - char * buffer, - int len) - { - auto in = static_cast(context); - in->read(buffer, len); - return in->gcount(); - } - } -} - void DomParser::parse_stream(std::istream& in) { release_underlying(); //Free any existing document. diff --git a/libxml++/parsers/saxparser.cc b/libxml++/parsers/saxparser.cc index 328bbcb5..2b0905a9 100644 --- a/libxml++/parsers/saxparser.cc +++ b/libxml++/parsers/saxparser.cc @@ -17,6 +17,19 @@ #include //For va_list. #include +namespace { + extern "C" { + static int _io_read_callback(void * context, + char * buffer, + int len) + { + auto in = static_cast(context); + in->read(buffer, len); + return in->gcount(); + } + } +} + namespace xmlpp { struct SaxParserCallback @@ -209,19 +222,6 @@ void SaxParser::parse_memory(const ustring& contents) parse_memory_raw((const unsigned char*)contents.c_str(), contents.size()); } -namespace { - extern "C" { - static int _io_read_callback(void * context, - char * buffer, - int len) - { - auto in = static_cast(context); - in->read(buffer, len); - return in->gcount(); - } - } -} - void SaxParser::parse_stream(std::istream& in) { if(context_) diff --git a/tests/meson.build b/tests/meson.build index 9e7948d1..7dd04142 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -5,10 +5,10 @@ test_programs = [ # [[dir-name], exe-name, [sources]] + [['istream_ioparser'], 'test', ['main.cc']], [['saxparser_chunk_parsing_inconsistent_state'], 'test', ['main.cc']], [['saxparser_parse_double_free'], 'test', ['main.cc']], [['saxparser_parse_stream_inconsistent_state'], 'test', ['main.cc']], - [['istream_ioparser'], 'test', ['main.cc']], ] foreach ex : test_programs From e9cfa4276bc07414f456b741e09dce1dcd7df752 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 9 Sep 2022 16:37:25 +0200 Subject: [PATCH 176/240] Makefile.am: Distribute subprojects/libxml2_cmake.wrap --- Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.am b/Makefile.am index c38f0442..dfc71dc0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,6 +36,7 @@ EXTRA_DIST = \ docs/reference/meson.build \ examples/meson.build \ libxml++/meson.build \ + subprojects/libxml2_cmake.wrap \ subprojects/mm-common.wrap \ tests/meson.build \ tools/build_scripts/tutorial-custom-cmd.py \ From f31bac6c078643eb77e2da837fb2085cd4a671e2 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 9 Sep 2022 16:38:42 +0200 Subject: [PATCH 177/240] 5.0.2 --- NEWS | 40 ++++++++++++++++++++++++++++++++++++++++ configure.ac | 2 +- meson.build | 2 +- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 0a7da1cf..735f8fc3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,43 @@ +5.0.2 (stable): + +* Document, Node: Recognize HTML documents + (Kjell Ahlstedt) Issue #23 (rkd77) +* Parsers: Avoid std::getline for istream inputs + (Andrew Potter) Pull request #28 +* Many small updates, suggested by the clang-tidy program + (Rosen Penev) Pull requests #33-#35, #37-#43 + +Build: +* Meson build: When mm-common >= 1.0.4 is used, Perl is not required + (Kjell Ahlstedt) +* Win32: Don't include afxres.h in resources +* Support Visual Studio 2022 + (Chun-wei Fan) +* Meson build: Specify 'check' option in run_command() + Will be necessary with future versions of Meson. + (Kjell Ahlstedt) +* Meson build: Avoid configuration warnings + (Kjell Ahlstedt, Rosen Penev) Pull request #27 +* docs/manual: Sort example file lists + See https://gitlab.gnome.org/GNOME/gtkmm-documentation/-/merge_requests/15 + by Bernhard M. Wiedemann + (Kjell Ahlstedt) +* Meson build: Enable static building on windows + (Andrew Potter) Pull request #29 +* Meson build: Require meson >= 0.60.0 +* Meson build: libxml2 can be built as a subproject + (Andrew Potter) Pull request #30 +* NMake Makefiles: Remove dependency on msvc_recommended_pragmas.h +* NMake Makefiles: Make things more configurable + (Chun-wei Fan) Issue #44 (lxxxd) + +Documentation: +* docs/manual: Upgrade from DocBook 4.1 to DocBook 5.0 + (Kjell Ahlstedt) +* MSVC_NMake/README: Document dependency placement + (Chun-wei Fan) Issue #44 (lxxxd) + + 5.0.1 (stable): Build: diff --git a/configure.ac b/configure.ac index 67893d62..ad7521c5 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [5.0.1], +AC_INIT([libxml++], [5.0.2], [https://github.com/libxmlplusplus/libxmlplusplus/issues], [libxml++], [https://libxmlplusplus.github.io/libxmlplusplus/]) AC_PREREQ([2.59]) diff --git a/meson.build b/meson.build index 8d0f7826..515d0028 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ # This file is part of libxml++. project('libxml++', 'cpp', - version: '5.0.1', + version: '5.0.2', license: 'LGPLv2.1+', default_options: [ 'warning_level=1', From 888e998b71e3db1dd9552fb387d62b3a922c1374 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 14 Sep 2022 07:56:08 +0200 Subject: [PATCH 178/240] Convert README to README.md * README -> README.md * Makefile.am: Distribute README.md * configure.ac: Set `foreign` option to automake. Without the `foreign` option, old versions of automake require a README file, which no longer exists. New versions (like 1.16.5) without the `foreign` option require README or README.md. --- Makefile.am | 4 ++- README => README.md | 60 ++++++++++++++++++++++++++++++++------------- configure.ac | 2 +- 3 files changed, 47 insertions(+), 19 deletions(-) rename README => README.md (84%) diff --git a/Makefile.am b/Makefile.am index dfc71dc0..92c59007 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,9 @@ nodist_pkgconfig_DATA = $(LIBXMLXX_MODULE_NAME).pc include $(srcdir)/MSVC_NMake/filelist.am -dist_noinst_DATA = $(addprefix MSVC_NMake/,$(msvc_nmake_data)) +dist_noinst_DATA = \ + $(addprefix MSVC_NMake/,$(msvc_nmake_data)) \ + README.md dist_noinst_SCRIPTS = autogen.sh diff --git a/README b/README.md similarity index 84% rename from README rename to README.md index d037f78f..e063ca9d 100644 --- a/README +++ b/README.md @@ -1,24 +1,23 @@ -libxml++ --------- - +# libxml++ libxml++ (a.k.a. libxmlplusplus) provides a C++ interface to XML files. It uses libxml2 to access the XML files, and in order to configure libxml++ you must have both libxml2 and pkg-config installed. -To get the latest version of libxml++, see -https://libxmlplusplus.github.io/libxmlplusplus/ -To contact the developers, send e-mail to the mailing list at -http://mail.gnome.org/mailman/listinfo/libxmlplusplus-list -We welcome patches, but it helps to discuss them first. +To get the latest version of libxml++, see the +[libxml++ web site](https://libxmlplusplus.github.io/libxmlplusplus/) + +To contact the developers, send e-mail to the +[libxml++ mailing list](https://mail.gnome.org/mailman/listinfo/libxmlplusplus-list) See the examples directory for example code. Use pkg-config to discover the necessary include and linker arguments. For instance, +``` pkg-config libxml++-5.0 --cflags --libs +``` If you build with Autotools, ideally you would use PKG_CHECK_MODULES in your configure.ac file. - # Building Whenever possible, you should use the official binary packages approved by the @@ -31,8 +30,10 @@ See MSVC_NMake/README ## Building from a release tarball Extract the tarball and go to the extracted directory: +``` $ tar xf libxml++-@LIBXMLXX_VERSION@.tar.xz $ cd libxml++-@LIBXMLXX_VERSION@ +``` It's easiest to build with Meson, if the tarball was made with Meson, and to build with Autotools, if the tarball was made with Autotools. @@ -46,31 +47,43 @@ of untracked/. Don't call the builddir 'build'. There is a directory called 'build' with files used by Autotools. - +``` $ meson --prefix /some_directory --libdir lib your_builddir . $ cd your_builddir - +``` If the tarball was made with Autotools, you must enable maintainer-mode: +``` $ meson configure -Dmaintainer-mode=true - +``` Then, regardless of how the tarball was made: +``` $ ninja $ ninja install +``` You can run the tests like so: +``` $ ninja test +``` ### Building from a tarball with Autotools If the tarball was made with Autotools: +``` $ ./configure --prefix=/some_directory +``` If the tarball was made with Meson, you must enable maintainer-mode: +``` $ ./autogen.sh --prefix=/some_directory - +``` Then, regardless of how the tarball was made: +``` $ make $ make install +``` You can build the examples and tests, and run the tests, like so: +``` $ make check +``` ## Building from git @@ -78,8 +91,9 @@ Building from git can be difficult so you should prefer building from a release tarball unless you need to work on the libxml++ code itself. jhbuild can be a good help - https://gitlab.gnome.org/GNOME/jhbuild - https://wiki.gnome.org/Projects/Jhbuild +- https://gitlab.gnome.org/GNOME/jhbuild +- https://wiki.gnome.org/Projects/Jhbuild +- https://gnome.pages.gitlab.gnome.org/jhbuild ### Building from git with Meson @@ -87,24 +101,36 @@ Maintainer-mode is enabled by default when you build from a git clone. Don't call the builddir 'build'. There is a directory called 'build' with files used by Autotools. - +``` $ meson --prefix /some_directory --libdir lib your_builddir . $ cd your_builddir $ ninja $ ninja install +``` You can run the tests like so: +``` $ ninja test +``` You can create a tarball like so: +``` $ ninja dist +``` ### Building from git with Autotools - +``` $ ./autogen.sh --prefix=/some_directory $ make $ make install +``` You can build the examples and tests, and run the tests, like so: +``` $ make check +``` You can create a tarball like so: +``` $ make distcheck +``` or +``` $ make dist +``` diff --git a/configure.ac b/configure.ac index ad7521c5..e1c7544a 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,7 @@ AC_CONFIG_AUX_DIR([build]) AC_CONFIG_MACRO_DIR([build]) AC_CONFIG_HEADERS([config.h libxml++config.h]) -AM_INIT_AUTOMAKE([1.9 -Wno-portability dist-bzip2 no-define nostdinc subdir-objects]) +AM_INIT_AUTOMAKE([1.9 -Wno-portability dist-bzip2 no-define nostdinc subdir-objects foreign]) # Support silent build rules. # Disable by either passing --disable-silent-rules to configure or passing V=1 to make. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) From 2669b1f5c26292fa5bea09113e21415576060d43 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 28 Sep 2022 12:43:23 +0200 Subject: [PATCH 179/240] meson.build: Detect if we build from a git subtree See https://gitlab.gnome.org/GNOME/gtkmm/-/merge_requests/72 --- meson.build | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 515d0028..af96644c 100644 --- a/meson.build +++ b/meson.build @@ -53,13 +53,15 @@ if not python_version.version_compare(python_version_req) endif # Do we build from a git repository? -# Suppose we do if and only if a '.git' directory or file exists. +# Suppose we do if and only if the meson.build file is tracked by git. cmd_py = ''' -import os -import sys -sys.exit(os.path.isdir("@0@") or os.path.isfile("@0@")) -'''.format(project_source_root / '.git') -is_git_build = run_command(python3, '-c', cmd_py, check: false).returncode() != 0 +import shutil, subprocess, sys +if not shutil.which('git'): + sys.exit(1) +cmd = [ 'git', 'ls-files', '--error-unmatch', 'meson.build' ] +sys.exit(subprocess.run(cmd, cwd="@0@", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode) +'''.format(project_source_root) +is_git_build = run_command(python3, '-c', cmd_py, check: false).returncode() == 0 # Are we testing a dist tarball while it's being built? # There ought to be a better way. https://github.com/mesonbuild/meson/issues/6866 From 7fac1fda56af67cb2e9eb84b62ac49d76ba29b15 Mon Sep 17 00:00:00 2001 From: fanc999 Date: Fri, 21 Oct 2022 15:34:25 +0800 Subject: [PATCH 180/240] exceptions/exception.h: Try fixing linking on MinGW (#46) Using the xmlpp::exception class may lead to a linker error on its vtable on MinGW, unless the whole class is exported, but we also want to avoid exporting that whole class under Visual Studio, so that we can avoid having the built DLL/import library being tied to a particular STL version, so define macros to accomdate such situations and apply it to the xmlpp::exception class. This should not affect the ABI stability on Visual Studio builds. Fixes: https://github.com/libxmlplusplus/libxmlplusplus/issues/45 --- libxml++/exceptions/exception.h | 12 ++++++------ libxml++config.h.in | 11 +++++++++++ libxml++config.h.meson | 11 +++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/libxml++/exceptions/exception.h b/libxml++/exceptions/exception.h index e6b3d97a..7a657222 100644 --- a/libxml++/exceptions/exception.h +++ b/libxml++/exceptions/exception.h @@ -36,17 +36,17 @@ namespace xmlpp /** Base class for all xmlpp exceptions. */ -class exception : public std::exception +class LIBXMLPP_VISIBILITY_DEFAULT exception : public std::exception { public: - LIBXMLPP_API + LIBXMLPP_MEMBER_METHOD explicit exception(const ustring& message); - LIBXMLPP_API ~exception() noexcept override; + LIBXMLPP_MEMBER_METHOD ~exception() noexcept override; - LIBXMLPP_API const char* what() const noexcept override; + LIBXMLPP_MEMBER_METHOD const char* what() const noexcept override; - LIBXMLPP_API virtual void raise() const; - LIBXMLPP_API virtual exception* clone() const; + LIBXMLPP_MEMBER_METHOD virtual void raise() const; + LIBXMLPP_MEMBER_METHOD virtual exception* clone() const; private: ustring message_; diff --git a/libxml++config.h.in b/libxml++config.h.in index cfa46e4d..4310c295 100755 --- a/libxml++config.h.in +++ b/libxml++config.h.in @@ -24,6 +24,10 @@ #ifdef LIBXMLPP_DLL #ifdef LIBXMLPP_BUILD #define LIBXMLPP_API __declspec(dllexport) + #ifdef __GNUC__ + #define LIBXMLPP_VISIBILITY_DEFAULT __attribute__((visibility("default"))) + #define LIBXMLPP_MEMBER_METHOD + #endif #elif !defined (__GNUC__) #define LIBXMLPP_API __declspec(dllimport) #else /* don't dllimport classes/methods on GCC/MinGW */ @@ -34,5 +38,12 @@ #define LIBXMLPP_API #endif /* GLIBMM_DLL */ +#ifndef LIBXMLPP_VISIBILITY_DEFAULT + #define LIBXMLPP_VISIBILITY_DEFAULT +#endif +#ifndef LIBXMLPP_MEMBER_METHOD + #define LIBXMLPP_MEMBER_METHOD LIBXMLPP_API +#endif + #endif /* _LIBXMLPP_CONFIG_H */ diff --git a/libxml++config.h.meson b/libxml++config.h.meson index 2a5f03b2..d1b06ccb 100755 --- a/libxml++config.h.meson +++ b/libxml++config.h.meson @@ -26,6 +26,10 @@ #ifdef LIBXMLPP_DLL #ifdef LIBXMLPP_BUILD #define LIBXMLPP_API __declspec(dllexport) + #ifdef __GNUC__ + #define LIBXMLPP_VISIBILITY_DEFAULT __attribute__((visibility("default"))) + #define LIBXMLPP_MEMBER_METHOD + #endif #elif !defined (__GNUC__) #define LIBXMLPP_API __declspec(dllimport) #else /* don't dllimport classes/methods on GCC/MinGW */ @@ -36,5 +40,12 @@ #define LIBXMLPP_API #endif /* GLIBMM_DLL */ +#ifndef LIBXMLPP_VISIBILITY_DEFAULT + #define LIBXMLPP_VISIBILITY_DEFAULT +#endif +#ifndef LIBXMLPP_MEMBER_METHOD + #define LIBXMLPP_MEMBER_METHOD LIBXMLPP_API +#endif + #endif /* _LIBXMLPP_CONFIG_H */ From b8d403ffb8b47855cead9bb7df8271e8eec3a87b Mon Sep 17 00:00:00 2001 From: fanc999 Date: Fri, 21 Oct 2022 15:35:03 +0800 Subject: [PATCH 181/240] headers: Drop LIBXMLPP_API from 'friend' members (#47) They aren't really necessary and can raise warnings on Windows MinGW builds unless their locations were exchanged with 'class' or 'struct', but doing so is not liked by Visual Studio. --- libxml++/document.h | 2 +- libxml++/parsers/saxparser.h | 2 +- libxml++/parsers/textreader.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libxml++/document.h b/libxml++/document.h index 648b9121..bf204a5b 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -72,7 +72,7 @@ class Document : public NonCopyable ~Init() noexcept; }; - friend LIBXMLPP_API class SaxParser; + friend class SaxParser; public: /** Create a new document. diff --git a/libxml++/parsers/saxparser.h b/libxml++/parsers/saxparser.h index 13640516..affacbf2 100644 --- a/libxml++/parsers/saxparser.h +++ b/libxml++/parsers/saxparser.h @@ -250,7 +250,7 @@ class SaxParser : public Parser // and never seen in the API: std::unique_ptr entity_resolver_doc_; - friend LIBXMLPP_API struct SaxParserCallback; + friend struct SaxParserCallback; }; } // namespace xmlpp diff --git a/libxml++/parsers/textreader.h b/libxml++/parsers/textreader.h index 807f3456..dbc22ed8 100644 --- a/libxml++/parsers/textreader.h +++ b/libxml++/parsers/textreader.h @@ -292,7 +292,7 @@ class TextReader: public NonCopyable private: class PropertyReader; - friend LIBXMLPP_API class PropertyReader; + friend class PropertyReader; LIBXMLPP_API void setup_exceptions(); From 822636ae26f407bb34ee42c9a7c13962f9d8e97d Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Fri, 21 Oct 2022 23:45:46 +0800 Subject: [PATCH 182/240] libxml++config.h.[in|meson]: Try again to fix MinGW builds Apparently it's not enough to decorate a class with __attribute__((visibility("default"))), so also decorate it with __declspec(dllexport), via macros as needed. Pointed out by Kjell in PR #46. --- libxml++config.h.in | 2 +- libxml++config.h.meson | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libxml++config.h.in b/libxml++config.h.in index 4310c295..f37f78a1 100755 --- a/libxml++config.h.in +++ b/libxml++config.h.in @@ -25,7 +25,7 @@ #ifdef LIBXMLPP_BUILD #define LIBXMLPP_API __declspec(dllexport) #ifdef __GNUC__ - #define LIBXMLPP_VISIBILITY_DEFAULT __attribute__((visibility("default"))) + #define LIBXMLPP_VISIBILITY_DEFAULT LIBXMLPP_API __attribute__((visibility("default"))) #define LIBXMLPP_MEMBER_METHOD #endif #elif !defined (__GNUC__) diff --git a/libxml++config.h.meson b/libxml++config.h.meson index d1b06ccb..2d0d9973 100755 --- a/libxml++config.h.meson +++ b/libxml++config.h.meson @@ -27,7 +27,7 @@ #ifdef LIBXMLPP_BUILD #define LIBXMLPP_API __declspec(dllexport) #ifdef __GNUC__ - #define LIBXMLPP_VISIBILITY_DEFAULT __attribute__((visibility("default"))) + #define LIBXMLPP_VISIBILITY_DEFAULT LIBXMLPP_API __attribute__((visibility("default"))) #define LIBXMLPP_MEMBER_METHOD #endif #elif !defined (__GNUC__) From 404776de71e3ee6a0c1351460b84f83269273ffc Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 24 Oct 2022 13:45:44 +0200 Subject: [PATCH 183/240] Add mingw-cross-file.txt Useful when cross-building from Linux to Windows with MinGW. --- mingw-cross-file.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 mingw-cross-file.txt diff --git a/mingw-cross-file.txt b/mingw-cross-file.txt new file mode 100644 index 00000000..342ebe55 --- /dev/null +++ b/mingw-cross-file.txt @@ -0,0 +1,23 @@ +# Cross compiling with MinGW, Linux -> Windows +# meson --cross-file mingw-cross-file.txt ..... + +[constants] +prefix = 'x86_64-w64-mingw32-' + +[binaries] +c = prefix + 'gcc' +cpp = prefix + 'g++' +ar = prefix + 'ar' +strip = prefix + 'strip' +windres = prefix + 'windres' +exe_wrapper = 'wine64' + +[host_machine] +system = 'windows' +cpu_family = 'x86_64' +cpu = 'x86_64' +endian = 'little' + +[cmake] +CMAKE_C_COMPILER = prefix + 'gcc' +CMAKE_CXX_COMPILER = prefix + 'g++' From dc8531ab4b0b3269b39959b799ff244df41078d0 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 25 Oct 2022 15:44:12 +0200 Subject: [PATCH 184/240] docs/index.md: Change libxmlplusplus-list to Discourse The libxmlplusplus-list will soon be closed for new contributions. --- docs/index.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/index.md b/docs/index.md index 0eae0a44..da08b2d0 100644 --- a/docs/index.md +++ b/docs/index.md @@ -44,8 +44,15 @@ You can also browse online the [reference documentation](https://developer-old.g Libxml++ uses the GitHub [git repository](https://github.com/libxmlplusplus/libxmlplusplus). -Bugs and patches are tracked in GitHub's [issue tracker](https://github.com/libxmlplusplus/libxmlplusplus/issues). +Bugs and patches are tracked in GitHub's [issue tracker](https://github.com/libxmlplusplus/libxmlplusplus/issues) +and [pull request tracker](https://github.com/libxmlplusplus/libxmlplusplus/pulls). -## Contact +## Discussion -Please use the [libxmlplusplus-list mailing list](http://mail.gnome.org/mailman/listinfo/libxmlplusplus-list) or GitHub. Please do not just email the developers directly. +You can discuss libxml++ questions on GNOME's [Discourse](https://discourse.gnome.org) +instance, under the [Platform/Language bindings](https://discourse.gnome.org/c/platform/language-bindings) +category with a _cplusplus_ tag. + +There is an old mailing list, which is now closed for new posts. +There is an archive of messages [here](http://mail.gnome.org/archives/libxmlplusplus-list/). +Please do not email the developers directly. From 3811761b88b3c54f6bbaec99cf8180beeb7f2ad0 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sat, 17 Dec 2022 12:04:41 +0100 Subject: [PATCH 185/240] CI: Remove obsolete autotools tests --- .github/workflows/autotools-clang-8.yml | 25 ------------------------- .github/workflows/autotools-clang-9.yml | 25 ------------------------- .github/workflows/autotools-gcc-8.yml | 25 ------------------------- 3 files changed, 75 deletions(-) delete mode 100644 .github/workflows/autotools-clang-8.yml delete mode 100644 .github/workflows/autotools-clang-9.yml delete mode 100644 .github/workflows/autotools-gcc-8.yml diff --git a/.github/workflows/autotools-clang-8.yml b/.github/workflows/autotools-clang-8.yml deleted file mode 100644 index d460684d..00000000 --- a/.github/workflows/autotools-clang-8.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "CI: autotools: clang 8" - -on: [push] - -jobs: - build: - - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v1 - - name: Build - run: | - sudo apt update - sudo apt install libxml2-dev mm-common clang-8 docbook-xsl - export CXX=clang++-8 - ./autogen.sh --enable-warnings=fatal - make - - name: Test - run: make check - - name: Distcheck - run: | - # distcheck runs configure again so we need to specify CXX again. - export CXX=clang++-8 - make distcheck diff --git a/.github/workflows/autotools-clang-9.yml b/.github/workflows/autotools-clang-9.yml deleted file mode 100644 index 4ea2c11f..00000000 --- a/.github/workflows/autotools-clang-9.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "CI: autotools: clang 9" - -on: [push] - -jobs: - build: - - runs-on: ubuntu-20.04 - - steps: - - uses: actions/checkout@v1 - - name: Build - run: | - sudo apt update - sudo apt install libxml2-dev mm-common clang-9 docbook-xsl - export CXX=clang++-9 - ./autogen.sh --enable-warnings=fatal - make - - name: Test - run: make check - - name: Distcheck - run: | - # distcheck runs configure again so we need to specify CXX again. - export CXX=clang++-9 - make distcheck diff --git a/.github/workflows/autotools-gcc-8.yml b/.github/workflows/autotools-gcc-8.yml deleted file mode 100644 index b68aaaaa..00000000 --- a/.github/workflows/autotools-gcc-8.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: "CI: autotools: gcc 8" - -on: [push] - -jobs: - build: - - runs-on: ubuntu-18.04 - - steps: - - uses: actions/checkout@v1 - - name: Build - run: | - sudo apt update - sudo apt install libxml2-dev mm-common g++-8 docbook-xsl - export CXX=g++-8 - ./autogen.sh --enable-warnings=fatal - make - - name: Test - run: make check - - name: Distcheck - run: | - # distcheck runs configure again so we need to specify CXX again. - export CXX=g++-8 - make distcheck From e5900c451a5cef4d60d713f98bba034a3ecec066 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 18 Dec 2022 16:34:16 +0100 Subject: [PATCH 186/240] CI: Add publish-docs.yml --- .github/workflows/publish-docs.yml | 75 ++++++++++++++++++++++++++++++ docs/_config.yml | 2 +- docs/_layouts/default.html | 17 +++++++ docs/index.md | 31 +++++++++--- docs/style.css | 4 ++ 5 files changed, 121 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/publish-docs.yml create mode 100644 docs/_layouts/default.html create mode 100644 docs/style.css diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml new file mode 100644 index 00000000..2414d2f6 --- /dev/null +++ b/.github/workflows/publish-docs.yml @@ -0,0 +1,75 @@ +# Sample workflow for building and deploying a Jekyll site to GitHub Pages + +# Copied from https://github.com/libxmlplusplus/libxmlplusplus/actions/new +# and changed. Actions -> New workflow -> Pages -> Jekyll + +name: Deploy Jekyll with GitHub Pages dependencies preinstalled + +# 2022-12-17: ubuntu-latest = ubuntu-22.04 +on: + # Runs on pushes targeting the default branch + push: + branches: ["master"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow one concurrent deployment +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + # Build job + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Build + run: | + # Prevent blocking apt install on a question during configuring of tzdata. + export DEBIAN_FRONTEND=noninteractive + sudo apt update + sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common g++ meson ninja-build python3-setuptools python3-pip --yes + meson -Dbuild-documentation=true -Dbuild-examples=false -Dbuild-tests=false _build + meson compile -C _build + - name: Collect Documentation + # Collect all documentation to be published. + run: | + mkdir _publish _publish/_layouts _publish/manual _publish/reference + # Copy files from the git repository. + cp docs/_config.yml docs/*.md docs/style.css _publish + cp docs/_layouts/*.html _publish/_layouts + # Move generated documentation. + mv _build/docs/manual/html _publish/manual + mv _build/docs/reference/html _publish/reference + - name: Setup Pages + uses: actions/configure-pages@v2 + - name: Build with Jekyll + uses: actions/jekyll-build-pages@v1 + with: + source: ./_publish + destination: ./_site + - name: Upload artifact + uses: actions/upload-pages-artifact@v1 + + # Deployment job + # Publish documentation at https://libxmlplusplus.github.io/libxmlplusplus/ + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v1 + diff --git a/docs/_config.yml b/docs/_config.yml index d163e0a4..3f90fe29 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -1 +1 @@ -name: libxml++ +title: libxml++ diff --git a/docs/_layouts/default.html b/docs/_layouts/default.html new file mode 100644 index 00000000..6025e935 --- /dev/null +++ b/docs/_layouts/default.html @@ -0,0 +1,17 @@ +--- +--- + + + + libxml++ -- a C++ wrapper for the libxml2 XML parser library. + + + + + +
+

{{page.title}}

+ {{ content }} +
+ + diff --git a/docs/index.md b/docs/index.md index da08b2d0..de0a4d39 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,8 +2,6 @@ layout: default title: libxml++ --- -# libxml++ - ## Introduction libxml++ is a C++ wrapper for the [libxml2](http://www.xmlsoft.org) XML parser library. @@ -27,18 +25,37 @@ libxml++-5.0: Does not depend on glibmm, is not as good at handling UTF-8 string ## Download -You can download libxml++ from [here](https://download.gnome.org/sources/libxml++/). +You can download libxml++ from the [GNOME download site](https://download.gnome.org/sources/libxml++/). ## Required Libraries * [libxml2](http://www.xmlsoft.org/) -* libxml++-2.6 and libxml++-3.0: [glibmm-2.4](https://developer.gnome.org/glibmm/2.64/) -* libxml++-4.0: [glibmm-2.68](https://developer.gnome.org/glibmm/2.68/) +* libxml++-2.6 and libxml++-3.0: [glibmm-2.4](https://developer-old.gnome.org/glibmm/2.64/) +* libxml++-4.0: [glibmm-2.68](https://gnome.pages.gitlab.gnome.org/glibmm/) ## Documentation -The short [manual](https://developer-old.gnome.org/libxml++-tutorial/) gives an overview of the libxml++ API. -You can also browse online the [reference documentation](https://developer-old.gnome.org/libxml++/). +### libxml++-5.0 + +The short [manual](manual/html/index.html) gives an overview of the libxml++ API. +You can also browse online the [reference documentation](reference/html/index.html). + +### Other ABI Versions + +libxml++-2.6: [manual](https://developer-old.gnome.org/libxml++-tutorial/2.42/) +and [reference documentation](https://developer-old.gnome.org/libxml++/2.42/) + +libxml++-3.0: [manual](https://developer-old.gnome.org/libxml++-tutorial/3.2/) +and [reference documentation](https://developer-old.gnome.org/libxml++/3.2/) + +libxml++-4.0: [manual](https://developer-old.gnome.org/libxml++-tutorial/4.0/) +and [reference documentation](https://developer-old.gnome.org/libxml++/4.0) + +This documentation is frozen on the web. It does not document the latest releases. +If you want newer documentation, you can download a tarball from +[GitHub releases](https://github.com/libxmlplusplus/libxmlplusplus/releases/) +or the [GNOME download site](https://download.gnome.org/sources/libxml++/), +extract it, and view the documentation at *untracked/docs/*. ## Development diff --git a/docs/style.css b/docs/style.css new file mode 100644 index 00000000..ebb5b16f --- /dev/null +++ b/docs/style.css @@ -0,0 +1,4 @@ +body { + background-color: #F7F7F7; + font-family: Verdana, Arial, Helvetica, sans-serif; +} From 00cd26419c635528d1ce34511567eb012690dea0 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 4 Jan 2023 16:19:37 +0100 Subject: [PATCH 187/240] Meson build: Don't copy files with configure_file() It's deprecated since Meson 0.64. The replacement, fs.copyfile(), is not useful here. It only copies from the source directory to the build directory. --- MSVC_NMake/libxml++/meson.build | 8 ++++---- meson.build | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/MSVC_NMake/libxml++/meson.build b/MSVC_NMake/libxml++/meson.build index bbb237e8..f4193a66 100644 --- a/MSVC_NMake/libxml++/meson.build +++ b/MSVC_NMake/libxml++/meson.build @@ -1,6 +1,6 @@ # MSVC_NMake/libxml++ -# Input: pkg_conf_data, xmlxxconfig_h +# Input: pkg_conf_data, xmlxxconfig_h_meson # Output: xmlxx_rc xmlxx_rc = configure_file( @@ -9,9 +9,9 @@ xmlxx_rc = configure_file( configuration: pkg_conf_data, ) -# Copy the generated configuration header into the MSVC project directory. +# Make a copy of the generated configuration header in the MSVC project directory. configure_file( - input: xmlxxconfig_h, + input: xmlxxconfig_h_meson, output: 'libxml++config.h', - copy: true, + configuration: pkg_conf_data, ) diff --git a/meson.build b/meson.build index af96644c..610fd8f0 100644 --- a/meson.build +++ b/meson.build @@ -393,9 +393,10 @@ configure_file( install_dir: install_pkgconfigdir, ) +xmlxxconfig_h_meson = files('libxml++config.h.meson') install_includeconfigdir = install_libdir / xmlxx_pcname / 'include' -xmlxxconfig_h = configure_file( - input: 'libxml++config.h.meson', +configure_file( + input: xmlxxconfig_h_meson, output: 'libxml++config.h', configuration: pkg_conf_data, install_dir: install_includeconfigdir, From e076c81964669a329b97605e85dd2f268135fee1 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 4 Jan 2023 13:13:59 +0100 Subject: [PATCH 188/240] meson.build: Fix the evaluation of is_git_build on Windows See gtkmm#131 --- meson.build | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/meson.build b/meson.build index 610fd8f0..bf988eef 100644 --- a/meson.build +++ b/meson.build @@ -56,12 +56,17 @@ endif # Suppose we do if and only if the meson.build file is tracked by git. cmd_py = ''' import shutil, subprocess, sys -if not shutil.which('git'): +git_exe = shutil.which('git') +if not git_exe: sys.exit(1) -cmd = [ 'git', 'ls-files', '--error-unmatch', 'meson.build' ] -sys.exit(subprocess.run(cmd, cwd="@0@", stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode) -'''.format(project_source_root) -is_git_build = run_command(python3, '-c', cmd_py, check: false).returncode() == 0 +cmd = [ git_exe, 'ls-files', '--error-unmatch', 'meson.build' ] +sys.exit(subprocess.run(cmd, cwd=sys.argv[1], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode) +''' +is_git_build = run_command( + python3, '-c', cmd_py, + project_source_root, + check: false, +).returncode() == 0 # Are we testing a dist tarball while it's being built? # There ought to be a better way. https://github.com/mesonbuild/meson/issues/6866 From 6c6649b7887e5c03beeb198db60b348103826f2f Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 4 Jan 2023 15:10:16 +0100 Subject: [PATCH 189/240] meson.build: Simplify lookup of python command See libsigcplusplus PR#83 --- meson.build | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/meson.build b/meson.build index bf988eef..51f0ab6d 100644 --- a/meson.build +++ b/meson.build @@ -44,13 +44,8 @@ project_build_root = meson.current_build_dir() cpp_compiler = meson.get_compiler('cpp') is_msvc = cpp_compiler.get_id() == 'msvc' -python3 = import('python').find_installation() -python_version = python3.language_version() -python_version_req = '>= 3.5' -if not python_version.version_compare(python_version_req) - error('Requires Python @0@, found @1@.'.format(python_version_req, python_version)) -endif +python3 = find_program('python3', version: '>=3.5') # Do we build from a git repository? # Suppose we do if and only if the meson.build file is tracked by git. From a7d457eb489671123516998e6fcab00a1b6b62c4 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 20 Mar 2023 14:42:40 +0100 Subject: [PATCH 190/240] README.md, CI: meson -> meson setup --- .github/workflows/meson-clang-10.yml | 2 +- .github/workflows/meson-gcc-10.yml | 2 +- .github/workflows/publish-docs.yml | 2 +- README.md | 7 ++----- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/workflows/meson-clang-10.yml b/.github/workflows/meson-clang-10.yml index 3f521d8a..97694f20 100644 --- a/.github/workflows/meson-clang-10.yml +++ b/.github/workflows/meson-clang-10.yml @@ -20,7 +20,7 @@ jobs: sudo pip3 install "meson>=0.55.0" export CC=clang-10 export CXX=clang++-10 - meson -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true _build + meson setup -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true _build cd _build meson compile - name: Test diff --git a/.github/workflows/meson-gcc-10.yml b/.github/workflows/meson-gcc-10.yml index 4e704937..3a53e981 100644 --- a/.github/workflows/meson-gcc-10.yml +++ b/.github/workflows/meson-gcc-10.yml @@ -20,7 +20,7 @@ jobs: sudo pip3 install "meson>=0.55.0" export CC=gcc-10 export CXX=g++-10 - meson -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true _build + meson setup -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true _build cd _build meson compile - name: Test diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 2414d2f6..1c48ad49 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -38,7 +38,7 @@ jobs: export DEBIAN_FRONTEND=noninteractive sudo apt update sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common g++ meson ninja-build python3-setuptools python3-pip --yes - meson -Dbuild-documentation=true -Dbuild-examples=false -Dbuild-tests=false _build + meson setup -Dbuild-documentation=true -Dbuild-examples=false -Dbuild-tests=false _build meson compile -C _build - name: Collect Documentation # Collect all documentation to be published. diff --git a/README.md b/README.md index e063ca9d..10110a0a 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,6 @@ have both libxml2 and pkg-config installed. To get the latest version of libxml++, see the [libxml++ web site](https://libxmlplusplus.github.io/libxmlplusplus/) -To contact the developers, send e-mail to the -[libxml++ mailing list](https://mail.gnome.org/mailman/listinfo/libxmlplusplus-list) - See the examples directory for example code. Use pkg-config to discover the necessary include and linker arguments. For instance, @@ -48,7 +45,7 @@ of untracked/. Don't call the builddir 'build'. There is a directory called 'build' with files used by Autotools. ``` - $ meson --prefix /some_directory --libdir lib your_builddir . + $ meson setup --prefix /some_directory --libdir lib your_builddir . $ cd your_builddir ``` If the tarball was made with Autotools, you must enable maintainer-mode: @@ -102,7 +99,7 @@ Maintainer-mode is enabled by default when you build from a git clone. Don't call the builddir 'build'. There is a directory called 'build' with files used by Autotools. ``` - $ meson --prefix /some_directory --libdir lib your_builddir . + $ meson setup --prefix /some_directory --libdir lib your_builddir . $ cd your_builddir $ ninja $ ninja install From b9dcf7e9bbf5157b0c8b245a918110389cbe4ce4 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 20 Mar 2023 14:43:12 +0100 Subject: [PATCH 191/240] meson.build: Simplify if-file-exists test and use meson.project_[build,source]_root(), new in meson 0.56.0. --- meson.build | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/meson.build b/meson.build index 51f0ab6d..0b3fa68c 100644 --- a/meson.build +++ b/meson.build @@ -37,10 +37,9 @@ macos_darwin_versions = [ '@0@.@1@'.format(libtool_soversion[0] + 1, libtool_soversion[1]) ] -# Use these instead of meson.source_root() and meson.build_root() in subdirectories. -# source_root() and build_root() are not useful, if this is a subproject. -project_source_root = meson.current_source_dir() -project_build_root = meson.current_build_dir() +# Source and build root directories of the current (sub)project. +project_source_root = meson.project_source_root() +project_build_root = meson.project_build_root() cpp_compiler = meson.get_compiler('cpp') is_msvc = cpp_compiler.get_id() == 'msvc' @@ -237,17 +236,9 @@ if maintainer_mode project_source_root / 'untracked' / 'docs', check: true, ) -else - cmd_py = ''' -import os -import sys -sys.exit(os.path.isfile("@0@")) -'''.format(doc_reference_py) - file_exists = run_command(python3, '-c', cmd_py, check: false).returncode() != 0 - if not file_exists - warning('Missing files in untracked/. ' + \ - 'Enable maintainer-mode if you want to build documentation or create a dist tarball.') - endif +elif not import('fs').is_file(doc_reference_py) + warning('Missing files in untracked/.\n ' + \ + 'Enable maintainer-mode if you want to build documentation or create a dist tarball.') endif # Check if perl is required and available. From c2184c55b7b5f3e46ca0e3f059106e227d4acbcb Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 22 Mar 2023 12:42:21 +0100 Subject: [PATCH 192/240] Doxyfile.in: LIBXMLXX_API -> LIBXMLPP_API --- docs/reference/Doxyfile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in index 91accf57..67994acc 100644 --- a/docs/reference/Doxyfile.in +++ b/docs/reference/Doxyfile.in @@ -291,7 +291,7 @@ PREDEFINED = __cplusplus \ "G_GNUC_PURE=" \ "G_GNUC_WARN_UNUSED_RESULT=" \ "G_MODULE_EXPORT=" \ - "LIBXMLXX_API=" + "LIBXMLPP_API=" EXPAND_AS_DEFINED = LIBXMLXX_MAJOR_VERSION \ LIBXMLXX_MINOR_VERSION \ LIBXMLXX_MICRO_VERSION From 81da7ce28c1aa71a18d5540b9d0d8cf2baba93b0 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 22 Mar 2023 13:19:05 +0100 Subject: [PATCH 193/240] 5.0.3 --- NEWS | 17 +++++++++++++++++ configure.ac | 2 +- meson.build | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index 735f8fc3..fb671ad4 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,20 @@ +5.0.3 (stable): + +* exception: Fix linking on MinGW + (Chun-wei Fan) Issue #45 (Rosen Penev) + (Chun-wei Fan) Pull request #46 +* headers: Drop LIBXMLPP_API from 'friend' members + (Chun-wei Fan) Pull request #47 + +Meson build: +* Detect if we build from a git subtree + (William Roy) Merge request gtkmm!72 +* Don't copy files with configure_file() + (Kjell Ahlstedt) +* Fix the evaluation of is_git_build on Windows + (Kjell Ahlstedt) Issue gtkmm#131 (William Roy) + + 5.0.2 (stable): * Document, Node: Recognize HTML documents diff --git a/configure.ac b/configure.ac index e1c7544a..2c9c26c4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [5.0.2], +AC_INIT([libxml++], [5.0.3], [https://github.com/libxmlplusplus/libxmlplusplus/issues], [libxml++], [https://libxmlplusplus.github.io/libxmlplusplus/]) AC_PREREQ([2.59]) diff --git a/meson.build b/meson.build index 0b3fa68c..935aece6 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ # This file is part of libxml++. project('libxml++', 'cpp', - version: '5.0.2', + version: '5.0.3', license: 'LGPLv2.1+', default_options: [ 'warning_level=1', From a8d810fdbc2bf4c524a22e528cf168e7711d363d Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 22 Mar 2023 12:42:41 +0100 Subject: [PATCH 194/240] Use callback functions with C linkage * libxml++/parsers/parser.[cc|h]: Deprecate callback_[parser|validity]_[error|warning](), enum MsgType, callback_error_or_warning(MsgType...). Add ParserCallbackCFuncType, get_callback_[parser|validity]_[error|warning]_cfunc(), callback_error_or_warning(bool, bool...). Use local 'extern "C"' callback functions. * libxml++/validators/validator.[cc|h]: Deprecate callback_validity_[error|warning](). Add ValidatorCallbackCFuncType, get_callback_validity_[error|warning]_cfunc(), callback_error_or_warning(bool...). Use local 'extern "C"' callback functions. * libxml++/validators/dtdvalidator.cc: * libxml++/validators/relaxngvalidator.cc: * libxml++/validators/xsdvalidator.cc: Use get_callback_validity_[error|warning]_cfunc(). Code that mixes up C linkage and C++ linkage has undefined behavior. Most compilers make no difference between C and C++ linkage, so it has not been an issue so far. But see issue glibmm#1. --- libxml++/parsers/parser.cc | 108 +++++++++++++++++++++--- libxml++/parsers/parser.h | 29 +++++++ libxml++/validators/dtdvalidator.cc | 4 +- libxml++/validators/relaxngvalidator.cc | 3 +- libxml++/validators/validator.cc | 70 +++++++++++++++ libxml++/validators/validator.h | 20 +++++ libxml++/validators/xsdvalidator.cc | 3 +- 7 files changed, 219 insertions(+), 18 deletions(-) diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc index cfe6addc..6d6c3f6a 100644 --- a/libxml++/parsers/parser.cc +++ b/libxml++/parsers/parser.cc @@ -9,6 +9,48 @@ #include +namespace +{ +// C++ linkage +using ErrorOrWarningFuncType = void (*)(bool parser, bool error, void* ctx, + const char* msg, va_list var_args); +ErrorOrWarningFuncType p_callback_error_or_warning; + +extern "C" +{ +static void c_callback_parser_error(void* ctx, const char* msg, ...) +{ + va_list var_args; + va_start(var_args, msg); + p_callback_error_or_warning(true, true, ctx, msg, var_args); + va_end(var_args); +} + +static void c_callback_parser_warning(void* ctx, const char* msg, ...) +{ + va_list var_args; + va_start(var_args, msg); + p_callback_error_or_warning(true, false, ctx, msg, var_args); + va_end(var_args); +} +static void c_callback_validity_error(void* ctx, const char* msg, ...) +{ + va_list var_args; + va_start(var_args, msg); + p_callback_error_or_warning(false, true, ctx, msg, var_args); + va_end(var_args); +} + +static void c_callback_validity_warning(void* ctx, const char* msg, ...) +{ + va_list var_args; + va_start(var_args, msg); + p_callback_error_or_warning(false, false, ctx, msg, var_args); + va_end(var_args); +} +} // extern "C" +} // anonymous namespace + namespace xmlpp { @@ -136,17 +178,17 @@ void Parser::initialize_context() if (context_->sax && pimpl_->throw_messages_) { //Tell the parser context about the callbacks. - context_->sax->fatalError = &callback_parser_error; - context_->sax->error = &callback_parser_error; - context_->sax->warning = &callback_parser_warning; + context_->sax->fatalError = get_callback_parser_error_cfunc(); + context_->sax->error = get_callback_parser_error_cfunc(); + context_->sax->warning = get_callback_parser_warning_cfunc(); } if (pimpl_->throw_messages_) { //Tell the validity context about the callbacks: //(These are only called if validation is on - see above) - context_->vctxt.error = &callback_validity_error; - context_->vctxt.warning = &callback_validity_warning; + context_->vctxt.error = get_callback_validity_error_cfunc(); + context_->vctxt.warning = get_callback_validity_warning_cfunc(); } //Allow callback_error_or_warning() to retrieve the C++ instance: @@ -232,6 +274,7 @@ void Parser::check_for_error_and_warning_messages() exception_ = std::make_unique(msg); } +#ifndef LIBXMLXX_DISABLE_DEPRECATED //static void Parser::callback_parser_error(void* ctx, const char* msg, ...) { @@ -271,6 +314,44 @@ void Parser::callback_validity_warning(void* ctx, const char* msg, ...) //static void Parser::callback_error_or_warning(MsgType msg_type, void* ctx, const char* msg, va_list var_args) +{ + const bool is_parser = (msg_type == MsgType::ParserError) || (msg_type == MsgType::ParserWarning); + const bool is_error = (msg_type == MsgType::ParserError) || (msg_type == MsgType::ValidityError); + callback_error_or_warning(is_parser, is_error, ctx, msg, var_args); +} +#endif // LIBXMLXX_DISABLE_DEPRECATED + +//static +ParserCallbackCFuncType Parser::get_callback_parser_error_cfunc() +{ + p_callback_error_or_warning = &callback_error_or_warning; + return &c_callback_parser_error; +} + +//static +ParserCallbackCFuncType Parser::get_callback_parser_warning_cfunc() +{ + p_callback_error_or_warning = &callback_error_or_warning; + return &c_callback_parser_warning; +} + +//static +ParserCallbackCFuncType Parser::get_callback_validity_error_cfunc() +{ + p_callback_error_or_warning = &callback_error_or_warning; + return &c_callback_validity_error; +} + +//static +ParserCallbackCFuncType Parser::get_callback_validity_warning_cfunc() +{ + p_callback_error_or_warning = &callback_error_or_warning; + return &c_callback_validity_warning; +} + +//static +void Parser::callback_error_or_warning(bool is_parser, bool is_error, void* ctx, + const char* msg, va_list var_args) { //See xmlHTMLValidityError() in xmllint.c in libxml for more about this: @@ -294,20 +375,19 @@ void Parser::callback_error_or_warning(MsgType msg_type, void* ctx, try { - switch (msg_type) + if (is_parser) { - case MsgType::ParserError: + if (is_error) parser->on_parser_error(ubuff); - break; - case MsgType::ParserWarning: + else parser->on_parser_warning(ubuff); - break; - case MsgType::ValidityError: + } + else // validator + { + if (is_error) parser->on_validity_error(ubuff); - break; - case MsgType::ValidityWarning: + else parser->on_validity_warning(ubuff); - break; } } catch (...) diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index 17803f5b..440c21f4 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -19,6 +19,9 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { struct _xmlParserCtxt; + + /** @newin{5,2} */ + using ParserCallbackCFuncType = void (*)(void* ctx, const char* msg, ...); } #endif //DOXYGEN_SHOULD_SKIP_THIS @@ -199,15 +202,21 @@ class Parser : public NonCopyable LIBXMLPP_API virtual void check_for_error_and_warning_messages(); +#ifndef LIBXMLXX_DISABLE_DEPRECATED + /** @deprecated Use get_callback_parser_error_cfunc() instead. */ LIBXMLPP_API static void callback_parser_error(void* ctx, const char* msg, ...); + /** @deprecated Use get_callback_parser_warning_cfunc() instead. */ LIBXMLPP_API static void callback_parser_warning(void* ctx, const char* msg, ...); + /** @deprecated Use get_callback_validity_error_cfunc() instead. */ LIBXMLPP_API static void callback_validity_error(void* ctx, const char* msg, ...); + /** @deprecated Use get_callback_validity_warning_cfunc() instead. */ LIBXMLPP_API static void callback_validity_warning(void* ctx, const char* msg, ...); + /** @deprecated */ enum class MsgType { ParserError, @@ -216,9 +225,29 @@ class Parser : public NonCopyable ValidityWarning }; + /** @deprecated Use the other callback_error_or_warning() overload instead. */ LIBXMLPP_API static void callback_error_or_warning(MsgType msg_type, void* ctx, const char* msg, va_list var_args); +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** @newin{5,2} */ + LIBXMLPP_API + static ParserCallbackCFuncType get_callback_parser_error_cfunc(); + /** @newin{5,2} */ + LIBXMLPP_API + static ParserCallbackCFuncType get_callback_parser_warning_cfunc(); + /** @newin{5,2} */ + LIBXMLPP_API + static ParserCallbackCFuncType get_callback_validity_error_cfunc(); + /** @newin{5,2} */ + LIBXMLPP_API + static ParserCallbackCFuncType get_callback_validity_warning_cfunc(); + + /** @newin{5,2} */ + LIBXMLPP_API + static void callback_error_or_warning(bool is_parser, bool is_error, void* ctx, + const char* msg, va_list var_args); _xmlParserCtxt* context_; std::unique_ptr exception_; diff --git a/libxml++/validators/dtdvalidator.cc b/libxml++/validators/dtdvalidator.cc index f456f1e7..1ae700e5 100644 --- a/libxml++/validators/dtdvalidator.cc +++ b/libxml++/validators/dtdvalidator.cc @@ -97,8 +97,8 @@ void DtdValidator::initialize_context() if (pimpl_->context) { //Tell the validation context about the callbacks: - pimpl_->context->error = &callback_validity_error; - pimpl_->context->warning = &callback_validity_warning; + pimpl_->context->error = get_callback_validity_error_cfunc(); + pimpl_->context->warning = get_callback_validity_warning_cfunc(); //Allow the callback_validity_*() methods to retrieve the C++ instance: pimpl_->context->userData = this; diff --git a/libxml++/validators/relaxngvalidator.cc b/libxml++/validators/relaxngvalidator.cc index dfc42cf1..9bb10c20 100644 --- a/libxml++/validators/relaxngvalidator.cc +++ b/libxml++/validators/relaxngvalidator.cc @@ -125,7 +125,8 @@ RelaxNGValidator::operator bool() const noexcept void RelaxNGValidator::initialize_context() { - xmlRelaxNGSetValidErrors(pimpl_->context, &callback_validity_error, &callback_validity_warning, this); + xmlRelaxNGSetValidErrors(pimpl_->context, get_callback_validity_error_cfunc(), + get_callback_validity_warning_cfunc(), this); SchemaValidatorBase::initialize_context(); } diff --git a/libxml++/validators/validator.cc b/libxml++/validators/validator.cc index fa9f7b18..25889b29 100644 --- a/libxml++/validators/validator.cc +++ b/libxml++/validators/validator.cc @@ -13,6 +13,33 @@ #include //For va_list. #include //For unique_ptr. +namespace +{ +// C++ linkage +using ErrorOrWarningFuncType = void (*)(bool error, void* ctx, + const char* msg, va_list var_args); +ErrorOrWarningFuncType p_callback_error_or_warning; + +extern "C" +{ +static void c_callback_validity_error(void* ctx, const char* msg, ...) +{ + va_list var_args; + va_start(var_args, msg); + p_callback_error_or_warning(true, ctx, msg, var_args); + va_end(var_args); +} + +static void c_callback_validity_warning(void* ctx, const char* msg, ...) +{ + va_list var_args; + va_start(var_args, msg); + p_callback_error_or_warning(false, ctx, msg, var_args); + va_end(var_args); +} +} // extern "C" +} // anonymous namespace + namespace xmlpp { Validator::Validator() noexcept @@ -71,6 +98,7 @@ void Validator::check_for_validity_messages() exception_ = std::make_unique(msg); } +#ifndef LIBXMLXX_DISABLE_DEPRECATED void Validator::callback_validity_error(void* valid_, const char* msg, ...) { auto validator = static_cast(valid_); @@ -116,6 +144,48 @@ void Validator::callback_validity_warning(void* valid_, const char* msg, ...) } } } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +//static +ValidatorCallbackCFuncType Validator::get_callback_validity_error_cfunc() +{ + p_callback_error_or_warning = &callback_error_or_warning; + return &c_callback_validity_error; +} + +//static +ValidatorCallbackCFuncType Validator::get_callback_validity_warning_cfunc() +{ + p_callback_error_or_warning = &callback_error_or_warning; + return &c_callback_validity_warning; +} + +//static +void Validator::callback_error_or_warning(bool error, void* ctx, + const char* msg, va_list var_args) +{ + // The caller of a libxml2 function with a callback is assumed to have + // specified that the validation context is a xmlpp::Validator instance. + auto validator = static_cast(ctx); + + if (validator) + { + // Convert msg and var_args to a string: + const ustring buff = format_printf_message(msg, var_args); + + try + { + if (error) + validator->on_validity_error(buff); + else + validator->on_validity_warning(buff); + } + catch (...) + { + validator->handle_exception(); + } + } +} void Validator::handle_exception() { diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index f8d7882f..122c371f 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -11,11 +11,15 @@ #include #include #include +#include // va_list #include // std::unique_ptr #include extern "C" { struct _xmlValidCtxt; + + /** @newin{5,2} */ + using ValidatorCallbackCFuncType = void (*)(void* ctx, const char* msg, ...); } namespace xmlpp { @@ -81,10 +85,26 @@ class Validator : public NonCopyable LIBXMLPP_API virtual void check_for_validity_messages(); +#ifndef LIBXMLXX_DISABLE_DEPRECATED + /** @deprecated Use get_callback_validity_error_cfunc() instead. */ LIBXMLPP_API static void callback_validity_error(void* ctx, const char* msg, ...); + /** @deprecated Use get_callback_validity_warning_cfunc() instead. */ LIBXMLPP_API static void callback_validity_warning(void* ctx, const char* msg, ...); +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** @newin{5,2} */ + LIBXMLPP_API + static ValidatorCallbackCFuncType get_callback_validity_error_cfunc(); + /** @newin{5,2} */ + LIBXMLPP_API + static ValidatorCallbackCFuncType get_callback_validity_warning_cfunc(); + + /** @newin{5,2} */ + LIBXMLPP_API + static void callback_error_or_warning(bool error, void* ctx, + const char* msg, va_list var_args); std::unique_ptr exception_; // Built gradually - used in an exception at the end of validation. diff --git a/libxml++/validators/xsdvalidator.cc b/libxml++/validators/xsdvalidator.cc index 1de372fc..decb8be8 100644 --- a/libxml++/validators/xsdvalidator.cc +++ b/libxml++/validators/xsdvalidator.cc @@ -122,7 +122,8 @@ XsdValidator::operator bool() const noexcept void XsdValidator::initialize_context() { - xmlSchemaSetValidErrors(pimpl_->context, &callback_validity_error, &callback_validity_warning, this); + xmlSchemaSetValidErrors(pimpl_->context, get_callback_validity_error_cfunc(), + get_callback_validity_warning_cfunc(), this); SchemaValidatorBase::initialize_context(); } From b95854e4f8214a57267fd15bd0e65b9e48167500 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 22 Mar 2023 20:37:14 +0100 Subject: [PATCH 195/240] Parser, Validator: Put C function pointer types in namespace xmlpp --- libxml++/parsers/parser.h | 10 +++++++--- libxml++/validators/validator.h | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index 440c21f4..2181ec07 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -19,14 +19,18 @@ #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { struct _xmlParserCtxt; - - /** @newin{5,2} */ - using ParserCallbackCFuncType = void (*)(void* ctx, const char* msg, ...); } #endif //DOXYGEN_SHOULD_SKIP_THIS namespace xmlpp { +extern "C" { + /** Type of function pointer to callback function with C linkage. + * @newin{5,2} + */ + using ParserCallbackCFuncType = void (*)(void* ctx, const char* msg, ...); +} + /** XML parser. * * Abstract base class for DOM parser and SAX parser. diff --git a/libxml++/validators/validator.h b/libxml++/validators/validator.h index 122c371f..7f3ec859 100644 --- a/libxml++/validators/validator.h +++ b/libxml++/validators/validator.h @@ -17,13 +17,17 @@ extern "C" { struct _xmlValidCtxt; - - /** @newin{5,2} */ - using ValidatorCallbackCFuncType = void (*)(void* ctx, const char* msg, ...); } namespace xmlpp { +extern "C" { + /** Type of function pointer to callback function with C linkage. + * @newin{5,2} + */ + using ValidatorCallbackCFuncType = void (*)(void* ctx, const char* msg, ...); +} + class Document; /** Base class for XML validators. From 36c2b344810a2b7e30293d9626335454892f3019 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 5 Jul 2023 14:30:14 +0800 Subject: [PATCH 196/240] Meson: Cleanup and fix libxml2 dep search Use CMake to help us find libxml2, in addition to using pkg-config, as CMake actually looks up libxml2 for us using the headers in %INCLUDE% and the libraries in %LIB% in a more comprehensive way, so we don't need to reinvent the wheel. Since we use Meson 0.60.0 or later, we can use the CMake libxml2 dependency name together with libxml-2.0.pc to find libxml2 in one single call. Also update the libxml2 CMake subproject by using CMake to find ICU and liblzma in the same manner, and ensure that we have the correct libxml2 .lib in the resulting pkg-config file for libxml++. --- meson.build | 142 +++++++++++++++++++++------------------------------- 1 file changed, 58 insertions(+), 84 deletions(-) diff --git a/meson.build b/meson.build index 935aece6..b8b19728 100644 --- a/meson.build +++ b/meson.build @@ -100,92 +100,65 @@ install_pkgconfigdir = install_libdir / 'pkgconfig' # xmlxx_dep (created in libxml++/meson.build): # Dependencies when using the libxml++ library. -# libxml2's Windows-specific Makefiles don't create pkg-config files for us, so -# we may need to look for it manually on Windows xml2_min_ver = '2.7.7' xml2_req = '>= @0@'.format(xml2_min_ver) -xml2_dep = dependency('libxml-2.0', version: xml2_req, required: host_machine.system() != 'windows') -xml2_is_subproject = false +xml2_dep = dependency( + ['libxml-2.0', 'LibXml2'], + version: xml2_req, + required: host_machine.system() != 'windows' +) -libxml2_lib_set = false +# Setup CMake subproject for use, if needed if not xml2_dep.found() - libxml2_lib = 'libxml2' - libxml2_lib_set = true - xml2_dep = cpp_compiler.find_library(libxml2_lib, - has_headers: [ - 'libxml/globals.h', - 'libxml/parser.h', - 'libxml/parserInternals.h', - 'libxml/relaxng.h', - 'libxml/tree.h', - 'libxml/xinclude.h', - 'libxml/xpath.h', - 'libxml/xpathInternals.h', - 'libxml/xmlerror.h', - 'libxml/xmlIO.h', - 'libxml/xmlreader.h', - 'libxml/xmlschemas.h', - ], - required: false) - if xml2_dep.found() - xml_min_ver_split = xml2_min_ver.split('.') - xml_min_ver_int = xml_min_ver_split[0].to_int() * 10000 + \ - xml_min_ver_split[1].to_int() * 100 + \ - xml_min_ver_split[2].to_int() - - if not cpp_compiler.compiles('''#include - #if LIBXML_VERSION < @0@ - # error libxml2 versions must be @1@ or later - #endif'''.format(xml_min_ver_int.to_string(), xml2_min_ver), - name : 'libxml2 is @0@ or later'.format(xml2_min_ver)) - error('Your libxml2 installation must be @0@ or later'.format(xml2_min_ver)) - endif - else - cmake = import('cmake') - opt_var = cmake.subproject_options() - build_shared = get_option('default_library') != 'static' - iconv_dep = dependency('iconv', required: false) - icu_i18n_dep = dependency('icu-i18n', required: false) - icu_uc_dep = dependency('icu-uc', required: false) - lzma_dep = dependency('liblzma', required: false) - thread_dep = dependency('threads', required: false) - zlib_dep = dependency('zlib', required: false) - winsock_dep = cpp_compiler.find_library('ws2_32', required: false) - cmake_build_type = get_option('buildtype') - if get_option('buildtype') == 'debugoptimized' - cmake_build_type = 'RelWithDebInfo' - elif get_option('buildtype') == 'minsize' - cmake_build_type = 'MinSizeRel' - elif get_option('buildtype') == 'plain' - cmake_build_type = '' - endif - opt_var.add_cmake_defines({'BUILD_SHARED_LIBS': build_shared, - 'CMAKE_BUILD_TYPE': cmake_build_type, - 'CMAKE_MSVC_RUNTIME_LIBRARY': '', - 'CMAKE_C_FLAGS_INIT': '', - 'CMAKE_C_FLAGS_DEBUG': '', - 'CMAKE_C_FLAGS_RELEASE': '', - 'CMAKE_C_FLAGS_RELWITHDEBINFO': '', - 'CMAKE_C_FLAGS_MINSIZEREL': '', - 'LIBXML2_WITH_HTTP': host_machine.system() != 'windows' or winsock_dep.found(), - 'LIBXML2_WITH_ICONV': iconv_dep.found(), - 'LIBXML2_WITH_ICU': icu_i18n_dep.found() and icu_uc_dep.found(), - 'LIBXML2_WITH_LZMA': lzma_dep.found(), - 'LIBXML2_WITH_PYTHON': false, - 'LIBXML2_WITH_TESTS': build_tests, - 'LIBXML2_WITH_THREADS': thread_dep.found(), - 'LIBXML2_WITH_ZLIB': zlib_dep.found(), - }) - - xml2_sp = cmake.subproject('libxml2_cmake', options: opt_var) - xml2_dep = xml2_sp.dependency('LibXml2') - xml2_is_subproject = true - - if build_tests - test('testchar', xml2_sp.target('testchar')) - test('testdict', xml2_sp.target('testdict')) - endif + cmake = import('cmake') + opt_var = cmake.subproject_options() + build_shared = get_option('default_library') != 'static' + iconv_dep = dependency('iconv', required: false) + icu_i18n_dep = dependency('icu-i18n', 'ICU', + components: 'in', + required: false) + icu_uc_dep = dependency('icu-uc', 'ICU', + components: 'uc', + required: false) + lzma_dep = dependency(['liblzma','LibLZMA'], required: false) + thread_dep = dependency('threads', required: false) + zlib_dep = dependency('zlib', required: false) + winsock_dep = cpp_compiler.find_library('ws2_32', required: false) + cmake_build_type = get_option('buildtype') + if get_option('buildtype') == 'debugoptimized' + cmake_build_type = 'RelWithDebInfo' + elif get_option('buildtype') == 'minsize' + cmake_build_type = 'MinSizeRel' + elif get_option('buildtype') == 'plain' + cmake_build_type = '' endif + opt_var.add_cmake_defines({ + 'BUILD_SHARED_LIBS': build_shared, + 'CMAKE_BUILD_TYPE': cmake_build_type, + 'CMAKE_MSVC_RUNTIME_LIBRARY': '', + 'CMAKE_C_FLAGS_INIT': '', + 'CMAKE_C_FLAGS_DEBUG': '', + 'CMAKE_C_FLAGS_RELEASE': '', + 'CMAKE_C_FLAGS_RELWITHDEBINFO': '', + 'CMAKE_C_FLAGS_MINSIZEREL': '', + 'LIBXML2_WITH_HTTP': host_machine.system() != 'windows' or winsock_dep.found(), + 'LIBXML2_WITH_ICONV': iconv_dep.found(), + 'LIBXML2_WITH_ICU': icu_i18n_dep.found() and icu_uc_dep.found(), + 'LIBXML2_WITH_LZMA': lzma_dep.found(), + 'LIBXML2_WITH_PYTHON': false, + 'LIBXML2_WITH_TESTS': build_tests, + 'LIBXML2_WITH_THREADS': thread_dep.found(), + 'LIBXML2_WITH_ZLIB': zlib_dep.found(), + }) + xml2_sp = cmake.subproject('libxml2_cmake', options: opt_var) + xml2_dep = xml2_sp.dependency('LibXml2') +endif + +xml2_is_subproject = xml2_dep.type_name() == 'internal' + +if xml2_is_subproject and build_tests + test('testchar', xml2_sp.target('testchar')) + test('testdict', xml2_sp.target('testdict')) endif xmlxx_requires = [] @@ -196,9 +169,10 @@ libxml2_lib_pkgconfig = '' if xml2_dep.type_name() == 'pkgconfig' xmlxx_requires += ['libxml-2.0', xml2_req] else - if libxml2_lib_set - libxml2_lib_pkgconfig = '-l@0@'.format(libxml2_lib) - endif + libxml2_lib_pkgconfig = xml2_dep.get_variable( + cmake: 'LIBXML2_LIBRARIES', + default_value: 'LibXml2.lib', + ) endif xmlxx_requires = ' '.join(xmlxx_requires) From a2bbeac65c64b6648f820c7504b08183fa2d7171 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 5 Jul 2023 14:21:55 +0800 Subject: [PATCH 197/240] Update Visual Studo build docs Update the Visual Studio build documentation by: * Using MarkDown format, to make things easier for the eye, and use UNIX line endings. * Update information as appropriate, especially on Meson builds. --- MSVC_NMake/MSVC-Builds.md | 84 +++++++++++++++++++++++++++++++++++++++ MSVC_NMake/README | 35 ---------------- MSVC_NMake/filelist.am | 30 +++++++------- README.md | 2 +- 4 files changed, 100 insertions(+), 51 deletions(-) create mode 100644 MSVC_NMake/MSVC-Builds.md delete mode 100644 MSVC_NMake/README diff --git a/MSVC_NMake/MSVC-Builds.md b/MSVC_NMake/MSVC-Builds.md new file mode 100644 index 00000000..16da33b8 --- /dev/null +++ b/MSVC_NMake/MSVC-Builds.md @@ -0,0 +1,84 @@ +Building libxml++ with Visual Studio 2017 or later +- + +* You will need Visual Studio 2017 (MSVC 15.7.x) or later, as `C++-17` is +required and only 15.7.x or later had adequate `C++-17` support. +* Install libxml2 from https://xmlsoft.org/, either via Windows binaries or +building from source, using NMake or CMake. It is strongly recommended, if +building libxml2 from source, that Visual Studio 2015 or later is used. +* Add libxml2's include path to `%INCLUDE%` and its library path to `%LIB%`, or +placing the dependencies like the following: +``` +$(some_dir_1)\include + | + --libxml2\libxml\*.h + | + --(headers of libraries libxml2 depends on, such as ZLib, liblzma...) + +$(some_dir_2)\lib + | + --libxml2.lib + | + --(.lib's of libraries that libxml2 depends on, such as ZLib, liblzma) +``` +* You need libxml2's DLL and all of its dependent DLLs in `%PATH%` if linking +against a DLL build of libxml2 in order to run the tests. + +* Notice that for the built DLL and .lib the Visual Studio version is no +longer `vc$(VSVER)0`, but is named like the following (Visual Studio version), +to follow what is done in other C++ libraries such as Boost (use +`-Dmsvc14x-parallel-installable=false` to the Meson options or pass +`USE_COMPAT_LIBS=1` in the NMake commandline to override, recommended only if +rebuilding items using libxml++ is inconvenient): + * NMake: + * 2017: `VSVER=15`, `xml++-vc141-5_0.[dll|pdb|lib]` + * 2019: `VSVER=16`, `xml++-vc142-5_0.[dll|pdb|lib]` + * 2022: `VSVER=17`, `xml++-vc143-5_0.[dll|pdb|lib]` + * Meson: + * 2017: `VSVER=15`, `xml++-vc141-5.0-1[dll|pdb]`, `xml++-vc141-5.0.lib` + * 2019: `VSVER=16`, `xml++-vc142-5.0-1[dll|pdb]`, `xml++-vc142-5.0.lib` + * 2022: `VSVER=17`, `xml++-vc143-5.0-1[dll|pdb]`, `xml++-vc143-5.0.lib` + + +### NMake Builds +* Note that `$(Platform)` refers to the following: + * `$(Platform)` + * AMD64/x86_64/x64: `x64` + * ARM64/aarch64: `arm64` + * x86/i686: `Win32` + +* Run the following: +``` +cd $(srcroot)\MSVC_NMake +# Run "nmake /f Makefile.vc" to see to see what options are supported by +# the NMake Makefiles +# INCLUDEDIR is by default $(PREFIX)\include, and LIBDIR is by default +# $(PREFIX)\lib. PREFIX is by default $(srcroot)\..\vs$(VSVER\$(Platform). +# $(some_dir_1) and $(some_dir_2) refer to the sample layout listed above. + +nmake /f Makefile.vc CFG=[debug|release] [PREFIX=...] [INCLUDEDIR=$(some_dir_1)\include] [LIBDIR=$(some_dir_2)\lib] +``` +* The following targets are supported (only DLL builds are supported out of the +box with the NMake Makefiles): + * `all`, `libxmlxx_examples` (or nothing passed in): The libxml++ library as +a DLL with the example programs + * `tests`: The libxml++ library as a DLL with the test programs + +### Meson builds +Please also see [README.md](../README.md) for further details. + +For Visual Studio builds, it is also recommended that CMake is installed and can +be found in `%PATH%`, so that it can help with finding an installed libxml2, or +build libxml2 alongside with libxml++ if it is not previously installed. If +libxml2 is installed, you will most probably need to add its include directory +to `%INCLUDE%` and its library path to `%LIB%`, as described earlier. + + +Cedric Gustin +01/26/2005 + +Armin Burgmeier +10/03/2010 + +Chun-wei Fan +06/12/2020, updated 07/05/2023 diff --git a/MSVC_NMake/README b/MSVC_NMake/README deleted file mode 100644 index 3e0b0a44..00000000 --- a/MSVC_NMake/README +++ /dev/null @@ -1,35 +0,0 @@ -Building libxml++ with Visual Studio 2017 or later - -* You will need Visual Studio 2017 (MSVC 15.7) or later, as C++-17 is required and only 15.7 or later had - adequate C++-17 support -* Install libxml2 from https://xmlsoft.org/, either via Windows binaries or building from source. It is - strongly recommended, if building libxml2 from source, that Visual Studio 2015 or later is used -* Add libxml2 to the include and lib paths in Visual Studio. -* Run `nmake /f Makefile.vc CFG=[debug|release]` to buiild libxml++. Run `nmake /f Makefile.vc` without the - `CFG=[debug|release] flag to see which options are supported by the NMake Makefiles - -* It is recommended that the dependent items is to be placed like the following, or be placed in paths - indicated by %INCLUDE% and %LIB% respectively for the headers and .lib's: - -\include - | - -libxml2 (and items in its subdir(s)) - | - -(any dependent headers of libraries enabled by libxml2) - -\lib - | - -libxml2.lib - - Fine-tune by passing in PREFIX=..., INCLUDEDIR=... (default:$(PREFIX)\include, example would be - INCLUDEDIR=\include) and LIBDIR=... (default: $(PREFIX)\lib, example would be - LIBDIR=\lib) as needed. - -Cedric Gustin -01/26/2005 - -Armin Burgmeier -10/03/2010 - -Chun-wei Fan -06/12/2020 diff --git a/MSVC_NMake/filelist.am b/MSVC_NMake/filelist.am index 4dbe5555..11152a59 100644 --- a/MSVC_NMake/filelist.am +++ b/MSVC_NMake/filelist.am @@ -1,15 +1,15 @@ -## This file is part of libxml++. - -msvc_nmake_data = \ - README \ - libxml++/libxml++.rc \ - libxml++/libxml++config.h \ - build-rules-msvc.mak \ - config-msvc.mak \ - create-lists-msvc.mak \ - create-lists.bat \ - detectenv-msvc.mak \ - generate-msvc.mak \ - info-msvc.mak \ - install.mak \ - Makefile.vc +## This file is part of libxml++. + +msvc_nmake_data = \ + MSVC-Builds.md \ + libxml++/libxml++.rc \ + libxml++/libxml++config.h \ + build-rules-msvc.mak \ + config-msvc.mak \ + create-lists-msvc.mak \ + create-lists.bat \ + detectenv-msvc.mak \ + generate-msvc.mak \ + info-msvc.mak \ + install.mak \ + Makefile.vc diff --git a/README.md b/README.md index 10110a0a..87624aa1 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ supplier of your operating system, such as your Linux distribution. ## Building on Windows -See MSVC_NMake/README +See [MSVC-Builds.md](MSVC_NMake/MSVC-Builds.md) ## Building from a release tarball From c01f4275765dc9b38a3fba3d0d01c1e50dfabe54 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 9 Jul 2023 17:08:53 +0200 Subject: [PATCH 198/240] Doxyfile.in: Remove obsolete entries --- docs/reference/Doxyfile.in | 4 ---- 1 file changed, 4 deletions(-) diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in index 67994acc..5b4250a3 100644 --- a/docs/reference/Doxyfile.in +++ b/docs/reference/Doxyfile.in @@ -225,7 +225,6 @@ PDF_HYPERLINKS = YES USE_PDFLATEX = YES LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO -LATEX_SOURCE_CODE = NO LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # Configuration options related to the RTF output @@ -236,7 +235,6 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = -RTF_SOURCE_CODE = NO #--------------------------------------------------------------------------- # Configuration options related to the man page output #--------------------------------------------------------------------------- @@ -256,7 +254,6 @@ XML_PROGRAMLISTING = NO #--------------------------------------------------------------------------- GENERATE_DOCBOOK = NO DOCBOOK_OUTPUT = docbook -DOCBOOK_PROGRAMLISTING = NO #--------------------------------------------------------------------------- # Configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- @@ -307,7 +304,6 @@ EXTERNAL_PAGES = YES #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- -CLASS_DIAGRAMS = YES DIA_PATH = HIDE_UNDOC_RELATIONS = NO HAVE_DOT = YES From 7fe2c354d45bd381e68726658aa5ccf0daa345b7 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 9 Jul 2023 17:09:17 +0200 Subject: [PATCH 199/240] libxml++.pc.in: Update htmlrefpub --- libxml++.pc.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxml++.pc.in b/libxml++.pc.in index 6c219ae8..5d8d1dc3 100644 --- a/libxml++.pc.in +++ b/libxml++.pc.in @@ -8,7 +8,7 @@ includedir=@includedir@ docdir=${datarootdir}/doc/@LIBXMLXX_MODULE_NAME@ doxytagfile=${docdir}/reference/@LIBXMLXX_MODULE_NAME@.tag htmlrefdir=${docdir}/reference/html -htmlrefpub=http://library.gnome.org/devel/@PACKAGE_TARNAME@/unstable/ +htmlrefpub=https://libxmlplusplus.github.io/libxmlplusplus/reference/html/ Name: libxml++ Description: C++ wrapper for libxml From 10b935f45b84c82090bb2f4df7b7ce31cceac420 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 9 Jul 2023 17:09:44 +0200 Subject: [PATCH 200/240] Remove AUTHORS and add general information to README.md See https://gitlab.gnome.org/GNOME/gtkmm/-/issues/140 --- AUTHORS | 17 ----------------- README.md | 41 +++++++++++++++++++++++++++++++++++++---- libxmlplusplus.doap | 21 +++++++++++++-------- 3 files changed, 50 insertions(+), 29 deletions(-) delete mode 100644 AUTHORS diff --git a/AUTHORS b/AUTHORS deleted file mode 100644 index 25a25463..00000000 --- a/AUTHORS +++ /dev/null @@ -1,17 +0,0 @@ -Please do not email us directly - use the mailing list. -See https://libxmlplusplus.github.io/libxmlplusplus - -Maintainer ----------- -Christophe de Vienne - -Contributors ------------- - See the ChangeLog. - -Previous Maintainers: ----------------- - -Ari Johnson - - diff --git a/README.md b/README.md index 87624aa1..00cb72a6 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,53 @@ # libxml++ +C++ interface to libxml2 and XML files. + +# Introduction + libxml++ (a.k.a. libxmlplusplus) provides a C++ interface to XML files. It uses libxml2 to access the XML files, and in order to configure libxml++ you must have both libxml2 and pkg-config installed. -To get the latest version of libxml++, see the -[libxml++ web site](https://libxmlplusplus.github.io/libxmlplusplus/) +libxml++-2.6, libxml++-3.0, libxml++-4.0 and libxml++-5.0 are different +parallel-installable ABIs. This file describes libxml++-5.0. See the examples directory for example code. -Use pkg-config to discover the necessary include and linker arguments. For instance, +Use pkg-config to discover the necessary include and linker arguments. +For instance, ``` pkg-config libxml++-5.0 --cflags --libs ``` If you build with Autotools, ideally you would use PKG_CHECK_MODULES in your configure.ac file. +# General information + +Web site + - https://libxmlplusplus.github.io/libxmlplusplus/ + +Download location + - https://download.gnome.org/sources/libxml++/ + - https://github.com/libxmlplusplus/libxmlplusplus/releases/ + +Reference documentation + - https://libxmlplusplus.github.io/libxmlplusplus/reference/html/ + +Tarballs contain reference documentation. In tarballs generated with Meson, +see the untracked/docs/reference/html directory. + +Discussion on GNOME's discourse forum + - https://discourse.gnome.org/tag/cplusplus + - https://discourse.gnome.org/c/platform + +Git repository + - https://github.com/libxmlplusplus/libxmlplusplus + +Bugs can be reported to + - https://github.com/libxmlplusplus/libxmlplusplus/issues + +Patches can be submitted to + - https://github.com/libxmlplusplus/libxmlplusplus/pulls + # Building Whenever possible, you should use the official binary packages approved by the @@ -22,7 +55,7 @@ supplier of your operating system, such as your Linux distribution. ## Building on Windows -See [MSVC-Builds.md](MSVC_NMake/MSVC-Builds.md) +See [MSVC-Builds](MSVC_NMake/MSVC-Builds.md) ## Building from a release tarball diff --git a/libxmlplusplus.doap b/libxmlplusplus.doap index d3f3d637..88f82ee0 100644 --- a/libxmlplusplus.doap +++ b/libxmlplusplus.doap @@ -1,21 +1,26 @@ + + libxmlplusplus C++ bindings for libxml2 - libxmlplusplus (aka libxml++) is a C++ wrapper for the libxml2 XML parser library. + +libxmlplusplus (aka libxml++) is a C++ wrapper for the libxml2 XML parser library. It has SAX and DOM-like APIs, but does not attempt to conform exactly to -the DOM specification. Its API is simpler than the underlying libxml2 C API. +the DOM specification. Its API is simpler than the underlying libxml2 C API. + - + + - C++ @@ -27,9 +32,9 @@ the DOM specification. Its API is simpler than the underlying libxml2 C API. - Christophe de Vienne - - cdevienn + Kjell Ahlstedt + + kjellahl From d87a38dbf8a55fa26e9f836f18a4a04e1e634677 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 18 Jul 2023 11:06:10 +0200 Subject: [PATCH 201/240] Update docs/index.md Describe how to choose between the ABI versions. --- docs/index.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/docs/index.md b/docs/index.md index de0a4d39..ec86e1a1 100644 --- a/docs/index.md +++ b/docs/index.md @@ -8,29 +8,42 @@ libxml++ is a C++ wrapper for the [libxml2](http://www.xmlsoft.org) XML parser l ## License -Libxml++ is released under the [LGPL](http://www.gnu.org/licenses/lgpl.html#TOC1) version 2 or above +Libxml++ is released under the [LGPL](https://www.gnu.org/licenses/lgpl.html) version 2 or above. ## ABI Versions There are several ABI (Application Binary Interface) versions of libxml++. They can be installed in parallel. -libxml++-2.6: Old ABI, not recommended for new applications. Uses Glib::ustring from the glibmm-2.4 ABI. +- libxml++-2.6: Old ABI, not recommended for new applications. + Uses Glib::ustring from the glibmm-2.4 ABI. -libxml++-3.0: Uses Glib::ustring from the glibmm-2.4 ABI, therefore has methods that handle UTF-8 characters rather than raw bytes. +- libxml++-3.0: Uses Glib::ustring from the glibmm-2.4 ABI, + therefore has methods that handle UTF-8 characters rather than raw bytes. -libxml++-4.0: Uses Glib::ustring from the newer glibmm-2.68 ABI, therefore has methods that handle UTF-8 characters rather than raw bytes. +- libxml++-4.0: Uses Glib::ustring from the newer glibmm-2.68 ABI, + therefore has methods that handle UTF-8 characters rather than raw bytes. -libxml++-5.0: Does not depend on glibmm, is not as good at handling UTF-8 strings, but has fewer dependencies. +- libxml++-5.0: Does not depend on glibmm, is not as good at handling UTF-8 strings, + has fewer dependencies. + +The APIs of libxml++-3.0, libxml++-4.0 and libxml++-5.0 are very similar. +The only significant difference is that libxml++-5.0 uses xmlpp::ustring +instead of Glib::ustring. + +In a new application, choose between libxml++-4.0 with UTF-8 support and libxml++-5.0 +with fewer dependencies. Choose libxml++-3.0 only if you want UTF-8 support but +don't have access to the newer glibmm-2.68 ABI (glibmm version 2.68.0 or higher). ## Download -You can download libxml++ from the [GNOME download site](https://download.gnome.org/sources/libxml++/). +You can download libxml++ from [GitHub releases](https://github.com/libxmlplusplus/libxmlplusplus/releases/) +or the [GNOME download site](https://download.gnome.org/sources/libxml++/). ## Required Libraries * [libxml2](http://www.xmlsoft.org/) -* libxml++-2.6 and libxml++-3.0: [glibmm-2.4](https://developer-old.gnome.org/glibmm/2.64/) +* libxml++-2.6 and libxml++-3.0: [glibmm-2.4](https://developer-old.gnome.org/glibmm/2.66/) * libxml++-4.0: [glibmm-2.68](https://gnome.pages.gitlab.gnome.org/glibmm/) ## Documentation @@ -71,5 +84,5 @@ instance, under the [Platform/Language bindings](https://discourse.gnome.org/c/p category with a _cplusplus_ tag. There is an old mailing list, which is now closed for new posts. -There is an archive of messages [here](http://mail.gnome.org/archives/libxmlplusplus-list/). +There is an archive of messages [here](https://mail.gnome.org/archives/libxmlplusplus-list/). Please do not email the developers directly. From 5f5371776186fb3390d028848bed10953d17a865 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sat, 29 Jul 2023 11:08:39 +0200 Subject: [PATCH 202/240] CI: Use the ubuntu-latest runner and use the default versions of gcc and clang. --- ...{autotools-gcc-9.yml => autotools-clang.yml} | 10 +++++----- ...autotools-clang-10.yml => autotools-gcc.yml} | 10 +++++----- .../{meson-gcc-10.yml => meson-clang.yml} | 17 +++++++---------- .../{meson-clang-10.yml => meson-gcc.yml} | 17 +++++++---------- .github/workflows/publish-docs.yml | 4 ++-- 5 files changed, 26 insertions(+), 32 deletions(-) rename .github/workflows/{autotools-gcc-9.yml => autotools-clang.yml} (67%) rename .github/workflows/{autotools-clang-10.yml => autotools-gcc.yml} (65%) rename .github/workflows/{meson-gcc-10.yml => meson-clang.yml} (62%) rename .github/workflows/{meson-clang-10.yml => meson-gcc.yml} (61%) diff --git a/.github/workflows/autotools-gcc-9.yml b/.github/workflows/autotools-clang.yml similarity index 67% rename from .github/workflows/autotools-gcc-9.yml rename to .github/workflows/autotools-clang.yml index 5b24a14d..4e9b184e 100644 --- a/.github/workflows/autotools-gcc-9.yml +++ b/.github/workflows/autotools-clang.yml @@ -1,19 +1,19 @@ -name: "CI: autotools: gcc 9" +name: "Autotools: clang" on: [push] jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Build run: | sudo apt update - sudo apt install libxml2-dev mm-common g++-9 docbook-xsl - export CXX=g++-9 + sudo apt install libxml2-dev mm-common clang docbook-xsl + export CXX=clang++ ./autogen.sh --enable-warnings=fatal make - name: Test @@ -21,5 +21,5 @@ jobs: - name: Distcheck run: | # distcheck runs configure again so we need to specify CXX again. - export CXX=g++-9 + export CXX=clang++ make distcheck diff --git a/.github/workflows/autotools-clang-10.yml b/.github/workflows/autotools-gcc.yml similarity index 65% rename from .github/workflows/autotools-clang-10.yml rename to .github/workflows/autotools-gcc.yml index 9ab425d4..532e4b77 100644 --- a/.github/workflows/autotools-clang-10.yml +++ b/.github/workflows/autotools-gcc.yml @@ -1,19 +1,19 @@ -name: "CI: autotools: clang 10" +name: "Autotools: gcc" on: [push] jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - name: Build run: | sudo apt update - sudo apt install libxml2-dev mm-common clang-10 docbook-xsl - export CXX=clang++-10 + sudo apt install libxml2-dev mm-common g++ docbook-xsl + export CXX=g++ ./autogen.sh --enable-warnings=fatal make - name: Test @@ -21,5 +21,5 @@ jobs: - name: Distcheck run: | # distcheck runs configure again so we need to specify CXX again. - export CXX=clang++-10 + export CXX=g++ make distcheck diff --git a/.github/workflows/meson-gcc-10.yml b/.github/workflows/meson-clang.yml similarity index 62% rename from .github/workflows/meson-gcc-10.yml rename to .github/workflows/meson-clang.yml index 3a53e981..d2a3a272 100644 --- a/.github/workflows/meson-gcc-10.yml +++ b/.github/workflows/meson-clang.yml @@ -1,11 +1,11 @@ -name: "meson: gcc 10" +name: "Meson: clang" on: [push] jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 @@ -14,12 +14,9 @@ jobs: # Prevent blocking apt install on a question during configuring of tzdata. export DEBIAN_FRONTEND=noninteractive sudo apt update - sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common g++-10 ninja-build python3-setuptools python3-pip --yes - # Ubuntu 20.04 contains meson 0.53.2, but libxml++ requires meson >= 0.55.0. - # Install it with pip3 instead of apt. - sudo pip3 install "meson>=0.55.0" - export CC=gcc-10 - export CXX=g++-10 + sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common clang meson ninja-build python3-setuptools --yes + export CC=clang + export CXX=clang++ meson setup -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true _build cd _build meson compile @@ -31,7 +28,7 @@ jobs: run: | sudo apt install git --yes # dist runs setup again so we need to specify CC and CXX again. - export CC=gcc-10 - export CXX=g++-10 + export CC=clang + export CXX=clang++ cd _build meson dist diff --git a/.github/workflows/meson-clang-10.yml b/.github/workflows/meson-gcc.yml similarity index 61% rename from .github/workflows/meson-clang-10.yml rename to .github/workflows/meson-gcc.yml index 97694f20..625b700d 100644 --- a/.github/workflows/meson-clang-10.yml +++ b/.github/workflows/meson-gcc.yml @@ -1,11 +1,11 @@ -name: "meson: clang 10" +name: "Meson: gcc" on: [push] jobs: build: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 @@ -14,12 +14,9 @@ jobs: # Prevent blocking apt install on a question during configuring of tzdata. export DEBIAN_FRONTEND=noninteractive sudo apt update - sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common clang-10 ninja-build python3-setuptools python3-pip --yes - # Ubuntu 20.04 contains meson 0.53.2, but libxml++ requires meson >= 0.55.0. - # Install it with pip3 instead of apt. - sudo pip3 install "meson>=0.55.0" - export CC=clang-10 - export CXX=clang++-10 + sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common g++ meson ninja-build python3-setuptools --yes + export CC=gcc + export CXX=g++ meson setup -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true _build cd _build meson compile @@ -31,7 +28,7 @@ jobs: run: | sudo apt install git --yes # dist runs setup again so we need to specify CC and CXX again. - export CC=clang-10 - export CXX=clang++-10 + export CC=gcc + export CXX=g++ cd _build meson dist diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 1c48ad49..fbbe7826 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -3,9 +3,9 @@ # Copied from https://github.com/libxmlplusplus/libxmlplusplus/actions/new # and changed. Actions -> New workflow -> Pages -> Jekyll -name: Deploy Jekyll with GitHub Pages dependencies preinstalled +name: Publish docs -# 2022-12-17: ubuntu-latest = ubuntu-22.04 +# 2023-07-28: ubuntu-latest = ubuntu-22.04 on: # Runs on pushes targeting the default branch push: From 49471812d57adfb22dcce3cbea1a8956658731b9 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sat, 18 Nov 2023 18:34:07 +0100 Subject: [PATCH 203/240] Make it compatible with libxml2 >= 2.12.0 * libxml++/document.cc: * libxml++/dtd.cc: * libxml++/nodes/entitydeclaration.cc: * libxml++/nodes/entityreference.cc: * libxml++/validators/relaxngvalidator.cc: Modify #include directives. * libxml++/keepblanks.cc: Ignore deprecation of xmlKeepBlanksDefault(). * tests/saxparser_chunk_parsing_inconsistent_state/main.cc: Accept that MySaxParser::on_start_document() can be called before MySaxParser::on_error(). --- libxml++/document.cc | 1 + libxml++/dtd.cc | 2 +- libxml++/keepblanks.cc | 5 ++++- libxml++/nodes/entitydeclaration.cc | 2 +- libxml++/nodes/entityreference.cc | 2 +- libxml++/validators/relaxngvalidator.cc | 1 + .../saxparser_chunk_parsing_inconsistent_state/main.cc | 10 +++++++++- 7 files changed, 18 insertions(+), 5 deletions(-) diff --git a/libxml++/document.cc b/libxml++/document.cc index da0a8f52..d5476c69 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -16,6 +16,7 @@ #include #include +#include #include // XML_PARSE_NOXINCNODE, XML_PARSE_NOBASEFIX #include diff --git a/libxml++/dtd.cc b/libxml++/dtd.cc index 238b3a03..8014c071 100644 --- a/libxml++/dtd.cc +++ b/libxml++/dtd.cc @@ -8,7 +8,7 @@ #include #include -#include +#include #include diff --git a/libxml++/keepblanks.cc b/libxml++/keepblanks.cc index 4228b8dd..56b00cf5 100644 --- a/libxml++/keepblanks.cc +++ b/libxml++/keepblanks.cc @@ -5,8 +5,11 @@ * included with libxml++ as the file COPYING. */ -#include +// xmlKeepBlanksDefault() is deprecated since libxml2 2.12.0. +// Ignore deprecations here. +#define XML_DEPRECATED +#include #include namespace xmlpp diff --git a/libxml++/nodes/entitydeclaration.cc b/libxml++/nodes/entitydeclaration.cc index 0a6390e8..d5bfa751 100644 --- a/libxml++/nodes/entitydeclaration.cc +++ b/libxml++/nodes/entitydeclaration.cc @@ -5,7 +5,7 @@ */ #include -#include +#include namespace xmlpp { diff --git a/libxml++/nodes/entityreference.cc b/libxml++/nodes/entityreference.cc index 19b1b221..278a1263 100644 --- a/libxml++/nodes/entityreference.cc +++ b/libxml++/nodes/entityreference.cc @@ -6,7 +6,7 @@ #include -#include +#include namespace xmlpp { diff --git a/libxml++/validators/relaxngvalidator.cc b/libxml++/validators/relaxngvalidator.cc index 9bb10c20..68a814c0 100644 --- a/libxml++/validators/relaxngvalidator.cc +++ b/libxml++/validators/relaxngvalidator.cc @@ -22,6 +22,7 @@ #include "libxml++/parsers/domparser.h" #include "libxml++/relaxngschema.h" +#include #include namespace xmlpp diff --git a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc index 07cc3eff..53f55b3f 100644 --- a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc +++ b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc @@ -24,10 +24,14 @@ class MySaxParser : public xmlpp::SaxParser { +public: + bool throw_on_start_doc = true; + protected: void on_start_document() override { - throw std::runtime_error("some custom runtime exception"); + if (throw_on_start_doc) + throw std::runtime_error("some custom runtime exception"); } void on_error(const xmlpp::ustring& /* text */) override { @@ -43,6 +47,9 @@ int main() bool exceptionThrown = false; try { + // Depending on the libxml2 version, MySaxParser::on_start_document() + // may or may not be called before MySaxParser::on_error(). + parser.throw_on_start_doc = false; parser.parse_chunk(""); parser.parse_stream(ss); } From dceae7be55284972ad18ddc3e4688fe557c8f95e Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 11 Dec 2023 11:18:59 +0100 Subject: [PATCH 204/240] meson.build: Don't fail if warning_level=everything --- meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index b8b19728..bb7832d2 100644 --- a/meson.build +++ b/meson.build @@ -78,7 +78,12 @@ if is_dist_check else cpp_warnings = get_option('warnings') endif -warning_level = get_option('warning_level').to_int() +if get_option('warning_level') in ['0','1','2','3','4','5'] + warning_level = get_option('warning_level').to_int() +else + # For instance get_option('warning_level') == 'everything' + warning_level = 99 +endif werror = get_option('werror') build_deprecated_api = get_option('build-deprecated-api') build_documentation_opt = get_option('build-documentation') From 752dc40b078b9fcb336e296e5b0ab1f01e86bea3 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 11 Dec 2023 15:42:52 +0100 Subject: [PATCH 205/240] Parser docs: Add a link to parser options Add a link to libxml2's description of parser options in the documentation of Parser::set_parser_options(). --- libxml++/parsers/parser.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libxml++/parsers/parser.h b/libxml++/parsers/parser.h index 2181ec07..f99ebaba 100644 --- a/libxml++/parsers/parser.h +++ b/libxml++/parsers/parser.h @@ -126,7 +126,9 @@ class Parser : public NonCopyable bool get_include_default_attributes() const noexcept; /** Set and/or clear parser option flags. - * See the libxml2 documentation, enum xmlParserOption, for a list of parser options. + * See the libxml2 documentation, + * [enum xmlParserOption](https://gnome.pages.gitlab.gnome.org/libxml2/devhelp/libxml2-parser.html#xmlParserOption), + * for a list of parser options. * This method overrides other methods that set parser options, such as set_validate(), * set_substitute_entities() and set_include_default_attributes(). Use set_parser_options() * only if no other method can set the parser options you want. From 16172168fa8f60c9059974ea6310f1e38f7ac804 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 26 Dec 2023 10:37:18 +0100 Subject: [PATCH 206/240] README.md: Add info about building the documentation --- README.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/README.md b/README.md index 00cb72a6..d6e6145a 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,21 @@ Patches can be submitted to Whenever possible, you should use the official binary packages approved by the supplier of your operating system, such as your Linux distribution. +## Building the documentation + +The reference documentaion is built with Doxygen. + +The manual is a DocBook 5.0 document. These packages are recommended when building +the manual (can have other names in other distros): + - docbook5-xml (Ubuntu and Debian) or docbook5-schemas (Fedora) + - docbook-xsl (Ubuntu and Debian) or docbook-style-xsl (Fedora) + +It may be possible to build without these packages, but it will be slow and error prone. +The `xmllint` command is told to read files from http://docbook.org. +The `xsltproc` command is told to read files from http://docbook.sourceforge.net. +The commands first search for local copies of those files. If local copies exist +and are installed at expected locations, the commands make no network accesses. + ## Building on Windows See [MSVC-Builds](MSVC_NMake/MSVC-Builds.md) From 948fe0422403550988c3eacd6e8b963ea1dbc63f Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 26 Dec 2023 16:09:24 +0100 Subject: [PATCH 207/240] Make it compatible with libxml2 >= 2.13.0 * libxml++/document.cc: Modify #include directives. --- libxml++/document.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libxml++/document.cc b/libxml++/document.cc index d5476c69..85ca59f6 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -14,10 +14,10 @@ #include #include +#include // XML_PARSE_NOXINCNODE, XML_PARSE_NOBASEFIX #include #include #include -#include // XML_PARSE_NOXINCNODE, XML_PARSE_NOBASEFIX #include #include From f9b649cb8fd97860b834fa4884f2e368eae8a532 Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Fri, 29 Dec 2023 12:08:45 -0800 Subject: [PATCH 208/240] Add bcrypt dependency. Fixes #64 --- libxml++/meson.build | 2 +- meson.build | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libxml++/meson.build b/libxml++/meson.build index d51378e4..93736f9f 100644 --- a/libxml++/meson.build +++ b/libxml++/meson.build @@ -103,7 +103,7 @@ if host_machine.system() == 'windows' extra_xmlxx_objects += xmlxx_res if xml2_is_subproject - xmlxx_all_deps += [winsock_dep] + xmlxx_all_deps += [winsock_dep, bcrypt_dep] endif endif diff --git a/meson.build b/meson.build index bb7832d2..ed0692a5 100644 --- a/meson.build +++ b/meson.build @@ -129,6 +129,7 @@ if not xml2_dep.found() thread_dep = dependency('threads', required: false) zlib_dep = dependency('zlib', required: false) winsock_dep = cpp_compiler.find_library('ws2_32', required: false) + bcrypt_dep = cpp_compiler.find_library('bcrypt', required: false) cmake_build_type = get_option('buildtype') if get_option('buildtype') == 'debugoptimized' cmake_build_type = 'RelWithDebInfo' From 74608b97a3a6a9b230e28c5abaa138160c708838 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 8 Jan 2024 15:02:16 +0100 Subject: [PATCH 209/240] Meson build: Don't require the 'dot' command Make it possible to build documentation without the dot command. Set the HAVE_DOT option in Doxyfile during configuration. In Autotools builds it's still unconditionally YES. The inheritance diagrams don't look as nice without the dot command from the GraphViz package. See https://github.com/libsigcplusplus/libsigcplusplus/issues/98 --- configure.ac | 2 ++ docs/reference/Doxyfile.in | 2 +- docs/reference/meson.build | 3 ++- meson.build | 7 ++++++- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 2c9c26c4..5328bf10 100644 --- a/configure.ac +++ b/configure.ac @@ -38,6 +38,8 @@ LT_INIT([dlopen win32-dll disable-static]) AC_SUBST([LIBXMLXX_MODULES], ['libxml-2.0 >= 2.7.7']) AC_SUBST([LIBXML2_LIB_NO_PKGCONFIG], ['']) AC_SUBST([MSVC_TOOLSET_VER], ['']) +AC_SUBST(DOXYGEN_HAVE_DOT, [YES]) +AM_SUBST_NOTMAKE(DOXYGEN_HAVE_DOT) PKG_CHECK_MODULES([LIBXMLXX], [$LIBXMLXX_MODULES]) AC_LANG([C++]) diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in index 5b4250a3..32fd1511 100644 --- a/docs/reference/Doxyfile.in +++ b/docs/reference/Doxyfile.in @@ -306,7 +306,7 @@ EXTERNAL_PAGES = YES #--------------------------------------------------------------------------- DIA_PATH = HIDE_UNDOC_RELATIONS = NO -HAVE_DOT = YES +HAVE_DOT = @DOXYGEN_HAVE_DOT@ DOT_NUM_THREADS = 0 DOT_FONTNAME = Sans DOT_FONTSIZE = 10 diff --git a/docs/reference/meson.build b/docs/reference/meson.build index cda283c4..bf42bc91 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -2,7 +2,7 @@ # Input: project_build_root, project_source_root, xmlxx_pcname, # xmlxx_api_version, build_documentation, source_h_files, -# install_datadir, python3, doc_reference_py, can_add_dist_script +# install_datadir, python3, doc_reference_py, can_add_dist_script, dot # Output: install_docdir, install_devhelpdir, book_name, # if build_documentation: tag_file @@ -59,6 +59,7 @@ doc_conf_data.set('abs_top_builddir', project_build_root) doc_conf_data.set('abs_top_srcdir', project_source_root) doc_conf_data.set('LIBXMLXX_MODULE_NAME', book_name) doc_conf_data.set('DOXYGEN_TAGFILES', doxygen_tagfiles) +doc_conf_data.set('DOXYGEN_HAVE_DOT', dot.found() ? 'YES' : 'NO') doxyfile = configure_file( input: 'Doxyfile.in', diff --git a/meson.build b/meson.build index ed0692a5..9d3b0d9e 100644 --- a/meson.build +++ b/meson.build @@ -197,9 +197,14 @@ if maintainer_mode and not mm_common_get.found() mm_common_get = find_program('mm-common-get', required: true) endif doxygen = find_program('doxygen', required: build_documentation) -dot = find_program('dot', required: build_documentation) # Used by Doxygen +dot = find_program('dot', required: false) # Used by Doxygen, if found xsltproc = find_program('xsltproc', required: build_documentation) +if build_documentation and not dot.found() + message('The \'dot\' command is not found.\n ' + \ + 'This will affect the look of the inheritance diagrams in the documentation.') +endif + # Script files copied to 'untracked/' by mm-common-get. script_dir = project_source_root / 'untracked' / 'build_scripts' doc_reference_py = script_dir / 'doc-reference.py' From 07b7bfae768b54699d21e90ce2a9821aff4d163a Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 8 Jan 2024 16:29:53 +0100 Subject: [PATCH 210/240] Meson build: Add the build-manual option --- docs/manual/meson.build | 11 ++++++----- meson.build | 22 ++++++++++++++++++---- meson_options.txt | 6 ++++-- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/docs/manual/meson.build b/docs/manual/meson.build index b61271f8..6c7bd67e 100644 --- a/docs/manual/meson.build +++ b/docs/manual/meson.build @@ -3,12 +3,13 @@ # input: install_datadir, xmlxx_pcname, tutorial_custom_cmd_py, python3, # build_documentation, book_name, can_add_dist_script, xsltproc # output: can_parse_and_validate, build_pdf_by_default, can_build_pdf, -# install_tutorialdir +# install_tutorialdir, build_manual_opt, build_manual -xmllint = find_program('xmllint', required: false) +build_manual_opt = get_option('build-manual') +build_manual = build_manual_opt and build_documentation +xmllint = find_program('xmllint', required: false) can_parse_and_validate = xmllint.found() - validate = get_option('validation') ? 'true' : 'false' dblatex = find_program('dblatex', required: false) @@ -19,8 +20,8 @@ build_pdf_by_default = get_option('build-pdf') # Installation directories are relative to {prefix}. install_tutorialdir = install_datadir / 'doc' / book_name / 'manual' -if not build_documentation - # Documentation shall not be built or installed. +if not build_manual + # The manual shall not be built or installed. # Return to the calling meson.build file. subdir_done() endif diff --git a/meson.build b/meson.build index 9d3b0d9e..2a54c065 100644 --- a/meson.build +++ b/meson.build @@ -439,16 +439,29 @@ if build_documentation_opt == 'if-maintainer-mode' real_build_documentation = ' (@0@)'.format(build_documentation) endif -validate = get_option('validation') and can_parse_and_validate +explain_man = '' +if build_manual_opt and not build_manual + explain_man = ' (requires that documentation is built)' +endif + +validate = get_option('validation') and can_parse_and_validate and build_manual explain_val = '' if get_option('validation') and not validate - explain_val = ' (requires xmllint with Relax NG and DocBook V5.0 support)' + if not build_manual + explain_val = ' (requires that the tutorial is built)' + else + explain_val = ' (requires xmllint with Relax NG and DocBook V5.0 support)' + endif endif -build_pdf = build_pdf_by_default and can_build_pdf +build_pdf = build_pdf_by_default and can_build_pdf and build_manual explain_pdf = '' if build_pdf_by_default and not build_pdf - explain_pdf = ' (requires dblatex or (xsltproc and fop))' + if not build_manual + explain_pdf = ' (requires that the tutorial is built)' + else + explain_pdf = ' (requires dblatex or (xsltproc and fop))' + endif endif summary = [ @@ -461,6 +474,7 @@ summary = [ format(cpp_warnings, warning_level, werror), ' Build deprecated API: @0@'.format(build_deprecated_api), 'Build HTML documentation: @0@@1@'.format(build_documentation_opt, real_build_documentation), + ' Build tutorial: @0@@1@'.format(build_manual, explain_man), ' XML validation: @0@@1@'.format(validate, explain_val), ' Build PDF: @0@@1@'.format(build_pdf, explain_pdf), ' Build example programs: @0@'.format(build_examples), diff --git a/meson_options.txt b/meson_options.txt index f9449898..f362d77b 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -8,10 +8,12 @@ option('build-deprecated-api', type: 'boolean', value: true, description: 'Build deprecated API and include it in the library') option('build-documentation', type: 'combo', choices: ['false', 'if-maintainer-mode', 'true'], value: 'if-maintainer-mode', description: 'Build and install the documentation') +option('build-manual', type: 'boolean', value: true, + description: 'Build tutorial HTML files, if documentation is built') option('validation', type: 'boolean', value: true, - description: 'Validate the tutorial XML file') + description: 'Validate the tutorial XML file, if tutorial HTML files are built') option('build-pdf', type: 'boolean', value: false, - description: 'Build tutorial PDF file') + description: 'Build tutorial PDF file, if tutorial HTML files are built') option('build-examples', type: 'boolean', value: true, description: 'Build example programs') option('build-tests', type: 'boolean', value: true, From 3f304078fec77d957f2f778e3cfd1f6cde090473 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 10 Jan 2024 18:55:03 +0100 Subject: [PATCH 211/240] meson.build: Update htmlrefpub --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 2a54c065..02ad7cd0 100644 --- a/meson.build +++ b/meson.build @@ -412,7 +412,7 @@ endif if meson.is_subproject() pkgconfig_vars = { 'htmlrefdir': install_prefix / install_docdir / 'reference' / 'html', - 'htmlrefpub': 'http://library.gnome.org/devel/libxml++/unstable/' + 'htmlrefpub': 'https://libxmlplusplus.github.io/libxmlplusplus/reference/html/' } if build_documentation pkgconfig_vars += {'doxytagfile': tag_file.full_path()} From b923b8bcbb8c231280edf03b5622e2fa66c909b3 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 11 Jan 2024 14:10:47 +0100 Subject: [PATCH 212/240] 5.2.0 --- NEWS | 33 +++++++++++++++++++++++++++++++++ configure.ac | 2 +- meson.build | 2 +- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index fb671ad4..ca80f85c 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,36 @@ +5.2.0 (stable): + +* Use callback functions with C linkage + (Kjell Ahlstedt) Issue glibmm#1 (Murray Cumming) + +Documentation: +* Update Visual Studio build docs + (Chun-wei Fan) Pull request #52 +* Remove AUTHORS and add general information to README.md + (Kjell Ahlstedt) Issue gtkmm#140 +* Parser docs: Add a link to parser options +* README.md: Add info about building the documentation + (Kjell Ahlstedt) + +Meson build: +* Cleanup and fix libxml2 dep search + (Chun-wei Fan) Pull request #51 +* Don't fail if warning_level=everything + (Daniel Boles, Kjell Ahlstedt) Merge request gtkmm!87 +* Add bcrypt dependency when libxml2 is a subproject + Issue #64 (Kjell Ahlstedt) + (Andrew Potter) Pull request #65 +* Don't require the 'dot' command to build the documentation + (Kjell Ahlstedt) Issue libsigcplusplus#98 +* Add the build-manual option + (Kjell Ahlstedt) + +Build: +* Make it compatible with libxml2 >= 2.12.0 + by modifying #include directives + (Kjell Ahlstedt) + + 5.0.3 (stable): * exception: Fix linking on MinGW diff --git a/configure.ac b/configure.ac index 5328bf10..240b43cd 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [5.0.3], +AC_INIT([libxml++], [5.2.0], [https://github.com/libxmlplusplus/libxmlplusplus/issues], [libxml++], [https://libxmlplusplus.github.io/libxmlplusplus/]) AC_PREREQ([2.59]) diff --git a/meson.build b/meson.build index 02ad7cd0..e4b27ed9 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ # This file is part of libxml++. project('libxml++', 'cpp', - version: '5.0.3', + version: '5.2.0', license: 'LGPLv2.1+', default_options: [ 'warning_level=1', From d0a8e12ba08bc2311d780c55ab9ea1d158b36be3 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 21 Feb 2024 18:14:23 +0100 Subject: [PATCH 213/240] Node: Add eval_xpath() Fixes #66 --- examples/dom_xpath/main.cc | 94 ++++++++++++++++++++++++---------- libxml++/nodes/node.cc | 100 +++++++++++++++++++++++++++++-------- libxml++/nodes/node.h | 27 ++++++++++ 3 files changed, 174 insertions(+), 47 deletions(-) diff --git a/examples/dom_xpath/main.cc b/examples/dom_xpath/main.cc index 8c15b60e..aaa20345 100644 --- a/examples/dom_xpath/main.cc +++ b/examples/dom_xpath/main.cc @@ -40,6 +40,36 @@ std::string result_type_to_ustring(xmlpp::XPathResultType result_type) } } +void print_nodeset(const xmlpp::Node::const_NodeSet& set) +{ + // Print the structural paths and the values: + for(const auto& child : set) + { + std::cout << " " << child->get_path(); + + auto attribute = dynamic_cast(child); + if (attribute) + std::cout << ", value=\"" << attribute->get_value() << "\""; + + auto content_node = dynamic_cast(child); + if (content_node) + std::cout << ", content=\"" << content_node->get_content() << "\""; + + auto entity_reference = dynamic_cast(child); + if (entity_reference) + std::cout << ", text=\"" << entity_reference->get_original_text() << "\""; + + auto element = dynamic_cast(child); + if (element) + { + auto text_node = element->get_first_child_text(); + if (text_node) + std::cout << ", first_child_text=\"" << text_node->get_content() << "\""; + } + std::cout << std::endl; + } +} + bool xpath_test(const xmlpp::Node* node, const std::string& xpath) { bool result = true; @@ -49,39 +79,46 @@ bool xpath_test(const xmlpp::Node* node, const std::string& xpath) try { auto set = node->find(xpath); + std::cout << "find(): " << set.size() << " nodes have been found:" << std::endl; + print_nodeset(set); + } + catch (const xmlpp::exception& ex) + { + std::cerr << "Exception caught from find: " << ex.what() << std::endl; + result = false; + } - std::cout << set.size() << " nodes have been found:" << std::endl; - - //Print the structural paths and the values: - for(const auto& child : set) + try + { + auto var = node->eval_xpath(xpath); + std::cout << "eval_xpath(): "; + switch (var.index()) { - std::cout << " " << child->get_path(); - - auto attribute = dynamic_cast(child); - if (attribute) - std::cout << ", value=\"" << attribute->get_value() << "\""; - - auto content_node = dynamic_cast(child); - if (content_node) - std::cout << ", content=\"" << content_node->get_content() << "\""; - - auto entity_reference = dynamic_cast(child); - if (entity_reference) - std::cout << ", text=\"" << entity_reference->get_original_text() << "\""; - - auto element = dynamic_cast(child); - if (element) - { - auto text_node = element->get_first_child_text(); - if (text_node) - std::cout << ", first_child_text=\"" << text_node->get_content() << "\""; - } - std::cout << std::endl; + case 0: // nodeset + { + auto set = std::get<0>(var); + std::cout << set.size() << " nodes have been found:" << std::endl; + print_nodeset(set); + break; + } + case 1: // boolean + std::cout << "Boolean: " << (std::get<1>(var) ? "true" : "false") << std::endl; + break; + case 2: // number + std::cout << "Number: " << std::get<2>(var) << std::endl; + break; + case 3: // string + std::cout << "String: " << std::get<3>(var) << std::endl; + break; + default: + std::cerr << "Unsupported result type." << std::endl; + result = false; + break; } } catch (const xmlpp::exception& ex) { - std::cerr << "Exception caught from find: " << ex.what() << std::endl; + std::cerr << "Exception caught from eval_xpath: " << ex.what() << std::endl; result = false; } @@ -122,6 +159,9 @@ int main(int argc, char* argv[]) // Find all sections, no matter where: result &= xpath_test(root, "//section"); + // Count the number of sections: + result &= !xpath_test(root, "count(//section)"); + // Find the title node (if there is one): result &= xpath_test(root, "title"); diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index c6ce949b..d3ead850 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -53,9 +53,8 @@ Tlist get_children_common(const xmlpp::ustring& name, xmlNode* child) return children; } -// Common part of all overloaded xmlpp::Node::find() methods. -template -Tvector find_common(const xmlpp::ustring& xpath, +// A common part of all overloaded xmlpp::Node::find() and eval_xpath() methods. +xmlXPathObject* find_common1(const xmlpp::ustring& xpath, const xmlpp::Node::PrefixNsMap* namespaces, xmlNode* node) { auto ctxt = xmlXPathNewContext(node->doc); @@ -72,22 +71,20 @@ Tvector find_common(const xmlpp::ustring& xpath, } auto result = xmlXPathEval((const xmlChar*)xpath.c_str(), ctxt); + xmlXPathFreeContext(ctxt); if (!result) - { - xmlXPathFreeContext(ctxt); - throw xmlpp::exception("Invalid XPath: " + xpath); - } - if (result->type != XPATH_NODESET) - { - xmlXPathFreeObject(result); - xmlXPathFreeContext(ctxt); - - throw xmlpp::internal_error("Only nodeset result types are supported."); - } + return result; +} +// A common part of all overloaded xmlpp::Node::find() and eval_xpath() methods. +// Tvector == NodeSet or const_NodeSet +// result->type == XPATH_NODESET +template +Tvector find_common2(xmlXPathObject* result, const char* method_name) +{ auto nodeset = result->nodesetval; Tvector nodes; if (nodeset && !xmlXPathNodeSetIsEmpty(nodeset)) @@ -99,15 +96,15 @@ Tvector find_common(const xmlpp::ustring& xpath, auto cnode = xmlXPathNodeSetItem(nodeset, i); if (!cnode) { - std::cerr << "Node::find(): The xmlNode was null." << std::endl; + std::cerr << "Node::" << method_name << "(): The xmlNode was null." << std::endl; continue; } if (cnode->type == XML_NAMESPACE_DECL) { - //In this case we would cast it to a xmlNs*, - //but this C++ method only returns Nodes. - std::cerr << "Node::find(): Ignoring an xmlNs object." << std::endl; + // In this case we would cast it to a xmlNs*, + // but this C++ method only returns Nodes. + std::cerr << "Node::" << method_name << "(): Ignoring an xmlNs object." << std::endl; continue; } @@ -122,11 +119,62 @@ Tvector find_common(const xmlpp::ustring& xpath, } xmlXPathFreeObject(result); - xmlXPathFreeContext(ctxt); return nodes; } +// Common part of all overloaded xmlpp::Node::find() methods. +template +Tvector find_common(const xmlpp::ustring& xpath, + const xmlpp::Node::PrefixNsMap* namespaces, xmlNode* node) +{ + auto result = find_common1(xpath, namespaces, node); + + if (result->type != XPATH_NODESET) + { + xmlXPathFreeObject(result); + throw xmlpp::internal_error("Only nodeset result types are supported."); + } + return find_common2(result, "find"); +} + +// Common part of all overloaded xmlpp::Node::eval_xpath() methods. +template +std::variant +eval_xpath_common(const xmlpp::ustring& xpath, + const xmlpp::Node::PrefixNsMap* namespaces, xmlNode* node) +{ + auto result = find_common1(xpath, namespaces, node); + + switch (result->type) + { + case XPATH_NODESET: + return find_common2(result, "eval_xpath"); + + case XPATH_BOOLEAN: + { + auto val = static_cast(result->boolval); + xmlXPathFreeObject(result); + return val; + } + case XPATH_NUMBER: + { + double val = result->floatval; + xmlXPathFreeObject(result); + return val; + } + case XPATH_STRING: + { + xmlpp::ustring val = reinterpret_cast(result->stringval); + xmlXPathFreeObject(result); + return val; + } + default: + xmlXPathFreeObject(result); + throw xmlpp::internal_error("Unsupported result type."); + } +} + // Common part of xmlpp::Node::eval_to_[boolean|number|string] xmlXPathObject* eval_common(const xmlpp::ustring& xpath, const xmlpp::Node::PrefixNsMap* namespaces, @@ -145,7 +193,7 @@ xmlXPathObject* eval_common(const xmlpp::ustring& xpath, reinterpret_cast(ns_uri.c_str())); } - auto xpath_value = xmlXPathEvalExpression( + auto xpath_value = xmlXPathEval( reinterpret_cast(xpath.c_str()), ctxt); xmlXPathFreeContext(ctxt); @@ -412,6 +460,18 @@ Node::const_NodeSet Node::find(const ustring& xpath, const PrefixNsMap& namespac return find_common(xpath, &namespaces, impl_); } +std::variant +Node::eval_xpath(const ustring& xpath, const PrefixNsMap& namespaces) +{ + return eval_xpath_common(xpath, &namespaces, impl_); +} + +std::variant +Node::eval_xpath(const ustring& xpath, const PrefixNsMap& namespaces) const +{ + return eval_xpath_common(xpath, &namespaces, impl_); +} + bool Node::eval_to_boolean(const ustring& xpath, XPathResultType* result_type) const { return eval_common_to_boolean(xpath, nullptr, result_type, impl_); diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index 9b4d2b08..fa1182bc 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -13,6 +13,7 @@ #include #include #include +#include #ifndef DOXYGEN_SHOULD_SKIP_THIS extern "C" { @@ -230,6 +231,32 @@ class LIBXMLPP_API Node : public NonCopyable */ const_NodeSet find(const ustring& xpath, const PrefixNsMap& namespaces) const; + /** Evaluate an XPath expression. + * @param xpath The XPath expression. + * @param namespaces A map of namespace prefixes to namespace URIs to be used while evaluating. + * @returns The resulting NodeSet (XPathResultType::NODESET), bool (XPathResultType::BOOLEAN), + * double (XPathResultType::NUMBER) or ustring (XPathResultType::STRING). + * @throws xmlpp::exception If the XPath expression cannot be evaluated. + * @throws xmlpp::internal_error If the result type is not nodeset, boolean, number or string. + * + * @newin{5,4} + */ + std::variant + eval_xpath(const ustring& xpath, const PrefixNsMap& namespaces = {}); + + /** Evaluate an XPath expression. + * @param xpath The XPath expression. + * @param namespaces A map of namespace prefixes to namespace URIs to be used while evaluating. + * @returns The resulting const_NodeSet (XPathResultType::NODESET), bool (XPathResultType::BOOLEAN), + * double (XPathResultType::NUMBER) or ustring (XPathResultType::STRING). + * @throws xmlpp::exception If the XPath expression cannot be evaluated. + * @throws xmlpp::internal_error If the result type is not nodeset, boolean, number or string. + * + * @newin{5,4} + */ + std::variant + eval_xpath(const ustring& xpath, const PrefixNsMap& namespaces = {}) const; + /** Evaluate an XPath expression. * @param xpath The XPath expression. * @param[out] result_type Result type of the XPath expression before conversion From ab5098e2a8b7fe69a991a28fe00a75e078f9a90e Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 21 May 2024 15:52:41 +0200 Subject: [PATCH 214/240] docs/index.md: Don't link to developer-old.gnome.org That web site has been removed. --- docs/index.md | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/docs/index.md b/docs/index.md index ec86e1a1..0c4051e7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -43,7 +43,7 @@ or the [GNOME download site](https://download.gnome.org/sources/libxml++/). ## Required Libraries * [libxml2](http://www.xmlsoft.org/) -* libxml++-2.6 and libxml++-3.0: [glibmm-2.4](https://developer-old.gnome.org/glibmm/2.66/) +* libxml++-2.6 and libxml++-3.0: glibmm-2.4 * libxml++-4.0: [glibmm-2.68](https://gnome.pages.gitlab.gnome.org/glibmm/) ## Documentation @@ -55,17 +55,8 @@ You can also browse online the [reference documentation](reference/html/index.ht ### Other ABI Versions -libxml++-2.6: [manual](https://developer-old.gnome.org/libxml++-tutorial/2.42/) -and [reference documentation](https://developer-old.gnome.org/libxml++/2.42/) - -libxml++-3.0: [manual](https://developer-old.gnome.org/libxml++-tutorial/3.2/) -and [reference documentation](https://developer-old.gnome.org/libxml++/3.2/) - -libxml++-4.0: [manual](https://developer-old.gnome.org/libxml++-tutorial/4.0/) -and [reference documentation](https://developer-old.gnome.org/libxml++/4.0) - -This documentation is frozen on the web. It does not document the latest releases. -If you want newer documentation, you can download a tarball from +The documentation of libxml++-2.6, libxml++-3.0 and libxml++-4.0 is not +available online. You can download a tarball from [GitHub releases](https://github.com/libxmlplusplus/libxmlplusplus/releases/) or the [GNOME download site](https://download.gnome.org/sources/libxml++/), extract it, and view the documentation at *untracked/docs/*. From 4b39bf0e0ae4d6f5d569e923522ccdc644858d1f Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Thu, 6 Jun 2024 08:32:01 -0700 Subject: [PATCH 215/240] Meson build: Use libxml2 meson build as fallback Fixes #67 --- .github/workflows/meson-windows-2022.yml | 4 +- Makefile.am | 2 +- libxml++/meson.build | 4 -- meson.build | 61 +------------------ .../{libxml2_cmake.wrap => libxml2.wrap} | 3 + 5 files changed, 7 insertions(+), 67 deletions(-) rename subprojects/{libxml2_cmake.wrap => libxml2.wrap} (68%) diff --git a/.github/workflows/meson-windows-2022.yml b/.github/workflows/meson-windows-2022.yml index 27a924b7..0f27f89b 100644 --- a/.github/workflows/meson-windows-2022.yml +++ b/.github/workflows/meson-windows-2022.yml @@ -20,7 +20,7 @@ jobs: architecture: x64 - name: Configure - run: meson setup --warnlevel 3 --werror -Dlibxml2_cmake:werror=false -Dmaintainer-mode=false _build + run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=false -Dmaintainer-mode=false _build - name: Compile run: ninja -C _build @@ -29,7 +29,7 @@ jobs: run: meson test -C _build - name: Configure static - run: meson setup --warnlevel 3 --werror -Dlibxml2_cmake:werror=false --default-library static -Dmaintainer-mode=false _build_static + run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=false --default-library static -Dmaintainer-mode=false _build_static - name: Compile static run: ninja -C _build_static diff --git a/Makefile.am b/Makefile.am index 92c59007..b7d45e28 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,7 +38,7 @@ EXTRA_DIST = \ docs/reference/meson.build \ examples/meson.build \ libxml++/meson.build \ - subprojects/libxml2_cmake.wrap \ + subprojects/libxml2.wrap \ subprojects/mm-common.wrap \ tests/meson.build \ tools/build_scripts/tutorial-custom-cmd.py \ diff --git a/libxml++/meson.build b/libxml++/meson.build index 93736f9f..34233f9a 100644 --- a/libxml++/meson.build +++ b/libxml++/meson.build @@ -101,10 +101,6 @@ if host_machine.system() == 'windows' windows = import('windows') xmlxx_res = windows.compile_resources(xmlxx_rc) extra_xmlxx_objects += xmlxx_res - - if xml2_is_subproject - xmlxx_all_deps += [winsock_dep, bcrypt_dep] - endif endif extra_include_dirs = ['..'] diff --git a/meson.build b/meson.build index e4b27ed9..a111cee5 100644 --- a/meson.build +++ b/meson.build @@ -110,63 +110,9 @@ xml2_req = '>= @0@'.format(xml2_min_ver) xml2_dep = dependency( ['libxml-2.0', 'LibXml2'], version: xml2_req, - required: host_machine.system() != 'windows' + fallback: ['libxml2'] ) -# Setup CMake subproject for use, if needed -if not xml2_dep.found() - cmake = import('cmake') - opt_var = cmake.subproject_options() - build_shared = get_option('default_library') != 'static' - iconv_dep = dependency('iconv', required: false) - icu_i18n_dep = dependency('icu-i18n', 'ICU', - components: 'in', - required: false) - icu_uc_dep = dependency('icu-uc', 'ICU', - components: 'uc', - required: false) - lzma_dep = dependency(['liblzma','LibLZMA'], required: false) - thread_dep = dependency('threads', required: false) - zlib_dep = dependency('zlib', required: false) - winsock_dep = cpp_compiler.find_library('ws2_32', required: false) - bcrypt_dep = cpp_compiler.find_library('bcrypt', required: false) - cmake_build_type = get_option('buildtype') - if get_option('buildtype') == 'debugoptimized' - cmake_build_type = 'RelWithDebInfo' - elif get_option('buildtype') == 'minsize' - cmake_build_type = 'MinSizeRel' - elif get_option('buildtype') == 'plain' - cmake_build_type = '' - endif - opt_var.add_cmake_defines({ - 'BUILD_SHARED_LIBS': build_shared, - 'CMAKE_BUILD_TYPE': cmake_build_type, - 'CMAKE_MSVC_RUNTIME_LIBRARY': '', - 'CMAKE_C_FLAGS_INIT': '', - 'CMAKE_C_FLAGS_DEBUG': '', - 'CMAKE_C_FLAGS_RELEASE': '', - 'CMAKE_C_FLAGS_RELWITHDEBINFO': '', - 'CMAKE_C_FLAGS_MINSIZEREL': '', - 'LIBXML2_WITH_HTTP': host_machine.system() != 'windows' or winsock_dep.found(), - 'LIBXML2_WITH_ICONV': iconv_dep.found(), - 'LIBXML2_WITH_ICU': icu_i18n_dep.found() and icu_uc_dep.found(), - 'LIBXML2_WITH_LZMA': lzma_dep.found(), - 'LIBXML2_WITH_PYTHON': false, - 'LIBXML2_WITH_TESTS': build_tests, - 'LIBXML2_WITH_THREADS': thread_dep.found(), - 'LIBXML2_WITH_ZLIB': zlib_dep.found(), - }) - xml2_sp = cmake.subproject('libxml2_cmake', options: opt_var) - xml2_dep = xml2_sp.dependency('LibXml2') -endif - -xml2_is_subproject = xml2_dep.type_name() == 'internal' - -if xml2_is_subproject and build_tests - test('testchar', xml2_sp.target('testchar')) - test('testdict', xml2_sp.target('testdict')) -endif - xmlxx_requires = [] libxml2_lib_pkgconfig = '' @@ -174,11 +120,6 @@ libxml2_lib_pkgconfig = '' # we found it by pkg-config if xml2_dep.type_name() == 'pkgconfig' xmlxx_requires += ['libxml-2.0', xml2_req] -else - libxml2_lib_pkgconfig = xml2_dep.get_variable( - cmake: 'LIBXML2_LIBRARIES', - default_value: 'LibXml2.lib', - ) endif xmlxx_requires = ' '.join(xmlxx_requires) diff --git a/subprojects/libxml2_cmake.wrap b/subprojects/libxml2.wrap similarity index 68% rename from subprojects/libxml2_cmake.wrap rename to subprojects/libxml2.wrap index a6f60f33..9c0e5f6d 100644 --- a/subprojects/libxml2_cmake.wrap +++ b/subprojects/libxml2.wrap @@ -2,3 +2,6 @@ url = https://gitlab.gnome.org/GNOME/libxml2.git revision = master depth = 1 + +[provide] +dependency_names = libxml-2.0 From 1a34aa2070636a389ce81695c7ee93aa8caf781d Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Sat, 8 Jun 2024 08:58:17 -0700 Subject: [PATCH 216/240] meson: set LIBXML2_LIB_NO_PKGCONFIG for cmake dep --- meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index a111cee5..4bebf5f9 100644 --- a/meson.build +++ b/meson.build @@ -118,8 +118,13 @@ libxml2_lib_pkgconfig = '' # Put libxml-2.0 in the 'Requires:' section in the generated pkg-config file if # we found it by pkg-config -if xml2_dep.type_name() == 'pkgconfig' +if xml2_dep.type_name() == 'pkgconfig' or xml2_dep.type_name() == 'internal' xmlxx_requires += ['libxml-2.0', xml2_req] +else + libxml2_lib_pkgconfig = xml2_dep.get_variable( + cmake: 'LIBXML2_LIBRARIES', + default_value: 'LibXml2.lib', + ) endif xmlxx_requires = ' '.join(xmlxx_requires) From e9782ba493add853088e160ff66badeb85d2358c Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 3 Jul 2024 18:56:18 +0200 Subject: [PATCH 217/240] docs/reference/Doxyfile.in: Remove obsolete entries --- docs/reference/Doxyfile.in | 5 ----- 1 file changed, 5 deletions(-) diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in index 32fd1511..2f38f50d 100644 --- a/docs/reference/Doxyfile.in +++ b/docs/reference/Doxyfile.in @@ -163,7 +163,6 @@ HTML_EXTRA_FILES = HTML_COLORSTYLE_HUE = 220 HTML_COLORSTYLE_SAT = 100 HTML_COLORSTYLE_GAMMA = 80 -HTML_TIMESTAMP = YES HTML_DYNAMIC_SECTIONS = NO HTML_INDEX_NUM_ENTRIES = 100 GENERATE_DOCSET = NO @@ -194,7 +193,6 @@ ENUM_VALUES_PER_LINE = 1 TREEVIEW_WIDTH = 250 EXT_LINKS_IN_WINDOW = NO FORMULA_FONTSIZE = 10 -FORMULA_TRANSPARENT = YES USE_MATHJAX = NO MATHJAX_FORMAT = HTML-CSS MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest @@ -308,8 +306,6 @@ DIA_PATH = HIDE_UNDOC_RELATIONS = NO HAVE_DOT = @DOXYGEN_HAVE_DOT@ DOT_NUM_THREADS = 0 -DOT_FONTNAME = Sans -DOT_FONTSIZE = 10 DOT_FONTPATH = CLASS_GRAPH = YES COLLABORATION_GRAPH = NO @@ -333,7 +329,6 @@ PLANTUML_JAR_PATH = PLANTUML_INCLUDE_PATH = DOT_GRAPH_MAX_NODES = 50 MAX_DOT_GRAPH_DEPTH = 0 -DOT_TRANSPARENT = NO DOT_MULTI_TARGETS = YES GENERATE_LEGEND = YES DOT_CLEANUP = YES From 512df9f80d825893d81a2bce502a9faa699cc359 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 3 Jul 2024 18:56:37 +0200 Subject: [PATCH 218/240] libxml++/libxml++.h: Don't link to developer-old.gnome.org meson.build: Require python3 >= 3.7. That's what Meson requires. --- libxml++/libxml++.h | 2 +- meson.build | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libxml++/libxml++.h b/libxml++/libxml++.h index e844a0e0..bb599527 100644 --- a/libxml++/libxml++.h +++ b/libxml++/libxml++.h @@ -14,7 +14,7 @@ * libxml++ is a C++ wrapper for the libxml2 XML parser and builder library. It presents a * simple C++-like API that can achieve common tasks with less code. * - * See also the libxml++ Tutorial + * See also the libxml++ Tutorial * and the libxml++ website. * * @section features Features diff --git a/meson.build b/meson.build index 4bebf5f9..8d5ecf7b 100644 --- a/meson.build +++ b/meson.build @@ -44,7 +44,7 @@ project_build_root = meson.project_build_root() cpp_compiler = meson.get_compiler('cpp') is_msvc = cpp_compiler.get_id() == 'msvc' -python3 = find_program('python3', version: '>=3.5') +python3 = find_program('python3', version: '>=3.7') # Do we build from a git repository? # Suppose we do if and only if the meson.build file is tracked by git. From 2fa72c0ffe9b330f77cf71c658348dc9c677c08d Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 3 Jul 2024 19:14:36 +0200 Subject: [PATCH 219/240] CI: Windows build: -Dlibxml2:python=disabled The type of this option has changed from boolean to feature. --- .github/workflows/meson-windows-2022.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/meson-windows-2022.yml b/.github/workflows/meson-windows-2022.yml index 0f27f89b..e9c99cdb 100644 --- a/.github/workflows/meson-windows-2022.yml +++ b/.github/workflows/meson-windows-2022.yml @@ -20,7 +20,7 @@ jobs: architecture: x64 - name: Configure - run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=false -Dmaintainer-mode=false _build + run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=disabled -Dmaintainer-mode=false _build - name: Compile run: ninja -C _build @@ -29,7 +29,7 @@ jobs: run: meson test -C _build - name: Configure static - run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=false --default-library static -Dmaintainer-mode=false _build_static + run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=disabled --default-library static -Dmaintainer-mode=false _build_static - name: Compile static run: ninja -C _build_static From 165eb9bd9c2a2b88dd5de3682812907099677ad7 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 3 Jul 2024 21:29:10 +0200 Subject: [PATCH 220/240] CI: Windows build: -Dlibxml2:minimum=true Hopefully a minimum libxml2 will build on Windows and have enough functionality for libxml++. --- .github/workflows/meson-windows-2022.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/meson-windows-2022.yml b/.github/workflows/meson-windows-2022.yml index e9c99cdb..71786f35 100644 --- a/.github/workflows/meson-windows-2022.yml +++ b/.github/workflows/meson-windows-2022.yml @@ -20,7 +20,7 @@ jobs: architecture: x64 - name: Configure - run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=disabled -Dmaintainer-mode=false _build + run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:minimum=true -Dmaintainer-mode=false _build - name: Compile run: ninja -C _build @@ -29,7 +29,7 @@ jobs: run: meson test -C _build - name: Configure static - run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=disabled --default-library static -Dmaintainer-mode=false _build_static + run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:minimum=true --default-library static -Dmaintainer-mode=false _build_static - name: Compile static run: ninja -C _build_static From fdc2a7f7d3c86770999897378761361ec8d9843c Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Thu, 4 Jul 2024 08:34:52 -0700 Subject: [PATCH 221/240] Revert "CI: Windows build: -Dlibxml2:minimum=true" This reverts commit 165eb9bd9c2a2b88dd5de3682812907099677ad7. --- .github/workflows/meson-windows-2022.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/meson-windows-2022.yml b/.github/workflows/meson-windows-2022.yml index 71786f35..e9c99cdb 100644 --- a/.github/workflows/meson-windows-2022.yml +++ b/.github/workflows/meson-windows-2022.yml @@ -20,7 +20,7 @@ jobs: architecture: x64 - name: Configure - run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:minimum=true -Dmaintainer-mode=false _build + run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=disabled -Dmaintainer-mode=false _build - name: Compile run: ninja -C _build @@ -29,7 +29,7 @@ jobs: run: meson test -C _build - name: Configure static - run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:minimum=true --default-library static -Dmaintainer-mode=false _build_static + run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=disabled --default-library static -Dmaintainer-mode=false _build_static - name: Compile static run: ninja -C _build_static From 591f701dbd236cbbe8bc6d4e91b4c119d515c935 Mon Sep 17 00:00:00 2001 From: Andrew Potter Date: Thu, 4 Jul 2024 08:45:02 -0700 Subject: [PATCH 222/240] CI: Disable iconv for Windows libxml2 --- .github/workflows/meson-windows-2022.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/meson-windows-2022.yml b/.github/workflows/meson-windows-2022.yml index e9c99cdb..67bc84ec 100644 --- a/.github/workflows/meson-windows-2022.yml +++ b/.github/workflows/meson-windows-2022.yml @@ -20,7 +20,7 @@ jobs: architecture: x64 - name: Configure - run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=disabled -Dmaintainer-mode=false _build + run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=disabled -Dlibxml2:iconv=disabled -Dmaintainer-mode=false _build - name: Compile run: ninja -C _build @@ -29,7 +29,7 @@ jobs: run: meson test -C _build - name: Configure static - run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=disabled --default-library static -Dmaintainer-mode=false _build_static + run: meson setup --warnlevel 3 -Dlibxml2:warning_level=0 --werror -Dlibxml2:werror=false -Dlibxml2:python=disabled -Dlibxml2:iconv=disabled --default-library static -Dmaintainer-mode=false _build_static - name: Compile static run: ninja -C _build_static From bc072b68b49775af37daab1ced64e40dbef157fc Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Fri, 5 Jul 2024 13:14:33 +0200 Subject: [PATCH 223/240] Parser: Ignore deprecation of xmlParserCtxt members * parsers/parser.cc: Direct access to xmlParserCtxt::options, linenumbers and lastError is deprecated since libxml2 2.14.0. Ignore deprecations. Use xmlCtxtGetLastError(). --- libxml++/parsers/parser.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libxml++/parsers/parser.cc b/libxml++/parsers/parser.cc index 6d6c3f6a..398fc091 100644 --- a/libxml++/parsers/parser.cc +++ b/libxml++/parsers/parser.cc @@ -4,6 +4,12 @@ * included with libxml++ as the file COPYING. */ +// Direct access to xmlParserCtxt::options and xmlParserCtxt::linenumbers +// is deprecated since libxml2 2.14.0. +// xmlCtxtGetOptions() is new in libxml2 2.14.0. +// Ignore deprecations here. +#define XML_DEPRECATED_MEMBER + #include "libxml++/exceptions/wrapped_exception.h" #include "libxml++/parsers/parser.h" @@ -361,7 +367,7 @@ void Parser::callback_error_or_warning(bool is_parser, bool is_error, void* ctx, auto parser = static_cast(context->_private); if(parser) { - auto ubuff = format_xml_error(&context->lastError); + auto ubuff = format_xml_error(xmlCtxtGetLastError(context)); if (ubuff.empty()) { // Usually the result of formatting var_args with the format string msg From d4389e1e012af7ab51113243b1d2dde11e4dac3b Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 15 Jul 2024 13:37:49 +0200 Subject: [PATCH 224/240] Meson build: Use Meson's pkgconfig module instead of using the libxml++.pc.in template. Require meson >= 0.62. Remove the can_add_dist_script variable. It's unnecessary when the meson version >= 0.58. --- docs/manual/meson.build | 20 +++++------ docs/reference/meson.build | 22 ++++++------ libxml++/meson.build | 32 ++++++++++++++++- meson.build | 72 ++++++++++++-------------------------- 4 files changed, 73 insertions(+), 73 deletions(-) diff --git a/docs/manual/meson.build b/docs/manual/meson.build index 6c7bd67e..940ecdeb 100644 --- a/docs/manual/meson.build +++ b/docs/manual/meson.build @@ -1,7 +1,7 @@ # docs/manual # input: install_datadir, xmlxx_pcname, tutorial_custom_cmd_py, python3, -# build_documentation, book_name, can_add_dist_script, xsltproc +# build_documentation, book_name, xsltproc # output: can_parse_and_validate, build_pdf_by_default, can_build_pdf, # install_tutorialdir, build_manual_opt, build_manual @@ -106,13 +106,11 @@ if can_build_pdf ) endif -if can_add_dist_script - # Distribute built files. - meson.add_dist_script( - python3, tutorial_custom_cmd_py, 'dist_doc', - doc_dist_dir, - meson.current_build_dir(), - meson.current_build_dir() / 'libxml++.xml', - meson.current_build_dir() / 'libxml++.pdf', - ) -endif +# Distribute built files. +meson.add_dist_script( + python3, tutorial_custom_cmd_py, 'dist_doc', + doc_dist_dir, + meson.current_build_dir(), + meson.current_build_dir() / 'libxml++.xml', + meson.current_build_dir() / 'libxml++.pdf', +) diff --git a/docs/reference/meson.build b/docs/reference/meson.build index bf42bc91..19302569 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -2,7 +2,7 @@ # Input: project_build_root, project_source_root, xmlxx_pcname, # xmlxx_api_version, build_documentation, source_h_files, -# install_datadir, python3, doc_reference_py, can_add_dist_script, dot +# install_datadir, python3, doc_reference_py, dot # Output: install_docdir, install_devhelpdir, book_name, # if build_documentation: tag_file @@ -128,14 +128,12 @@ meson.add_install_script( docinstall_flags ) -if can_add_dist_script - # Distribute built files and files copied by mm-common-get. - meson.add_dist_script( - python3, doc_reference_py, 'dist_doc', - doctool_dir, - doctool_dist_dir, - meson.current_build_dir(), - tag_file.full_path(), - devhelp_file.full_path(), - ) -endif +# Distribute built files and files copied by mm-common-get. +meson.add_dist_script( + python3, doc_reference_py, 'dist_doc', + doctool_dir, + doctool_dist_dir, + meson.current_build_dir(), + tag_file.full_path(), + devhelp_file.full_path(), +) diff --git a/libxml++/meson.build b/libxml++/meson.build index 34233f9a..eddb58e7 100644 --- a/libxml++/meson.build +++ b/libxml++/meson.build @@ -1,7 +1,8 @@ # libxml++ # Input: xmlxx_build_dep, xmlxx_pcname, xmlxx_libversion, xmlxx_api_version, -# install_includedir, xmlxx_rc, xmlxx_libname, macos_darwin_versions +# install_includedir, xmlxx_rc, xmlxx_libname, macos_darwin_versions, +# xmlxx_pc_requires, libxml2_lib_pkgconfig # Output: source_h_files, xmlxx_own_dep # There are no built source files in libxml++-5.0. @@ -116,6 +117,35 @@ xmlxx_library = library(xmlxx_libname, install: true, ) +# Generate .pc files, used by pkg-config. +pkg_config = import('pkgconfig') +pc_common_variables = [ + 'doxytagfile=${docdir}/reference/' + xmlxx_pcname + '.tag', + 'htmlrefdir=${docdir}/reference/html', + 'htmlrefpub=https://libxmlplusplus.github.io/libxmlplusplus/reference/html', +] +pc_variables = [ + 'exec_prefix=${prefix}', + 'datarootdir=${datadir}', + 'docdir=${datadir}/doc/' + xmlxx_pcname, +] + pc_common_variables +pc_uninstalled_variables = [ + 'docdir=${prefix}/docs', +] + pc_common_variables + +pkg_config.generate(xmlxx_library, + filebase: xmlxx_pcname, + variables: pc_variables, + uninstalled_variables: pc_uninstalled_variables, + name: meson.project_name(), + description: 'C++ wrapper for libxml2', + url: 'https://libxmlplusplus.github.io/libxmlplusplus/', + requires: xmlxx_pc_requires, + libraries: libxml2_lib_pkgconfig, + subdirs: [xmlxx_pcname], + extra_cflags: ['-I${libdir}/' + xmlxx_pcname + '/include'], +) + # This is used when building example programs and test programs. # It's also a part of xmlxx_dep, when libxml++ is a subproject. xmlxx_own_dep = declare_dependency( diff --git a/meson.build b/meson.build index 8d5ecf7b..9104b05b 100644 --- a/meson.build +++ b/meson.build @@ -7,7 +7,7 @@ project('libxml++', 'cpp', 'warning_level=1', 'cpp_std=c++17', ], - meson_version: '>= 0.60.0', # required for dependency('iconv') + meson_version: '>= 0.62.0', # required for variables in pkgconfig.generate() ) xmlxx_api_version = '5.0' @@ -113,22 +113,20 @@ xml2_dep = dependency( fallback: ['libxml2'] ) -xmlxx_requires = [] -libxml2_lib_pkgconfig = '' +xmlxx_pc_requires = [] +libxml2_lib_pkgconfig = [] # Put libxml-2.0 in the 'Requires:' section in the generated pkg-config file if # we found it by pkg-config if xml2_dep.type_name() == 'pkgconfig' or xml2_dep.type_name() == 'internal' - xmlxx_requires += ['libxml-2.0', xml2_req] + xmlxx_pc_requires += ['libxml-2.0' + xml2_req] else - libxml2_lib_pkgconfig = xml2_dep.get_variable( + libxml2_lib_pkgconfig += [xml2_dep.get_variable( cmake: 'LIBXML2_LIBRARIES', default_value: 'LibXml2.lib', - ) + )] endif -xmlxx_requires = ' '.join(xmlxx_requires) - # Make sure we link to libxml-2.0 xmlxx_build_dep = [xml2_dep] @@ -270,20 +268,8 @@ endif # Configure files pkg_conf_data = configuration_data() -pkg_conf_data.set('prefix', install_prefix) -pkg_conf_data.set('exec_prefix', '${prefix}') -pkg_conf_data.set('libdir', '${exec_prefix}' / install_libdir) -pkg_conf_data.set('datarootdir', '${prefix}' / install_datadir) -pkg_conf_data.set('datadir', '${datarootdir}') -pkg_conf_data.set('includedir', '${prefix}' / install_includedir) pkg_conf_data.set('PACKAGE_NAME', meson.project_name()) # MSVC_NMake/libxml++/libxml++.rc -pkg_conf_data.set('PACKAGE_TARNAME', meson.project_name()) pkg_conf_data.set('PACKAGE_VERSION', meson.project_version()) -pkg_conf_data.set('LIBXMLXX_MODULE_NAME', xmlxx_pcname) -pkg_conf_data.set('LIBXMLXX_API_VERSION', xmlxx_api_version) -pkg_conf_data.set('LIBXMLXX_MODULES', xmlxx_requires) -pkg_conf_data.set('LIBXML2_LIB_NO_PKGCONFIG', libxml2_lib_pkgconfig) -pkg_conf_data.set('MSVC_TOOLSET_VER', msvc14x_toolset_ver) if not build_deprecated_api pkg_conf_data.set('LIBXMLXX_DISABLE_DEPRECATED', 1) @@ -308,13 +294,6 @@ if cpp_compiler.get_argument_syntax() == 'msvc' endif endif -configure_file( - input: 'libxml++.pc.in', - output: xmlxx_pcname + '.pc', - configuration: pkg_conf_data, - install_dir: install_pkgconfigdir, -) - xmlxxconfig_h_meson = files('libxml++config.h.meson') install_includeconfigdir = install_libdir / xmlxx_pcname / 'include' configure_file( @@ -324,9 +303,6 @@ configure_file( install_dir: install_includeconfigdir, ) -# add_dist_script() is not allowed in a subproject if meson.version() < 0.58.0. -can_add_dist_script = not meson.is_subproject() or meson.version().version_compare('>= 0.58.0') - subdir('MSVC_NMake/libxml++') subdir('libxml++') subdir('examples') @@ -334,26 +310,24 @@ subdir('tests') subdir('docs/reference') subdir('docs/manual') -if can_add_dist_script - # Add a ChangeLog file to the distribution directory. - meson.add_dist_script( - python3, dist_changelog_py, - project_source_root, - ) +# Add a ChangeLog file to the distribution directory. +meson.add_dist_script( + python3, dist_changelog_py, + project_source_root, +) - # Don't distribute these files and directories. - dont_distribute = [ - '.github', - ] - # Add build scripts to the distribution directory, and delete .gitignore - # files and an empty $MESON_PROJECT_DIST_ROOT/build/ directory. - meson.add_dist_script( - python3, dist_build_scripts_py, - project_source_root, - 'untracked' / 'build_scripts', - dont_distribute, - ) -endif +# Don't distribute these files and directories. +dont_distribute = [ + '.github', +] +# Add build scripts to the distribution directory, and delete .gitignore +# files and an empty $MESON_PROJECT_DIST_ROOT/build/ directory. +meson.add_dist_script( + python3, dist_build_scripts_py, + project_source_root, + 'untracked' / 'build_scripts', + dont_distribute, +) if meson.is_subproject() pkgconfig_vars = { From 20ecb77bd12cfe45a046ffbdfc9a786175271a3c Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 15 Jul 2024 13:38:13 +0200 Subject: [PATCH 225/240] CI: Install meson >= 0.62 * .github/workflows/meson-clang.yml: * .github/workflows/meson-gcc.yml: * .github/workflows/publish-docs.yml: Install meson with pip instead of apt. --- .github/workflows/meson-clang.yml | 7 ++++++- .github/workflows/meson-gcc.yml | 7 ++++++- .github/workflows/publish-docs.yml | 8 ++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.github/workflows/meson-clang.yml b/.github/workflows/meson-clang.yml index d2a3a272..dd8d4a11 100644 --- a/.github/workflows/meson-clang.yml +++ b/.github/workflows/meson-clang.yml @@ -1,3 +1,5 @@ +# 2024-07-15: ubuntu-latest = ubuntu-22.04 +# See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories name: "Meson: clang" on: [push] @@ -14,7 +16,10 @@ jobs: # Prevent blocking apt install on a question during configuring of tzdata. export DEBIAN_FRONTEND=noninteractive sudo apt update - sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common clang meson ninja-build python3-setuptools --yes + sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common clang ninja-build python3-setuptools python3-pip --yes + # Ubuntu 22.04 contains meson 0.61.2, but libxml++ requires meson >= 0.62.0. + # Install it with pip instead of apt. + sudo pip install "meson>=0.62.0" export CC=clang export CXX=clang++ meson setup -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true _build diff --git a/.github/workflows/meson-gcc.yml b/.github/workflows/meson-gcc.yml index 625b700d..aaa1eff6 100644 --- a/.github/workflows/meson-gcc.yml +++ b/.github/workflows/meson-gcc.yml @@ -1,3 +1,5 @@ +# 2024-07-15: ubuntu-latest = ubuntu-22.04 +# See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories name: "Meson: gcc" on: [push] @@ -14,7 +16,10 @@ jobs: # Prevent blocking apt install on a question during configuring of tzdata. export DEBIAN_FRONTEND=noninteractive sudo apt update - sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common g++ meson ninja-build python3-setuptools --yes + sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common g++ ninja-build python3-setuptools python3-pip --yes + # Ubuntu 22.04 contains meson 0.61.2, but libxml++ requires meson >= 0.62.0. + # Install it with pip instead of apt. + sudo pip install "meson>=0.62.0" export CC=gcc export CXX=g++ meson setup -Dwarnings=fatal -Dwarning_level=3 -Dwerror=true _build diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index fbbe7826..eb4009f1 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -5,7 +5,8 @@ name: Publish docs -# 2023-07-28: ubuntu-latest = ubuntu-22.04 +# 2024-07-15: ubuntu-latest = ubuntu-22.04 +# See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories on: # Runs on pushes targeting the default branch push: @@ -37,7 +38,10 @@ jobs: # Prevent blocking apt install on a question during configuring of tzdata. export DEBIAN_FRONTEND=noninteractive sudo apt update - sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common g++ meson ninja-build python3-setuptools python3-pip --yes + sudo apt install libxml2-dev libxml2-utils docbook5-xml docbook-xsl mm-common g++ ninja-build python3-setuptools python3-pip --yes + # Ubuntu 22.04 contains meson 0.61.2, but libxml++ requires meson >= 0.62.0. + # Install it with pip instead of apt. + sudo pip install "meson>=0.62.0" meson setup -Dbuild-documentation=true -Dbuild-examples=false -Dbuild-tests=false _build meson compile -C _build - name: Collect Documentation From e37dd04ced67c409188001cf3bdf6fcde861c77a Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 13 Aug 2024 16:23:04 +0200 Subject: [PATCH 226/240] 5.4.0 --- NEWS | 26 ++++++++++++++++++++++++++ configure.ac | 2 +- meson.build | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index ca80f85c..aae1fdff 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,29 @@ +5.4.0 (stable): + +* Node: Add eval_xpath(). + (Kjell Ahlstedt) Issue #66 (Marie Preusse) + +Meson build: +* Require meson >= 0.62. +* Use Meson's pkgconfig module instead of the libxml++.pc.in template. + (Kjell Ahlstedt) + + +5.2.1 (stable): + +* Parser: Ignore deprecation of xmlParserCtxt members. + (Kjell Ahlstedt) + +Documentation: +* Don't link to removed developer-old.gnome.org. + (Kjell Ahlstedt) + +Meson build: +* Use libxml2 meson build when libxml2 is built as a subproject. + (Andrew Potter) Issue #67, Pull request #68 +* Require python3 >= 3.7. That's what Meson requires. + (Kjell Ahlstedt) + 5.2.0 (stable): * Use callback functions with C linkage diff --git a/configure.ac b/configure.ac index 240b43cd..1677fe1b 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ ## This file is part of libxml++. -AC_INIT([libxml++], [5.2.0], +AC_INIT([libxml++], [5.4.0], [https://github.com/libxmlplusplus/libxmlplusplus/issues], [libxml++], [https://libxmlplusplus.github.io/libxmlplusplus/]) AC_PREREQ([2.59]) diff --git a/meson.build b/meson.build index 9104b05b..b599220d 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ # This file is part of libxml++. project('libxml++', 'cpp', - version: '5.2.0', + version: '5.4.0', license: 'LGPLv2.1+', default_options: [ 'warning_level=1', From fd1d79fa23b7fa7789acd2e12512c8dd4e7a01dc Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 5 Nov 2024 09:22:28 +0100 Subject: [PATCH 227/240] docs/reference/Doxyfile.in: Remove unsupported entries --- docs/reference/Doxyfile.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/reference/Doxyfile.in b/docs/reference/Doxyfile.in index 2f38f50d..e6ac8265 100644 --- a/docs/reference/Doxyfile.in +++ b/docs/reference/Doxyfile.in @@ -142,8 +142,6 @@ REFERENCES_LINK_SOURCE = YES SOURCE_TOOLTIPS = YES USE_HTAGS = NO VERBATIM_HEADERS = NO -CLANG_ASSISTED_PARSING = NO -CLANG_OPTIONS = #--------------------------------------------------------------------------- # Configuration options related to the alphabetical class index #--------------------------------------------------------------------------- From 1e521236bb634c5b6446d16bc0f3edffd5577da9 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 5 Nov 2024 13:01:06 +0100 Subject: [PATCH 228/240] TextReader::get_xml_lang(): Fix memory leak --- libxml++/parsers/textreader.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc index 88f7ecd9..7ba56a39 100644 --- a/libxml++/parsers/textreader.cc +++ b/libxml++/parsers/textreader.cc @@ -186,7 +186,7 @@ ustring TextReader::get_value() const ustring TextReader::get_xml_lang() const { return propertyreader->String( - xmlTextReaderXmlLang(impl_)); + xmlTextReaderXmlLang(impl_), true); } TextReader::ReadState TextReader::get_read_state() const @@ -221,7 +221,8 @@ ustring TextReader::get_attribute( const ustring& namespaceURI) const { return propertyreader->String( - xmlTextReaderGetAttributeNs(impl_, (const xmlChar *)localName.c_str(), (const xmlChar *)namespaceURI.c_str()), true); + xmlTextReaderGetAttributeNs(impl_, (const xmlChar *)localName.c_str(), + (const xmlChar *)namespaceURI.c_str()), true); } ustring TextReader::lookup_namespace( From a4b335e680bf83cf0fc196da2fd92f1673714ce2 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 7 Nov 2024 12:44:51 +0100 Subject: [PATCH 229/240] TextReader: Use xmlTextReaderSetStructuredErrorHandler() instead of xmlTextReaderSetErrorHandler(). Use callback function with C linkage. The callback in textreader.cc was overlooked in commit a8d810fdbc2bf4c524a22e528cf168e7711d363d. --- libxml++/parsers/textreader.cc | 53 +++++++++++++++++++++++++++------- libxml++/parsers/textreader.h | 2 ++ 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc index 7ba56a39..346dc128 100644 --- a/libxml++/parsers/textreader.cc +++ b/libxml++/parsers/textreader.cc @@ -6,6 +6,43 @@ #include +namespace +{ +//TODO: When we can break ABI, change on_libxml_error(), and change ErrorFuncType to +// using ErrorFuncType = void (*)(void* userData, const xmlError* error); +// C++ linkage +using ErrorFuncType = void (*)(void* arg, const char* msg, int severity, void* locator); +ErrorFuncType p_callback_error; + +extern "C" +{ +static void c_callback_error(void* userData, const xmlError* error) +{ + const xmlpp::ustring msg = xmlpp::format_xml_error(error); + + // Compute severity as in libxml2's xmlreader.c file, + // static (i.e. private) function xmlTextReaderStructuredRelay(). + xmlParserSeverities severity{}; + switch (error->domain) + { + case XML_FROM_VALID: + case XML_FROM_DTD: + severity = (error->level == XML_ERR_WARNING) ? + XML_PARSER_SEVERITY_VALIDITY_WARNING : + XML_PARSER_SEVERITY_VALIDITY_ERROR; + break; + default: + severity = (error->level == XML_ERR_WARNING) ? + XML_PARSER_SEVERITY_WARNING : + XML_PARSER_SEVERITY_ERROR; + break; + } + p_callback_error(userData, msg.c_str(), severity, nullptr); +} + +} // extern "C" +} // anonymous namespace + namespace xmlpp { @@ -347,20 +384,16 @@ bool TextReader::is_valid() const void TextReader::setup_exceptions() { - xmlTextReaderErrorFunc func = nullptr; - void* arg = nullptr; - - // We respect any other error handlers already setup: - xmlTextReaderGetErrorHandler(impl_, &func, &arg); - if(!func) - { - func = (xmlTextReaderErrorFunc)&TextReader::on_libxml_error; - xmlTextReaderSetErrorHandler(impl_, func, this); - } + p_callback_error = &on_libxml_error; + xmlTextReaderSetStructuredErrorHandler(impl_, &c_callback_error, this); } void TextReader::on_libxml_error(void* arg, const char* msg, int severity, void* /* locator */) { + //TODO: Change this function when we can break ABI. + // It was created when setup_exceptions() called xmlTextReaderSetErrorHandler() + // instead of xmlTextReaderSetStructuredErrorHandler(). + auto ths = static_cast(arg); ths->severity_ = severity; ths->error_ = msg ? msg : "unknown parse error"; diff --git a/libxml++/parsers/textreader.h b/libxml++/parsers/textreader.h index dbc22ed8..8aea92a2 100644 --- a/libxml++/parsers/textreader.h +++ b/libxml++/parsers/textreader.h @@ -296,6 +296,8 @@ class TextReader: public NonCopyable LIBXMLPP_API void setup_exceptions(); + //TODO: When we can break ABI, change on_libxml_error() to + // static void on_libxml_error(void* userData, const xmlError* error); LIBXMLPP_API static void on_libxml_error(void * arg, const char *msg, int severity, void * locator); From e53842bb17638e0ab9a639bb034e591b6a79bf6d Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 7 Nov 2024 14:58:27 +0100 Subject: [PATCH 230/240] TextReader: xmlStructuredErrorFunc() changed in libxml2 2.12.0 Before 2.12.0: typedef void (*xmlStructuredErrorFunc) (void *userData, xmlError *error); Since 2.12.0: typedef void (*xmlStructuredErrorFunc) (void *userData, const xmlError *error); * libxml++/parsers/textreader.cc: The declaration of c_callback_error() must fit the libxml2 version being compiled with. As it's a function with C linkage, its name is not mangled. It's not an ABI break. --- libxml++/parsers/textreader.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc index 346dc128..5c779313 100644 --- a/libxml++/parsers/textreader.cc +++ b/libxml++/parsers/textreader.cc @@ -5,6 +5,7 @@ #include #include +#include namespace { @@ -16,7 +17,11 @@ ErrorFuncType p_callback_error; extern "C" { +#if LIBXML_VERSION >= 21200 static void c_callback_error(void* userData, const xmlError* error) +#else +static void c_callback_error(void* userData, xmlError* error) +#endif { const xmlpp::ustring msg = xmlpp::format_xml_error(error); From 6cdfd912e8e3fe683f2c17f124a846c0f79d8dee Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 25 Nov 2024 10:24:20 +0100 Subject: [PATCH 231/240] TextReader: Add methods that return std::optional Add read_inner_xml2(), read_outer_xml2(), read_string2(), get_base_uri2(), get_local_name2(), get_name2(), get_namespace_uri2(), get_prefix2(), get_value2(), get_xml_lang2(), get_attribute2() (3 overloaded ones), lookup_namespace2(). An empty string is not necessarily the same as no string. Deprecate the corresponding functions that return xmlpp::ustring. Fixes #71 --- examples/textreader/main.cc | 26 ++--- libxml++/parsers/textreader.cc | 101 ++++++++++++++++ libxml++/parsers/textreader.h | 207 ++++++++++++++++++++++++++++++++- 3 files changed, 318 insertions(+), 16 deletions(-) diff --git a/examples/textreader/main.cc b/examples/textreader/main.cc index 87129f69..16d72187 100644 --- a/examples/textreader/main.cc +++ b/examples/textreader/main.cc @@ -1,5 +1,3 @@ -// -*- C++ -*- - /* main.cc * * Copyright (C) 2002 The libxml++ development team @@ -19,13 +17,7 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include -#include - #include #include @@ -43,6 +35,12 @@ std::ostream & operator<<(std::ostream & o, indent const & in) return o; } +std::ostream& operator<<(std::ostream& o, const std::optional& s) +{ + o << s.value_or("{[(no value)]}"); + return o; +} + int main(int /* argc */, char** /* argv */) { try @@ -53,16 +51,18 @@ int main(int /* argc */, char** /* argv */) { int depth = reader.get_depth(); std::cout << indent(depth) << "--- node ---" << std::endl; - std::cout << indent(depth) << "name: " << reader.get_name() << std::endl; + std::cout << indent(depth) << "name: " << reader.get_name2() << std::endl; std::cout << indent(depth) << "depth: " << reader.get_depth() << std::endl; if(reader.has_attributes()) { std::cout << indent(depth) << "attributes: " << std::endl; + std::cout << indent(depth) << "attribute 0: " << reader.get_attribute2(0) << std::endl; + std::cout << indent(depth) << "attribute 9: " << reader.get_attribute2(9) << std::endl; reader.move_to_first_attribute(); do { - std::cout << indent(depth) << " " << reader.get_name() << ": " << reader.get_value() << std::endl; + std::cout << indent(depth) << " " << reader.get_name2() << ": " << reader.get_value2() << std::endl; } while(reader.move_to_next_attribute()); reader.move_to_element(); } @@ -71,11 +71,7 @@ int main(int /* argc */, char** /* argv */) std::cout << indent(depth) << "no attributes" << std::endl; } - if(reader.has_value()) - std::cout << indent(depth) << "value: '" << reader.get_value() << "'" << std::endl; - else - std::cout << indent(depth) << "novalue" << std::endl; - + std::cout << indent(depth) << "value: '" << reader.get_value2() << "'" << std::endl; } } catch(const std::exception& e) diff --git a/libxml++/parsers/textreader.cc b/libxml++/parsers/textreader.cc index 5c779313..58c4863f 100644 --- a/libxml++/parsers/textreader.cc +++ b/libxml++/parsers/textreader.cc @@ -63,6 +63,7 @@ class TextReader::PropertyReader char Char(int value); ustring String(xmlChar* value, bool free = false); ustring String(xmlChar const* value); + std::optional OptString(xmlChar* value); TextReader & owner_; }; @@ -115,6 +116,7 @@ bool TextReader::read() xmlTextReaderRead(impl_)); } +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring TextReader::read_inner_xml() { return propertyreader->String( @@ -132,6 +134,22 @@ ustring TextReader::read_string() return propertyreader->String( xmlTextReaderReadString(impl_), true); } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional TextReader::read_inner_xml2() +{ + return propertyreader->OptString(xmlTextReaderReadInnerXml(impl_)); +} + +std::optional TextReader::read_outer_xml2() +{ + return propertyreader->OptString(xmlTextReaderReadOuterXml(impl_)); +} + +std::optional TextReader::read_string2() +{ + return propertyreader->OptString(xmlTextReaderReadString(impl_)); +} bool TextReader::read_attribute_value() { @@ -145,11 +163,18 @@ int TextReader::get_attribute_count() const xmlTextReaderAttributeCount(impl_)); } +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring TextReader::get_base_uri() const { return propertyreader->String( xmlTextReaderBaseUri(impl_), true); } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional TextReader::get_base_uri2() const +{ + return propertyreader->OptString(xmlTextReaderBaseUri(impl_)); +} int TextReader::get_depth() const { @@ -181,6 +206,7 @@ bool TextReader::is_empty_element() const xmlTextReaderIsEmptyElement(impl_)); } +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring TextReader::get_local_name() const { return propertyreader->String( @@ -198,6 +224,22 @@ ustring TextReader::get_namespace_uri() const return propertyreader->String( xmlTextReaderNamespaceUri(impl_), true); } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional TextReader::get_local_name2() const +{ + return propertyreader->OptString(xmlTextReaderLocalName(impl_)); +} + +std::optional TextReader::get_name2() const +{ + return propertyreader->OptString(xmlTextReaderName(impl_)); +} + +std::optional TextReader::get_namespace_uri2() const +{ + return propertyreader->OptString(xmlTextReaderNamespaceUri(impl_)); +} TextReader::NodeType TextReader::get_node_type() const { @@ -207,11 +249,18 @@ TextReader::NodeType TextReader::get_node_type() const return static_cast(result); } +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring TextReader::get_prefix() const { return propertyreader->String( xmlTextReaderPrefix(impl_), true); } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional TextReader::get_prefix2() const +{ + return propertyreader->OptString(xmlTextReaderPrefix(impl_)); +} char TextReader::get_quote_char() const { @@ -219,6 +268,7 @@ char TextReader::get_quote_char() const xmlTextReaderQuoteChar(impl_)); } +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring TextReader::get_value() const { return propertyreader->String( @@ -230,6 +280,17 @@ ustring TextReader::get_xml_lang() const return propertyreader->String( xmlTextReaderXmlLang(impl_), true); } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional TextReader::get_value2() const +{ + return propertyreader->OptString(xmlTextReaderValue(impl_)); +} + +std::optional TextReader::get_xml_lang2() const +{ + return propertyreader->OptString(xmlTextReaderXmlLang(impl_)); +} TextReader::ReadState TextReader::get_read_state() const { @@ -245,6 +306,7 @@ void TextReader::close() check_for_exceptions(); } +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring TextReader::get_attribute(int number) const { return propertyreader->String( @@ -273,6 +335,33 @@ ustring TextReader::lookup_namespace( return propertyreader->String( xmlTextReaderLookupNamespace(impl_, (const xmlChar *)prefix.c_str()), true); } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional TextReader::get_attribute2(int number) const +{ + return propertyreader->OptString(xmlTextReaderGetAttributeNo(impl_, number)); +} + +std::optional TextReader::get_attribute2(const ustring& name) const +{ + return propertyreader->OptString( + xmlTextReaderGetAttribute(impl_, (const xmlChar*)name.c_str())); +} + +std::optional TextReader::get_attribute2( + const ustring& localName, + const ustring& namespaceURI) const +{ + return propertyreader->OptString( + xmlTextReaderGetAttributeNs(impl_, (const xmlChar*)localName.c_str(), + (const xmlChar *)namespaceURI.c_str())); +} + +std::optional TextReader::lookup_namespace2(const ustring& prefix) const +{ + return propertyreader->OptString(xmlTextReaderLookupNamespace( + impl_, prefix.empty() ? nullptr : (const xmlChar*)prefix.c_str())); +} bool TextReader::move_to_attribute(int number) { @@ -467,4 +556,16 @@ ustring TextReader::PropertyReader::String(xmlChar const* value) return (const char*)value; } +std::optional TextReader::PropertyReader::OptString(xmlChar* value) +{ + owner_.check_for_exceptions(); + + if (!value) + return {}; + + std::optional result = (char*)value; + xmlFree(value); + return result; +} + } // namespace xmlpp diff --git a/libxml++/parsers/textreader.h b/libxml++/parsers/textreader.h index 8aea92a2..caa3da64 100644 --- a/libxml++/parsers/textreader.h +++ b/libxml++/parsers/textreader.h @@ -13,12 +13,15 @@ #include "libxml++/ustring.h" #include +#include extern "C" { struct _xmlTextReader; } +//TODO: When we can break ABI/API, remove deprecated methods +// and rename all xyz2() to xyz(). namespace xmlpp { @@ -115,10 +118,12 @@ class TextReader: public NonCopyable */ LIBXMLPP_API bool read(); +#ifndef LIBXMLXX_DISABLE_DEPRECATED /** Reads the contents of the current node, including child nodes and markup. * @return A ustring containing the XML content, or an empty ustring if the current node is neither an element nor attribute, or has no child nodes. * @throws xmlpp::parse_error * @throws xmlpp::validity_error + * @deprecated 5.6: Use read_inner_xml2() instead. */ LIBXMLPP_API ustring read_inner_xml(); @@ -126,6 +131,7 @@ class TextReader: public NonCopyable * @return A ustring containing the XML content, or an empty ustring if the current node is neither an element nor attribute. * @throws xmlpp::parse_error * @throws xmlpp::validity_error + * @deprecated 5.6: Use read_outer_xml2() instead. */ LIBXMLPP_API ustring read_outer_xml(); @@ -133,8 +139,37 @@ class TextReader: public NonCopyable * @return A ustring containing the contents of the Element or Text node, or an empty ustring if the reader is positioned on any other type of node. * @throws xmlpp::parse_error * @throws xmlpp::validity_error + * @deprecated 5.6: Use read_string2() instead. */ LIBXMLPP_API ustring read_string(); +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Reads the contents of the current node, including child nodes and markup. + * @return A std::optional containing the XML content, or no value if + * the current node is neither an element nor attribute, or has no child nodes. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @newin{5,6} + */ + LIBXMLPP_API std::optional read_inner_xml2(); + + /** Reads the current node and its contents, including child nodes and markup. + * @return A std::optional containing the XML content, or no value if + * the current node is neither an element nor attribute. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @newin{5,6} + */ + LIBXMLPP_API std::optional read_outer_xml2(); + + /** Reads the contents of an element or a text node as a string. + * @return A std::optional containing the contents of the Element or Text node, + * or no value if the reader is positioned on any other type of node. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @newin{5,6} + */ + LIBXMLPP_API std::optional read_string2(); /** Parses an attribute value into one or more Text and EntityReference nodes. * @return A bool where true indicates the attribute value was parsed, and false indicates the reader was not positioned on an attribute node or all the attribute values have been read. @@ -153,10 +188,23 @@ class TextReader: public NonCopyable LIBXMLPP_API int get_attribute_count() const; +#ifndef LIBXMLXX_DISABLE_DEPRECATED /** Gets the base Uniform Resource Identifier (URI) of the current node. * @return The base URI of the current node or an empty ustring if not available. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @deprecated 5.6: Use get_base_uri2() instead. */ LIBXMLPP_API ustring get_base_uri() const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Gets the base Uniform Resource Identifier (URI) of the current node. + * @return The base URI of the current node, or no value if not available. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @newin{5,6} + */ + LIBXMLPP_API std::optional get_base_uri2() const; /** Gets the depth of the current node in the XML document. * @return The depth of the current node in the XML document, or -1 in case of error. @@ -188,9 +236,51 @@ class TextReader: public NonCopyable LIBXMLPP_API bool is_empty_element() const; +#ifndef LIBXMLXX_DISABLE_DEPRECATED + /** Gets the local name of the node. + * @return The local name of the node, or an empty ustring if not available. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @deprecated 5.6: Use get_local_name2() instead. + */ LIBXMLPP_API ustring get_local_name() const; + + /** Gets the qualified name of the node, equal to Prefix:LocalName. + * @return The qualified name of the node, or an empty ustring if not available. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @deprecated 5.6: Use get_name2() instead. + */ LIBXMLPP_API ustring get_name() const; + + /** Gets the URI defining the namespace associated with the node. + * @return The namespace URI, or an empty ustring if not available. + * @deprecated 5.6: Use get_namespace_uri2() instead. + */ LIBXMLPP_API ustring get_namespace_uri() const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Gets the local name of the node. + * @return The local name of the node, or no value if not available. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @newin{5,6} + */ + LIBXMLPP_API std::optional get_local_name2() const; + + /** Gets the qualified name of the node, equal to Prefix:LocalName. + * @return The qualified name of the node, or no value if not available. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @newin{5,6} + */ + LIBXMLPP_API std::optional get_name2() const; + + /** Gets the URI defining the namespace associated with the node. + * @return The namespace URI, or no value if not available. + * @newin{5,6} + */ + LIBXMLPP_API std::optional get_namespace_uri2() const; /** Get the node type of the current node. * @returns The xmlpp::TextReader::NodeType of the current node. @@ -202,10 +292,19 @@ class TextReader: public NonCopyable LIBXMLPP_API NodeType get_node_type() const; +#ifndef LIBXMLXX_DISABLE_DEPRECATED /** Get the namespace prefix associated with the current node. * @returns The namespace prefix, or an empty string if not available. + * @deprecated 5.6: Use get_prefix2() instead. */ LIBXMLPP_API ustring get_prefix() const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Get the namespace prefix associated with the current node. + * @returns The namespace prefix, or no value if not available. + * @newin{5,6} + */ + LIBXMLPP_API std::optional get_prefix2() const; /** Get the quotation mark character used to enclose the value of an attribute. * @returns Returns " or ' and -1 in case of error. @@ -213,25 +312,131 @@ class TextReader: public NonCopyable LIBXMLPP_API char get_quote_char() const; +#ifndef LIBXMLXX_DISABLE_DEPRECATED + /** Gets the text value of the node. + * @return The text value, or an empty ustring if not available. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @deprecated 5.6: Use get_value2() instead. + */ LIBXMLPP_API ustring get_value() const; + + /** Gets the xml:lang scope within which the node resides. + * @return The xml:lang value, or an empty ustring if not available. + * @deprecated 5.6: Use get_xml_lang2() instead. + */ LIBXMLPP_API ustring get_xml_lang() const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Gets the text value of the node. + * @return The text value, or no value if not available. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @newin{5,6} + */ + LIBXMLPP_API std::optional get_value2() const; + + /** Gets the xml:lang scope within which the node resides. + * @return The xml:lang value, or no value if not available. + * @newin{5,6} + */ + LIBXMLPP_API std::optional get_xml_lang2() const; + /** Gets the read state of the reader. + * @return The state value, or xmlpp::TextReader::ReadState::InternalError in case of error. + */ LIBXMLPP_API ReadState get_read_state() const; LIBXMLPP_API void close(); +#ifndef LIBXMLXX_DISABLE_DEPRECATED + /** Gets the value of the attribute with the specified index relative to the containing element. + * @param number The zero-based index of the attribute relative to the containing element. + * @return The value of the specified attribute, or an empty ustring in case of error. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @deprecated 5.6: Use get_attribute2(int) const instead. + */ LIBXMLPP_API ustring get_attribute(int number) const; + + /** Gets the value of the attribute with the specified qualified name. + * @param name The qualified name of the attribute. + * @return The value of the specified attribute, or an empty ustring in case of error. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @deprecated 5.6: Use get_attribute2(const ustring&) const instead. + */ LIBXMLPP_API ustring get_attribute(const ustring& name) const; + + /** Gets the value of the specified attribute. + * @param local_name The local name of the attribute. + * @param ns_uri The namespace URI of the attribute. + * @return The value of the specified attribute, or an empty ustring in case of error. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @deprecated 5.6: Use get_attribute2(const ustring&, const ustring&) const instead. + */ LIBXMLPP_API ustring get_attribute(const ustring& local_name, const ustring& ns_uri) const; + /** Resolves a namespace prefix in the scope of the current element. + * @param prefix The prefix whose namespace URI is to be resolved. + * To return the default namespace, specify an empty string. + * @return The the namespace URI to which the prefix maps, or an empty ustring in case of error. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @deprecated 5.6: Use lookup_namespace2() instead. + */ + LIBXMLPP_API + ustring lookup_namespace(const ustring& prefix) const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Gets the value of the attribute with the specified index relative to the containing element. + * @param number The zero-based index of the attribute relative to the containing element. + * @return The value of the specified attribute, or no value in case of error. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @newin{5,6} + */ + LIBXMLPP_API + std::optional get_attribute2(int number) const; + + /** Gets the value of the attribute with the specified qualified name. + * @param name The qualified name of the attribute. + * @return The value of the specified attribute, or no value in case of error. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @newin{5,6} + */ + LIBXMLPP_API + std::optional get_attribute2(const ustring& name) const; + + /** Gets the value of the specified attribute. + * @param local_name The local name of the attribute. + * @param ns_uri The namespace URI of the attribute. + * @return The value of the specified attribute, or no value in case of error. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @newin{5,6} + */ + LIBXMLPP_API + std::optional get_attribute2(const ustring& local_name, const ustring& ns_uri) const; + // TODO InputBuffer GetRemainder; + /** Resolves a namespace prefix in the scope of the current element. + * @param prefix The prefix whose namespace URI is to be resolved. + * To return the default namespace, specify an empty string. + * @return The the namespace URI to which the prefix maps, or no value in case of error. + * @throws xmlpp::parse_error + * @throws xmlpp::validity_error + * @newin{5,6} + */ LIBXMLPP_API - ustring lookup_namespace(const ustring& prefix) const; + std::optional lookup_namespace2(const ustring& prefix) const; LIBXMLPP_API bool move_to_attribute(int number); From ade9636a402f9de3c8edfa4024b1e6ff8b7d628c Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Sun, 8 Dec 2024 10:28:58 +0100 Subject: [PATCH 232/240] Add more methods that return std::optional * libxml++/attribute.[cc|h]: * libxml++/attributedeclaration.[cc|h]: * libxml++/attributenode.[cc|h]: Add get_value2(). * libxml++/document.[cc|h]: Add get_encoding2() * libxml++/dtd.[cc|h]: Add get_external_id2(), get_name2(), get_system_id2(). * libxml++/nodes/contentnode.[cc|h]: Add get_content2(). * libxml++/nodes/element.[cc|h]: Add get_attribute_value2(). * libxml++/nodes/entitydeclaration.[cc|h]: * libxml++/nodes/entityreference.[cc|h]: Add get_original_text2(), get_resolved_text2(). * libxml++/nodes/node.[cc|h]: Add get_name2(), get_namespace_prefix2(), get_namespace_uri2(), get_path2(). Deprecate the corresponding methods that return xmlpp::ustring. See #71 * examples/dom_build/main.cc: * examples/dom_parse_entities/main.cc: * examples/dom_parser/main.cc: * examples/dom_parser_raw/main.cc: * examples/dom_xinclude/main.cc: * examples/dom_xpath/main.cc: * examples/sax_parser_build_dom/main.cc: * tests/istream_ioparser/main.cc: Use the new methods instead of the deprecated ones. --- examples/dom_build/main.cc | 7 +-- examples/dom_parse_entities/main.cc | 18 ++++--- examples/dom_parser/main.cc | 34 +++++++------ examples/dom_parser_raw/main.cc | 2 +- examples/dom_xinclude/main.cc | 32 ++++++------ examples/dom_xpath/main.cc | 18 ++++--- examples/sax_parser_build_dom/main.cc | 6 +-- libxml++/attribute.cc | 13 +++++ libxml++/attribute.h | 13 ++++- libxml++/attributedeclaration.cc | 7 +++ libxml++/attributedeclaration.h | 8 +++ libxml++/attributenode.cc | 16 ++++++ libxml++/attributenode.h | 7 +++ libxml++/document.cc | 9 ++++ libxml++/document.h | 15 +++++- libxml++/dtd.cc | 23 +++++++++ libxml++/dtd.h | 35 +++++++++++++ libxml++/nodes/contentnode.cc | 13 +++++ libxml++/nodes/contentnode.h | 11 +++++ libxml++/nodes/element.cc | 11 +++++ libxml++/nodes/element.h | 15 +++++- libxml++/nodes/entitydeclaration.cc | 16 ++++++ libxml++/nodes/entitydeclaration.h | 19 +++++++ libxml++/nodes/entityreference.cc | 26 +++++++++- libxml++/nodes/entityreference.h | 18 +++++++ libxml++/nodes/node.cc | 71 ++++++++++++++++++++------- libxml++/nodes/node.h | 36 +++++++++++++- tests/istream_ioparser/main.cc | 4 +- 28 files changed, 416 insertions(+), 87 deletions(-) diff --git a/examples/dom_build/main.cc b/examples/dom_build/main.cc index eadc98d0..fcaef275 100644 --- a/examples/dom_build/main.cc +++ b/examples/dom_build/main.cc @@ -17,10 +17,6 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include @@ -28,7 +24,6 @@ int main(int /* argc */, char** /* argv */) { - try { xmlpp::Document document; @@ -64,7 +59,7 @@ main(int /* argc */, char** /* argv */) auto whole = document.write_to_string(); std::cout << "XML built at runtime: " << std::endl << whole << std::endl; - std::cout << "namespace of root node: " << nodeRoot->get_namespace_uri() << std::endl; + std::cout << "namespace of root node: " << nodeRoot->get_namespace_uri2().value_or("{[(no URI)]}") << std::endl; } catch(const std::exception& ex) { diff --git a/examples/dom_parse_entities/main.cc b/examples/dom_parse_entities/main.cc index 621fac74..f3e7c552 100644 --- a/examples/dom_parse_entities/main.cc +++ b/examples/dom_parse_entities/main.cc @@ -17,15 +17,17 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include #include +std::ostream& operator<<(std::ostream& o, const std::optional& s) +{ + o << s.value_or("{[(no value)]}"); + return o; +} + void print_node(const xmlpp::Node* node, bool substitute_entities, unsigned int indentation = 0) { const std::string indent(indentation, ' '); @@ -37,7 +39,7 @@ void print_node(const xmlpp::Node* node, bool substitute_entities, unsigned int const auto nodeText = dynamic_cast(node); if (nodeText && !nodeText->is_white_space()) { - std::cout << indent << "text = " << nodeText->get_content() << std::endl; + std::cout << indent << "text = " << nodeText->get_content2() << std::endl; } } else @@ -46,9 +48,9 @@ void print_node(const xmlpp::Node* node, bool substitute_entities, unsigned int const auto nodeEntityReference = dynamic_cast(node); if (nodeEntityReference) { - std::cout << indent << "entity reference name = " << nodeEntityReference->get_name() << std::endl; - std::cout << indent << " resolved text = " << nodeEntityReference->get_resolved_text() << std::endl; - std::cout << indent << " original text = " << nodeEntityReference->get_original_text() << std::endl; + std::cout << indent << "entity reference name = " << nodeEntityReference->get_name2() << std::endl; + std::cout << indent << " resolved text = " << nodeEntityReference->get_resolved_text2() << std::endl; + std::cout << indent << " original text = " << nodeEntityReference->get_original_text2() << std::endl; } } // end if (substitute_entities) diff --git a/examples/dom_parser/main.cc b/examples/dom_parser/main.cc index ae78b733..e9264a4f 100644 --- a/examples/dom_parser/main.cc +++ b/examples/dom_parser/main.cc @@ -17,14 +17,16 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include +std::ostream& operator<<(std::ostream& o, const std::optional& s) +{ + o << s.value_or("{[(no value)]}"); + return o; +} + void print_node(const xmlpp::Node* node, unsigned int indentation = 0) { const std::string indent(indentation, ' '); @@ -37,14 +39,14 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) if(nodeText && nodeText->is_white_space()) //Let's ignore the indenting - you don't always want to do this. return; - const auto nodename = node->get_name(); + const auto nodename = node->get_name2(); - if(!nodeText && !nodeComment && !nodename.empty()) //Let's not say "name: text". + if(!nodeText && !nodeComment && nodename) //Let's not say "name: text". { - const auto namespace_prefix = node->get_namespace_prefix(); + const auto namespace_prefix = node->get_namespace_prefix2(); std::cout << indent << "Node name = "; - if(!namespace_prefix.empty()) + if(namespace_prefix) std::cout << namespace_prefix << ":"; std::cout << nodename << std::endl; } @@ -56,15 +58,15 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) //Treat the various node types differently: if(nodeText) { - std::cout << indent << "text = \"" << nodeText->get_content() << "\"" << std::endl; + std::cout << indent << "text = \"" << nodeText->get_content2() << "\"" << std::endl; } else if(nodeComment) { - std::cout << indent << "comment = " << nodeComment->get_content() << std::endl; + std::cout << indent << "comment = " << nodeComment->get_content2() << std::endl; } else if(nodeContent) { - std::cout << indent << "content = " << nodeContent->get_content() << std::endl; + std::cout << indent << "content = " << nodeContent->get_content2() << std::endl; } else if(auto nodeElement = dynamic_cast(node)) { @@ -76,13 +78,13 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) //Print attributes: for (const auto& attribute : nodeElement->get_attributes()) { - const auto namespace_prefix = attribute->get_namespace_prefix(); + const auto namespace_prefix = attribute->get_namespace_prefix2(); std::cout << indent << " Attribute "; - if(!namespace_prefix.empty()) + if(namespace_prefix) std::cout << namespace_prefix << ":"; - std::cout << attribute->get_name() << " = " - << attribute->get_value() << std::endl; + std::cout << attribute->get_name2() << " = " + << attribute->get_value2() << std::endl; } const auto attribute = nodeElement->get_attribute("title"); @@ -93,7 +95,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) std::cout << "AttributeNode "; else if (dynamic_cast(attribute)) std::cout << "AttributeDeclaration "; - std::cout << "title = " << attribute->get_value() << std::endl; + std::cout << "title = " << attribute->get_value2() << std::endl; } } diff --git a/examples/dom_parser_raw/main.cc b/examples/dom_parser_raw/main.cc index 653128ca..3ab9bf85 100644 --- a/examples/dom_parser_raw/main.cc +++ b/examples/dom_parser_raw/main.cc @@ -27,7 +27,7 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) { std::cout << std::endl; //Separate nodes by an empty line. - std::cout << "Node name = " << node->get_name() << std::endl; + std::cout << "Node name = " << node->get_name2().value_or("{[(no name)]}") << std::endl; //Recurse through child nodes: for(const auto& child : node->get_children()) diff --git a/examples/dom_xinclude/main.cc b/examples/dom_xinclude/main.cc index 8017e0b6..f42fc7a4 100644 --- a/examples/dom_xinclude/main.cc +++ b/examples/dom_xinclude/main.cc @@ -16,14 +16,16 @@ * License along with this library. If not, see . */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include +std::ostream& operator<<(std::ostream& o, const std::optional& s) +{ + o << s.value_or("{[(no value)]}"); + return o; +} + void print_node(const xmlpp::Node* node, unsigned int indentation = 0) { const std::string indent(indentation, ' '); @@ -36,14 +38,14 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) if (nodeText && nodeText->is_white_space()) return; - const auto nodename = node->get_name(); + const auto nodename = node->get_name2(); - if (!nodeText && !nodeComment && !nodename.empty()) //Let's not say "name: text". + if (!nodeText && !nodeComment && nodename) //Let's not say "name: text". { - const auto namespace_prefix = node->get_namespace_prefix(); + const auto namespace_prefix = node->get_namespace_prefix2(); std::cout << indent << "Node name = "; - if (!namespace_prefix.empty()) + if (namespace_prefix) std::cout << namespace_prefix << ":"; std::cout << nodename << std::endl; } @@ -55,15 +57,15 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) //Treat the various node types differently: if (nodeText) { - std::cout << indent << "text = \"" << nodeText->get_content() << "\"" << std::endl; + std::cout << indent << "text = \"" << nodeText->get_content2() << "\"" << std::endl; } else if (nodeComment) { - std::cout << indent << "comment = " << nodeComment->get_content() << std::endl; + std::cout << indent << "comment = " << nodeComment->get_content2() << std::endl; } else if (nodeContent) { - std::cout << indent << "content = " << nodeContent->get_content() << std::endl; + std::cout << indent << "content = " << nodeContent->get_content2() << std::endl; } else if (auto nodeElement = dynamic_cast(node)) { @@ -73,18 +75,18 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) //Print attributes: for (const auto& attribute : nodeElement->get_attributes()) { - const auto namespace_prefix = attribute->get_namespace_prefix(); + const auto namespace_prefix = attribute->get_namespace_prefix2(); std::cout << indent << " Attribute "; - if (!namespace_prefix.empty()) + if (namespace_prefix) std::cout << namespace_prefix << ":"; - std::cout << attribute->get_name() << " = " << attribute->get_value() << std::endl; + std::cout << attribute->get_name2() << " = " << attribute->get_value2() << std::endl; } const auto attribute = nodeElement->get_attribute("title"); if (attribute) { - std::cout << indent << "title = " << attribute->get_value() << std::endl; + std::cout << indent << "title = " << attribute->get_value2() << std::endl; } } else if (dynamic_cast(node)) diff --git a/examples/dom_xpath/main.cc b/examples/dom_xpath/main.cc index aaa20345..f9b7b180 100644 --- a/examples/dom_xpath/main.cc +++ b/examples/dom_xpath/main.cc @@ -17,14 +17,16 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include +std::ostream& operator<<(std::ostream& o, const std::optional& s) +{ + o << s.value_or("{[(no value)]}"); + return o; +} + std::string result_type_to_ustring(xmlpp::XPathResultType result_type) { switch (result_type) @@ -45,7 +47,7 @@ void print_nodeset(const xmlpp::Node::const_NodeSet& set) // Print the structural paths and the values: for(const auto& child : set) { - std::cout << " " << child->get_path(); + std::cout << " " << child->get_path2(); auto attribute = dynamic_cast(child); if (attribute) @@ -53,18 +55,18 @@ void print_nodeset(const xmlpp::Node::const_NodeSet& set) auto content_node = dynamic_cast(child); if (content_node) - std::cout << ", content=\"" << content_node->get_content() << "\""; + std::cout << ", content=\"" << content_node->get_content2() << "\""; auto entity_reference = dynamic_cast(child); if (entity_reference) - std::cout << ", text=\"" << entity_reference->get_original_text() << "\""; + std::cout << ", text=\"" << entity_reference->get_original_text2() << "\""; auto element = dynamic_cast(child); if (element) { auto text_node = element->get_first_child_text(); if (text_node) - std::cout << ", first_child_text=\"" << text_node->get_content() << "\""; + std::cout << ", first_child_text=\"" << text_node->get_content2() << "\""; } std::cout << std::endl; } diff --git a/examples/sax_parser_build_dom/main.cc b/examples/sax_parser_build_dom/main.cc index 2bf67596..21927b65 100644 --- a/examples/sax_parser_build_dom/main.cc +++ b/examples/sax_parser_build_dom/main.cc @@ -19,10 +19,6 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifdef HAVE_CONFIG_H -#include -#endif - #include #include #include @@ -55,7 +51,7 @@ main(int argc, char* argv[]) // Use the custom DOM auto element = doc.get_root(); - std::cout << "root's name is \"" << element->get_name() << "\"" << std::endl; + std::cout << "root's name is \"" << element->get_name2().value_or("{[(no name)]}") << "\"" << std::endl; auto nl = element->find("//path[@style != '']"); if(!nl.empty()) { diff --git a/libxml++/attribute.cc b/libxml++/attribute.cc index 18b1f44b..e10d1a50 100644 --- a/libxml++/attribute.cc +++ b/libxml++/attribute.cc @@ -5,6 +5,8 @@ */ #include "libxml++/attribute.h" +#include "libxml++/attributedeclaration.h" +#include "libxml++/attributenode.h" #include @@ -20,4 +22,15 @@ Attribute::~Attribute() { } +std::optional Attribute::get_value2() const +{ + auto attr_decl = dynamic_cast(this); + if (attr_decl) + return attr_decl->get_value2(); + auto attr_node = dynamic_cast(this); + if (attr_node) + return attr_node->get_value2(); + return {}; +} + } //namespace xmlpp diff --git a/libxml++/attribute.h b/libxml++/attribute.h index b450ce3e..9e902713 100644 --- a/libxml++/attribute.h +++ b/libxml++/attribute.h @@ -7,11 +7,13 @@ #ifndef __LIBXMLPP_ATTRIBUTE_H #define __LIBXMLPP_ATTRIBUTE_H - #include "libxml++/ustring.h" - #include +#include +//TODO: When we can break API/ABI, remove get_value(), rename get_value2() +// to get_value(), make it virtual. Do the same in AttributeDeclaration and +// AttributeNmode. namespace xmlpp { @@ -26,8 +28,15 @@ class LIBXMLPP_API Attribute : public Node /** Get the value of this attribute. * @returns The attribute's value. + * @deprecated 5.6: Use get_value2() instead. */ virtual ustring get_value() const = 0; + + /** Get the value of this attribute. + * @returns The attribute's value, or no value if the attribute has no value. + * @newin{5,6} + */ + std::optional get_value2() const; }; } // namespace xmlpp diff --git a/libxml++/attributedeclaration.cc b/libxml++/attributedeclaration.cc index bd30b097..f15ce60b 100644 --- a/libxml++/attributedeclaration.cc +++ b/libxml++/attributedeclaration.cc @@ -22,6 +22,13 @@ AttributeDeclaration::~AttributeDeclaration() ustring AttributeDeclaration::get_value() const { + return cobj()->defaultValue ? (const char*)cobj()->defaultValue : ""; +} + +std::optional AttributeDeclaration::get_value2() const +{ + if (!cobj()->defaultValue) + return {}; return (const char*)cobj()->defaultValue; } diff --git a/libxml++/attributedeclaration.h b/libxml++/attributedeclaration.h index 0072da77..c14f765a 100644 --- a/libxml++/attributedeclaration.h +++ b/libxml++/attributedeclaration.h @@ -33,9 +33,17 @@ class LIBXMLPP_API AttributeDeclaration : public Attribute /** Get the default value of this attribute. * @returns The attribute's default value. + * @deprecated 5.6: Use get_value2() instead. */ ustring get_value() const override; + /** Get the default value of this attribute. + * @returns The attribute's default value, or not value if the attribute + * has no default value. + * @newin{5,6} + */ + std::optional get_value2() const; + ///Access the underlying libxml implementation. _xmlAttribute* cobj() noexcept; diff --git a/libxml++/attributenode.cc b/libxml++/attributenode.cc index cd48554c..44d2f4ac 100644 --- a/libxml++/attributenode.cc +++ b/libxml++/attributenode.cc @@ -34,6 +34,22 @@ ustring AttributeNode::get_value() const return retn; } +std::optional AttributeNode::get_value2() const +{ + xmlChar* value = nullptr; + if (cobj()->ns && cobj()->ns->href) + value = xmlGetNsProp(cobj()->parent, cobj()->name, cobj()->ns->href); + else + value = xmlGetNoNsProp(cobj()->parent, cobj()->name); + + if (!value) + return {}; + + std::optional result = (const char*)value; + xmlFree(value); + return result; +} + void AttributeNode::set_value(const ustring& value) { if (cobj()->ns) diff --git a/libxml++/attributenode.h b/libxml++/attributenode.h index 77dcfd92..a72250c5 100644 --- a/libxml++/attributenode.h +++ b/libxml++/attributenode.h @@ -34,9 +34,16 @@ class LIBXMLPP_API AttributeNode : public Attribute /** Get the value of this attribute. * @returns The attribute's value. + * @deprecated 5.6: Use get_value2() instead. */ ustring get_value() const override; + /** Get the value of this attribute. + * @returns The attribute's value, or no value if the attribute has no value. + * @newin{5,6} + */ + std::optional get_value2() const; + /** Set the value of this attribute. * * @newin{3,0} Replaces Attribute::set_value() diff --git a/libxml++/document.cc b/libxml++/document.cc index 85ca59f6..3cd72aab 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -194,6 +194,7 @@ Document::~Document() xmlFreeDoc(impl_); } +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring Document::get_encoding() const { ustring encoding; @@ -202,6 +203,14 @@ ustring Document::get_encoding() const return encoding; } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional Document::get_encoding2() const +{ + if (!impl_->encoding) + return {}; + return (const char*)impl_->encoding; +} Dtd* Document::get_internal_subset() const { diff --git a/libxml++/document.h b/libxml++/document.h index bf204a5b..9ae580fa 100644 --- a/libxml++/document.h +++ b/libxml++/document.h @@ -17,6 +17,7 @@ #include #include +#include #include /* std::string or ustring in function prototypes in libxml++? @@ -92,10 +93,22 @@ class Document : public NonCopyable LIBXMLPP_API ~Document() override; - /** @return The encoding used in the source from which the document has been loaded. +#ifndef LIBXMLXX_DISABLE_DEPRECATED + /** Get the encoding used in the source from which the document has been loaded. + * @return The encoding used in the source from which the document has been loaded. + * @deprecated 5.6: Use get_encoding2() instead. */ LIBXMLPP_API ustring get_encoding() const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Get the encoding used in the source from which the document has been loaded. + * @return The encoding used in the source from which the document has been loaded, + * if any, else no value. + * @newin{5,6} + */ + LIBXMLPP_API + std::optional get_encoding2() const; /** Get the internal subset of this document. * @returns A pointer to the DTD, or nullptr if not found. diff --git a/libxml++/dtd.cc b/libxml++/dtd.cc index 8014c071..dda2a41c 100644 --- a/libxml++/dtd.cc +++ b/libxml++/dtd.cc @@ -107,6 +107,7 @@ void Dtd::parse_stream(std::istream& in) pimpl_->is_dtd_owner = true; } +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring Dtd::get_name() const { return (pimpl_->dtd && pimpl_->dtd->name) ? (const char*)pimpl_->dtd->name : ""; @@ -121,6 +122,28 @@ ustring Dtd::get_system_id() const { return (pimpl_->dtd && pimpl_->dtd->SystemID) ? (const char*)pimpl_->dtd->SystemID : ""; } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional Dtd::get_name2() const +{ + if (!(pimpl_->dtd && pimpl_->dtd->name)) + return {}; + return (const char*)pimpl_->dtd->name; +} + +std::optional Dtd::get_external_id2() const +{ + if (!(pimpl_->dtd && pimpl_->dtd->ExternalID)) + return {}; + return (const char*)pimpl_->dtd->ExternalID; +} + +std::optional Dtd::get_system_id2() const +{ + if (!(pimpl_->dtd && pimpl_->dtd->SystemID)) + return {}; + return (const char*)pimpl_->dtd->SystemID; +} _xmlDtd* Dtd::cobj() noexcept { diff --git a/libxml++/dtd.h b/libxml++/dtd.h index cd9b51a2..258c7c3f 100644 --- a/libxml++/dtd.h +++ b/libxml++/dtd.h @@ -9,6 +9,7 @@ #include #include "libxml++/ustring.h" +#include #include #include // std::unique_ptr @@ -117,9 +118,43 @@ class Dtd : public NonCopyable */ LIBXMLPP_API void parse_stream(std::istream& in); +#ifndef LIBXMLXX_DISABLE_DEPRECATED + /** Get the name of the DTD. + * @return The name of the DTD. + * @deprecated 5.6: Use get_name2() instead. + */ LIBXMLPP_API ustring get_name() const; + + /** Get the external identifier for PUBLIC DTD. + * @return The external identifier for PUBLIC DTD. + * @deprecated 5.6: Use get_external_id2() instead. + */ LIBXMLPP_API ustring get_external_id() const; + + /** Get the URI for a SYSTEM or PUBLIC DTD. + * @return The URI for a SYSTEM or PUBLIC DTD. + * @deprecated 5.6: Use get_system_id2() instead. + */ LIBXMLPP_API ustring get_system_id() const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Get the name of the DTD. + * @return The name of the DTD, if any, else no value. + * @newin{5,6} + */ + LIBXMLPP_API std::optional get_name2() const; + + /** Get the external identifier for PUBLIC DTD. + * @return The external identifier for PUBLIC DTD, if any, else no value. + * @newin{5,6} + */ + LIBXMLPP_API std::optional get_external_id2() const; + + /** Get the URI for a SYSTEM or PUBLIC DTD. + * @return The URI for a SYSTEM or PUBLIC DTD, if any, else no value. + * @newin{5,6} + */ + LIBXMLPP_API std::optional get_system_id2() const; /** Access the underlying libxml implementation. */ diff --git a/libxml++/nodes/contentnode.cc b/libxml++/nodes/contentnode.cc index 2347f479..a7a42535 100644 --- a/libxml++/nodes/contentnode.cc +++ b/libxml++/nodes/contentnode.cc @@ -19,6 +19,7 @@ ContentNode::ContentNode(xmlNode* node) ContentNode::~ContentNode() {} +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring ContentNode::get_content() const { if(cobj()->type == XML_ELEMENT_NODE) @@ -28,6 +29,18 @@ ustring ContentNode::get_content() const return cobj()->content ? (char*)cobj()->content : ""; } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional ContentNode::get_content2() const +{ + if (cobj()->type == XML_ELEMENT_NODE) + throw internal_error("this node type doesn't have content"); + + if (!cobj()->content) + return {}; + + return (char*)cobj()->content; +} void ContentNode::set_content(const ustring& content) { diff --git a/libxml++/nodes/contentnode.h b/libxml++/nodes/contentnode.h index b14485db..b074ac8d 100644 --- a/libxml++/nodes/contentnode.h +++ b/libxml++/nodes/contentnode.h @@ -20,11 +20,22 @@ class LIBXMLPP_API ContentNode : public Node explicit ContentNode(_xmlNode* node); ~ContentNode() override; +#ifndef LIBXMLXX_DISABLE_DEPRECATED /** Get the text of this content node. * @returns The text. Note that the 5 predefined entities (&, ", <, >, ') * are always resolved, so this content will show their human-readable equivalents. + * @deprecated 5.6: Use get_content2() instead. */ ustring get_content() const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Get the text of this content node. + * @returns The text, or no value if this node has no text. Note that the 5 + * predefined entities (&, ", <, >, ') are always resolved, + * so this content will show their human-readable equivalents. + * @newin{5,6} + */ + std::optional get_content2() const; /** Set the text of this content node * @param content The text. This must be unescaped, meaning that the predefined entities will be created for you where necessary. diff --git a/libxml++/nodes/element.cc b/libxml++/nodes/element.cc index ef1b6b03..64abd3f2 100644 --- a/libxml++/nodes/element.cc +++ b/libxml++/nodes/element.cc @@ -92,11 +92,22 @@ const Attribute* Element::get_attribute(const ustring& name, return const_cast(this)->get_attribute(name, ns_prefix); } +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring Element::get_attribute_value(const ustring& name, const ustring& ns_prefix) const { const auto attr = get_attribute(name, ns_prefix); return attr ? attr->get_value() : ustring(); } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional Element::get_attribute_value2( + const ustring& name, const ustring& ns_prefix) const +{ + const auto attr = get_attribute(name, ns_prefix); + if (!attr) + return {}; + return attr->get_value2(); +} Attribute* Element::set_attribute(const ustring& name, const ustring& value, const ustring& ns_prefix) diff --git a/libxml++/nodes/element.h b/libxml++/nodes/element.h index 922a26c9..8252ab31 100644 --- a/libxml++/nodes/element.h +++ b/libxml++/nodes/element.h @@ -79,16 +79,27 @@ class LIBXMLPP_API Element : public Node const Attribute* get_attribute(const ustring& name, const ustring& ns_prefix = ustring()) const; +#ifndef LIBXMLXX_DISABLE_DEPRECATED /** Get the value of the attribute with this name, and optionally with this namespace. * For finer control, you might use get_attribute() and use the methods of the Attribute class. * @param name The name of the attribute whose value will be retrieved. * @param ns_prefix Namespace prefix. * @return The text value of the attribute, or an empty string if no such attribute was found. - * - * @newin{2,20} + * @deprecated 5.6: Use get_attribute_value2() instead. */ ustring get_attribute_value(const ustring& name, const ustring& ns_prefix = ustring()) const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Get the value of the attribute with this name, and optionally with this namespace. + * For finer control, you might use get_attribute() and use the methods of the Attribute class. + * @param name The name of the attribute whose value will be retrieved. + * @param ns_prefix Namespace prefix. + * @return The text value of the attribute, or no value if no such attribute was found. + * @newin{5,6} + */ + std::optional get_attribute_value2(const ustring& name, + const ustring& ns_prefix = {}) const; /** Set the value of the attribute with this name, and optionally with this namespace. * A matching attribute will be added if no matching attribute already exists. diff --git a/libxml++/nodes/entitydeclaration.cc b/libxml++/nodes/entitydeclaration.cc index d5bfa751..ba26f409 100644 --- a/libxml++/nodes/entitydeclaration.cc +++ b/libxml++/nodes/entitydeclaration.cc @@ -17,6 +17,7 @@ EntityDeclaration::EntityDeclaration(xmlNode* node) EntityDeclaration::~EntityDeclaration() {} +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring EntityDeclaration::get_resolved_text() const { return cobj()->content ? (const char*)cobj()->content : ""; @@ -26,6 +27,21 @@ ustring EntityDeclaration::get_original_text() const { return cobj()->orig ? (const char*)cobj()->orig : ""; } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional EntityDeclaration::get_resolved_text2() const +{ + if (!cobj()->content) + return {}; + return (const char*)cobj()->content; +} + +std::optional EntityDeclaration::get_original_text2() const +{ + if (!cobj()->orig) + return {}; + return (const char*)cobj()->orig; +} xmlEntity* EntityDeclaration::cobj() noexcept { diff --git a/libxml++/nodes/entitydeclaration.h b/libxml++/nodes/entitydeclaration.h index 30d3df8d..a78f378a 100644 --- a/libxml++/nodes/entitydeclaration.h +++ b/libxml++/nodes/entitydeclaration.h @@ -29,18 +29,37 @@ class LIBXMLPP_API EntityDeclaration : public ContentNode explicit EntityDeclaration(_xmlNode* node); ~EntityDeclaration() override; +#ifndef LIBXMLXX_DISABLE_DEPRECATED /** Get the text with character references (like "ß") resolved. * If the entity declaration does not contain any reference to another entity, * this is the text that an entity reference would have resolved to, if the XML * document had been parsed with Parser::set_substitute_entities(true). * @returns The text with character references unescaped. + * @deprecated 5.6: Use get_resolved_text2() instead. */ ustring get_resolved_text() const; /** Get the text as read from the XML or DTD file. * @returns The escaped text. + * @deprecated 5.6: Use get_original_text2() instead. */ ustring get_original_text() const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Get the text with character references (like "ß") resolved. + * If the entity declaration does not contain any reference to another entity, + * this is the text that an entity reference would have resolved to, if the XML + * document had been parsed with Parser::set_substitute_entities(true). + * @returns The text with character references unescaped, if any, else no value. + * @newin{5,6} + */ + std::optional get_resolved_text2() const; + + /** Get the text as read from the XML or DTD file. + * @returns The escaped text, if any, else no value. + * @newin{5,6} + */ + std::optional get_original_text2() const; ///Access the underlying libxml implementation. _xmlEntity* cobj() noexcept; diff --git a/libxml++/nodes/entityreference.cc b/libxml++/nodes/entityreference.cc index 278a1263..18e5ccf9 100644 --- a/libxml++/nodes/entityreference.cc +++ b/libxml++/nodes/entityreference.cc @@ -18,6 +18,7 @@ EntityReference::EntityReference(xmlNode* node) EntityReference::~EntityReference() {} +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring EntityReference::get_resolved_text() const { ustring result; @@ -48,10 +49,33 @@ ustring EntityReference::get_original_text() const if(pch) result = (const char*)pch; } - return result; } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional EntityReference::get_resolved_text2() const +{ + // Get the child xmlEntity node (there should only be 1). + auto cChild = cobj()->children; + if (!(cChild && cChild->type == XML_ENTITY_DECL)) + return {}; + auto cEntity = (xmlEntity*)cChild; + if (!cEntity->content) + return {}; + return (const char*)cEntity->content; +} +std::optional EntityReference::get_original_text2() const +{ + // Get the child xmlEntity node (there should only be 1). + auto cChild = cobj()->children; + if (!(cChild && cChild->type == XML_ENTITY_DECL)) + return {}; + auto cEntity = (xmlEntity*)cChild; + if (!cEntity->orig) + return {}; + return (const char*)cEntity->orig; +} } //namespace xmlpp diff --git a/libxml++/nodes/entityreference.h b/libxml++/nodes/entityreference.h index 60a64fc7..768cb5d5 100644 --- a/libxml++/nodes/entityreference.h +++ b/libxml++/nodes/entityreference.h @@ -20,19 +20,37 @@ class LIBXMLPP_API EntityReference : public Node explicit EntityReference(_xmlNode* node); ~EntityReference() override; +#ifndef LIBXMLXX_DISABLE_DEPRECATED /** Get the text with character references (like "ß") resolved. * If the corresponding entity declaration does not contain any reference to * another entity, this is the text that the reference would have resolved to * if the XML document had been parsed with Parser::set_substitute_entities(true). * @returns The text with character references unescaped. + * @deprecated 5.6: Use get_resolved_text2() instead. */ ustring get_resolved_text() const; /** Get the text as read from the XML or DTD file. * @returns The escaped text. + * @deprecated 5.6: Use get_original_text2() instead. */ ustring get_original_text() const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + /** Get the text with character references (like "ß") resolved. + * If the corresponding entity declaration does not contain any reference to + * another entity, this is the text that the reference would have resolved to + * if the XML document had been parsed with Parser::set_substitute_entities(true). + * @returns The text with character references unescaped, if any, else no value. + * @newin{5,6} + */ + std::optional get_resolved_text2() const; + + /** Get the text as read from the XML or DTD file. + * @returns The escaped text, if any, else no value. + * @newin{5,6} + */ + std::optional get_original_text2() const; }; } // namespace xmlpp diff --git a/libxml++/nodes/node.cc b/libxml++/nodes/node.cc index d3ead850..cdf03ee4 100644 --- a/libxml++/nodes/node.cc +++ b/libxml++/nodes/node.cc @@ -406,10 +406,19 @@ Node* Node::import_node(const Node* node, bool recursive) return static_cast(added_node->_private); } +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring Node::get_name() const { return impl_->name ? (const char*)impl_->name : ""; } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional Node::get_name2() const +{ + if (!impl_->name) + return {}; + return (const char*)impl_->name; +} void Node::set_name(const ustring& name) { @@ -432,6 +441,7 @@ const xmlNode* Node::cobj() const noexcept return impl_; } +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring Node::get_path() const { xmlChar* path = xmlGetNodePath(impl_); @@ -439,6 +449,17 @@ ustring Node::get_path() const xmlFree(path); return retn; } +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional Node::get_path2() const +{ + xmlChar* path = xmlGetNodePath(impl_); + if (!path) + return {}; + std::optional result = (char*)path; + xmlFree(path); + return result; +} Node::NodeSet Node::find(const ustring& xpath) { @@ -505,11 +526,23 @@ ustring Node::eval_to_string(const ustring& xpath, const PrefixNsMap& namespaces return eval_common_to_string(xpath, &namespaces, result_type, impl_); } +#ifndef LIBXMLXX_DISABLE_DEPRECATED ustring Node::get_namespace_prefix() const { - if(impl_->type == XML_DOCUMENT_NODE || - impl_->type == XML_HTML_DOCUMENT_NODE || - impl_->type == XML_ENTITY_DECL) + return get_namespace_prefix2().value_or(""); +} + +ustring Node::get_namespace_uri() const +{ + return get_namespace_uri2().value_or(""); +} +#endif // LIBXMLXX_DISABLE_DEPRECATED + +std::optional Node::get_namespace_prefix2() const +{ + if (impl_->type == XML_DOCUMENT_NODE || + impl_->type == XML_HTML_DOCUMENT_NODE || + impl_->type == XML_ENTITY_DECL) { //impl_ is actually of type xmlDoc or xmlEntity, instead of just xmlNode. //libxml does not always use GObject-style inheritance, so xmlDoc and @@ -517,22 +550,24 @@ ustring Node::get_namespace_prefix() const //Therefore, a call to impl_->ns would be invalid. //This can be an issue when calling this method on a Node returned by Node::find(). //See the TODO comment on Document, suggesting that Document should derive from Node. - - return ustring(); + return {}; } - else if (impl_->type == XML_ATTRIBUTE_DECL) + + if (impl_->type == XML_ATTRIBUTE_DECL) { - //impl_ is actually of type xmlAttribute, instead of just xmlNode. + // impl_ is actually of type xmlAttribute, instead of just xmlNode. auto attr = reinterpret_cast(impl_); - return attr->prefix ? (const char*)attr->prefix : ""; + if (!attr->prefix) + return {}; + return (const char*)attr->prefix; } - else if(impl_->ns && impl_->ns->prefix) - return (char*)impl_->ns->prefix; - else - return ustring(); + + if (!(impl_->ns && impl_->ns->prefix)) + return {}; + return (const char*)impl_->ns->prefix; } -ustring Node::get_namespace_uri() const +std::optional Node::get_namespace_uri2() const { if(impl_->type == XML_DOCUMENT_NODE || impl_->type == XML_HTML_DOCUMENT_NODE || @@ -545,14 +580,12 @@ ustring Node::get_namespace_uri() const //Therefore, a call to impl_->ns would be invalid. //This can be an issue when calling this method on a Node returned by Node::find(). //See the TODO comment on Document, suggesting that Document should derived from Node. - - return ustring(); + return {}; } - if(impl_->ns && impl_->ns->href) - return (char*)impl_->ns->href; - else - return ustring(); + if (!(impl_->ns && impl_->ns->href)) + return {}; + return (const char*)impl_->ns->href; } void Node::set_namespace(const ustring& ns_prefix) diff --git a/libxml++/nodes/node.h b/libxml++/nodes/node.h index fa1182bc..c0693600 100644 --- a/libxml++/nodes/node.h +++ b/libxml++/nodes/node.h @@ -12,6 +12,7 @@ #include "libxml++/ustring.h" #include #include +#include #include #include @@ -68,10 +69,19 @@ class LIBXMLPP_API Node : public NonCopyable */ ~Node() override; +#ifndef LIBXMLXX_DISABLE_DEPRECATED /** Get the name of this node. * @returns The node's name. + * @deprecated 5.6: Use get_name2() instead. */ ustring get_name() const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Get the name of this node. + * @returns The node's name, if any, else no value. + * @newin{5,6} + */ + std::optional get_name2() const; /** Set the name of this node. * @param name The new name for the node. @@ -85,15 +95,31 @@ class LIBXMLPP_API Node : public NonCopyable */ void set_namespace(const ustring& ns_prefix); +#ifndef LIBXMLXX_DISABLE_DEPRECATED /** Get the namespace prefix of this node. * @returns The node's namespace prefix. Can be an empty string. + * @deprecated 5.6: Use get_namespace_prefix2() instead. */ ustring get_namespace_prefix() const; /** Get the namespace URI of this node. * @returns The node's namespace URI. Can be an empty string. + * @deprecated 5.6: Use get_namespace_uri2() instead. */ ustring get_namespace_uri() const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Get the namespace prefix of this node. + * @returns The node's namespace prefix, or no value if the node has no namespace prefix. + * @newin{5,6} + */ + std::optional get_namespace_prefix2() const; + + /** Get the namespace URI of this node. + * @returns The node's namespace URI, or no value if the node has no namespace URI. + * @newin{5,6} + */ + std::optional get_namespace_uri2() const; /** Discover at what line number this node occurs in the XML file. * @returns The line number. @@ -187,11 +213,19 @@ class LIBXMLPP_API Node : public NonCopyable */ Node* import_node(const Node* node, bool recursive = true); - +#ifndef LIBXMLXX_DISABLE_DEPRECATED /** Get the XPath of this node. * @result The XPath of the node. + * @deprecated 5.6: Use get_path2() instead. */ ustring get_path() const; +#endif // LIBXMLXX_DISABLE_DEPRECATED + + /** Get the XPath of this node. + * @result The XPath of the node, or no value in case of error. + * @newin{5,6} + */ + std::optional get_path2() const; /** Find nodes from an XPath expression. * @param xpath The XPath of the nodes. diff --git a/tests/istream_ioparser/main.cc b/tests/istream_ioparser/main.cc index b94dc825..906d57f5 100644 --- a/tests/istream_ioparser/main.cc +++ b/tests/istream_ioparser/main.cc @@ -107,7 +107,7 @@ int main() { auto doc = parser.get_document(); - assert(doc->get_root_node()->get_name() == "root"); + assert(doc->get_root_node()->get_name2() == "root"); } { @@ -120,7 +120,7 @@ int main() } assert(buf.underflow_calls + buf.uflow_calls < 3); auto doc = parser.get_document(); - assert(doc->get_root_node()->get_name() == "root"); + assert(doc->get_root_node()->get_name2() == "root"); } } { // Check SaxParser works well with normal and custom istreams. From 4819ea5e5dfda475bdc2d6ab9377b8c7c080540b Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Thu, 12 Dec 2024 15:25:57 +0100 Subject: [PATCH 233/240] CI: Update publish-docs.yml Use actions/upload-pages-artifact@v3 instead of v1, to avoid a soon deprecated version of upload-artifact. --- .github/workflows/publish-docs.yml | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index eb4009f1..c4a885b4 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -1,11 +1,11 @@ # Sample workflow for building and deploying a Jekyll site to GitHub Pages # Copied from https://github.com/libxmlplusplus/libxmlplusplus/actions/new -# and changed. Actions -> New workflow -> Pages -> Jekyll +# and changed. Actions -> New workflow -> Pages -> GitHub Pages Jekyll name: Publish docs -# 2024-07-15: ubuntu-latest = ubuntu-22.04 +# 2024-12-12: ubuntu-latest = ubuntu-22.04 # See https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories on: # Runs on pushes targeting the default branch @@ -21,10 +21,11 @@ permissions: pages: write id-token: write -# Allow one concurrent deployment +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. concurrency: group: "pages" - cancel-in-progress: true + cancel-in-progress: false jobs: # Build job @@ -32,7 +33,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Build run: | # Prevent blocking apt install on a question during configuring of tzdata. @@ -55,14 +56,14 @@ jobs: mv _build/docs/manual/html _publish/manual mv _build/docs/reference/html _publish/reference - name: Setup Pages - uses: actions/configure-pages@v2 + uses: actions/configure-pages@v5 - name: Build with Jekyll uses: actions/jekyll-build-pages@v1 with: source: ./_publish destination: ./_site - name: Upload artifact - uses: actions/upload-pages-artifact@v1 + uses: actions/upload-pages-artifact@v3 # Deployment job # Publish documentation at https://libxmlplusplus.github.io/libxmlplusplus/ @@ -75,5 +76,5 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v1 + uses: actions/deploy-pages@v4 From 1f48d89e4540f7fdf47b128ac44bd19235664b0a Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Tue, 21 Jan 2025 09:13:04 +0100 Subject: [PATCH 234/240] Meson build: Simplify some get_variable() calls * docs/reference/meson.build: dependency().get_variable(pkgconfig: 'varname', internal: 'varname') -> dependency().get_variable('varname'). Possible when meson version >= 0.58. --- docs/reference/meson.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/reference/meson.build b/docs/reference/meson.build index 19302569..0ea195d0 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -17,7 +17,7 @@ docinstall_flags = [] foreach module : tag_file_modules depmod = dependency(module, required: false) if depmod.found() - doxytagfile = depmod.get_variable(pkgconfig: 'doxytagfile', internal: 'doxytagfile', default_value: '') + doxytagfile = depmod.get_variable('doxytagfile', default_value: '') if doxytagfile != '' if depmod.type_name() == 'internal' # Subprojects must build their tag files before doxygen is called. @@ -27,8 +27,8 @@ foreach module : tag_file_modules doxygen_tag_targets += subproject(module).get_variable('global_tag_file_target') endif endif - htmlrefpub = depmod.get_variable(pkgconfig: 'htmlrefpub', internal: 'htmlrefpub', default_value: '') - htmlrefdir = depmod.get_variable(pkgconfig: 'htmlrefdir', internal: 'htmlrefdir', default_value: '') + htmlrefpub = depmod.get_variable('htmlrefpub', default_value: '') + htmlrefdir = depmod.get_variable('htmlrefdir', default_value: '') if htmlrefpub == '' htmlrefpub = htmlrefdir elif htmlrefdir == '' From 52bbe149d5b7096f36fb124b1467313225eb57e0 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Wed, 12 Feb 2025 19:22:15 +0100 Subject: [PATCH 235/240] Meson build: Add install_tag keyword argument --- docs/manual/meson.build | 3 ++- docs/reference/meson.build | 4 +++- examples/meson.build | 3 ++- meson.build | 2 ++ tests/meson.build | 3 ++- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/manual/meson.build b/docs/manual/meson.build index 940ecdeb..1c69899d 100644 --- a/docs/manual/meson.build +++ b/docs/manual/meson.build @@ -72,7 +72,8 @@ custom_target('manual_html', ], build_by_default: true, install: true, - install_dir: install_tutorialdir + install_dir: install_tutorialdir, + install_tag: 'doc', ) if can_parse_and_validate diff --git a/docs/reference/meson.build b/docs/reference/meson.build index 0ea195d0..72c7077f 100644 --- a/docs/reference/meson.build +++ b/docs/reference/meson.build @@ -102,6 +102,7 @@ tag_file = custom_target('html_and_tag', build_by_default: build_documentation, install: true, install_dir: install_reference_docdir, + install_tag: 'doc', ) devhelp_file = custom_target('devhelp', @@ -125,7 +126,8 @@ meson.add_install_script( devhelp_file.full_path(), install_devhelpdir, install_reference_docdir / 'html', - docinstall_flags + docinstall_flags, + install_tag: 'doc', ) # Distribute built files and files copied by mm-common-get. diff --git a/examples/meson.build b/examples/meson.build index 938e1c03..e9d9bd60 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -39,7 +39,8 @@ foreach ex : example_programs exe_file = executable(ex_name, ex_sources, dependencies: xmlxx_own_dep, implicit_include_directories: false, - build_by_default: build_examples + build_by_default: build_examples, + install: false, ) if build_examples diff --git a/meson.build b/meson.build index b599220d..ca525da2 100644 --- a/meson.build +++ b/meson.build @@ -300,7 +300,9 @@ configure_file( input: xmlxxconfig_h_meson, output: 'libxml++config.h', configuration: pkg_conf_data, + install: true, install_dir: install_includeconfigdir, + install_tag: 'devel', ) subdir('MSVC_NMake/libxml++') diff --git a/tests/meson.build b/tests/meson.build index 7dd04142..161a6462 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -25,7 +25,8 @@ foreach ex : test_programs exe_file = executable(ex_name, ex_sources, dependencies: xmlxx_own_dep, implicit_include_directories: false, - build_by_default: build_tests + build_by_default: build_tests, + install: false, ) if build_tests From 9ab8b9b640cb9a0c6572df77652dbe537d228ee1 Mon Sep 17 00:00:00 2001 From: Tom spot Callaway Date: Tue, 25 Mar 2025 11:59:36 -0400 Subject: [PATCH 236/240] remove invalid FSF licenses from license text and in-file attributions Signed-off-by: Tom spot Callaway --- COPYING | 5 ++--- examples/dom_build/main.cc | 3 +-- examples/dom_parse_entities/main.cc | 3 +-- examples/dom_parser/main.cc | 3 +-- examples/dom_parser_raw/main.cc | 3 +-- examples/dom_read_write/main.cc | 3 +-- examples/dom_xpath/main.cc | 3 +-- examples/dtdvalidation/main.cc | 3 +-- examples/sax_exception/main.cc | 3 +-- examples/sax_exception/myparser.cc | 3 +-- examples/sax_exception/myparser.h | 3 +-- examples/sax_parser/main.cc | 3 +-- examples/sax_parser/myparser.cc | 3 +-- examples/sax_parser/myparser.h | 3 +-- examples/sax_parser_build_dom/main.cc | 3 +-- examples/sax_parser_build_dom/svgdocument.cc | 3 +-- examples/sax_parser_build_dom/svgdocument.h | 3 +-- examples/sax_parser_build_dom/svgelement.cc | 3 +-- examples/sax_parser_build_dom/svgelement.h | 3 +-- examples/sax_parser_build_dom/svggroup.h | 3 +-- examples/sax_parser_build_dom/svgparser.cc | 3 +-- examples/sax_parser_build_dom/svgparser.h | 3 +-- examples/sax_parser_build_dom/svgpath.h | 3 +-- examples/sax_parser_entities/main.cc | 3 +-- examples/sax_parser_entities/myparser.cc | 3 +-- examples/sax_parser_entities/myparser.h | 3 +-- examples/schemavalidation/main.cc | 3 +-- examples/textreader/main.cc | 3 +-- libxml++/exceptions/exception.h | 3 +-- libxml++/exceptions/internal_error.h | 3 +-- libxml++/exceptions/parse_error.h | 3 +-- libxml++/exceptions/validity_error.h | 3 +-- libxml++/exceptions/wrapped_exception.cc | 3 +-- libxml++/exceptions/wrapped_exception.h | 3 +-- libxml++/ustring.h | 3 +-- tests/Makefile.am | 3 +-- tests/istream_ioparser/main.cc | 3 +-- tests/saxparser_chunk_parsing_inconsistent_state/main.cc | 3 +-- tests/saxparser_parse_double_free/main.cc | 3 +-- tests/saxparser_parse_stream_inconsistent_state/main.cc | 3 +-- 40 files changed, 41 insertions(+), 81 deletions(-) diff --git a/COPYING b/COPYING index b1e3f5a2..2551a65a 100644 --- a/COPYING +++ b/COPYING @@ -2,7 +2,7 @@ Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -484,8 +484,7 @@ convey the exclusion of warranty; and each file should have at least the Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + License along with this library; if not, see . Also add information on how to contact you by electronic and paper mail. diff --git a/examples/dom_build/main.cc b/examples/dom_build/main.cc index fcaef275..2fd160e9 100644 --- a/examples/dom_build/main.cc +++ b/examples/dom_build/main.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include diff --git a/examples/dom_parse_entities/main.cc b/examples/dom_parse_entities/main.cc index f3e7c552..f3295cd2 100644 --- a/examples/dom_parse_entities/main.cc +++ b/examples/dom_parse_entities/main.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include diff --git a/examples/dom_parser/main.cc b/examples/dom_parser/main.cc index e9264a4f..85dd5b7b 100644 --- a/examples/dom_parser/main.cc +++ b/examples/dom_parser/main.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include diff --git a/examples/dom_parser_raw/main.cc b/examples/dom_parser_raw/main.cc index 3ab9bf85..3d1fc38d 100644 --- a/examples/dom_parser_raw/main.cc +++ b/examples/dom_parser_raw/main.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include diff --git a/examples/dom_read_write/main.cc b/examples/dom_read_write/main.cc index 3cdba11f..3d9a115a 100644 --- a/examples/dom_read_write/main.cc +++ b/examples/dom_read_write/main.cc @@ -15,8 +15,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifdef HAVE_CONFIG_H diff --git a/examples/dom_xpath/main.cc b/examples/dom_xpath/main.cc index f9b7b180..1df4884a 100644 --- a/examples/dom_xpath/main.cc +++ b/examples/dom_xpath/main.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include diff --git a/examples/dtdvalidation/main.cc b/examples/dtdvalidation/main.cc index 8ac0a314..d1abbfce 100644 --- a/examples/dtdvalidation/main.cc +++ b/examples/dtdvalidation/main.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ diff --git a/examples/sax_exception/main.cc b/examples/sax_exception/main.cc index 2b5407ed..67d77553 100644 --- a/examples/sax_exception/main.cc +++ b/examples/sax_exception/main.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ /* This example is nearly the same than sax_parser, but demonstrate how exception diff --git a/examples/sax_exception/myparser.cc b/examples/sax_exception/myparser.cc index 5004b251..85833fdd 100644 --- a/examples/sax_exception/myparser.cc +++ b/examples/sax_exception/myparser.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include "myparser.h" diff --git a/examples/sax_exception/myparser.h b/examples/sax_exception/myparser.h index 7ac22901..4aa15f02 100644 --- a/examples/sax_exception/myparser.h +++ b/examples/sax_exception/myparser.h @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_EXAMPLES_MYPARSER_H diff --git a/examples/sax_parser/main.cc b/examples/sax_parser/main.cc index 0cb5adc0..16265482 100644 --- a/examples/sax_parser/main.cc +++ b/examples/sax_parser/main.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifdef HAVE_CONFIG_H diff --git a/examples/sax_parser/myparser.cc b/examples/sax_parser/myparser.cc index 5c929479..fb8335c4 100644 --- a/examples/sax_parser/myparser.cc +++ b/examples/sax_parser/myparser.cc @@ -15,8 +15,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include "myparser.h" diff --git a/examples/sax_parser/myparser.h b/examples/sax_parser/myparser.h index 9dde6643..dc45c429 100644 --- a/examples/sax_parser/myparser.h +++ b/examples/sax_parser/myparser.h @@ -15,8 +15,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_EXAMPLES_MYPARSER_H diff --git a/examples/sax_parser_build_dom/main.cc b/examples/sax_parser_build_dom/main.cc index 21927b65..bfbd26a6 100644 --- a/examples/sax_parser_build_dom/main.cc +++ b/examples/sax_parser_build_dom/main.cc @@ -15,8 +15,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include diff --git a/examples/sax_parser_build_dom/svgdocument.cc b/examples/sax_parser_build_dom/svgdocument.cc index b9190536..82387312 100644 --- a/examples/sax_parser_build_dom/svgdocument.cc +++ b/examples/sax_parser_build_dom/svgdocument.cc @@ -15,8 +15,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include "svgdocument.h" diff --git a/examples/sax_parser_build_dom/svgdocument.h b/examples/sax_parser_build_dom/svgdocument.h index 9c343919..f0f32e2d 100644 --- a/examples/sax_parser_build_dom/svgdocument.h +++ b/examples/sax_parser_build_dom/svgdocument.h @@ -15,8 +15,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_SVGDOCUMENT_H diff --git a/examples/sax_parser_build_dom/svgelement.cc b/examples/sax_parser_build_dom/svgelement.cc index de17d4e4..fc7fde62 100644 --- a/examples/sax_parser_build_dom/svgelement.cc +++ b/examples/sax_parser_build_dom/svgelement.cc @@ -15,8 +15,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include "svgelement.h" diff --git a/examples/sax_parser_build_dom/svgelement.h b/examples/sax_parser_build_dom/svgelement.h index 362869e6..c371990f 100644 --- a/examples/sax_parser_build_dom/svgelement.h +++ b/examples/sax_parser_build_dom/svgelement.h @@ -15,8 +15,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_SVGELEMENT_H diff --git a/examples/sax_parser_build_dom/svggroup.h b/examples/sax_parser_build_dom/svggroup.h index 3502ad4e..d4f3c905 100644 --- a/examples/sax_parser_build_dom/svggroup.h +++ b/examples/sax_parser_build_dom/svggroup.h @@ -15,8 +15,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_SVGGROUP_H diff --git a/examples/sax_parser_build_dom/svgparser.cc b/examples/sax_parser_build_dom/svgparser.cc index 89f9e529..fe32385b 100644 --- a/examples/sax_parser_build_dom/svgparser.cc +++ b/examples/sax_parser_build_dom/svgparser.cc @@ -15,8 +15,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include diff --git a/examples/sax_parser_build_dom/svgparser.h b/examples/sax_parser_build_dom/svgparser.h index ef28c29a..111d9ac0 100644 --- a/examples/sax_parser_build_dom/svgparser.h +++ b/examples/sax_parser_build_dom/svgparser.h @@ -15,8 +15,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_SVGPARSER_H diff --git a/examples/sax_parser_build_dom/svgpath.h b/examples/sax_parser_build_dom/svgpath.h index bc75970a..2d9e7f98 100644 --- a/examples/sax_parser_build_dom/svgpath.h +++ b/examples/sax_parser_build_dom/svgpath.h @@ -15,8 +15,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_SVGPATH_H diff --git a/examples/sax_parser_entities/main.cc b/examples/sax_parser_entities/main.cc index 97948873..e2d558c2 100644 --- a/examples/sax_parser_entities/main.cc +++ b/examples/sax_parser_entities/main.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifdef HAVE_CONFIG_H diff --git a/examples/sax_parser_entities/myparser.cc b/examples/sax_parser_entities/myparser.cc index a19cdf6e..d8b4a980 100644 --- a/examples/sax_parser_entities/myparser.cc +++ b/examples/sax_parser_entities/myparser.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include "myparser.h" diff --git a/examples/sax_parser_entities/myparser.h b/examples/sax_parser_entities/myparser.h index 312667c2..61d2f6f6 100644 --- a/examples/sax_parser_entities/myparser.h +++ b/examples/sax_parser_entities/myparser.h @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_EXAMPLES_MYPARSER_H diff --git a/examples/schemavalidation/main.cc b/examples/schemavalidation/main.cc index a5de5e07..2c6fb29d 100644 --- a/examples/schemavalidation/main.cc +++ b/examples/schemavalidation/main.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifdef HAVE_CONFIG_H diff --git a/examples/textreader/main.cc b/examples/textreader/main.cc index 16d72187..da5d85b4 100644 --- a/examples/textreader/main.cc +++ b/examples/textreader/main.cc @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #include diff --git a/libxml++/exceptions/exception.h b/libxml++/exceptions/exception.h index 7a657222..b86269b5 100644 --- a/libxml++/exceptions/exception.h +++ b/libxml++/exceptions/exception.h @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_EXCEPTION_H diff --git a/libxml++/exceptions/internal_error.h b/libxml++/exceptions/internal_error.h index 2ad6fe19..0126247d 100644 --- a/libxml++/exceptions/internal_error.h +++ b/libxml++/exceptions/internal_error.h @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_INTERNAL_ERROR_H diff --git a/libxml++/exceptions/parse_error.h b/libxml++/exceptions/parse_error.h index 50ebc8d6..c4185fc0 100644 --- a/libxml++/exceptions/parse_error.h +++ b/libxml++/exceptions/parse_error.h @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_PARSE_ERROR_H diff --git a/libxml++/exceptions/validity_error.h b/libxml++/exceptions/validity_error.h index d8831b4f..1a1ab0ad 100644 --- a/libxml++/exceptions/validity_error.h +++ b/libxml++/exceptions/validity_error.h @@ -13,8 +13,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_VALIDITY_ERROR_H diff --git a/libxml++/exceptions/wrapped_exception.cc b/libxml++/exceptions/wrapped_exception.cc index 00cdc37f..6044a7e1 100644 --- a/libxml++/exceptions/wrapped_exception.cc +++ b/libxml++/exceptions/wrapped_exception.cc @@ -11,8 +11,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see . */ #include "wrapped_exception.h" diff --git a/libxml++/exceptions/wrapped_exception.h b/libxml++/exceptions/wrapped_exception.h index ad60f88e..f523e319 100644 --- a/libxml++/exceptions/wrapped_exception.h +++ b/libxml++/exceptions/wrapped_exception.h @@ -11,8 +11,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see . */ #ifndef __LIBXMLPP_WRAPPED_EXCEPTION_H diff --git a/libxml++/ustring.h b/libxml++/ustring.h index fabb3ffb..97a53461 100644 --- a/libxml++/ustring.h +++ b/libxml++/ustring.h @@ -12,8 +12,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see . * */ diff --git a/tests/Makefile.am b/tests/Makefile.am index ad58ba03..734ca14b 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -11,8 +11,7 @@ ## Lesser General Public License for more details. ## ## You should have received a copy of the GNU Lesser General Public -## License along with this library; if not, write to the Free Software -## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +## License along with this library; if not, see . AM_CPPFLAGS = -I$(top_builddir) -I$(top_srcdir) -I. $(LIBXMLXX_CFLAGS) AM_CXXFLAGS = $(LIBXMLXX_WXXFLAGS) diff --git a/tests/istream_ioparser/main.cc b/tests/istream_ioparser/main.cc index 906d57f5..61f5833c 100644 --- a/tests/istream_ioparser/main.cc +++ b/tests/istream_ioparser/main.cc @@ -11,8 +11,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see . */ #include diff --git a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc index 53f55b3f..a6ee1787 100644 --- a/tests/saxparser_chunk_parsing_inconsistent_state/main.cc +++ b/tests/saxparser_chunk_parsing_inconsistent_state/main.cc @@ -11,8 +11,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see . */ #include diff --git a/tests/saxparser_parse_double_free/main.cc b/tests/saxparser_parse_double_free/main.cc index 75ef6c9d..395bf6ed 100644 --- a/tests/saxparser_parse_double_free/main.cc +++ b/tests/saxparser_parse_double_free/main.cc @@ -11,8 +11,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see . */ #include diff --git a/tests/saxparser_parse_stream_inconsistent_state/main.cc b/tests/saxparser_parse_stream_inconsistent_state/main.cc index 795d5848..8e319284 100644 --- a/tests/saxparser_parse_stream_inconsistent_state/main.cc +++ b/tests/saxparser_parse_stream_inconsistent_state/main.cc @@ -11,8 +11,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * License along with this library; if not, see . */ #include From e7c72ef72133a5620319193d5c141f4ba9369022 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 28 Apr 2025 15:02:45 +0200 Subject: [PATCH 237/240] Remove ChangeLog.pre-2-36-0 --- ChangeLog.pre-2-36-0 | 2839 ------------------------------------------ 1 file changed, 2839 deletions(-) delete mode 100644 ChangeLog.pre-2-36-0 diff --git a/ChangeLog.pre-2-36-0 b/ChangeLog.pre-2-36-0 deleted file mode 100644 index 0b836fe1..00000000 --- a/ChangeLog.pre-2-36-0 +++ /dev/null @@ -1,2839 +0,0 @@ -2.36.0: - -2012-10-25 Kjell Ahlstedt - - Element::set_namespace_declaration(): No error to set the same URI twice. - - * libxml++/nodes/element.[h|cc]: Don't throw an exception from - set_namespace_declaration(), if a namespace prefix is assigned the same URI - twice. Bug #635846, comment 27. - -2012-10-10 Kjell Ahlstedt - - Require libxml-2.0 >= 2.7.3. - - * configure.ac: Require libxml-2.0 >= 2.7.3. - Don't know if it's really necessary, but 2.7.2 from 2008-10-03 is the oldest - release available at ftp://xmlsoft.org/libxml2, and 2.7.2 contains a bug that - makes examples/import_node segfault. - -2012-10-10 Kjell Ahlstedt - - Parser::initialize_context(): Call xmlCtxtUseOptions(). - - * libxml++/parsers/parser.cc: initialize_context(): Call xmlCtxtUseOptions() - instead of setting context_->validate and replaceEntities. - xmlCtxtUseOptions() does that and more. - -2.35.4: - -2012-08-28 Kjell Ahlstedt - - Add XInclude processing. - - * Makefile.am: Add XIncludeStart and XIncludeEnd nodes. - * examples/Makefile.am: Add dom_xinclude example. - * examples/README: Add dom_xinclude example and other missing examples. - * examples/dom_xinclude/example.xml: - * examples/dom_xinclude/include1.txt: - * examples/dom_xinclude/include2.xml: - * examples/dom_xinclude/main.cc: New files. - * libxml++/document.[h|cc]: Add process_xinclude(). - * libxml++/libxml++.h: Add new header files. - * libxml++/nodes/node.cc: create_wrapper(): Create XIncludeStart and - XIncludeEnd nodes. - * libxml++/nodes/xincludeend.[h|cc]: - * libxml++/nodes/xincludestart.[h|cc]: New files. - * .gitignore: Ignore /examples/dom_xinclude/dom_xinclude. Bug #338521. - -2012-08-28 Kjell Ahlstedt - - Parser: Make it thread-safe. - - * configure.ac: Require glibmm-2.4 >= 2.32.0. - * libxml++/parsers/parser.cc: Protect all accesses to extra_parser_data with - a Glib::Threads::Mutex. Bug #681467. - -2012-08-10 Kjell Ahlstedt - - Document: Make the Document(xmlDoc*) constructor public. - - * libxml++/document.h: Make the Document(xmlDoc*) constructor public. - Remove friend declarations that become unnecessary. Bug #668980. - -2012-08-09 Kjell Ahlstedt - - Improve the DtdValidation and SchemaValidation example programs. - - * examples/dtdvalidation/main.cc: - * examples/schemavalidation/main.cc: Print all information from all thrown - xmlpp exceptions. - -2012-08-09 Kjell Ahlstedt - - Validators: Improve the error handling. - - * libxml++/validators/validator.[h|cc]: - * libxml++/validators/dtdvalidator.[h|cc]: - * libxml++/validators/schemavalidator.[h|cc]: Check more return codes from - libxml2 functions. Improve the description of member functions in the - reference documentation. Bug #635846. - -2012-08-07 Kjell Ahlstedt - - Add incremental parsing to the SaxParser example program. - - * examples/sax_parser/main.cc: Uncomment and correct the code that shows - incremental parsing with SaxParser::parse_chunk(). - -2012-08-07 Kjell Ahlstedt - - Parsers: Improve the error handling. - - * libxml++/parsers/domparser.[h|cc]: - * libxml++/parsers/saxparser.[h|cc]: - * libxml++/parsers/textreader.[h|cc]: Check more return codes from libxml2 - functions. Improve the description of errors in the reference documentation. - Bug #635846. - -2012-08-07 Kjell Ahlstedt - - Document, Element, Node: Remove unnecessary tests for null pointers. - - * libxml++/document.cc: - * libxml++/nodes/element.cc: - * libxml++/nodes/node.cc: Remove tests for null pointer before calling - xmlFreeNode(), which does nothing if given a null pointer. These unnecessary - tests were newly added when error handling was improved. Bug #635846. - -2012-08-05 Kjell Ahlstedt - - Schema::set_document(): Create empty document. - - * libxml++/schema.[h|cc]: set_document(): If the argument 'document' is 0, - create an empty document, as the documentation says. - -2012-08-05 Kjell Ahlstedt - - Document, Schema: Improve the error handling. - - * libxml++/document.[h|cc]: - * libxml++/schema.[h|cc]: Check more return codes from libxml2 functions. - Improve the description of errors in the reference documentation. Bug #635846. - -2012-08-02 Kjell Ahlstedt - - Element, Node: Improve the error handling. - - * libxml++/nodes/element.[h|cc]: - * libxml++/nodes/node.[h|cc]: Check more return codes from libxml2 functions. - Improve the description of errors in the reference documentation. Bug #635846. - -2.35.3: - -2012-06-19 Kjell Ahlstedt - - Add examples/Makefile.am. Let 'make check' run the examples. - - * examples/Makefile.am: New file. Let 'make check' both compile and run the - example programs. - * Makefile.am: Call examples/Makefile. Move all 'examples' stuff to - examples/Makefile.am. - * configure.ac: Remove --enable-examples. Generate examples/Makefile. - * .gitignore: Ignore make-check-sh. Bug #678390. - -2012-06-19 Kjell Ahlstedt - - Example programs: Fix return codes and print errors on std::cerr. - - * examples/*/main.cc: Return EXIT_FAILURE in case of failure. Print error - messages on std::cerr. The example programs can then be run by 'make check'. - Bug #678390. - -2012-04-20 Kjell Ahlstedt - - Node: Add functions eval_to_[boolean|number|string](). - - * examples/dom_xpath/example.xml: Add an element with numeric value. - * examples/dom_xpath/main.cc: Add calls to the new functions. - * libxml++/nodes/node.[h|cc]: - Add the functions eval_to_[boolean|number|string](). Bug #316244. - -2012-04-19 Kjell Ahlstedt - - Node: Make the previous fix thread-safe. - - * libxml++/nodes/node.cc: Delete the C++ wrapper of a deleted attribute node - without using xmlDeregisterNodeDefault. Bug #672992 comments 9-12. - -2012-04-19 Kjell Ahlstedt - - Node: Fix memory problems in import_node(). - - * libxml++/nodes/node.[h|cc]: Return added_node instead of imported_node, - which libxml2 may delete. Delete the C++ wrapper of a deleted attribute node. - * examples/import_node/example[1|2].xml: - * examples/import_node/main.cc: Import attributes and a text node which is - merged with an existing text node. Bug #672992. - -2012-04-12 Kjell Ahlstedt - - Define LIBXMLCPP_EXCEPTIONS_ENABLED unconditionally. - - * configure.ac: Add AC_DEFINE([LIBXMLCPP_EXCEPTIONS_ENABLED],[1],... - -2012-03-30 Murray Cumming - - Node: Check for a null pointer, to fix a scan-build warning. - - * libxml++/nodes/node.cc: This seems unlikely. - -2.35.2: - -2012-03-21 Murray Cumming - - Fix a warning found by clang++ - - * libxml++/parsers/textreader.h: PropertyReader is a class, not - a struct. - -2012-03-20 Murray Cumming - - Remove the --disable-api-exceptions configure option. - - And remove the #ifdefs and #else blocks from the code. - This is not used by anybody now, as far as I know, so this makes the - code easier to maintain. - -2012-03-20 Murray Cumming - - A fix for the previous commit. - - * libxml++/nodes/node.cc: get_first_child() const: Use the name - parameter. - -2012-03-19 Murray Cumming - - Node: Add get_first_child(). - - * libxml++/nodes/node.[h|cc]: This is like get_children(), - but it returns only the first node, optionally returning - the first one with a certain name. - Based on a patch by Ilya Murav'jov in bug #648125 . - -2.35.1: - -2012-02-15 Kjell Ahlstedt - - Handle attributes with default values correctly. - - * libxml++/attributedeclaration.[h|cc]: - * libxml++/attributenode.[h|cc]: New files. - * Makefile.am: - * libxml++/Makefile.am: Add the new files. - * libxml++/libxml++.h: Add the new .h files. - * docs/manual/libxml++_without_code.xml: Add AttributeDeclaration and - AttributeNode in the list of node classes. - * libxml++/attribute.[h|cc]: Make get_value() useful also for default values - (XML_ATTRIBUTE_DECL). Fix set_value() for attributes in a namespace. - * libxml++/nodes/element.[h|cc]: get_attribute(): Add description. Don't use - xmlHasProp(), it ignores namespace. - * libxml++/nodes/node.cc: get_namespace_prefix(), get_namespace_uri(), - set_namespace(), create_wrapper(): Add code for XML_ATTRIBUTE_DECL. - * examples/dom_parser/example.dtd: Add attribute 'title' with default value. - * examples/dom_parser/example.xml: Add attribute 'title' with explicit value. - Bug #669635. - -2012-02-15 Kjell Ahlstedt - - Node: Correct mis-spelt LIBXMLCPP_EXCEPTIONS_ENABLED. - - * libxml++/nodes/node.h: Add some "@throws exception". - * libxml++/nodes/node.cc: Change LIBXMLCPP_EXCEPTIONS_ENABLE to - LIBXMLCPP_EXCEPTIONS_ENABLED in find_impl() and set_namespace(). - -2012-02-15 Kjell Ahlstedt - - Improved handling of entity references and processing instructions. - - * libxml++/nodes/entitydeclaration.[h|cc]: New files. - * Makefile.am: - * libxml++/Makefile.am: Add the new files. - * libxml++/libxml++.h: Add the new .h file. - * docs/manual/libxml++_without_code.xml: Add EntityDeclaration in the list - of node classes. - * libxml++/document.[h|cc]: Add add_processing_instruction(). - * libxml++/nodes/element.[h|cc]: Add add_child_entity_reference() and - add_child_processing_instruction(). - * libxml++/nodes/entityreference.h: Improve the description of - get_resolved_text() and get_original_text(). - * libxml++/nodes/node.cc: get_namespace_prefix() and get_namespace_uri(): - XML_ENTITY_DECL has no namespace. Don't try to find it. - create_wrapper(): Create an EntityDeclaration when type == XML_ENTITY_DECL. - free_wrappers(): Don't walk the child list when type == XML_ENTITY_REF_NODE. - * examples/dom_build/main.cc: Add entity declarations and references, and - processing instructions to the built xml file. - * examples/dom_parse_entities/example.dtd: Make it compatible with example.xml. - * examples/dom_parse_entities/example.xml: Add an entity definition that - contains entity references. - * examples/dom_parse_entities/main.cc: Print the parsed file both with and - without entity substitution. - * examples/dom_parser/example.dtd: Make it compatible with example.xml. - * examples/dom_parser/main.cc: Add command flag -E (Don't substitute entities). - Bug #669481 - -2012-02-15 Kjell Ahlstedt - - Add some files to .gitignore. - - * .gitignore: Add docs files that are copied from mm-common. - Add /MSVC_Net2010/libxml++/libxml++.rc and - /examples/dom_read_write/example_output.xml. - -2012-02-15 Kjell Ahlstedt - - Add @newin{2,36} to some new functions where it's missing. - - * libxml++/exceptions/exception.h: Add @newin{2,36} to format_xml_error() and - format_xml_parser_error(). - * libxml++/parsers/parser.h: Add @newin{2,36} to [set|get]_throw_messages(). - Bug #304020. - -2012-02-10 Kjell Ahlstedt - - Make the schema validation example program work with no arguments. - - * examples/schemavalidation/main.cc: Correct the test for number of arguments. - -2012-01-30 Kjell Ahlstedt - - Parser: Throw more detailed error messages. - - * examples/dom_parser/main.cc: Add command parameters -v -e -t. - * libxml++/exceptions/exception.[h|cc]: Add format_xml_error() and - format_xml_parser_error(). - * libxml++/parsers/domparser.cc: Call format_xml_error() and - format_xml_parser_error() to get more detailed messages in exceptions. - * libxml++/parsers/parser.[h|cc]: Add [set|get]_throw_messages() and (local in - .cc until ABI can be broken) on_parser_[error|warning](). Bug #304020. - -2012-01-30 Murray Cumming - - Document: Make the Document(xmlDoc*) constructor protected. - - * libxml++/document.h: This was requested in bug #668980 (A. Pignotti). - -2011-09-09 Murray Cumming - - Document: write_to_*(): Make sure that we write UTF-8 out. - - * libxml++/document.cc: Because the xmlDocDump*() functions use some other - encoding if you specify NULL, causing errors such as: - xmlEscapeEntities : char out of range - -2.34.2: - -2011-09-06 Mathias Lorente - - Node::create_new_child_node(): Use the default namespace if none is specified. - - * libxml++/nodes/node.cc: This is better than just ignoring it. - Bug #656110 - -2011-07-20 Murray Cumming - - ContentNode::get_content(): Fix a documentation typo. - - * libxml++/nodes/contentnode.h: Mention > instead of &qt (a q - instead of a g, and no ;.). - -2011-07-20 Mathias Lorente - - Add Element::add_child_cdata(). - - * libxml++/nodes/element.[h|cc]: Add add_child_cdata(), using - xmlNewCDataBlock(), like the existing add_child_text(). - * examples/sax_parser_build_dom/example.xml: - * examples/sax_parser_build_dom/svgparser.[h|cc]: Use the new API. - -2.34.1: - -2011-04-17 Murray Cumming - - Fix distcheck. - - * Makefile.am: Specify the full path to docbook-customisation.xsl, - which is apparently necessary with the autotools that I have here. - -2011-04-17 Murray Cumming - - Fix the build with --enable-warnings=fatal. - - * configure.ac: Use -no-long-long to avoid an (apparently new) compiler - warning about long long not being supported by C++98. glibmm already had - this option. - -2011-04-17 Murray Cumming - - Do not require mm-common during the tarball build. - - * configure.ac: Add a MM_CONFIG_DOCTOOL_DIR() call. - -2.34.0: - -2011-02-24 Murray Cumming - - Fix the build with the changed linker behaviour on Ubuntu Natty. - - * Makefile.am: Link the examples to glibmm explicitly. - -2.33.2: - -2011-02-11 Murray Cumming - - Node::remove_child(): Fix a use of deleted memory - - * libxml++/nodes/node.cc: - Use a temporary variable to avoid accessing the node C++ instance after we - have deleted it. Valgrind foudn this. - Also remove the comment about the libxml deleting our C++ instance via a - callback, because we don't do that anymore. - -2010-11-26 Murray Cumming - - Check some libxml function return values. - - * libxml++/document.cc: do_write_to_stream(): - * libxml++/schema.cc: set_document(): Check the results from - xmlSchemaNewDocParserCtxt() and xmlSaveFormatFileTo(). - Bug #635846 (Markus Elfring). - -2.33.1: - -2010-11-14 Murray Cumming - - free_wrappers(): Fix crash. - - * libxml++/nodes/node.cc: free_wrappers(): Revert my change to check - xmlNode::properties for all types, because the layout of some structs - is apparently completely different (not really deriving fully), and this - caused a crash in examples/sax_parser/. - Added an explanatory comment. - -2010-11-14 Murray Cumming - - Change the --enable-examples default to yes. - - * configure.ac: Build the examples by default, so we at least check the - build more often. Disabling them is only useful for package building, - which is the less common case. - -2010-11-14 Murray Cumming - - Moved create_wrapper() and free_wrappers() to Node. - - * libxml++/document.[h|cc]: - * libxml++/nodes/node.[h|cc]: Moved create_wrapper() and free_wrappers() - to here from Document. - free_wrappers(): Never return inside the switch/case, so we check - xmlNode::properties for all struct types, and to avoid making the behaviour - non-obvious. - * libxml++/parsers/textreader.cc: - * libxml++/validators/dtdvalidator.cc: - * libxml++/nodes/element.cc: Adapted. - -2010-11-08 Alessandro Pignotti - - Make libxml++ compatible with separate and multi-threaded libxml2 usage. - - * libxml++/document.[h|cc]: Added create_wrapper() and free_wrappers(), - replacing on_libxml_construct() and on_libxml_destruct() . - Init(): Do not register these global callbacks with libxml. - * libxml++/nodes/element.cc: - * libxml++/nodes/node.[h|cc]: - * libxml++/parsers/textreader.cc: - * libxml++/validators/dtdvalidator.cc: Call these create_wrapper() before - ever trying to get a C++ instance from a C instance. Call free_wrappers() - in destructors and other places where we want the instance to be destroyed. - - This avoids use of libxml's global function pointers, which are not - thread-safe. - -2010-11-08 Murray Cumming - - Do not call xmlCleanupParser() because it is brutal. - - * libxml++/document.cc: ~Init(): Do not call xmlCleanupParser() because it - breaks libxml generally and should only be called by an application - explicitly before it ends, for instance at the end of its main(). - -2010-10-19 Knut Aksel Røysland - - Node::get_parent(): Removed code duplication. - - * libxml++/nodes/node.cc: get_parent() const: Use const_cast<> to call - the non-const version, instead of duplicating the code. - -2.32.0: - -2010-10-14 Murray Cumming - - website: Change the mailing list location, because I moved it. - - * docs/index.html: The mailing list is now at gnome.org. - -2010-10-03 Armin Burgmeier - - * MSVC_Net2005/README: - * MSVC_Net2005/examples/dom_build/dom_build.vcproj: - * MSVC_Net2005/examples/dom_parse_entities/dom_parse_entities.vcproj: - * MSVC_Net2005/examples/dom_parser/dom_parser.vcproj: - * MSVC_Net2005/examples/dom_parser_raw/dom_parser_raw.vcproj: - * MSVC_Net2005/examples/dom_read_write/dom_read_write.vcproj: - * MSVC_Net2005/examples/dom_xpath/dom_xpath.vcproj: - * MSVC_Net2005/examples/dtdvalidation/dtdvalidation.vcproj: - * MSVC_Net2005/examples/import_node/import_node.vcproj: - * MSVC_Net2005/examples/sax_exception/sax_exception.vcproj: - * MSVC_Net2005/examples/sax_parser/sax_parser.vcproj: - * MSVC_Net2005/examples/sax_parser_build_dom/sax_parser_build_dom.vcproj: - * MSVC_Net2005/examples/sax_parser_entities/sax_parser_entities.vcproj: - * MSVC_Net2005/examples/schemavalidation/schemavalidation.vcproj: - * MSVC_Net2005/examples/textreader/textreader.vcproj: - * MSVC_Net2005/gendef/gendef.vcproj: - * MSVC_Net2005/libxml++.sln: - * MSVC_Net2005/libxml++/libxml++.vcproj: - * MSVC_Net2008/README: - * MSVC_Net2008/examples/dom_build/dom_build.vcproj: - * MSVC_Net2008/examples/dom_parse_entities/dom_parse_entities.vcproj: - * MSVC_Net2008/examples/dom_parser/dom_parser.vcproj: - * MSVC_Net2008/examples/dom_parser_raw/dom_parser_raw.vcproj: - * MSVC_Net2008/examples/dom_read_write/dom_read_write.vcproj: - * MSVC_Net2008/examples/dom_xpath/dom_xpath.vcproj: - * MSVC_Net2008/examples/dtdvalidation/dtdvalidation.vcproj: - * MSVC_Net2008/examples/import_node/import_node.vcproj: - * MSVC_Net2008/examples/sax_exception/sax_exception.vcproj: - * MSVC_Net2008/examples/sax_parser/sax_parser.vcproj: - * MSVC_Net2008/examples/sax_parser_build_dom/sax_parser_build_dom.vcproj: - * MSVC_Net2008/examples/sax_parser_entities/sax_parser_entities.vcproj: - * MSVC_Net2008/examples/schemavalidation/schemavalidation.vcproj: - * MSVC_Net2008/examples/textreader/textreader.vcproj: - * MSVC_Net2008/gendef/gendef.vcproj: - * MSVC_Net2008/libxml++.sln: - * MSVC_Net2008/libxml++/libxml++.vcproj: - * MSVC_Net2010/README: - * MSVC_Net2010/examples/dom_build/dom_build.vcxproj: - * MSVC_Net2010/examples/dom_build/dom_build.vcxproj.filters: - * MSVC_Net2010/examples/dom_parse_entities/dom_parse_entities.vcxproj: - * MSVC_Net2010/examples/dom_parse_entities/dom_parse_entities.vcxproj.filters: - * MSVC_Net2010/examples/dom_parser/dom_parser.vcxproj: - * MSVC_Net2010/examples/dom_parser/dom_parser.vcxproj.filters: - * MSVC_Net2010/examples/dom_parser_raw/dom_parser_raw.vcxproj: - * MSVC_Net2010/examples/dom_parser_raw/dom_parser_raw.vcxproj.filters: - * MSVC_Net2010/examples/dom_read_write/dom_read_write.vcxproj: - * MSVC_Net2010/examples/dom_read_write/dom_read_write.vcxproj.filters: - * MSVC_Net2010/examples/dom_xpath/dom_xpath.vcxproj: - * MSVC_Net2010/examples/dom_xpath/dom_xpath.vcxproj.filters: - * MSVC_Net2010/examples/dtdvalidation/dtdvalidation.vcxproj: - * MSVC_Net2010/examples/dtdvalidation/dtdvalidation.vcxproj.filters: - * MSVC_Net2010/examples/import_node/import_node.vcxproj: - * MSVC_Net2010/examples/import_node/import_node.vcxproj.filters: - * MSVC_Net2010/examples/sax_exception/sax_exception.vcxproj: - * MSVC_Net2010/examples/sax_exception/sax_exception.vcxproj.filters: - * MSVC_Net2010/examples/sax_parser/sax_parser.vcxproj: - * MSVC_Net2010/examples/sax_parser/sax_parser.vcxproj.filters: - * MSVC_Net2010/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj: - * MSVC_Net2010/examples/sax_parser_build_dom/sax_parser_build_dom.vcxproj.filters: - * MSVC_Net2010/examples/sax_parser_entities/sax_parser_entities.vcxproj: - * MSVC_Net2010/examples/sax_parser_entities/sax_parser_entities.vcxproj.filters: - * MSVC_Net2010/examples/schemavalidation/schemavalidation.vcxproj: - * MSVC_Net2010/examples/schemavalidation/schemavalidation.vcxproj.filters: - * MSVC_Net2010/examples/textreader/textreader.vcxproj: - * MSVC_Net2010/examples/textreader/textreader.vcxproj.filters: - * MSVC_Net2010/gendef/gendef.cc: - * MSVC_Net2010/gendef/gendef.vcxproj: - * MSVC_Net2010/gendef/gendef.vcxproj.filters: - * MSVC_Net2010/libxml++.sln: - * MSVC_Net2010/libxml++/libxml++.rc.in: - * MSVC_Net2010/libxml++/libxml++.vcxproj: - * MSVC_Net2010/libxml++/libxml++.vcxproj.filters: - * Makefile.am: - * configure.ac: Added support for MSVC 2010 and 64 bit. - -2010-06-13 Murray Cumming - - Node::find(): Check xmlNode::type for a XML_NAMESPACE_DECL. - - * libxml++/nodes/node.cc: find_impl(): if the xmlNode has type - XML_NAMESPACE_DECL then it is actually a xmlNs, which is not like a xmlNode - at all (thanks to the awful undocumented libxml++ system of struct - inheritance). - So we just igore these items. We need to decide what the caller really - expects. - -2010-06-13 Murray Cumming - - Node::find(): Revert some of my previous change because it breaks some code. - - * libxml++/nodes/node.cc: find_impl(): Restore the previous behaviour, - because the strange use of _private only seems to happen sometimes. - -2010-06-13 Murray Cumming - - Node::find(): Cope with weird use of _private in xmlNodeSet. - - * libxml++/nodes/node.cc: The xmlNodeSet seems to contain extra xmlNodes that - were never given to on_libxml_construct(). Those xmlNodes seem to abuse - private_, where we find our real xmlNodes containing our C++ Nodes. - This fixes bug #386013 (Max Kirillov) though it depends on undocumented - libxml behaviour. - -2010-06-13 Murray Cumming > - - Node::find(): Use libxml functions instead of direct C access. - - * libxml++/nodes/node.cc: Use xmlXPathNodeSetIsEmpty(), - xmlXPathNodeSetGetLength() and xmlXPathNodeSetItem() instead of direct - xmlNodeSet struct access. - -2010-06-13 Murray Cumming - - Manual: Use git.gnome.org as the link to the examples source code. - - * docs/manual/libxml++_without_code.xml: Use git.gnome.org for the examples - url base, as we do in gtkmm-documentation. - -2010-06-13 Murray Cumming - - Restore the mm-common make target and update a link. - - * Makefile.am: Restore (and update) the post-html target that was lost when - we redid the build system for mm-common. - * docs/index.html: Change the link to the manual to point to its new location - at library.gnome.org. - -2.30.1: - -2010-05-04 Murray Cumming - - Documentation: Don't hide undocumented API. - - * docs/reference/Doxyfile.in: Use the same options as gtkmm (mostly). - In particular, don't hide undocumented API, such as NodeSet, to fix - bug #583412 (Hubert Figuiere). - -2010-05-04 Murray Cumming - - Documentation: Improvements. - - * libxml++/libxml++.h: Expand the main page text, linking to the tutorial - and to important classes. - * libxml++/parsers/domparser.h: - * libxml++/schema.h: Correct the class descriptions. - * libxml++/parsers/textreader.h: Add a class description. - * libxml++/nodes/element.h: - * libxml++/nodes/node.h: - * libxml++/parsers/saxparser.h: - * libxml++/validators/schemavalidator.h: - Correct @newin2p2* to @newin{2,*} now that we use mm-common. - -2010-04-27 David King - - Further documentation main page improvements - - * libxml++/libxml++.h: Some minor improvements. - -2010-04-23 David King - - Documentation main page improvements - - * libxml++/libxml++.h: Add external links and compilation example. - -2010-04-16 David King - - Minor documentation update - - * docs/index.html: Link to latest gnome.org resources. - * libxml++/libxml++.h: Add minimal documentation for main page. - -2010-04-06 Murray Cumming - - .pc file: Add datarootdir. - - * libxml++-2.6.pc.in: Add datarootdir and datadir, as in the gtkmm .pc.in - file, because I started seeing this warning when running autogen.sh in Glom: - Variable 'datarootdir' not defined in '/opt/gnome228/lib/pkgconfig/libxml++-2.6.pc' - -2010-04-03 Armin Burgmeier - - * MSVC_Net2005/libxml++.sln: - * MSVC_Net2008/libxml++.sln: Add dom_parser_raw project to the - solution files. - -2010-03-30 Murray Cumming - - Stop exceptions when using std::cout and UTF-8. - - * examples/*/main.cc: Initialize the global C and C++ locale to prevent - exceptions when ouputing a ustring (with non-ASCII UTF-8) to std::cout. - We don't see this problem when writing gtkmm apps because gtk_init() (via - Gtk::Main) initializes the C locale correctly. - - Thanks to Daniel Elstner for the solution (he will document it properly - in the Glib::ustring API reference) and to Nic Reveles and others for - noticing the problem. - -2010-03-30 David King - - Update pkg-config file - - * libxml++-2.6.pc.in: Add documentation locations to pkg-config file. - Update other fields to use variables, rather than hardcoded values. - -=== 2.30.0 === - -2010-03-30 David King - - Disable AM_MAINTAINER_MODE by default - - * configure.ac: Pass the disable parameter to AM_MAINTAINER_MODE so - that tarball users do not need doxygen, mm-common, etc. if they modify - files. Maintainer mode is still enabled if running autogen.sh. - -2010-03-29 David King - - Move a target outside a conditional block to fix the build - - * Makefile.am: Move docs/manual/libxml++.xml target outside the - ENABLE_DOCUMENTATION conditional block. - -2010-03-29 David King - - Use mm-common for reference documentation generation - - * .gitignore: Update. - - * Makefile.am: Remove SUBDIRS. Make examples build and documentation - build conditional. Build reference documentation with doc-reference.am - from mm-common. Add docs/manual/libxml++.pdf target, but do not enable - it by default. Add autogen.sh and docs/manual/insert_example_code.pl to - dist_noinst_SCRIPTS. Add docs/manual/html/*.html to - MAINTAINERCLEANFILES. - - * autogen.sh: Add --enable-maintainer-mode to arguments passed to - configure. - - * configure.ac: Add AM_MAINTAINER_MODE. Add a configure argument to - enable the build of the examples. Use mm-common macros to add a - configure argument to enable documentation, and use the glibmm - tagfile. Check for xmllint and db2latex for DTD validation of the - DocBook manual and building the PDF documentation, repectively. Remove - the last non-toplevel Makefiles from AC_CONFIG_FILES. - - * docs/Makefile.am: - * docs/Makefile_web.am_fragment: - * docs/manual/Makefile.am: - * docs/reference/Makefile.am: Remove from repository, and move content - to Makefile.am. - - * docs/manual/docbook-customisation.xsl: Add DocBook customisation - parameters. - - * docs/manual/libxml++_without_code.xml: Make validate. - - * docs/reference/Doxyfile.in: Update from mm-common. - - * docs/reference/README: Remove empty file. - -2010-03-27 David King - - Fix several compiler warnings - - * examples/dom_build/main.cc: - * examples/dtdvalidation/main.cc: - * examples/import_node/main.cc: - * examples/sax_exception/main.cc: - * examples/sax_exception/my_parser.cc: - * examples/sax_parser/main.cc: - * examples/sax_parser/my_parser.cc: - * examples/sax_parser_build_dom/svgparser.cc: - * examples/sax_parser_entities/myparser.cc: - * examples/textreader/main.cc: - * libxml++/parsers/textreader.cc: Comment out unused parameters and - variables. - - * libxml++/parsers/saxparser.cc: Fill in missing fields of - xmlSAXHandler struct. - -2010-03-27 David King - - Refactor build system - - * Makefile.am: Merge from subdir Makefile.am files, excluding doc. - - * MSVC_Net2005/examples/dom_parser_raw/dom_parser_raw.vcproj: - * MSVC_Net2008/examples/dom_parser_raw/dom_parser_raw.vcproj: Add - missing Visual studio project files. - - * MSVC_Net2005/examples/*/Makefile.am: - * MSVC_Net2005/examples/Makefile.am: - * MSVC_Net2005/gendef/Makefile.am: - * MSVC_Net2005/libxml++/Makefile.am: - * MSVC_Net2008/examples/*/Makefile.am: - * MSVC_Net2008/examples/Makefile.am: - * MSVC_Net2008/gendef/Makefile.am: - * MSVC_Net2008/libxml++/Makefile.am: Remove from repository, and move - content to Makefile.am, making the MSVC project file build - non-recursive. - - * README: Update. - - * autogen.sh: Copy from gtkmm. - - * configure.in: Move to configure.ac. - - * configure.ac: Require autoconf 2.59 and automake 1.9. Use new-style - AC_INIT() with bug-report link and homepage URL. Use mm-common for - initialisation of version variables. Require libtool 2.2.6 for much - faster builds. Use MM_ARG_ENABLE_WARNINGS to configure compiler - warning flags. Use MM_CHECK_PERL to check for the required Perl - version. Use AC_CONFIG_FILES rather than AC_OUTPUT. Update for - Makefile.am changes. - - * config.h.in: Remove from repository, as autoheader is now used. - - * */.cvsignore: Remove old files. - - * doc/manual/Makefile.am: Use the correct Perl. - - * doc/reference/Doxyfile.in: - * MSVC_Net2005/libxml++/libxml++.rc.in: - * MSVC_Net2008/libxml++/libxml++.rc.in: Use new-style variable names. - - * examples/Makefile.am_fragment: - * examples/Makefile.am: - * examples/*/Makefile.am: Remove from repository, and move content to - Makefile.am, making the examples build non-recursive. - - * .gitignore: Update. - - * libxml++/Makefile.am: - * libxml++/*/Makefile.am: Remove from repository, and move content to - Makefile.am, making the libxml++ build non-recursive. - - * libxml++.spec.in: - * INSTALL: Remove from repository. - - * scripts/README: - * scripts/Makfile.am: Remove from repository. - - * scripts/reduced.m4: Move to macros/reduced.m4 - -2010-03-08 Murray Cumming - - Use 0 instead of NULL. - - * MSVC_Net2005/gendef/gendef.cc: - * MSVC_Net2008/gendef/gendef.cc: - * libxml++/attribute.cc: - * libxml++/document.cc: - * libxml++/io/outputbuffer.cc: - * libxml++/io/parserinputbuffer.cc: - * libxml++/nodes/node.cc: - * libxml++/parsers/domparser.cc: - * libxml++/parsers/parser.cc: - * libxml++/parsers/textreader.cc: - * libxml++/schema.cc: - * libxml++/schema.h: Do not use NULL. It is unwise in C++. - -=== 2.26.1 === - -2009-07-27 Johannes Schmid - - * libxml++/validators/schemavalidator.cc: - * libxml++/schema.cc: Fixed exception handling - problems in non-exception build - * examples/sax_parser/myparser.cc/h: Make example build withouth exceptions, - it's useless then though - * examples/schemavalidation/main.cc: Fixed build without exceptions - -2009-07-27 Johannes Schmid - - New tarball release - - * configure.in: Updated version to 2.26.1 - * NEWS: updated - -2009-05-07 Murray Cumming - - Fix the build without exceptions, hopefully. - - * libxml++/parsers/textreader.cc: check_for_exceptions(): - Add an ifdef so that this should build with exceptions disabled, - though there is no alternative API yet. Noticed by David King. - -2009-05-07 Murray Cumming - - * libxml++/parsers/textreader.cc: Whitespace corrections. - -2009-03-25 Hubert Figuiere - - * libxml++/parsers/saxparser.h: Fix some warnings triggered - by -Wshadow. - -2009-03-23 Hubert Figuiere - - * libxml++/parsers/textreader.cc: severity_ was not initialised - at construction time. (Closes #576516) - -2.26.0: - -2009-03-16 Murray Cumming - - * configure.in: Increased version number to match GNOME 2.26. - -2.24.3: - -2009-03-02 Armin Burgmeier - - * libxml++/validators/validator.h: - * libxml++/parsers/parser.h: Removed the vsnprintf #define on Windows. - This could conflict with another define otherwise. Both MSVC and MinGW - have vsnprintf (without underscore) as well, and I verified libxml++ - still compiles in both. If we still need the definition for some - reason, then we should re-add it into the source files, so that other - libraries don't conflict with our definition. - -2009-01-09 Stef Walter - - * libxml++/parsers/textreader.[h|cc]: Add setup_exceptions(), setting - the on_libxml_error() callback, and call it from the constructors. - check_for_exceptions(): Actually check some member variables and throw an - exception if necessary. - This should fix bug #348006. - It breaks ABI because it adds member variables, but we decided that is - OK because nobody could actually be using this class seriously before - now because it had no error checking. - -2.24.2: - -2008-12-20 Armin Burgmeier - - * libxml++/schema.cc (set_document): Set embedded_doc_ according to - the embed parameter instead of always setting it to false, so that we - actually release the document in release_underlying(). - (release_underlying): Free the schema in all cases, also when the - document was not embedded, to avoid a memory leak. - - * libxml++/validators/schemavalidator.cc (parse_file, parse_memory, - parse_document): Make sure not to leak the xmlSchemaParserCtxtPtr in - case of an exception. Bug #563321, Arjan Franzen. - -2008-12-18 Armin Burgmeier - - * win32_msvc6/: - * Makefile.am: - * configure.in: Removed outdated MSVC6 project. - -2.24.1: - -2008-12-12 Armin Burgmeier - - * MSVC_Net2008/examples/sax_parser/sax_parser.vcproj.HALLWA.Armin.user: - Removed this generated file. It went in by accident. - - * MSVC_Net2008/examples/sax_parser/sax_parser.vcproj: Added the - example project file instead, which should have been added from the - beginning. - -2008-12-12 Armin Burgmeier - - * MSVC_Net2005/libxml++/libxml++.vcproj: - * MSVC_Net2008/libxml++/libxml++.vcproj: Added schema.cc and - schemavalidator.cc to the project. Bug #563664 (Arjan Franzen). - - * MSVC_Net2005/examples/schemavalidation/schemavalidation.vcproj: - * MSVC_Net2005/examples/schemavalidation/Makefile.am: - * MSVC_Net2005/examples/Makefile.am: - * MSVC_Net2005/libxml++.sln: Added the schema validator example to the - MSVC8 solution file. - - * MSVC_Net2008/examples/schemavalidation/schemavalidation.vcproj: - * MSVC_Net2008/examples/schemavalidation/Makefile.am: - * MSVC_Net2008/examples/Makefile.am: - * MSVC_Net2008/libxml++.sln: Added the schema validator example to the - MSVC9 solution file. - -2008-12-12 Przemysław Grzegorczyk - - * libxml++/schema.cc: Fix a typo to fix the build. - -2008-12-08 Murray Cumming - - * libxml++/validators/validator.cc: check_for_exception(): Use an - auto_ptr<> to avoid leaking the exception, as in - Parser::check_for_exception(). - Bug #563321 (Arjan Franzen) - -2008-12-05 Murray Cumming - - * libxml++/schema.cc: release_underlying(): Use xmlSchemaFree() - to avoid a leak, as suggested by Balazs Tirpak. Bug #312216. - -2008-10-09 Armin Burgmeier - - * MSVC_Net2005/*/*.vcproj: Adapt the new DLL naming convention. - - * MSVC_Net2008/: Added project files for Visual Studio 2008. - - * Makefile.am: - * configure.in: Added the new files to the distribution. - -2.24.0: - - * configure.in: Increased version to match GNOME 2.24: - -2.23.3: - -2008-08-16 Murray Cumming - - * libxml++/attribute.cc: get_value(): xmlGetNsProp() takes the - namespace URI, not the prefix. - Bug #547689 (Sergei Fedorov) - -2008-08-14 Murray Cumming - - * examples/dom_parser/Makefile.am: - * examples/dom_parser/example_with_namespace.xml: - Added an example using namespace prefixes, from bug - #547689. - * examples/dom_parser/main.cc: Comment out the call to set_validate(), - because that example does not have a DTD. - Show the namespace prefixes in the output. - * libxml++/attribute.cc: get_value(): Use xmlGetNsProp() instead of - xmlGetProp(), so we don't ignore the namespace prefix, so we get - the correct value. - Bug #547689 (Sergei Fedorov) - -2008-08-10 Armin Burgmeier - - * MSVC_Net2005/: Renamed from MSVC_Net2003. - - * MSVC_Net2005/libxml++/libxml++.vcproj: Link against libxml2.lib - instead of xml2.lib because that's how it is called in Tor's GTK+ - bundle. - - * MSVC_Net2005/libxml++/libxml++.rc.in: Removed "#include resource.h" - because there is no resource.h. - - * MSVC_Net2005/libxml++/libxml++.sln: Build all examples by default. - - * Makefile.am: - * configure.in: Adapt build files for the MSVC_Net2003 -> MSVC_Net2005 - rename. - -2.23.2: - -2008-05-05 Murray Cumming - - * examples/sax_parser/main.cc (main): Use parse_file() but leave - the parse_chunk() version commented out, to simplify this example. - * examples/sax_parser/myparser.cc - Catch Glib::ConvertError exceptions when using std::cout, though - libxml++ should really always supply valid UTF-8 to us. - -2008-04-14 Armin Burgmeier - - * libxml++/parsers/saxparser.h: - * libxml++/parsers/saxparser.cc: Added a parse_chunk_raw() method and - changed parse_chunk() to use it. - -2.23.1: - -2008-03-26 Murray Cumming - - * examples/schemavalidation/Makefile.am: Corrected a filename to - fix distcheck - * libxml++/schema.h: - * libxml++/validators/schemavalidator.h: Added the newin2p24 doxygen - keyword. - -2008-03-26 Emilien KIA - - * configure.in: - * libxml++/Makefile.am: - * libxml++/libxml++.h: - * libxml++/schema.cc: - * libxml++/schema.h: Added Schema class, similar to the existing Dtd - class. - * libxml++/validators/Makefile.am: - * libxml++/validators/schemavalidator.cc - * libxml++/validators/schemavalidator.h: Added Schema validator class, - similar to the existing DtdValidator class. - - * examples/Makefile.am: - * examples/schemavalidation/: New example, similar to the - existing dtdvalidation example. - - Bug #312216. - -2008-03-26 Murray Cumming - - * docs/Makefile.am: Fixed the post-html rule. - * docs/index.html: Corrected some links. - * libxml++/nodes/node.h: Corrected documentation for the new methods - from the previous commit. - -2008-03-26 Murray Cumming - - * libxml++/nodes/element.cc: - * libxml++/nodes/element.h: Added add_child_text() with a previous_node - parameter, for adding between existing nodes. - Added add_child_text_before() too. - * libxml++/nodes/node.cc: - * libxml++/nodes/node.h: Added add_child() with a previous_node - parameter, for adding between existing nodes. - Added add_child_before() too. - - * docs/index.html: Removed the license clarifications text because I - always found it to be arbitrary and not very informative. - * docs/reference/Doxyfile.in: Added a newin2p24 doxygen keyword. - * docs/reference/Makefile.am: Do not create a version-specific - directory name for reference documentation. The Since: text and links - in the documentation are enough to know what was in what version. - -This is the svn trunk branch. See also the gnome-2-22 branch. - -2.22.0: - -2008-03-07 Deng Xiyue - - * libxml++/document.cc: - * libxml++/document.h: Add a destructor - (does not break ABI because the base class already has a - virtual destructor) that calls xmlCleanupParser to match the - existing call to xmlInitParser() in the constructor. Fixes - a memory leak. - Bug #501168 (Matt G.) - -2008-01-17 Roland Stigge - - * libxml++/attribute.cc: - * libxml++/dtd.cc: - * libxml++/dtd.h: - * libxml++/io/ostreamoutputbuffer.h: - * libxml++/io/outputbuffer.h: - * libxml++/keepblanks.cc: - * libxml++/keepblanks.h: - * libxml++/libxml++.h: - * libxml++/nodes/cdatanode.cc: - * libxml++/nodes/cdatanode.h: - * libxml++/nodes/commentnode.cc: - * libxml++/nodes/commentnode.h: - * libxml++/nodes/contentnode.cc: - * libxml++/nodes/element.cc: - * libxml++/nodes/element.h: - * libxml++/nodes/entityreference.cc: - * libxml++/nodes/entityreference.h: - * libxml++/nodes/node.cc: - * libxml++/nodes/processinginstructionnode.cc: - * libxml++/nodes/processinginstructionnode.h: - * libxml++/nodes/textnode.cc: - * libxml++/nodes/textnode.h: - * libxml++/parsers/domparser.cc: - * libxml++/parsers/domparser.h: - * libxml++/parsers/parser.cc: - * libxml++/parsers/parser.h: - * libxml++/parsers/saxparser.cc: - * libxml++/parsers/textreader.h: - Correct the name of the files in their comment blocks, - though this could just be removed instead. - Bug #510056. - -2008-01-17 Martin Michlmayr > - - * libxml++/parsers/parser.cc: - * libxml++/parsers/textreader.h: - Added includes to fix the build with gcc 4.3 - pre-releases. - Bug #510053. - -2.20.0: - -2007-08-30 Murray Cumming - - * examples/dom_parser_raw/main.cc: When exceptions are disabled, assume that they are also - disabled in glibmm and then use the extra error parameter to Glib::convert(), to fix the - build when using glibmm with disabled exceptions. - * docs/manual/Makefile.am: Use maintainer-clean instead of clean-local to delete the html, - but this still seems to be deleted when building debian packages. - -2.19.2: - -2007-08-29 Murray Cumming - - * scripts/Makefile.am: distcheck fixes. - -2007-08-29 Murray Cumming - - * autogen.sh: - * Makefile.am: - * configure.in: - * scripts/Makefile.am: - * scripts/reduced.m4: Added an --enable-api-exceptions - configure option, which defines LIBXMLCPP_EXCEPTIONS_ENABLED - in libxml++config.h. - * examples/dom_build/main.cc: - * examples/dom_parse_entities/main.cc: - * examples/dom_parser/main.cc: - * examples/dom_parser_raw/main.cc: - * examples/dom_read_write/main.cc: - * examples/dom_xpath/main.cc: - * examples/dtdvalidation/main.cc: - * examples/import_node/main.cc: - * examples/sax_exception/main.cc: - * examples/sax_exception/myparser.cc: - * examples/sax_parser/main.cc: - * examples/sax_parser_build_dom/main.cc: - * examples/sax_parser_entities/main.cc: - * examples/textreader/main.cc: - * libxml++/document.cc: - * libxml++/exceptions/exception.cc: - * libxml++/exceptions/internal_error.cc: - * libxml++/exceptions/parse_error.cc: - * libxml++/exceptions/validity_error.cc: - * libxml++/io/outputbuffer.cc: - * libxml++/io/parserinputbuffer.cc: - * libxml++/libxml++config.h.in: - * libxml++/nodes/contentnode.cc: - * libxml++/nodes/element.cc: - * libxml++/nodes/node.cc: - * libxml++/parsers/domparser.cc: - * libxml++/parsers/parser.cc: - * libxml++/parsers/saxparser.cc: - * libxml++/parsers/textreader.cc: - * libxml++/validators/dtdvalidator.cc: - * libxml++/validators/validator.cc: - Put LIBXMLCPP_EXCEPTIONS_ENABLED ifdefs around uses of - try, catch, and throw, so that libxml++ can build with - CXXFLAGS="-fno-exceptions". However, we might still - need some alternative error checking API. - -2.19.1: - -2007-07-30 Stef Walter - - * libxml++/nodes/element.cc: - * libxml++/nodes/element.h: Added get_attribute_value(), - to get a simple text value for an attribute, as a - convenience. - Patch in bug #373573. - -2007-07-30 Murray Cumming - - * docs/reference/Doxyfile.in: Added newin2p18, - newin2p20, and newin2p22 tags. - -This is the trunk branch for libxml++ 2.19/2.20. -See also the gnome-2-18 branch. - -2.18.2: - -2007-07-25 Christophe de Vienne - - * libxml++/parsers/textreader.cc: get_name(): - Fixed a memory leak. bug #447535. - -2.18.1: - -2007-06-10 Murray Cumming - - * libxml++/document.cc: add_comment(), - * libxml++/nodes/element.cc: add_child_text(): - add_child_comment(): Avoid accessing freed memory - when the text nodes are merged by xmlAddChild(). - -2.18.0: - -2007-02-10 Murray Cumming - - * examples/dom_parse_entities/main.cc: - * examples/dom_parser/main.cc: - * examples/dom_parser_raw/main.cc: - * examples/dom_read_write/main.cc: - * examples/dom_xpath/main.cc: - * examples/dtdvalidation/main.cc: - * examples/sax_parser/main.cc: - * examples/sax_parser_build_dom/main.cc: - * examples/sax_parser_entities/main.cc: Use std::string for file paths, - because we can not know the encoding of file paths. std::string therefore - means unknown encoding. - -2007-02-06 Artur Wegele - - * libxml++/parsers/parser.h: - * libxml++/validators/validator.h: Check for _MSC_VER instead - of WIN32 before setting MSVC++ pragmas, because that is apparently - more reliable. Bug #380110. - -2.17.2: - -2006-10-25 Nate Nielsen - - * libxml++/nodes/node.cc: - * libxml++/nodes/node.h: Node::get_next_sibling(), - Node::get_previous_sibling(). Bug #351867 - -2006-11-17 Nate Nielsen - - * libxml++/parsers/textreader.cc - * libxml++/parsers/textreader.h: Clean up TextReader() data - constructor signature. Removed '-1' as a special null terminated - value. This brings it inline with other parsers. - -2.17.1: - -2006-11-11 Nate Nielsen - - * libxml++/nodes/element.cc: Element::set_attribute(): - Fix redeclaration of variable in if-block. Bug #361950 - -2006-11-11 Nate Nielsen - - * libxml++/parsers/textreader.cc - * libxml++/parsers/textreader.h: TextReader() can now parse - memory buffers as well as files. Bug #351215 - -2006-11-11 Nate Nielsen - - * libxml++/nodes/node.cc: - * libxml++/nodes/node.h: Add Node::get_parent() Bug #351876 - -2006-04-24 Cedric Gustin - - * configure.in: Disable autoheader. - * config.h.in: New file. Added comments about the difference - between config.h.in and libxml++config.h.in. - -2006-04-21 Cedric Gustin - - * libxml++/Makefile.am: Added libxml++config.h.in to EXTRA_DIST. - -2006-04-21 Cedric Gustin - - * MSVC_Net2003/*.vcproj: Updated for Visual Studio 2005. Added the - /vd2 compiler flag (Bug #158040). Renamed target DLL to - xml++-2.6 to comply to the value returned by "pkg-config --libs - --msvc-syntax libxml++-2.6". - * MSVC_Net2003/libxml++.sln: Updated for Visual Studio 2005. - * MSVC_Net2003/gendef/gendef.cc: Redirect output of dumpbin to a - file. - * MSVC_Net2003/libxml++/Makefile.am: Get a local copy of the - libxml++config.h file created at configure time and distribute it - in the source tarball. - * libxml++/Makefile.am: Add -DLIBXMLPP_BUILD to the DEFS compiler - flags (switch between dllexport/dllimport on win32). Also install - libxml++config.h to $(prefix)/lib/libxml++-2.6/include. - * libxml++/*/*.Makefile.am: Add -DLIBXMLPP_BUILD to the DEFS - compiler flags (switch between dllexport/dllimport on win32). - * libxml++/exceptions/exception.h: Tag the xmlpp:exception classs - with LIBXMLPP_API to get rid of auto-import errors on win32 - (mingw32/cygwin). - * libxml++/libxml++config.h.in: New file. Define LIBXMLPP_API and - switch between dllimport and dllexport on win32. - * libxml++-2.6.pc.in: Add ${libdir}/libxml++-2.6/include to Cflags - (for libxml++config.h). - * configure.in: Added test for a native win32 platform. Use the - ms-bitfields on this platform only. Added the libxml++config.h - configuration file. - -2.14.0: - -2006-03-13 Christophe de Vienne - - * docs/index.html: Updated version number - -2006-03-13 Christophe de Vienne - - * NEWS, configure.in: Prepared release 2.14.0 - -2006-03-08 Murray Cumming - - * libxml++/nodes/contentnode.h: get_content() documentation: - Replace the TODO because I know know that apos is the fifth - predefined entity. - set_content(): Mention that the predefined entities are used - _where necessary_ because XML does not require use of quot or - apos in text nodes - just in attribute values. - -2.13.1: - -2005-12-20 Murray Cumming - - * docs/manual/libxml++_without_code.xml: Mention pkg-config. - -2005-12-16 Murray Cumming - - * libxml++/document.h: Minor grammar fixes in documentation. - * libxml++/nodes/node.h: Correct find() documentation slightly. - -2005-12-15 Robert Fleming - - * libxml++/nodes/node.cc: - * libxml++/nodes/node.h: Add find() overload that - takes namespaces to register, using xmlXPathRegisterNs(). - Bug #323935. - -2005-12-15 Murray Cumming - - * libxml++/nodes/node.cc: set_namespace(): Pass 0 to - xmlSearchNs() for empty (default) namespaces, instead of - an empty string, as we do elsewhere. This makes - Document::create_root_node() for when not specifying a - namespace. Bug #318186 from Erik Oestby. - -2005-12-15 Vadim Zeitlin - - * docs/reference/Doxyfile.in: Fix paths so buildir!=srcdir - builds work. Bug #319863. - -2005-09-21 Christophe de Vienne - - * libxml++.spec.in: Fixed include and .pc paths. Fixes #316827. - -This is the HEAD branch, for API additions. See also the gnome-2-12 branch. - -2.12.0: - -2005-08-26 Christophe de Vienne - - * libxml++/parsers/textreader.h: Added xmlReadState "Reading" as - suggested by Sebastian Moss. - -2.11.0: - -2005-08-25 YS - - * libxml++/Makefile.am: Changed link order to solve a link issue - on cygwin. Bug #314419. - -2005-06-13 Marek Rouchal - - * libxml++/io/istreamparserinputbuffer.cc: - * libxml++/io/istreamparserinputbuffer.h: - * libxml++/io/parserinputbuffer.cc: - * libxml++/io/parserinputbuffer.h: Remove extra ;s. - Bug #307481 - -2005-05-15 Murray Cumming - - * libxml++/document.h: Add comments about possibly deriving this - from Node, though it needs investigation, and we can not do this - in the stable API. - * libxml++/nodes/node.cc: get_namespace(), get_namespace_prefix(): - Return an empty string if the node is actually a Document, because - the underlying xmlDocument struct has no ns field. This should - prevent the crash in bug #161825. - -2005-05-15 Murray Cumming - - * docs/index.html: Add link to the LGPL text. - -2005-04-24 Murray Cumming - - * libxml++/parsers/domparser.cc: parse_context(): - Delete the context after, not before, checking it for an error. - Bug #156352 from Jim Garrison. - -2005-04-24 Murray Cumming - - * libxml++/parsers/saxparser.cc: SaxParserCallback::characters() - Call on_characters(), not on_cdata_block(), so that the correct - derived handler is called. Bug #301712 and patch from - Aaron Walker. - -2005-04-24 Murray Cumming - - * libxml++-2.6.pc.in: Remove -I for the include location of - a config file, because we don't install one. Bug #301727 - from Aaron Walker. - -2005-03-15 Murray Cumming - - * libxml++/document.cc: set_entity_declaration(): Pass 0 instead - of empty strings for the public ID and system ID, if an empty - string is provided. This stops libxml from using a useless empty - string. - -2005-03-09 Cedric Gustin - - * MSVC_Net2003/Makefile.am: Add blank.cpp to EXTRA_DIST. - * MSVC_Net2003/examples/*/*.vcproj: Change name of PDB file to - $(OutDir)/$(TargetName).pdb. - -This is the HEAD branch. - -2.10.0: - -2005-03-08 Christophe de Vienne - - * docs/reference/Makefile.am: Added one more rule so the "make - distcheck" works from a clean cvs working copy. - -2005-03-08 Christophe de Vienne - - * docs/manual/Makefile.am, docs/reference/Makefile.am: Added a few - rules so that "make dist" generated the documentation if it's - absent. - -2005-02-15 Murray Cumming - - * docs/manual/Makefule.am: Added insert_example_code to EXTRA_DIST, - though it should not be needed when building from a DIST anyway, - because we distribute the html. - -2.9.2: - -2005-02-13 Christophe de Vienne - - * docs/manual/Makefile.am: Removed README from EXTRA_DIST. - -2005-02-12 Christophe de Vienne - - * libxml++/nodes/node.cc: Fixed a little inefficency in find (#161925) - -2005-02-11 Murray Cumming - - * docs/: Added manual. - * configure.in: Use GLIBMM_CHECK_PERL to get the perl path, needed - to insert the example code in the manual. - * docs/Makefile.am: Move the reference and manual into a docs folder - so that the docs and the examples have the same relative path. - * docs/index.html: Mention the manual and update the links. - -2005-02-11 Murray Cumming - - * libxml++/document.cc: do_write_to_string(): libml returns the - number of bytes instead of the number of characters, so use the - appropriate ustring constructor, to avoid an exception later. - Bug found by Cyril Picard. - * docs/reference/Makefile.am: Install the reference documentation. - Distribute the built reference documentatoin, and Do not rebuild it - every time. - * docs/reference/Doxyfile.in: Generate doxygen tags so that other - documentation can link to the libxml++ documentation. Use the - libstdc++ and glibmm doxygen tags to link to their documentation, - for instance for Glib::ustring. - -2005-01-26 Cedric Gustin - - * MSVC_Net2003/README: Updated for 2.8.0 - -2005-01-26 Cedric Gustin - - * configure.in: parse micro version tags at configure time (for - libxml++.rc). Added support for shared libraries (DLL) on - win32. Added MSVC_Net2003 Makefiles. - * Makefile.am: Added MSVC_Net2003 subdir. - * libxml++/Makefile.am: Added linker flags for shared libraries - (DLL) on win32. - * examples/Makefile.am_fragment: Removed trailing slash in INCLUDES. - * MSVC_Net2003/*: Initial release. - -2.9.1: - -2004-12-25 Murray Cumming - - * libxml++/parsers/domparser.[h|cc], saxparser.[h|cc]: Added - parse_memory_raw() for libxml documents that are not utf8-encoded or - are encoded in an unknown encoding. - * examples/: Added dom_parser_raw() to test parsing of UCS2-encoded - text. - -2004-12-20 Murray Cumming - - * This is the HEAD branch, for gnome 2.9/2.10. - -2004-12-18 Murray Cumming - - * libxml++/docs/index.html: Bugs: Minor english corrections, and - more useful bugzilla links. - * libxml++/docs/Makefile.am: Build the reference documentation as - part of the main cvs build, but distribute it so that it does not need - to be rebuilt when building a tarball. - -2004-12-18 Murray Cumming - - * libxml++/nodes/node.cc: Node::find(): Check the result of - xmlXPathEval and throw an exception about invalid xpaths, instead of - crashing. Bug #161549 from Caleb Epstein. - -2004-12-18 Murray Cumming - - * libxml++/parsers/saxparser.cc: parse_memory(), parse_chunk(), - domparser.cc: parse_memory, parse_chunk(): Use Glib::ustring::bytes() - to get the size of the array, not size() or length(), which gets - the number of utf8 characters. It might not even be utf8. - * examples/sax_parser_build_dom/svgparser.cc: Use !empty() instead of - size() > 0. It is more efficient. - -2004-11-30 Murray Cumming - - * libxml++/validator.h: Removed an extra ; that g++ 3.4 complains - about. - -2.8.0: - -2004-09-12 Murray Cumming - - * libxml++/libxml++.h: Add include for xmlreader.h. - * examples/saxparser/myparser.cc, saxparser_entities/myparser.cc: - Correct (and uncomment) the code to read the attribute values. - -2.7.1: - -2004-09-06 Christophe de Vienne - - * configure.in: Prepared release 2.7.1. - -2004-08-13 Christophe de Vienne - - * libxml++/parsers/domparser.cc, libxml++/parsers/parser.cc: Fixed - bug #150082. - -2.7.0: - -2004-06-24 Murray Cumming - - * configure.in, Makefile.am, libxml++-2.*.pc.in: Reverted the changes - that made it install a 2.8 pc.in file, and which decreased the .so - name. 2.8 is not parallel-installable with 2.6, and this would only - have been a half-done transition if it was. - -2004-06-22 Murray Cumming - - * libxml++/io/outputbuffer.cc, inputbuffer.cc: - Added include of libxml/globals.h before include of libxml/xmlIO.h, - because xmlIO.h needs the definition of - xmlParserInputBufferCreateFilenameFunc. - -2004-05-28 Christophe de Vienne - - * configure.in, examples/Makefile.am, examples/dtdvalidation/Makefile.am, - examples/dtdvalidation/example.dtd, examples/dtdvalidation/main.cc, - libxml++/Makefile.am, libxml++/dtd.[h|cc], libxml++/io/Makefile.am, - libxml++/io/istreamparserinputbuffer.[h|cc], - libxml++/io/parserinputbuffer.[h|cc], - libxml++/libxml++.h, libxml++/validators/Makefile.am, - libxml++/validators/dtdvalidator.[h|cc] - libxml++/validators/validator.[h|cc]: - Integrated dtdvalidator patch proposed by Guillaume Arreckx. - Modified a bit the patch: - - renamed *.cpp -> *.cc - - fixed a few comments which where copy/paste from other files - - replaced std::string with Glib::ustring - - Added Dtd::cobj, since the patch rely on it. - - added a validaty_error as suggested by jon - - -2004-04-26 Christophe de VIENNE - - * libxml++/nodes/contentnode.cc: Fixed set_content which used xmlNodeAddContent - instead of xmlNodeSetContent (thanks to Marcello Orizi who outlined it). - -2004-05-05 Christophe de Vienne - - * libxml++/parsers/saxparser.cc: One more (last one I hope) change - about Glib::ustring instanciation from a buffer + lenght. We now - use Glib::ustring::ustring(In begin, In end) constructor. Thanks to - Jonathan Wakely. - -2004-05-04 Christophe de Vienne - - * libxml++/parsers/saxparser.cc: Replaced again the use of - Glib::ustring(const char*) constructor by Glib::ustring(std::string). - Fixes #141824. - -2004-05-04 Christophe de Vienne - - * libxml++/parsers/saxparser.cc: Replace the use of - Glib::ustring(const char*, unsigned) constructor by Glib::ustring(const char*). - Fixes #141824. - -2004-05-04 Murray Cumming - - * libxml++-2.6.pc.in: Made it require glibmm-2.4, so that apps do not - have to check for this themselves. - -2.6.0: - -2004-04-13 Murray Cumming - - * libxml++/Makefile.am: Change library name to 2.6 instead of 2.5. - * libxml++-2.6.pc.in: Report the changed library name. - -2004-03-27 Murray Cumming - - * libxml++/parsers/textreader.[h|cc]: Correct constness of - get_current_node(), so there is a const and non-const version. - -2.5.2: - -2004-02-16 Christophe de VIENNE - - * libxml++/nodes/element.cc: Check return value of xmlHasNsProp to - fix issue #134390 (as reported by John Coyle). Use xmlHasProp instead - of testing each attributes. - -2004-02-16 Christophe de VIENNE - - * libxml++-2.6.pc.in: Added libxml-2.0 to Requires: and removed - @LIBXML_LIBS@ from libs, as suggested by Albert Chin. - -2004-02-16 Christophe de VIENNE - - * libxml++/nodes/node.cc, libxml++/parsers/parser.h: - Merged in patches from Albert Chin to get libxml++ build using the SUN, - HP, SGI & AIX C++ compilers. - -2004-02-13 Jim Garrison - - * libxml++/attribute.h, libxml++/document.h, libxml++/dtd.h, - libxml++/io/ostreamoutputbuffer.[h|cc], - libxml++/io/outputbuffer.[h|cc], libxml++/keepblanks.[h|cc], - libxml++/nodes/node.h, libxml++/parsers/parser.h, - libxml++/parsers/saxparser.h, libxml++/parsers/textreader.[h|cc]: - Removed unnecessary semicolons - -2.5.1: - -2004-02-08 Jim Garrison - - * libxml++/document.[h|cc]: added Document::cobj() function - -2004-02-06 Christophe de Vienne - - * libxml++/parsers/sax_parser.cc: Fixed issue #132014. - -2004-02-06 Christophe de Vienne - - * libxml++/parsers/[Makefile.am|textreader.h|textreader.cc]: Added - TextReader interface. It is almost the patch which is here : - http://sourceforge.net/tracker/index.php?func=detail&aid=842730&group_id=12999&atid=312999 - with Glib::ustring instead of std::string, and member functions names - changed to be consistent with other interfaces. - * configure.in, examples/Makefile.am, examples/textreader: Added an example - of TextReader interface. - -2004-02-05 Jim Garrison - - * libxml++/document.[h|cc]: added create_root_node_by_import() - -2004-01-13 Christophe de Vienne - - * libxml++/io/document.cc: Gives NULL strings instead of empty ones to - xmlCreateIntSubset. Fixes issue #131329. - -2004-01-12 Christophe de Vienne - - * libxml++/io/outputbuffer.cc: Fix return value of xmlIO callbacks. (Fixes - issue #131018). - -2003-12-19 Murray Cumming - - * configure.in: Added glibmm-2.4 to the pkg-config check. - * Used regexxer to do a complete std::string/Glib::ustring rename. - Everything seems to still work. I think the parse_chunk(stream) - stuff might need some attention/thought. - -2003-12-19 Murray Cumming - - * removed acinclude.m4 because we do not need it anymore because - we do not need AM_LIBXML now that we use pkg-config. - * libxml++/Makefile.am: Generate a library with 2.5 in the name, - instead of 1.0 - * configure.in: Change version to 2.5.0. - * examples/Makefile.am_fragment: Link to the new library name. - * Renamed libxml++-1.0.pc.in to libxml++-2.6.pc.in: and changed the - library name that pkg-config reports for --libs. - * So, this is now the libxml++ 2.6 API, with a library name of 2.5 - while it is unstable. It is parallel-installable with libxml++ 1.0. - -This is the HEAD branch, for libxml++ 2.5/2.6. - -1.0.0: - -2003-12-18 Ephraim Vider - * examples/sax_parser_build_dom/svgelement.cc,svgpath.h: - - removed unneeded method qualification (msvc6 error) - * examples/sax_parser_entities/myparser.cc: - - removed namespace qualification (msvc6 error) - - removed return from void function - -2003-12-18 Ephraim Vider - - * win32_msvc6: updated MSVC projects to include new sources and examples - -2003-12-12 Christophe de Vienne - - * libxml++/parsers/sax_parser.cc: removed initialisation of userData - with this at the context creation (solution given by Murray). - -2003-12-11 Murray Cumming - - * libxml++/Makefile.am: Generate a library with 1.0 in the name, - instead of 0.1 - * configure.in: Change version to 1.0.0, and change shared library - version to 1.0.0 because we are staring again witt the first - version of a new shared library. - * examples/Makefile.am_fragment: Link to the new library name. - * libxml++-1.0.pc.in: Change the library name that pkg-config - reports for --libs. - -2003-12-08 Ephraim Vider - - * libxml++/document.cc: remove return statement from void functions - -0.28: - -2003-12-08 Christophe de Vienne - - * libxml++.spec.in: Removed libxml++.m4 and xml++-config from %files - section. - -2003-12-08 Murray Cumming - - * examples/ Added sax_parser_build_dom example from Dan Dennedy. - It does some funky stuff (see the comments) but it is an - interesting concept. See the description in examples/README. - -2003-12-03 Christophe de Vienne - - * configure.in: use libxml-2.0 instead of xml2 for libxml2 detection - by pkg-config. - * libxml++/parser/sax_parser.[h|cc]: Replaced AttributeMap by AttributeList, - which is now an ordered container (std::deque). Added a functor that can be - used with std::find_if to get an Attribute by it's name. - * libxml++/document.h: Fixed a typo in a doxygen command. - -2003-12-03 Murray Cumming - - * examples/README: explained what the examples do. - -2003-11-28 Christophe de Vienne - - * libxml++/docs/index.html: Added libxml2 version we relay on, as - suggested by Paul Breslin. - * configure.in: Prepared 0.28 release. Check for libxml2 >= 2.5.8 using - pkg-config instead of old-style autoconf macro. - * acinclude.m4: Removed. - -2003-11-27 Murray Cumming - - * Added examples/sax_parser_entites to test the new functionality. - * Added doxygen documentation to almost every class and method, - including mentioning that the parse methods throw exceptions. - -2003-11-27 Murray Cumming - - * Applied patch from Dan Dennedy to add entity handling to the - SAX parser, using a 2nd Document instance to manage the entity - definitions in order to provide a default entity reference resolver - implementation for on_get_entity(). With some minor changes from me. - -2003-11-13 Christophe de Vienne - - * libxml++/io/Makefile.am: Made libio a non installed library. - * libxml++/document.cc: Fixed a serious issue with threading: callbacks - were defined only for the main thread. - -0.27: - -2003-10-28 Murray Cumming - - * libxml++/nodes/element.[h|cc]: Changed get_child_content() to - get_child_text(), set_child_content() to set_child_text(), - add_comment() to add_child_comment(), and add_content() to - add_child_content() to make the API clearer. - -2003-10-25 Christophe de Vienne - - * libxml++/document.[h|cc]: Added Document::add_comment and added some - documentation. - -2003-10-22 Murray Cumming - - * libxml++/parsers/saxparser.[h.cc]: Added on_entity_declararation() - callback, and demonstrated it in examples/sax_parser/. - Added documentation to on_get_entity() giving clues about how to use - it, though it is too difficult for me to try. - -2003-10-18 Christophe de Vienne - - * All: All private members previously having a leading underscore in their - name now have it postfixed. Ex: _impl becomes impl_. - -2003-10-18 Christophe de Vienne - - * libxml++/io/outputbuffer.[h|cc]: Removed conversion operator to - underlying C structure. cobj() is now public. - * libxml++/document.cc: use OutputBuffer::cobj() instead of implicit - conversion. - -2003-10-18 Christophe de Vienne - - * libxml++/nodes/Makefile.am: Removed some trailing white spaces after a - backslash. - -2003-10-14 Murray Cumming - - * Added lots of doxygen documentation, try to document everything 100%. - * libxml++/nodes/element.[h|cc]: Made get_attributes() non-const - and added a const get_attributes() const overload, like - Node::get_children(). - * Moved AttributesList typedef from Node to Element, because that's - where it is used. - * libxml++/parsers/parser.[h|cc]: Added get/set_substitute_entities(), - like get/set_validate(), which affects _context->replaceEntities in - initialize_context(). - * Added libxml++/nodes/entityreference.[h|cc], with a - get_resolved_text() method. - * libxml++/document.cc: - - on_libxml_construct(): For the default, used when a node is not - recognised, create a Node rather than a ContentNode. Everything is a - Node so this should have less chance of being wrong. - - Added case to create an EntityReference. - * Added examples/dom_parse_entities. - -2003-09-30 Jonathan Wakely - - * libxml++/document.cc, libxml++/nodes/element.cc, - libxml++/nodes/node.cc: Preserve const-quals when casting between - strings of different character types. - -2003-09-26 Christophe de Vienne - - * libxml++/io/outputbuffer.[h|cc]: Yet another cleaning of the interface - and implementation. OutputBuffer is now non copyable, and the callback - process is now the same for write and close. - * libxml++/io/(ostream)outputbuffer.h: Added Doxygen documentation. - -2003-09-26 Christophe de Vienne - - * libxml++/io/: Small corrections after Murray comments on the patch. It's - even more clean now. - -2003-09-26 Christophe de Vienne - - * libxml++/io/: Added classes to wrap xmlIO output buffers. This classes - are OutputBuffer and OStreamOutputBuffer. - * libxml++/document.h: - - Added write_to_stream, which is implemented thanks to OutputBuffer. - - Removed virtual specifier on write_to_xxx functions. Their - implemention now calls a private virtual function do_write_to_xxx. This - also avoid having almost identical functions implementation in normal and - formatted versions of the functions. - -2003-09-24 Christophe de Vienne - - * libxml++/examples/dom_build/main.cc: Now demonstrate add_comment - too. - -2003-09-24 Dan Dennedy - - * libxml++/nodes/element.[h|cc]: Added Element::add_comment. - -2003-09-23 Christophe de Vienne - - * libxml++/document.h, libxml++/keepblanks.h, libxml++/noncopyable.h, - libxml++/nodes/node.h: Updated documentation. - -0.26: - -2003-09-22 Christophe de Vienne - - * examples/dom_build/main.cpp: Use Element::set_attribute instead of - Element::add_attribute which no longer exists. - -2003-09-19 Murray Cumming - - * libxml++/node/element.h: Removed add_attribute because it is the same as - set_attribute. - -2003-09-18 Murray Cumming - - * libxml++/node/element.h: Added set_namespace_declaration(). - element, node: methods take prefix instead of uri and prefix, because - that's what we want to specify most of the time. If no such namespace - prefix has been declared then an exception will be thrown. If we want - to specify a node name and attribute namespaces by uri (which would - result in a prefix in the eventual .xml code) then we could add those - methods later. If anybody needs them. - -2003-09-17 Christophe de Vienne - - * docs/reference/Doxyfile(.in): Doxyfile is now generated from Doxyfile.in - by configure so the version number is included in main page. The dot image - format is changed to png, the index is not disabled anymore. - -2003-09-15 Fredrik Arnerup - - * libxml++/document.cc: Added a call to xmlInitParser to avoid - threading problems. - -2003-09-05 Murray Cumming - - Based on the patch from Dan Dennedy, with changes: - * libxml++/node.[h|cc], - libxml++/element.[h|cc]: Added namespace_uri and namespace_prefix - parameters to methods, to support speficiation of nodes and children - also with namespace information. - * Added Node::get_namespace_prefix() and get_namespace_uri() and - set_namespace(). - * examples/dom_build/: Modified the example to do namespace stuff, - to test this. - -2003-08-20 Murray Cumming - - * libxml++/node.[h|cc]: import_node() now takes a _const_ Node, as - suggested by Rafael Vuijk. - -2003-07-20 Ephraim Vider - - * win32_msvc6: libxml++.dsp, examples/import_node.dsp, examples/Makefile.am: - - added import_node example project - -0.25: - -2003-07-16 Christophe de Vienne - - * libxml++.m4, xml++-config.in, configure.in, Makefile.am: removed old-style - autoconf libxml++ detection macro and script. - -2003-07-15 Christophe de Vienne - - * all but exceptions/*.[h|cc]: removed throw specification from functions - declaration. - -2003-07-11 Eric Bourque - - * nodes/node.[h|cc]: Added import_node function - * examples/import_node: Added an example of using import_node, and modified - autoconf files accordingly. - -2003-06-25 Ephraim Vider - - * win32_msvc6: libxml++.dsp: added _REENTRANT to support libxml with threads - - examples/Makefile.am: added new example project - -2003-06-16 Christophe de Vienne - - * docs/index.html: Added a link to Doxygen website. - -2003-06-16 Ephraim Vider - - * win32_msvc6/*: Fixed MSVC6 project files. - -2003-06-13 Christophe de Vienne - - * docs/Makefile.am: Fixed the post-html rule which was sending twice the - reference. - * docs/index.html: Added keyword "XML". - -0.24: - -2003-06-11 Christophe de Vienne - - * libxml++/parsers/domparser.cc: - - Fixed parse_stream. Parsing success was not checked before creating - Document. - - Check for errNo after parsing. - -2003-06-02 Ephraim Vider - * libxml++/nodes: - Added ContentNode as a base class for all non-element nodes - - TextNode and CommentNode are derived from ContentNode - - Added CdataNode and ProcessingInstructionNode as specific types - derived from ContentNode - - Will create ContentNode as a default node type when assert is - disabled - - Modified dom_parser example to better handle new types - Modified files: textnode.[h|cc] commentnode.[h|cc] - Added files: contentnode.[h|cc] cdatanode.[h|cc] processinginstructionnode.[h|cc] - - * node.cc: - Fix. return empty string and not 0 - * updated MSVC projects to include new sources and example - -2003-06-10 Jonathan Wakely - - * libxml++/parsers/saxparser.cc: Replace with - to support older compilers. - -2003-06-06 Christophe de Vienne - - * libxml++/document.cc: Little change in write_to_xxx_formatted. The - keepblanks parameter is kept to true, but xmlIndentOutputTree is set to 1. - This avoid libxml2 to add some significant whitespace into content nodes, - but still format the output. - -2003-06-05 Christophe de Vienne - - * libxml++/keepblanks.[h|cc]: Moved KeepBlanks::Default definition - to .cc file if compiler is MSVC 6.0. - -2003-06-04 Morten Hanssen - - * libxml++/Document.cc: Fixed a memory leak in - write_to_string[_formatted]() functions. - -2003-06-02 Murray Cumming - - * libxml++/Document.[h|cc]: Removed the standalone parse_* methods - because they just duplicate functionality and nobody seems to be - using them. - Renamed the private construct() and destruct() callbacks to - on_libxml_construct() and on_libxml_destruct() and added some - simple comments to explain their purpose. - * libxml++/node.[h|cc]: Added Node::is_white_space(), to make it - easier for the application to ignore white space. Used it in - the dom_parser example.. - -2003-05-29 Murray Cumming - - * Removed some struct keywords from method and variable definitions. - They don't seem to be necessary, and they do not match the method - definitions in the .cc files. - * Some syntax clean-up - tabs to spaces and adding spaces. - * examples/dom_parse/main.cc: Say when something is a text node. - -2003-05-28 Christophe de Vienne - - * lixml++/document.[h|cc]: Added write_to_file_formatted and - write_to_string_formatted. - -2003-05-25 Jonathan Wakely - - * libxml++/parsers/saxparser.cc: Included - -2003-05-23 Jonathan Wakely - - * libxml++/parsers/saxparser.[h|cc]: Correct comments. - -2003-05-23 Christophe de Vienne - - * all header files: Removed libxml2 headers inclusion. Added necessary - forward declaration of libxml2 structures. - * libxml++/parsers/saxparser.[h|cc]: Moved static callback functions into - a struct defined only in the .cc file, SaxParserCallback. - Added boolean parameter to SaxParser constructor to activate on_get_entity - callback (default to false). This technique could eventually be extended to - other functions in the future. - * libxml++-1.0.pc.in: removed libxml headers include path from Cflags. - -2003-05-22 Christophe de Vienne - - * libxml++/nodes/node.[h|cc]: Added Node::set_name(). - -2003-05-20 Christophe de Vienne - - * libxml++/nodes/[node.cc|element.h]: Minor syntax adjustments to allow - compiling with g++ -ansi -pedantic -Wall without any warning. - -0.23: - -2003-05-20 Christophe de Vienne - - * libxml++/keepblanks.[h|cc]: New KeepBlanks class which change settings - related to xmlKeepBlanksDefault and xmlIndentTreeOuput. - * libxml++/[document.cc|parsers/*parsers.cc]: use KeepBlanks instead of - manually call xmlKeepBlanksDefault(). Significant white spaces are not - removed/added anymore. - * example/dom_read_write/example_output.xml: removed. - -2003-05-16 Murray Cumming - - * libxml++/noncopyable.[h|cc]: New xmlpp::NonCopyable base class, which - should prevent people from using automatically-generated copy - constructors when they shouldn't. Not tested yet. - * libxml++/examples/dom_read_write: New example/test. This does - show that we are removing significant white space. This has been - discussed on the list and apparently Christophe has a fix for it. - -2003-05-06 Andy Glew - - * libxml++/nodes/node.cc: Node::find( nonexistent_xpath ) now return - empty NodeSet - -2003-04-24 Christophe de Vienne - - * libxml++/parsers/saxparser.cc: Fixed a memory leak pointed by "thierry" - . The sax handler of the context is not reset - to 0 before context release anymore. In parse() the default one is saved - then restored after effective parsing, so libxml handle itself its - destruction. - -2003-04-20 Christophe de Vienne - - * libxml++/document.cc: Removed a warning message that was put on std::cout - if an unknown type of node was created and replaced it by an assert. This - avoid the need to include iostream(.h). - -2003-04-18 Murray Cumming - - * Applied Jaka Jejcic's patch to fix compilation on NetBSD, including - iostream.h instead of istream.h. - -2003-04-09 Eric Bourque - - * libxml++.spec.in: modified spec file to be library version agnostic. - -2003-03-19 Ephraim Vider - - * added msvc support in win32_msvc6. - -2003-03-17 Ephraim Vider - - * Modified sax_exception example: - - corrected Clone() return type for MyException in myparser.[h|cc] - - catch all exceptions in main.cc - handle real errors too - -0.22: - -2003-03-15 Murray Cumming - - * libxml++/parser/domparser.cc: Added const overload of get_document(). - -2003-03-13 Christophe de Vienne - - * libxml++/parser/domparser.cc: Test if context creation is - successfull in the different parse_xxx functions. If it is no an - internal_error is thrown. - -2003-03-06 Ephraim Vider - - * made DomParser a wrapper around Document - removed all functions that were duplicates of document - functions and added get_document() - files: domparser.[h|cc] document.h - - * fixed compilation errors for msvc: - - corrected Clone() return type for derived exceptions - - corrected getline to std::getline in saxparser.cc - - changed clear() to erase() in parser.cc - - added #define for vsprintf in parser.h - - fixed warning in element.cc - -0.21: - -2003-02-21 Eric Bourque - - * Added spec.in, for creating RPMs. - -2003-02-20 Murray Cumming - - * libxml++/nodes/node.[h|cc]: Moved get_child_content(), - set_child_content(), add_content(), and has_content() from Node to - derived Element class instead of just throwing an exception if it - isn't an Element. This means you can't use set_child_content() on a - TextNode - you should be using TextNode::set_content() anyway, which - makes a lot more sense. Corrected set_child_content() to create a - TextNode instead of creating a node with the content as the name, - fixing the output of the dom_build example. - -2003-02-20 Murray Cumming - - * libxml++/parsers/parser.[h|cc]: - initialize_contex(): Request iniitialization and connect callbacks - check_exception(): Throw exception if any validation problems have - been found - the messages are built up gradually by repeated - callbacks. - set_validate(): Enables validation before calling parse_*(). - Alternatively, use 2nd bool parameter to the DomParser constructor. - * libxml++/exceptions/: Added validation_error class. - * examples/dom_parser: Added a DTD and changed example.xml to - something that uses it. Also added example_invalid.xml to test - the exceptions. - -2003-02-12 Ole Laursen - - * examples/sax_parser/main.cc: Added chunk-wise parsing to the - example. - - * libxml++/parsers/saxparser.[h,cc]: Added functionality for - parsing chunks of data. - -2003-02-17 Murray Cumming - - * libxml++/parsers/*.[h|cc]: All parsing is now done via contexts, - which required a little duplication of the implementation of functions - such as xmlParseFile(), most of which is now in - DomParser::parse_context(). This avoids use of global functions such - as xmlKeepBlanksDefault() by setting these booleans directly in the - context, in Parser::initialize_context(). - However, xmlCreateFileParserCtxt() does seem to be affected by - xmlKeepBlanksDefault so we still have to use it temporarily, restoring - the old value afterwards - see the comments in DomParser::parse_file(). - This should allow us to add validation to the API. - -0.20: - -2003-02-15 Murray Cumming - - * libxml++/nodes/node.cc: (remove_child): Implemented it with - xmlUnlinkNode and xmlFreeNode, so that it's actually removed. - -2003-02-15 Murray Cumming - - * Added examples/dom_xpath, with code from Stefan Seefeld's dom - example. - -2003-02-15 Murray Cumming - - * Reverted the Node::child_iterator API change because it was - undiscussed and is unfinished. The BRANCH_1_0 and HEAD branches are now - merged. BRANCH_1_0 should no longer be used. This was never in 0.19. - -0.19: - -2003-02-07 Murray Cumming - - * Moved method implementations such as get_attributes() into derived - classes instead of using "using methodname();". That seems clearer. - However it shows that we should probably create a shared base class for - Content and Comment, as in the DOM. - -2003-02-06 Murray Cumming - - * libxml++/parsers/saxparser.[h|cc]: Corrected some coding style. - -2003-02-06 Murray Cumming - - * Changed c_obj() to cobj() because it's more like gobj() used in - gtkmm, gnomemm, etc. - -2003-02-06 Murray Cumming - - * libxml++/nodes/node.*: Corrected code style. - -2003-02-06 Murray Cumming - - * libxml++/nodes/node.[h|cc], libxml++/attribute.[h|cc]: Made c_obj() - accessors public so people can use them. Provided const and non-const - versions of them. Put implementation in .cc file. - * Reverted some of Stefan's coding style changes and corrected the - coding style in libxml++/nodes/document.[h|cc]. - * libxml++/document.h: Made the destructor virtual, because there are - virtual methods. - -2002-02-04 Stefan Seefeld - - * libxml++/node.[h,cc]: add new insert_child and append_child methods - (using new iterators), add get_path and find methods for xpath lookup - - * examples/dom: new example code to illustrate the new features - -2002-02-03 Stefan Seefeld - - * libxml++/node.h, libxml++/parsers/saxparser.[h,cc], - examples/sax_parser/*.[h,cc], examples/sax_exception/*.[h,cc]: - SaxParser::AttributeMap is now a map. - -2002-02-03 Stefan Seefeld - - * libxml++/node.h: add child_iterators for simple C++ style - iteration (to get eventually rid of NodeList) - -2002-02-03 Stefan Seefeld - - * libxml++/attribute.[h,cc], libxml++/nodes/node.[h,cc], - libxml++/document.cc: derive Attribute from Node, and make - get_value() use libxml2 accessor instead of raw pointer - -2002-02-03 Stefan Seefeld - - * libxml++/document.[h,cc], libxml++/parsers/domparser.[h,cc], - libxml++/libxml++.h, libxml++/Makefile.am: introduce new Document type. - * examples/dom_build/main.cc: make dom_build example use new - Document type - -2002-02-03 Stefan Seefeld - - * acinclude.m4: The AM_LIBXML macro now checks for a libxml2 - version >= 2.5.1. - * libxml++/nodes/node.cc: compare strings, not pointers, in - get_attribute() - -2003-01-31 Stefan Seefeld - - * various: overall change to use libxml2 as implementation, - not only as I/O backend. With corrections by Murray Cumming. - Further explanation by murrayc: Instead of maintaining its own - C++ data structures and then creating libxml data structures from them, - it now manipulates the libxml data structures directly, so the C++ and C - APIs are always in sync. - -2003-01-21 Valentin Rusu - - * added CDATA section handler to SaxParser - -2003-01-05 Valentin Rusu - - * fixed a potential buffer overflow problem into saxparser.cc - -0.18: - -2003-01-31 Stefan Seefeld - - * various: overall change to use libxml2 as implementation, - not only as I/O backend. - -2003-01-05 Murray Cumming - - * examples/dom_build/main.cc: Removed some useless test C code. - -2002-12-24 Morten Brix Pedersen - - * Include instead of to compile on gcc 2.95.4. - -2002-12-26 Murray Cumming - - * libxml++/nodes/element.c (write): Add back the code to write the - attributes to the C libxml structure. This code got lost during the - refactoring. - -2002-12-25 Murray Cumming - - * Removed unused constructors, to simplify things. Made Node's - destructor virtual, because we delete them polymorphically, and - because it has virtual methods. - -2002-12-25 Murray Cumming - - * libxml++/nodes/node.[h|cc]: Removed the initialized member - variable and its accessor, because it's not used. - -2002-12-19 Murray Cumming - - * libxml++/parsers/domparser.[h|cc]: get/set_root_node() now returns - an Element instead of a Node. - -2002-12-19 Murray Cumming - - * Changed const & accessors to get_*() methods. For instance, - Node::name -> Node::get_name - Node::children() -> Node::get_children() - Element::attributes() -> Element::get_attributes() - Attribute::value -> Attribute::get_value() - -2002-12-18 Murray Cumming - - * Added libxml++/nodes/commentnode.[h|cc] and used it in Node so that - comments don't just show up as name=comment Nodes. - * examples/dom_parser/example.xml: Added a comment. - * examples/dom_parser/main.cc: Do a dynamic_cast<> check for comments - too. - -2002-12-18 Christophe de Vienne - - * libxml++/parser/saxparser.cc: Fixed a bug in exception handling in - parse_stream. Thanks to Fredrik Arnerup for reporting - the bug. - -2002-12-17 Murray Cumming - - * Added libxml++/nodes/textnode.[h|cc]. This should remove the - confusion about whether content()/set_content() should be used on - a text node or the parent of a text node. - * libxml++/nodes/node.[h|cc]: - - Node::write() is now virtual, and - different in TextNode. - - content() replaced by get_child_content, which returns a TextNode* - instead of a string. - - set_content() replaced by set_child_content(). - * Added libxml++/nodes/element.[h|cc] so that TextNode can inherit - from a Node class without the attributes API. As per the Java DOM API, - Node still has the children API - I guess there's some reason for that, - though I don't see how a TextNode could have children. - -2002-12-17 Murray Cumming - - * Moved node.[h|cc] into nodes sub directory, in preparation for the - multiple-node-types API change. - -2002-12-12 Jonathan Wakely - - * libxml++/parsers/saxparser.cc, saxparser.h (on_get_entity): New - virtual function to allow derived classes to override entity handling - -2002-12-16 Murray Cumming - - * libxml++/node.cc: write(): - - Don't set the node->type directly. Let - xmlNodeSetContent take care of adding a suitable child node. This - was leading to segfaults when write() later tried to add a child node - to a text node. - - Throw internal_error exception when xmlNewChild returns NULL. - - -0.17:. - -2002-12-10 Christophe de Vienne - - * configure.in: updated version numbers for next release. Generic - version is now 0.17, library version is 3:0:0 - * NEWS: updated with changes since 0.16 version. - -2002-12-10 Christophe de Vienne - - * libxml++/node.cc: fixed write() which was using the accessors content() - and has_content(). Since they return something for both the text - node and the parent node, the output was weird. - -2002-12-09 Murray Cumming - - * libxml++/node.cc: content(): If the cached content string is empty, - try to get the content of a child "text" node. This makes content() - work as expected after creating a document with set_content() and - later reparsing it. - -2002-12-09 Murray Cumming - - * libxml++/parsers/dom_parser.cc (release_underlying): Set pointers - to 0 so that the get_*() methods generate new instances instead of - returning invalid pointers. - -2002-12-09 Murray Cumming - - * libxml++/node.cc: Node::remove_child() and Node::remove_attribute: - delete the objects when forgetting about them. - * libxml++/node.h: Added reference docs explaining the above. - -2002-12-07 Murray Cumming - - * libxml++/parsers/domparser.cc, saxparser.cc: Added comments about - the use of xmlKeepBlanksDefault() and xmlLineNumbersDefault(). - * libxml++/parsers/saxparser.[h|cc]: Change exception & to exception&. - -2002-12-06 Christophe de Vienne - - * libxml++/parsers/domparser.cc: Enabled xml option LineNumbers - and disabled KeepBlanks before each parsing. - * libxml++/parsers/sax_parser.cc: Enabled xml option KeepBlanks - before each parsing. - * example/dom_parser/main.cc: Added line number display for each - non-content node. Changed a bit content display - * Note: in a near future I may change these options settings to - let the user choose which options he wants/wants not. - - -2002-12-03 Jone Marius Vignes - - * libxml++/parsers/domparser.cc: Changed the exception in - write_to_string() to "write_to_string() failed." - * libxml++/parsers/domparser.h: Corrected documentation of - write_to_string() and write_to_file() to clarify that these methods - doesn't return booleans - -2002-12-02 Christophe de Vienne - - * libxml++/exceptions/*.[h|cc]: Added and implemented virtual - methods Raise() and Clone. - * libxml++/parser/sax_parser.[h|cc]: Each callback method can now - throw some exceptions as long as they herit from xmlpp::exception - AND implement Raise() and Clone(). - * libxml++/examples/sax_exception/: Added an example which demonstrate - the use of exceptions inside a SaxParser. - -2002-11-29 Murray Cumming - - * autogen.sh: Added libtoolize to generate files such as ltmain.sh. - -2002-11-28 Christophe de Vienne - - * acinclude.m4: The AM_LIBXML macro now checks for a libxml2 - version >= 2.4.1. - -2002-11-21 Christophe de Vienne - - * libxml++/parsers/*.[h|cc]: added Parser::parse_stream method - and implemented it in both DomParser and SaxParser. Tests based - on the examples (not commited in the cvs) worked perfectly. - -2002-11-20 Christophe de Vienne - - * libxml++/parsers/saxparser.cc: fixed a memory leak (thanks - to Chris Leishman who reported it. - -2002-11-20 Murray Cumming - - * Changed use of the term properties to attributes in the API, - because that is the correct terminology. - -0.16: - -2002-11-19 Christophe de Vienne - - * configure.in: updated version numbers for next release. - version is set to 0.16, library version to 2:0:0 - -2002-11-19 Murray Cumming - - * docs: Added index.html, which can be a main website page. - * docs/Makefile.am: Added rsync command to upload the html, - including the reference documentation. - -2002-11-19 Murray Cumming - - * Added Dtd class, which is just a collection of std::strings. - * libxml++/parsers/domparser.[h|cc]: Added set_internal_subset() and - get_internal_subset() to set the DTD declaration. This is set in the - underlying C xmlDoc during write_to_file() and write_to_disk(). - -2002-11-18 Murray Cumming - - * libxml++/node.[h|cc]: - - Rename is_content() to has_content(), because that's what it tells - us. Removed _is_content member bool - we can check _content.empty() - instead. - - write(): Do not manually set the xmlNode's type field to TEXT. This - corrupted the tree. Tested content nodes in example/dom_build. - -2002-11-18 Murray Cumming - - * libxml++/parsers/domparser.cc (write_to_*): Corrected no-root-node - check. - -2002-11-18 Murray Cumming - - * libxml++/exceptions/exception.[h|cc]: Corrected signature of what() - method, adding const throw(). - -2002-11-18 Murray Cumming - - * libxml++/parsers/domparser.[h|cc]: Added DomParser::set_root_node(). - * examples: Added dom_build, to show runtime construction of an XML - tree. - -2002-11-18 Murray Cumming - - * Parser, DomParser, SaxParser: parse_file() and parse_memory() now - throw exceptions. - * DomParser::write_to_file(): throws exception instead of using a bool - return value. - * examples/domparser/: Catches exceptions. - -2002-11-18 Christophe de Vienne - * libxml++/exceptions: splitted exception.[h|cc] in this directory. - The libxml_error has been removed for now, and a parse_error added. - -2002-11-17 Christophe de Vienne - * libxml++/attribute.h: Changed macro __LIBXMLPP_PROPERTY_H to __LIBXMLPP_ATTRIBUTE_H - * libxml++/exception.[h|cc]: Added xmlpp::exception, xmlpp::libxml_error and - xmlpp::internal_error classes. It's very basic for now. - -2002-11-17 Murray Cumming - - * Node, Attribute: set_*() method now have void return types. - * DomParser: Now has an empty underlying in-memory document when the - default constructor is used. This means that get_root_node() should - always return something, so we can build XML documents in memory - without loading any XML first. - -2002-11-16 Murray Cumming - - * libxml++/attribute.h: Added explicit to constructor. - -2002-11-16 Murray CUmming - - * libxml++/parsers/domparser: Renamed write() method to write_to_file() - and added write_to_string(). - -2002-11-16 Murray Cumming - - * libxml++-1.0.pc.in: More corrections. This was hopelessly broken - before. - -2002-11-16 Murray Cumming - - * libxml++-1.0.pc.in: Corrected typo. - -2002-11-16 Murray Cumming - - * docs/reference/Doxyfile: Used doxywizard to mark the Recursive - option, so it reads the libxml++/parsers directory too. - -2002-11-16 Murray Cumming - - * Attribute, Node: Added Doxygen class comment block. Changed some - something * to something*. - -2002-11-16 Murray Cumming - - * libxml++/node.[h|cc]: Added parameter names. Made const and non-const - overloads of children() method. - * libxml++/parsers/domparser.[h|cc]: Added const get_root_node() const - overload. - -2002-11-16 Christophe de Vienne - * libxml++/parsers/*: renamed method Parser::parse to - Parser::parse_file - -2002-11-16 Christophe de Vienne - * libxml++/parsers/saxparser.[h|cc]: rewritten - SaxParser::parse(filename) and SaxParser::parse_memory(string). - They both use a SaxParser::parse() - method. The parse_chunk and finish methods has been removed. - * example/sax_parser/parser.cc: minor bugfix: the Attribute pointer - was printed instead of the value. - -2002-11-16 Christophe de Vienne - * Property: has been renamed to Attribute. However, the "properties" - token has been kept when speaking of all the attributes of a node, - as in the libxml library. - * node.cc: rewritten a few loops so they have a more 'c++' looking. - rewritten some portions of code where an attribute is searched by name. - -2002-11-15 Murray Cumming - * Changed e.g. std::string &something to std::string& something, - using regexxer. - -2002-11-15 Christophe de Vienne - * example/sax_parser/parser.cc: #included - -2002-11-15 Christophe de Vienne - * libxml++/parsers/saxparser.cc: #included cstdarg instead of stdarg.h - to follow the c++ standard. #included to have std::cerr - it's - needed on strict c++ compiler (g++ 3.2 for instance). - * example/dom_parser/main.cc: #included - -2002-11-15 Murray Cumming - - * libxml++/parsers/saxparser.cc: #included stdarg.h - it seems to - be necessary with some compilers. - -2002-11-15 Murray Cumming - - * DomParser:: Added get_encoding() and write() methods. - * Removed Tree - Use DomParser instead. - -2002-11-15 Murray Cumming - - * SaxParser now inherits from Parser, with parse() and parse_memory() - methods. - * Added example/sax_parser example, but the start_element callback - doesn't seem to be called. - -2002-11-15 Murray Cumming - - * Parser, DomParser: Added parse_memory() method. - * Node::children(): Removed bad early-optimisation hack - it returned - a static function variable instead of returning by value. This meant - that >1 results of children() could not be used simultaneously. - For instance, this meant that it could not be called recursively. - -2002-11-12 Murray Cumming - - * Node, Property: Used explicit keyword on constructors. - -2002-11-12 Murray Cumming - - * Added parsers directory. - * Renamed Parser to SaxParser. - * Added DomParser, intended as a replacement for Tree, but that has - not yet been removed. I don't intend to implement the libxml-1 - compatibility stuff. - * Added examples directory structure, with one tiny dom_parser example. - -2002-11-12 Christophe de Vienne - * node.[h|cc]: name() method now return a reference. - * Tree/Node: The readnode and writenode functions have been removed - and transfered somehow into Node as a new constructor and write(). - The libxml++-private.[h|cc] has been removed. - -2002-11-12 Murray Cumming - - * Parser: It's no longer a templated type - to provide your own - callback implementations you can now just derive your own parser and - override the on_*() methods. - -2002-11-12 Murray Cumming - - * Moved implementation into the .cc files. - * Changed n, v and p parameter names to name, value and properties. - -2002-11-12 Murray Cumming - - * Split the single xml.[h|cc] files into node, property, tree and - parser files, with a libxml++.h header file that includes them all. - * Removed the XML prefixes from type names - we don't need it because - we use a namespace now. - * Placed typedefed lists and map inside their classes. For instance, - XMLNodeList is now xmlpp::Node::NodeList. - * Node::children(): Use !(n.empty()) instead of (n.length() == 0), for - perfomance. - * Tree: changed fn parameter names to filename. - -2002-11-12 Christophe de Vienne - * AUTHORS: Added Murray Cumming to the contributors - -2002-11-08 Christophe de Vienne - * libxml++/xml.cc: corrected _line initialisation in XMLNode::XMLNode(const XMLNode *from) - -2002-11-08 Christophe de Vienne - - * libxml++/xml.cc: Test if doc encoding is not null before - reading it (thanks to Marcel Bosc). - -2002-11-05 Murray Cumming - - * Added docs/reference/. Run make in this directory to generate - reference documentation with doxygen. - * libxml++/xml.h: Removed macros around namespace - all compilers - must now support namespaces. - * libxml++/xml.[h|cc]: Replaced (void) with () - it's not necessary - in C++. - -2002-11-05 Murray Cumming - - * libxml++/Makefile.am and configure.in: Implemented shared library - interface versioning. - -2002-11-05 Murray Cumming - - * Put source code in libxml++ directory, ready for it to be split up - into separate files. Client code should now include - libxml++/xml++.h rather than just xml++.h. - -2002-11-05 Murray Cumming - - * Headers are now installed in a versioned directory, to allow - coexistence with future major versions of libxml++. You may need to - remove the previously installed xml++.h file. - * Library name changed to libxml++-0.1, to be changed to libxml++-1.0 - when libxml++ stabilizes its API. This is also to allow future versions - to be parallel installed. - * Added pkg-config file as a simpler and more maintainable alternative - to the -config file and m4 script. - -Version 0.14 - * Ported to g++ 3.2. The code should now also compile on compilers which are a bit more strict about c++ than previous versions of g++ - * Added method XMLNode::line() wich returns the line number of a non content node in the source file. - * Added encoding file support through XMLTree::encoding() and XMLTree::set_encoding() methods - * Replacement of hash_map by map for node properties lists, since it has been reported to be faster, and to simplify porting to other plarfoms. - * libxml++ classes has been put in a separated namespace, libxmlpp. If you don't want namespace, just undefine the LIBXMLPP_USE_NAMESPACE - * encoding and compression settings are now loaded at parsing of file/buffer. - - -Version O.12 to 0.13 - No Changelog. - -Version O.11 - * Modified interface to allow for more complete coverage of possible uses of XML files. - -Version O.10 - * Added SAX parser. - -Version O.2 to 0.9 - No Changelog. - -Version O.1 - * Original release. From 24cce95ddedec35bf16e22e1e4686307d6e56b8c Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 28 Apr 2025 15:03:23 +0200 Subject: [PATCH 238/240] Meson build: Don't distribute libxmlplusplus.doap --- meson.build | 1 + 1 file changed, 1 insertion(+) diff --git a/meson.build b/meson.build index ca525da2..b7f31e55 100644 --- a/meson.build +++ b/meson.build @@ -320,6 +320,7 @@ meson.add_dist_script( # Don't distribute these files and directories. dont_distribute = [ + 'libxmlplusplus.doap', '.github', ] # Add build scripts to the distribution directory, and delete .gitignore From 3b5399b24dff7343b0ee1f27dc0e12ab28954971 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 28 Apr 2025 15:04:25 +0200 Subject: [PATCH 239/240] Documentation: Clarify download locations Future releases will not be stored at download.gnome.org/sources/. Very old releases are not stored at github.com/libxmlplusplus/ libxmlplusplus/releases/. --- README.md | 2 +- docs/.gitignore | 1 + docs/index.md | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 docs/.gitignore diff --git a/README.md b/README.md index d6e6145a..15e40c8b 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Web site - https://libxmlplusplus.github.io/libxmlplusplus/ Download location - - https://download.gnome.org/sources/libxml++/ + - https://download.gnome.org/sources/libxml++/ (until 5.4.0) - https://github.com/libxmlplusplus/libxmlplusplus/releases/ Reference documentation diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 00000000..57510a2b --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1 @@ +_site/ diff --git a/docs/index.md b/docs/index.md index 0c4051e7..db26ce69 100644 --- a/docs/index.md +++ b/docs/index.md @@ -38,7 +38,9 @@ don't have access to the newer glibmm-2.68 ABI (glibmm version 2.68.0 or higher) ## Download You can download libxml++ from [GitHub releases](https://github.com/libxmlplusplus/libxmlplusplus/releases/) -or the [GNOME download site](https://download.gnome.org/sources/libxml++/). +(since 2.42.0, 3.2.0, 4.0.0 and 5.0.0) +or the [GNOME download site](https://download.gnome.org/sources/libxml++/) +(until 2.42.3, 3.2.5, 4.2.0 and 5.4.0). ## Required Libraries From 3f4f5405cc94870ae95071c9414d0f091a468b84 Mon Sep 17 00:00:00 2001 From: Kjell Ahlstedt Date: Mon, 28 Apr 2025 16:13:12 +0200 Subject: [PATCH 240/240] Document: Ignore deprecation of xmlIndentTreeOutput --- libxml++/document.cc | 4 ++++ libxml++/keepblanks.cc | 1 + 2 files changed, 5 insertions(+) diff --git a/libxml++/document.cc b/libxml++/document.cc index 3cd72aab..9222a6e3 100644 --- a/libxml++/document.cc +++ b/libxml++/document.cc @@ -7,6 +7,10 @@ * which should be included with libxml++ as the file COPYING. */ +// xmlIndentTreeOutput is deprecated since libxml2 2.15.0. +// Ignore deprecations here. +#define XML_DEPRECATED + #include #include #include diff --git a/libxml++/keepblanks.cc b/libxml++/keepblanks.cc index 56b00cf5..f00660f6 100644 --- a/libxml++/keepblanks.cc +++ b/libxml++/keepblanks.cc @@ -6,6 +6,7 @@ */ // xmlKeepBlanksDefault() is deprecated since libxml2 2.12.0. +// xmlIndentTreeOutput is deprecated since libxml2 2.15.0. // Ignore deprecations here. #define XML_DEPRECATED