diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..3cb1495 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ + +Makefile eol=lf +configure eol=lf \ No newline at end of file diff --git a/.gitignore b/.gitignore index b23381e..73c4c38 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,13 @@ *.o *.d +x86 +x64 +.vs +*.user apidoc config.mk libxmlmm.a libxmlmm.dll libxmlmm.so libxmlmm.pc -test-libxmlmm.exe -test-libxmlmm +libxmlmm-test.exe \ No newline at end of file diff --git a/Makefile b/Makefile index f2f44e9..49624d1 100644 --- a/Makefile +++ b/Makefile @@ -5,24 +5,23 @@ $(error config.mk not built. Run configure script.) endif CXX ?= g++ -CXXFLAGS += -Iinclude -DVERSION=\"$(VERSION)\" $(XML2_CFLAGS) +CXXFLAGS += -I. -DVERSION=\"$(VERSION)\" $(XML2_CFLAGS) LDFLAGS += -headers = $(wildcard include/*.h) -lib_hdr = $(wildcard src/*.h) -lib_src = $(wildcard src/*.cpp) +lib_hdr = $(wildcard libxmlmm/*.h) +lib_src = $(wildcard libxmlmm/*.cpp) lib_libs = $(XML2_LIBS) -test_hdr = $(wildcard test/*.h) -test_src = $(wildcard test/*.cpp) -test_libs = $(lib_libs) -lUnitTest++ +test_hdr = $(wildcard libxmlmm-test/*.h) +test_src = $(wildcard libxmlmm-test/*.cpp) +test_libs = $(lib_libs) extra_dist = Makefile README.md $(wildcard docs/*.md) -dist_files = $(headers) $(lib_hdr) $(lib_src) $(test_hdr) $(test_src) $(extra_dist) +dist_files = $(lib_hdr) $(lib_src) $(test_hdr) $(test_src) $(extra_dist) -ifeq ($(MSYSTEM), MINGW32) +ifeq ($(OS),Windows_NT) EXEEXT = .exe LIBEXT = .dll else - EXEEXT = + EXEEXT = .exe LIBEXT = .so endif @@ -33,14 +32,14 @@ all: libxmlmm$(LIBEXT) libxmlmm$(LIBEXT): $(patsubst %.cpp, %.o, $(lib_src)) $(CXX) -shared -fPIC $(CXXFLAGS) $(LDFLAGS) $^ $(lib_libs) -Wl,--out-implib=$(patsubst %$(LIBEXT),%.a, $@) -o $@ -check: test-libxmlmm$(EXEEXT) - ./test-libxmlmm$(EXEEXT) +check: libxmlmm-test$(EXEEXT) + ./libxmlmm-test$(EXEEXT) -test-libxmlmm$(EXEEXT): libxmlmm$(LIBEXT) $(patsubst %.cpp, %.o, $(test_src)) +libxmlmm-test$(EXEEXT): libxmlmm$(LIBEXT) $(patsubst %.cpp, %.o, $(test_src)) $(CXX) $(CXXFLAGS) $(LDFLAGS) $^ $(test_libs) -o $@ clean: - rm -f src/*.o src/*.d test/*.o test/*.d libxmlmm$(LIBEXT) test-libxmlmm$(EXEEXT) + rm -f libxmlmm/*.o libxmlmm/*.d libxmlmm-test/*.o libxmlmm-test/*.d libxmlmm$(LIBEXT) libxmlmm-test$(EXEEXT) dist: mkdir libxmlmm-$(VERSION) @@ -50,7 +49,7 @@ dist: install: libxmlmm$(LIBEXT) mkdir -p $(prefix)/include/libxmlmm - cp $(headers) $(prefix)/include/libxmlmm + cp $(lib_hdr) $(prefix)/include/libxmlmm mkdir -p $(prefix)/lib cp libxmlmm.a $(prefix)/lib mkdir -p $(prefix)/lib/pkgconfig diff --git a/configure b/configure index 1ef838f..0e16e03 100644 --- a/configure +++ b/configure @@ -2,7 +2,7 @@ # defaults prefix=/usr/local -VERSION="0.5.0" +VERSION="0.6.0" ERRORS=0 # Parse Arguments @@ -162,8 +162,8 @@ if test $ERRORS = 0; then echo "" echo "Writing config.mk" echo "CONFIG_MK_INCLUDED = 1" >> config.mk - echo "preifx ?= $prefix" >> config.mk - export_variable VERISON + echo "prefix ?= $prefix" >> config.mk + export_variable VERSION export_variable XML2_CFLAGS export_variable XML2_LIBS diff --git a/test/CDataTest.cpp b/libxmlmm-test/CDataTest.cpp similarity index 75% rename from test/CDataTest.cpp rename to libxmlmm-test/CDataTest.cpp index cfc69e7..b5f13cf 100644 --- a/test/CDataTest.cpp +++ b/libxmlmm-test/CDataTest.cpp @@ -1,31 +1,31 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include #include #include "rtest.h" -#include "Document.h" -#include "Element.h" -#include "CData.h" +#include +#include +#include // NOTE: Nodes can not live w/o their Document. @@ -35,51 +35,51 @@ SUITE(CDataTest) TEST(cdata_get_content) { xml::Document doc; - - std::string xml = + + std::string xml = "\n" "\n"; - + doc.read_from_string(xml); - + xml::Element* element = doc.get_root_element(); CHECK(element != NULL); - + std::vector children = element->get_children(); - CHECK_EQUAL(1, children.size()); + CHECK_EQUAL(1, children.size()); xml::CData* c_data = dynamic_cast(children.at(0)); CHECK(c_data != NULL); - CHECK_EQUAL("This is a test.", c_data->get_content()); + CHECK_EQUAL("This is a test.", c_data->get_content()); } - + //------------------------------------------------------------------------------ TEST(cdata_element_get_text) { xml::Document doc; - - std::string xml = + + std::string xml = "\n" "\n"; - + doc.read_from_string(xml); - + xml::Element* element = doc.get_root_element(); CHECK(element != NULL); - - CHECK_EQUAL("This is a test.", element->get_text()); + + CHECK_EQUAL("This is a test.", element->get_text()); } - + //------------------------------------------------------------------------------ TEST(cdata_behaves_like_text_in_xpath) { xml::Document doc; - - std::string xml = + + std::string xml = "\n" "\n"; - + doc.read_from_string(xml); std::string text = doc.query_string("/test/text()"); CHECK_EQUAL("This is a test.", text); } -} \ No newline at end of file +} \ No newline at end of file diff --git a/test/DocumentTest.cpp b/libxmlmm-test/DocumentTest.cpp similarity index 85% rename from test/DocumentTest.cpp rename to libxmlmm-test/DocumentTest.cpp index 1396946..04b385e 100644 --- a/test/DocumentTest.cpp +++ b/libxmlmm-test/DocumentTest.cpp @@ -1,30 +1,30 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include #include #include "rtest.h" -#include "Document.h" -#include "exceptions.h" +#include +#include SUITE(DocumentTest) { @@ -41,20 +41,20 @@ SUITE(DocumentTest) xml::Document doc; xml::Element* root = doc.create_root_element("test"); CHECK(root != NULL); - CHECK_EQUAL("test", root->get_name()); + CHECK_EQUAL("test", root->get_name()); } - + //------------------------------------------------------------------------------ - TEST(get_root_node_throws_on_no_root_element) + TEST(get_root_node_throws_on_no_root_element) { xml::Document doc; CHECK_THROW(doc.get_root_element(), xml::NoRootElement); } - + //------------------------------------------------------------------------------ - TEST(constness) + TEST(constness) { - const std::string xml = + const std::string xml = "\n" \ "\n"; const xml::Document doc(xml); @@ -62,49 +62,49 @@ SUITE(DocumentTest) CHECK(doc.get_root_element() != NULL); CHECK_EQUAL(xml, doc.write_to_string()); } - + //------------------------------------------------------------------------------ TEST(write_to_string) { xml::Document doc; xml::Element* root = doc.create_root_element("test"); - - std::string xml = + + std::string xml = "\n" \ "\n"; CHECK_EQUAL(xml, doc.write_to_string()); } - + //------------------------------------------------------------------------------ TEST(read_from_string) { xml::Document doc; - - std::string xml = + + std::string xml = "\n" "\n"; - + doc.read_from_string(xml); - + xml::Element* root = doc.get_root_element(); CHECK(root != NULL); - CHECK_EQUAL("test", root->get_name()); + CHECK_EQUAL("test", root->get_name()); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ TEST(build_html) { xml::Document doc; - xml::Element* html = doc.create_root_element("html"); - - xml::Element* head = html->add_element("head"); + xml::Element* html = doc.create_root_element("html"); + + xml::Element* head = html->add_element("head"); xml::Element* title = head->add_element("title"); title->set_text("This is a test HTML."); xml::Element* style_link = head->add_element("link"); style_link->set_attribute("rel", "stylesheet"); style_link->set_attribute("type", "text/css"); style_link->set_attribute("href", "style.css"); - + xml::Element* body = html->add_element("body"); xml::Element* h1 = body->add_element("h1"); h1->set_text("This is a test HTML"); @@ -113,11 +113,11 @@ SUITE(DocumentTest) xml::Element* em1 = p1->add_element("em"); em1->set_text("libxmlmm"); p1->add_text(". It aimes to see if a HTML document can be created with the interface."); - + std::stringstream buff; buff << doc; - - std::string ref = + + std::string ref = "\n" "This is a test HTML." "" @@ -126,7 +126,7 @@ SUITE(DocumentTest) CHECK_EQUAL(ref, buff.str()); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ TEST(read_from_stream) { std::stringstream xmat( @@ -142,7 +142,7 @@ SUITE(DocumentTest) " \n" "\n"); - const std::string xml(xmat.str()); + const std::string xml(xmat.str()); const xml::Document check(xml); xml::Document doc; @@ -150,8 +150,8 @@ SUITE(DocumentTest) // We assume our earlier testing of write_to_string is valid CHECK_EQUAL(doc.write_to_string(), check.write_to_string()); } - -//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ TEST(xpath_string_query) { std::stringstream xmsg( @@ -163,24 +163,24 @@ SUITE(DocumentTest) " Mike\n" " Hello everybody!\n" "\n"); - + xml::Document doc; doc.read_from_stream(xmsg); - + std::string body = doc.query_string("/message/body"); CHECK_EQUAL("Hello everybody!", body); std::string body_text = doc.query_string("/message/body/text()"); - CHECK_EQUAL("Hello everybody!", body_text); + CHECK_EQUAL("Hello everybody!", body_text); double to_count = doc.query_number("count(/message/to)"); - CHECK_CLOSE(3.0, to_count, 1e-4); - + CHECK_CLOSE(3.0, to_count, 1e-4); + std::string message_version_string = doc.query_string("/message/@version"); - CHECK_EQUAL("1.2", message_version_string); + CHECK_EQUAL("1.2", message_version_string); double message_version_number = doc.query_number("/message/@version"); - CHECK_CLOSE(1.2, message_version_number, 1e-4); + CHECK_CLOSE(1.2, message_version_number, 1e-4); } - -//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ TEST(xpath_get_elements) { std::stringstream xmsg( @@ -192,22 +192,22 @@ SUITE(DocumentTest) " Mike\n" " Hello everybody!\n" "\n"); - + xml::Document doc; doc.read_from_stream(xmsg); - + std::vector to_nodes = doc.find_nodes("/message/to"); CHECK_EQUAL(3, to_nodes.size()); - + std::vector to_elements = doc.find_elements("/message/to"); CHECK_EQUAL(3, to_elements.size()); - + CHECK_EQUAL("Joe", to_elements[0]->get_text()); CHECK_EQUAL("Sally", to_elements[1]->get_text()); CHECK_EQUAL("Mike", to_elements[2]->get_text()); } - -//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ TEST(xpath_get_element) { std::stringstream xmsg( @@ -219,46 +219,46 @@ SUITE(DocumentTest) " Mike\n" " Hello everybody!\n" "\n"); - + xml::Document doc; doc.read_from_stream(xmsg); - + xml::Node* from_node = doc.find_node("/message/from"); CHECK(from_node != NULL); - + xml::Element* from_element = doc.find_element("/message/from"); CHECK(from_element != NULL); - + CHECK_EQUAL("Mack", from_element->get_text()); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ TEST(writes_latin1) { xml::Document doc; xml::Element* root = doc.create_root_element("test"); - + std::stringstream buff; // NOTE: This implicitly tests write_to_string too. doc.write_to_stream(buff, "ISO-8859-1"); - - std::string ref = + + std::string ref = "\n" "\n"; CHECK_EQUAL(ref, buff.str()); } - -//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ TEST(writes_latin1_to_file) { xml::Document doc; xml::Element* root = doc.create_root_element("test"); - + std::stringstream buff; // NOTE: This implicitly tests write_to_string too. doc.write_to_stream(buff, "ISO-8859-1"); - - std::string ref = + + std::string ref = "\n" "\n"; CHECK_EQUAL(ref, buff.str()); diff --git a/test/ElementTest.cpp b/libxmlmm-test/ElementTest.cpp similarity index 90% rename from test/ElementTest.cpp rename to libxmlmm-test/ElementTest.cpp index 53fc5ca..cb7218a 100644 --- a/test/ElementTest.cpp +++ b/libxmlmm-test/ElementTest.cpp @@ -1,32 +1,32 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include #include #include "rtest.h" -#include "Document.h" -#include "Element.h" -#include "Comment.h" -#include "exceptions.h" +#include +#include +#include +#include // NOTE: Elements can not live w/o their Document. @@ -57,7 +57,7 @@ SUITE(ElementTest) root->set_text("This is a test"); CHECK_EQUAL("This is a test", root->get_text()); } - + //------------------------------------------------------------------------------ TEST(add_text) { @@ -67,7 +67,7 @@ SUITE(ElementTest) root->add_text(" a test"); CHECK_EQUAL("This is a test", root->get_text()); } - + //------------------------------------------------------------------------------ TEST(get_set_attribute) { @@ -77,7 +77,7 @@ SUITE(ElementTest) CHECK(root->has_attribute("key")); CHECK_EQUAL("value", root->get_attribute("key")); } - + //------------------------------------------------------------------------------ TEST(remove_attribute) { @@ -85,10 +85,10 @@ SUITE(ElementTest) xml::Element* root = doc.create_root_element("test"); root->set_attribute("key", "value"); root->remove_attribute("key"); - + CHECK(! root->has_attribute("key")); } - + //------------------------------------------------------------------------------ TEST(add_element) { @@ -98,32 +98,32 @@ SUITE(ElementTest) CHECK(element1 != NULL); CHECK_EQUAL("element1", element1->get_name()); } - + //------------------------------------------------------------------------------ TEST(get_parent) { xml::Document doc; xml::Element* root = doc.create_root_element("test"); xml::Element* element1 = root->add_element("element1"); - CHECK_EQUAL(root, element1->get_parent()); + CHECK_EQUAL(root, element1->get_parent()); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ TEST(browse_children) { xml::Document doc; xml::Element* root = doc.create_root_element("test"); - xml::Element* element1 = root->add_element("element1"); + xml::Element* element1 = root->add_element("element1"); xml::Element* element2 = root->add_element("element2"); xml::Element* element3 = root->add_element("element3"); - + std::vector children = root->get_children(); CHECK_EQUAL(3, children.size()); CHECK_EQUAL(element1, children[0]); CHECK_EQUAL(element2, children[1]); CHECK_EQUAL(element3, children[2]); } - + //------------------------------------------------------------------------------ TEST(simple_xpath_querry) { @@ -136,52 +136,52 @@ SUITE(ElementTest) " \n" " \n" "\n"); - + xml::Document doc; doc.read_from_stream(xmat); - + xml::Element* xroot = doc.get_root_element(); CHECK(xroot != NULL); - + xml::Element* xambient = xroot->find_element("./ambient"); CHECK(xambient != NULL); CHECK_EQUAL("ambient", xambient->get_name()); } - + //------------------------------------------------------------------------------ TEST(get_attribute_with_type) { std::stringstream xmsg( "\n" "\n"); - + xml::Document doc; doc.read_from_stream(xmsg); - + xml::Element* xroot = doc.get_root_element(); CHECK(xroot != NULL); - + CHECK_CLOSE(1.2f, xroot->get_attribute("version"), 1e-4f); CHECK_EQUAL(1, xroot->get_attribute("id")); CHECK_EQUAL("1.2", xroot->get_attribute("version")); } - + //------------------------------------------------------------------------------ TEST(get_attribute_with_invalid_type) { std::stringstream xmsg( "\n" "\n"); - + xml::Document doc; doc.read_from_stream(xmsg); - + xml::Element* xroot = doc.get_root_element(); CHECK(xroot != NULL); - + CHECK_THROW(xroot->get_attribute("version"), xml::Exception); - } - + } + //------------------------------------------------------------------------------ TEST(set_attribute_with_type) { @@ -190,5 +190,5 @@ SUITE(ElementTest) root->set_attribute("key", 8); CHECK(root->has_attribute("key")); CHECK_EQUAL("8", root->get_attribute("key")); - } + } } diff --git a/libxmlmm-test/libxmlmm-test.vcxproj b/libxmlmm-test/libxmlmm-test.vcxproj new file mode 100644 index 0000000..325360c --- /dev/null +++ b/libxmlmm-test/libxmlmm-test.vcxproj @@ -0,0 +1,175 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {a5fc3c73-9270-477a-8410-114d7c1515d2} + libxmlmmtest + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ + $(PlatformTarget)\$(Configuration)\ + + + false + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ + $(PlatformTarget)\$(Configuration)\ + + + true + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ + $(PlatformTarget)\$(Configuration)\ + + + false + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ + $(PlatformTarget)\$(Configuration)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + $(SolutionDir);%(AdditionalIncludeDirectories) + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + $(SolutionDir);%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + $(SolutionDir);%(AdditionalIncludeDirectories) + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + $(SolutionDir);%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + + + + + + + + + + + + + {ab20fad1-392f-4f4c-b835-419e9afbea92} + + + + + + \ No newline at end of file diff --git a/libxmlmm-test/libxmlmm-test.vcxproj.filters b/libxmlmm-test/libxmlmm-test.vcxproj.filters new file mode 100644 index 0000000..6ed2661 --- /dev/null +++ b/libxmlmm-test/libxmlmm-test.vcxproj.filters @@ -0,0 +1,39 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + \ No newline at end of file diff --git a/libxmlmm-test/libxmlmm-test.vcxproj.user b/libxmlmm-test/libxmlmm-test.vcxproj.user new file mode 100644 index 0000000..88a5509 --- /dev/null +++ b/libxmlmm-test/libxmlmm-test.vcxproj.user @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/test/rtest.cpp b/libxmlmm-test/rtest.cpp similarity index 98% rename from test/rtest.cpp rename to libxmlmm-test/rtest.cpp index 6b90018..cee718b 100644 --- a/test/rtest.cpp +++ b/libxmlmm-test/rtest.cpp @@ -11,7 +11,7 @@ namespace rtest static std::vector tests; return tests; } - + int run() { std::vector& tests = get_tests(); @@ -39,10 +39,10 @@ namespace rtest failed++; } } - + unsigned int succeded = tests.size() - failed; std::cerr << succeded << " of " << tests.size() << " tests succeded." << std::endl; - + return failed == 0 ? 0 : -1; } diff --git a/test/rtest.h b/libxmlmm-test/rtest.h similarity index 100% rename from test/rtest.h rename to libxmlmm-test/rtest.h diff --git a/test/test.cpp b/libxmlmm-test/test.cpp similarity index 76% rename from test/test.cpp rename to libxmlmm-test/test.cpp index fce3254..d7d1399 100644 --- a/test/test.cpp +++ b/libxmlmm-test/test.cpp @@ -1,28 +1,28 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include "rtest.h" int main() -{ +{ return rtest::run(); } diff --git a/libxmlmm.sln b/libxmlmm.sln new file mode 100644 index 0000000..6fdc000 --- /dev/null +++ b/libxmlmm.sln @@ -0,0 +1,41 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30406.217 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxmlmm", "libxmlmm\libxmlmm.vcxproj", "{AB20FAD1-392F-4F4C-B835-419E9AFBEA92}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libxmlmm-test", "libxmlmm-test\libxmlmm-test.vcxproj", "{A5FC3C73-9270-477A-8410-114D7C1515D2}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AB20FAD1-392F-4F4C-B835-419E9AFBEA92}.Debug|x64.ActiveCfg = Debug|x64 + {AB20FAD1-392F-4F4C-B835-419E9AFBEA92}.Debug|x64.Build.0 = Debug|x64 + {AB20FAD1-392F-4F4C-B835-419E9AFBEA92}.Debug|x86.ActiveCfg = Debug|Win32 + {AB20FAD1-392F-4F4C-B835-419E9AFBEA92}.Debug|x86.Build.0 = Debug|Win32 + {AB20FAD1-392F-4F4C-B835-419E9AFBEA92}.Release|x64.ActiveCfg = Release|x64 + {AB20FAD1-392F-4F4C-B835-419E9AFBEA92}.Release|x64.Build.0 = Release|x64 + {AB20FAD1-392F-4F4C-B835-419E9AFBEA92}.Release|x86.ActiveCfg = Release|Win32 + {AB20FAD1-392F-4F4C-B835-419E9AFBEA92}.Release|x86.Build.0 = Release|Win32 + {A5FC3C73-9270-477A-8410-114D7C1515D2}.Debug|x64.ActiveCfg = Debug|x64 + {A5FC3C73-9270-477A-8410-114D7C1515D2}.Debug|x64.Build.0 = Debug|x64 + {A5FC3C73-9270-477A-8410-114D7C1515D2}.Debug|x86.ActiveCfg = Debug|Win32 + {A5FC3C73-9270-477A-8410-114D7C1515D2}.Debug|x86.Build.0 = Debug|Win32 + {A5FC3C73-9270-477A-8410-114D7C1515D2}.Release|x64.ActiveCfg = Release|x64 + {A5FC3C73-9270-477A-8410-114D7C1515D2}.Release|x64.Build.0 = Release|x64 + {A5FC3C73-9270-477A-8410-114D7C1515D2}.Release|x86.ActiveCfg = Release|Win32 + {A5FC3C73-9270-477A-8410-114D7C1515D2}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ADD5A517-FE5A-472D-A0B3-A5E8E99308F2} + EndGlobalSection +EndGlobal diff --git a/src/Attribute.cpp b/libxmlmm/Attribute.cpp similarity index 84% rename from src/Attribute.cpp rename to libxmlmm/Attribute.cpp index 14e8041..3acc109 100644 --- a/src/Attribute.cpp +++ b/libxmlmm/Attribute.cpp @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include "Attribute.h" #include "utils.h" @@ -27,7 +27,7 @@ namespace xml //------------------------------------------------------------------------------ Attribute::Attribute(xmlNode* const cobj) : Node(cobj) {} - + //------------------------------------------------------------------------------ std::string Attribute::get_value() const { @@ -38,7 +38,7 @@ namespace xml } return ""; } - + //------------------------------------------------------------------------------ void Attribute::set_value(const std::string& value) { diff --git a/include/Attribute.h b/libxmlmm/Attribute.h similarity index 79% rename from include/Attribute.h rename to libxmlmm/Attribute.h index 07ef025..fd498f6 100644 --- a/include/Attribute.h +++ b/libxmlmm/Attribute.h @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #pragma once #include @@ -28,7 +28,7 @@ namespace xml { /** * XML Attribtue Node Wrapper - **/ + **/ class Attribute : public Node { public: @@ -36,15 +36,15 @@ namespace xml * Construct Wrapper **/ explicit Attribute(xmlNode* const cobj); - + /** * Get the value of this node. Empty if not found. - **/ + **/ virtual std::string get_value() const; - + /** * Set the value. **/ void set_value(const std::string& value); - }; + }; } diff --git a/src/CData.cpp b/libxmlmm/CData.cpp similarity index 78% rename from src/CData.cpp rename to libxmlmm/CData.cpp index f883ca1..ff13f08 100644 --- a/src/CData.cpp +++ b/libxmlmm/CData.cpp @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include "CData.h" diff --git a/include/CData.h b/libxmlmm/CData.h similarity index 78% rename from include/CData.h rename to libxmlmm/CData.h index 60dcf5a..3bbacd1 100644 --- a/include/CData.h +++ b/libxmlmm/CData.h @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #pragma once #include "Content.h" @@ -26,7 +26,7 @@ namespace xml { /** * CData Node - **/ + **/ class LIBXMLMM_EXPORT CData : public Content { public: @@ -34,6 +34,6 @@ namespace xml * Construct Wrapper **/ explicit CData(xmlNode* const cobj); - - }; + + }; } diff --git a/src/Comment.cpp b/libxmlmm/Comment.cpp similarity index 79% rename from src/Comment.cpp rename to libxmlmm/Comment.cpp index 6fbc448..408f960 100644 --- a/src/Comment.cpp +++ b/libxmlmm/Comment.cpp @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include "Comment.h" diff --git a/include/Comment.h b/libxmlmm/Comment.h similarity index 78% rename from include/Comment.h rename to libxmlmm/Comment.h index 3e80d0f..2422225 100644 --- a/include/Comment.h +++ b/libxmlmm/Comment.h @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #pragma once @@ -27,7 +27,7 @@ namespace xml { /** * XML Comment Node Wrapper - **/ + **/ class LIBXMLMM_EXPORT Comment : public Content { public: @@ -35,6 +35,6 @@ namespace xml * Construct Wrapper **/ explicit Comment(xmlNode* const cobj); - - }; + + }; } diff --git a/src/Content.cpp b/libxmlmm/Content.cpp similarity index 73% rename from src/Content.cpp rename to libxmlmm/Content.cpp index c55ab14..6e82e9e 100644 --- a/src/Content.cpp +++ b/libxmlmm/Content.cpp @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include "Content.h" #include "utils.h" @@ -25,9 +25,9 @@ namespace xml { //------------------------------------------------------------------------------ - Content::Content(xmlNode* cobj) + Content::Content(xmlNode* cobj) : Node(cobj) {} - + //------------------------------------------------------------------------------ std::string Content::get_value() const { @@ -38,22 +38,22 @@ namespace xml return std::string(); } -//------------------------------------------------------------------------------ - std::string Content::get_content() const +//------------------------------------------------------------------------------ + std::string Content::get_content() const { - return this->get_value(); + return this->get_value(); } - + //------------------------------------------------------------------------------ - void Content::set_content(const std::string& value) + void Content::set_content(const std::string& value) { xmlNodeSetContent(cobj, reinterpret_cast(value.c_str())); } - + //------------------------------------------------------------------------------ - bool Content::is_blank() const + bool Content::is_blank() const { - return xmlIsBlankNode(const_cast(cobj)); + return xmlIsBlankNode(const_cast(cobj)); } } diff --git a/include/Content.h b/libxmlmm/Content.h similarity index 81% rename from include/Content.h rename to libxmlmm/Content.h index 0e0d12c..553e8d5 100644 --- a/include/Content.h +++ b/libxmlmm/Content.h @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #pragma once @@ -29,7 +29,7 @@ namespace xml { /** * XML Text Node Wrapper - **/ + **/ class LIBXMLMM_EXPORT Content : public Node { public: @@ -37,14 +37,14 @@ namespace xml * Construct Wrapper **/ explicit Content(xmlNode* const cobj); - + /** - * Get the value of this node. + * Get the value of this node. * * @return Returns the value of this node or empty if not found. **/ virtual std::string get_value() const; - + /** * Set the value of this node. * @@ -58,17 +58,17 @@ namespace xml * @deprecated Use get_value(). **/ std::string get_content() const; - + /** * Set the content of a content node. * * @deprecated Use set_value(). **/ void set_content(const std::string& value); - + /** * Check if a given note is a blank node. **/ - bool is_blank() const; - }; + bool is_blank() const; + }; } diff --git a/src/Document.cpp b/libxmlmm/Document.cpp similarity index 90% rename from src/Document.cpp rename to libxmlmm/Document.cpp index f6a6a2e..7780a2b 100644 --- a/src/Document.cpp +++ b/libxmlmm/Document.cpp @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include "Document.h" @@ -28,7 +28,7 @@ namespace xml { - + //------------------------------------------------------------------------------ Document::Document() : cobj(xmlNewDoc(BAD_CAST "1.0")) @@ -53,7 +53,7 @@ namespace xml //------------------------------------------------------------------------------ bool Document::has_root_element() const { - return xmlDocGetRootElement(cobj) != NULL; + return xmlDocGetRootElement(cobj) != NULL; } //------------------------------------------------------------------------------ @@ -67,7 +67,7 @@ namespace xml return reinterpret_cast(root->_private); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ const Element* Document::get_root_element() const { return const_cast(this)->get_root_element(); @@ -78,21 +78,21 @@ namespace xml { if (has_root_element()) { - throw Exception("xml::Document::create_root_element(): Already has a root element."); + throw Exception("xml::Document::create_root_element(): Already has a root element."); } - - xmlNode* root = xmlNewDocNode(cobj, NULL, reinterpret_cast(name.c_str()), NULL); + + xmlNode* root = xmlNewDocNode(cobj, NULL, reinterpret_cast(name.c_str()), NULL); if (root == NULL) { throw Exception(get_last_error()); } - + xmlDocSetRootElement(cobj, root); - + return reinterpret_cast(root->_private); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ std::string Document::write_to_string() const { xmlChar* buffer = 0; @@ -106,10 +106,10 @@ namespace xml std::string xml(reinterpret_cast(buffer)); xmlFree(buffer); - + return xml; } - + //------------------------------------------------------------------------------ std::string Document::write_to_string(const std::string& encoding) const { @@ -124,17 +124,17 @@ namespace xml std::string xml(reinterpret_cast(buffer)); xmlFree(buffer); - + return xml; } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void Document::write_to_stream(std::ostream& os) const { - os << write_to_string(); + os << write_to_string(); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void Document::write_to_stream(std::ostream& os, const std::string& encoding) const { os << write_to_string(encoding); @@ -150,7 +150,7 @@ namespace xml } } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void Document::write_to_file(const std::string& file, const std::string& encoding) const { int result = xmlSaveFormatFileEnc(file.c_str(), cobj, encoding.c_str(), 1); @@ -159,13 +159,13 @@ namespace xml throw Exception(get_last_error()); } } - + //------------------------------------------------------------------------------ void Document::read_from_string(const std::string& xml) { xmlDoc* tmp_cobj = xmlReadDoc(reinterpret_cast(xml.c_str()), NULL, NULL, 0); if (tmp_cobj == NULL) - { + { throw Exception(get_last_error()); } xmlFreeDoc(cobj); @@ -178,19 +178,19 @@ namespace xml read_from_string(read_until_eof(is)); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void Document::read_from_file(const std::string& file) { xmlDoc* tmp_cobj = xmlReadFile(file.c_str(), NULL, 0); if (tmp_cobj == NULL) - { + { throw Exception(get_last_error()); } xmlFreeDoc(cobj); cobj = tmp_cobj; } - -//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ Node* Document::find_node(const std::string& xpath) { try @@ -202,8 +202,8 @@ namespace xml throw EmptyDocument(); } } - -//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ const Node* Document::find_node(const std::string& xpath) const { try @@ -216,7 +216,7 @@ namespace xml } } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ std::vector Document::find_nodes(const std::string& xpath) { try @@ -228,9 +228,9 @@ namespace xml throw EmptyDocument(); } } - -//------------------------------------------------------------------------------ - std::vector Document::find_nodes(const std::string& xpath) const + +//------------------------------------------------------------------------------ + std::vector Document::find_nodes(const std::string& xpath) const { try { @@ -242,7 +242,7 @@ namespace xml } } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ Element* Document::find_element(const std::string& xpath) { try @@ -254,7 +254,7 @@ namespace xml throw EmptyDocument(); } } - + //------------------------------------------------------------------------------ const Element* Document::find_element(const std::string& xpath) const { @@ -267,8 +267,8 @@ namespace xml throw EmptyDocument(); } } - -//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ std::vector Document::find_elements(const std::string& xpath) { try @@ -280,7 +280,7 @@ namespace xml throw EmptyDocument(); } } - + //------------------------------------------------------------------------------ std::vector Document::find_elements(const std::string& xpath) const { @@ -293,10 +293,10 @@ namespace xml throw EmptyDocument(); } } - + //------------------------------------------------------------------------------ - std::string Document::query_string(const std::string& xpath) const - { + std::string Document::query_string(const std::string& xpath) const + { try { return get_root_element()->query_string(xpath); @@ -307,7 +307,7 @@ namespace xml } } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ double Document::query_number(const std::string& xpath) const { try @@ -321,15 +321,15 @@ namespace xml } //------------------------------------------------------------------------------ - LIBXMLMM_EXPORT + LIBXMLMM_EXPORT std::ostream& operator << (std::ostream& os, const Document& doc) { doc.write_to_stream(os); return os; } - + //------------------------------------------------------------------------------ - LIBXMLMM_EXPORT + LIBXMLMM_EXPORT std::istream& operator >> (std::istream& is, Document& doc) { doc.read_from_stream(is); diff --git a/include/Document.h b/libxmlmm/Document.h similarity index 88% rename from include/Document.h rename to libxmlmm/Document.h index 2fd8cab..ff0c5be 100644 --- a/include/Document.h +++ b/libxmlmm/Document.h @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #pragma once @@ -34,19 +34,19 @@ namespace xml /** * XML DOM Document * - * This class is the root class for the XML DOM. + * This class is the root class for the XML DOM. * - * @todo Rename write_to_file and friends to write_file - **/ + * @todo Rename write_to_file and friends to write_file + **/ class LIBXMLMM_EXPORT Document { - public: - /** + public: + /** * Default Constructor **/ Document(); - - /** + + /** * Construct and populate from the specified xml string. * * @exception exception Throws exception if the xml is invalid. @@ -59,14 +59,14 @@ namespace xml * Destructor **/ ~Document(); - + /** * Check if the document has a root element. * * @return true if the document has a root element. **/ bool has_root_element() const; - + /** * Get the root element. * @@ -79,8 +79,8 @@ namespace xml **/ Element* get_root_element(); const Element* get_root_element() const; - /** @} **/ - + /** @} **/ + /** * Create the root element of a document. * @@ -92,56 +92,56 @@ namespace xml * has a root element. **/ Element* create_root_element(const std::string& name); - + /** * Write document to string. **/ std::string write_to_string() const; - + /** * Write document to string. **/ std::string write_to_string(const std::string& encoding) const; - + /** * Write document to stream. **/ void write_to_stream(std::ostream& os) const; - + /** * Write document to stream. **/ void write_to_stream(std::ostream& os, const std::string& encoding) const; - + /** * Write document to file. **/ void write_to_file(const std::string& file) const; - + /** * Write document to file. **/ void write_to_file(const std::string& file, const std::string& encoding) const; - + /** * Read document from string. * * @todo Add error handling. **/ void read_from_string(const std::string& xml); - + /** * Read document from stream. * * @todo Add error handling. **/ void read_from_stream(std::istream& is); - + /** * Read the XML document from file. **/ void read_from_file(const std::string& file); - + /** * Find a given node. * @@ -154,7 +154,7 @@ namespace xml Node* find_node(const std::string& xpath); const Node* find_node(const std::string& xpath) const; /** @} **/ - + /** * Find a given set of nodes. * @@ -167,7 +167,7 @@ namespace xml std::vector find_nodes(const std::string& xpath); std::vector find_nodes(const std::string& xpath) const; /** @} **/ - + /** * Find a given element. * @@ -180,7 +180,7 @@ namespace xml Element* find_element(const std::string& xpath); const Element* find_element(const std::string& xpath) const; /** @} **/ - + /** * Find a given set of elements. * @@ -192,8 +192,8 @@ namespace xml **/ std::vector find_elements(const std::string& xpath); std::vector find_elements(const std::string& xpath) const; - /** @} **/ - + /** @} **/ + /** * Query a value. * @@ -206,25 +206,25 @@ namespace xml std::string query_string(const std::string& xpath) const; double query_number(const std::string& xpath) const; /** @} **/ - + private: xmlDoc* cobj; - + LibXmlSentry libxml_sentry; - + Document(const Document&); Document& operator = (const Document&); - }; - - /** + }; + + /** * Stream insert operator. **/ - LIBXMLMM_EXPORT + LIBXMLMM_EXPORT std::ostream& operator << (std::ostream& os, const Document& doc); - - /** + + /** * Stream extract operator. **/ - LIBXMLMM_EXPORT + LIBXMLMM_EXPORT std::istream& operator >> (std::istream& is, Document& doc); } diff --git a/src/Element.cpp b/libxmlmm/Element.cpp similarity index 90% rename from src/Element.cpp rename to libxmlmm/Element.cpp index 576b3a8..ea41596 100644 --- a/src/Element.cpp +++ b/libxmlmm/Element.cpp @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include "Element.h" #include "exceptions.h" @@ -25,15 +25,15 @@ #include #include -#include +#include namespace xml { //------------------------------------------------------------------------------ Element::Element(xmlNode* const cobj) : Node(cobj) {} - -//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ std::string Element::get_name() const { assert(cobj != NULL); @@ -44,18 +44,18 @@ namespace xml return std::string(); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void Element::set_name(const std::string& value) { xmlNodeSetName(cobj, reinterpret_cast(value.c_str())); } - + //------------------------------------------------------------------------------ bool Element::has_attribute(const std::string& key) const { return xmlGetProp(cobj, reinterpret_cast(key.c_str())) != NULL; } - + //------------------------------------------------------------------------------ std::string Element::get_attribute(const std::string& key) const { @@ -66,22 +66,22 @@ namespace xml } return reinterpret_cast(value); } - + //------------------------------------------------------------------------------ void Element::set_attribute(const std::string& key, const std::string& value) { xmlSetProp(cobj, reinterpret_cast(key.c_str()), reinterpret_cast(value.c_str())); } - + //------------------------------------------------------------------------------ void Element::remove_attribute(const std::string& key) { - xmlUnsetProp(cobj, reinterpret_cast(key.c_str())); + xmlUnsetProp(cobj, reinterpret_cast(key.c_str())); } //------------------------------------------------------------------------------ std::string Element::get_value() const - { + { const Content* const content = get_text_node(); if (content != NULL) { @@ -90,10 +90,10 @@ namespace xml return std::string(); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ std::string Element::get_text() const { - return this->get_value(); + return this->get_value(); } //------------------------------------------------------------------------------ @@ -108,7 +108,7 @@ namespace xml if (child->type == XML_CDATA_SECTION_NODE) { return reinterpret_cast(child->_private); - } + } } return NULL; } @@ -131,18 +131,18 @@ namespace xml void Element::add_text(const std::string& text) { xmlNode* node = xmlNewText(reinterpret_cast(text.c_str())); - xmlAddChild(cobj, node); + xmlAddChild(cobj, node); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ Element* Element::add_element(const std::string& name) { xmlNode* node = xmlNewNode(NULL, reinterpret_cast(name.c_str())); - xmlAddChild(cobj, node); + xmlAddChild(cobj, node); return reinterpret_cast(node->_private); } - -//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ std::vector Element::get_children() { std::vector children; @@ -155,7 +155,7 @@ namespace xml return children; } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ std::vector Element::get_children() const { std::vector children; @@ -167,20 +167,20 @@ namespace xml } return children; } - -//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ Element* Element::find_element(const std::string& xpath) { return this->find(xpath); } - + //------------------------------------------------------------------------------ const Element* Element::find_element(const std::string& xpath) const { return this->find(xpath); } - -//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ std::vector Element::find_elements(const std::string& xpath) { return this->find_all(xpath); diff --git a/include/Element.h b/libxmlmm/Element.h similarity index 85% rename from include/Element.h rename to libxmlmm/Element.h index 5af00a6..8134cec 100644 --- a/include/Element.h +++ b/libxmlmm/Element.h @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #pragma once @@ -32,15 +32,15 @@ namespace xml { /** * XML Element Wrapper - **/ + **/ class LIBXMLMM_EXPORT Element : public Node { - public: - /** + public: + /** * Construct the Wrapper **/ explicit Element(xmlNode* const cobj); - + /** * Get the node's name. Empty if not found. **/ @@ -50,15 +50,15 @@ namespace xml * Set a node's name. **/ void set_name(const std::string& value); - + /** * Check if a given attribute exists. **/ bool has_attribute(const std::string& key) const; - - /** - * Get a given attribute. - * + + /** + * Get a given attribute. + * * This method will retrive an attribute. * * @param id the attribtue id @@ -68,7 +68,7 @@ namespace xml * this element. **/ std::string get_attribute(const std::string& key) const; - + /** * Get a given attribute in given type. * @@ -87,22 +87,22 @@ namespace xml T get_attribute(const std::string& id) const { std::stringstream conv(get_attribute(id)); - + T value; conv >> value; if (! conv.eof()) { throw xml::Exception("xml::Element::get_attribute<>: Type conversion failed."); } - + return value; } - + /** * Set an attribute. **/ void set_attribute(const std::string& id, const std::string& value); - + /** * Set an attribute with generic type. **/ @@ -113,21 +113,21 @@ namespace xml conv << value; set_attribute(id, conv.str()); } - + /** * Remove a given attribute. **/ void remove_attribute(const std::string& key); - + /** * Get the value of this node. Empty if not found. **/ virtual std::string get_value() const; - + /** * Get the element's text. Empty if not found. - * - * @tood Merge multiple text bits? + * + * @tood Merge multiple text bits? **/ std::string get_text() const; @@ -137,33 +137,33 @@ namespace xml * @todo Is this funciton really needed? **/ Content* get_text_node() const; - + /** - * Set the + * Set the **/ void set_text(const std::string& text); - + /** * Add/append text to this element. **/ void add_text(const std::string& text); - + /** * Add a element. **/ Element* add_element(const std::string& name); - + /** * Get all children of this element. * - * @return All children of this element. + * @return All children of this element. **/ std::vector get_children(); /** * Get all children of this element. * - * @return All children of this element. + * @return All children of this element. **/ std::vector get_children() const; @@ -178,7 +178,7 @@ namespace xml Element* find_element(const std::string& xpath); const Element* find_element(const std::string& xpath) const; /** @} **/ - + /** * Find a given set of elements. * @@ -189,9 +189,9 @@ namespace xml **/ std::vector find_elements(const std::string& xpath); std::vector find_elements(const std::string& xpath) const; - /** @} **/ - - private: - - }; + /** @} **/ + + private: + + }; } diff --git a/src/LibXmlSentry.cpp b/libxmlmm/LibXmlSentry.cpp similarity index 98% rename from src/LibXmlSentry.cpp rename to libxmlmm/LibXmlSentry.cpp index 168beee..25d1b08 100644 --- a/src/LibXmlSentry.cpp +++ b/libxmlmm/LibXmlSentry.cpp @@ -1,6 +1,6 @@ -// +// // Copyright (c) 2008 Sean Farrell -// +// // Permission is hereby granted, free of charge, to any person // obtaining a copy of this software and associated documentation // files (the "Software"), to deal in the Software without @@ -9,10 +9,10 @@ // copies of the Software, and to permit persons to whom the // Software is furnished to do so, subject to the following // conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,7 +21,7 @@ // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // OTHER DEALINGS IN THE SOFTWARE. -// +// #include "LibXmlSentry.h" @@ -46,7 +46,7 @@ namespace xml } use_count++; } - + //------------------------------------------------------------------------------ LibXmlSentry::~LibXmlSentry() { diff --git a/include/LibXmlSentry.h b/libxmlmm/LibXmlSentry.h similarity index 82% rename from include/LibXmlSentry.h rename to libxmlmm/LibXmlSentry.h index 5ada649..6b9215f 100644 --- a/include/LibXmlSentry.h +++ b/libxmlmm/LibXmlSentry.h @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #pragma once @@ -26,8 +26,8 @@ namespace xml /** * Manages libxml's initialisation and cleanup. * - * @note This class is an internal helper class that manages libxml's - * initialisation and cleanup. + * @note This class is an internal helper class that manages libxml's + * initialisation and cleanup. * * @note Multiple instances of LibXmlSentry can live side by side, libxml * will only be initialized once. @@ -35,21 +35,21 @@ namespace xml class LibXmlSentry { public: - /** + /** * Initialize libxml and register callback functions for construction * and destruction of wrappers. **/ LibXmlSentry(); - + /** * Clean up libxml. **/ ~LibXmlSentry(); - + private: /** The number of instances of libxml. **/ static unsigned int use_count; - + LibXmlSentry(const LibXmlSentry&); LibXmlSentry& operator = (const LibXmlSentry&); }; diff --git a/src/Node.cpp b/libxmlmm/Node.cpp similarity index 88% rename from src/Node.cpp rename to libxmlmm/Node.cpp index 169bb42..339d688 100644 --- a/src/Node.cpp +++ b/libxmlmm/Node.cpp @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include "Node.h" @@ -36,14 +36,14 @@ namespace xml { assert(cobj != NULL); } - + //------------------------------------------------------------------------------ - Node::~Node() + Node::~Node() { assert(cobj != NULL); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ std::string Node::get_path() const { xmlChar* path = xmlGetNodePath(cobj); @@ -51,12 +51,12 @@ namespace xml { throw Exception("xml::Node::get_path(): failed to allocated path"); } - + std::string value(reinterpret_cast(path)); xmlFree(path); return value; } - + //------------------------------------------------------------------------------ Element* Node::get_parent() { @@ -66,69 +66,69 @@ namespace xml } else { - // Ok, this never happens! - // A xmlNode only has no parent if it it is a document node + // Ok, this never happens! + // A xmlNode only has no parent if it it is a document node // (not root element) and this is not wraped by Node. throw Exception("no parent"); } } - + //------------------------------------------------------------------------------ const Element* Node::get_parent() const { return const_cast(this)->get_parent(); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ Node* Node::find_node(const std::string& xpath) { return this->find(xpath); } - + //------------------------------------------------------------------------------ const Node* Node::find_node(const std::string& xpath) const { return this->find(xpath); } - + //------------------------------------------------------------------------------ std::vector Node::find_nodes(const std::string& xpath) { return this->find_all(xpath); } - + //------------------------------------------------------------------------------ std::vector Node::find_nodes(const std::string& xpath) const { return this->find_all(xpath); } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ std::string Node::query_string(const std::string& xpath) const { FindNodeset search(cobj, xpath); const xmlXPathObject* result = search; - + std::string value; if (result->type == XPATH_STRING) { - value = reinterpret_cast(result->stringval); + value = reinterpret_cast(result->stringval); } else if (result->type == XPATH_NUMBER) { - value = to_string(result->floatval); + value = to_string(result->floatval); } else if (result->type == XPATH_NODESET) { const xmlNodeSet* nodeset = result->nodesetval; if (nodeset) { - // Concatenate all the text from all the text nodes we have. + // Concatenate all the text from all the text nodes we have. // NOTE: we technically shouldn't have to do this // since all adjacent text nodes are supposed to merge to // a single node, but that doesn't always happen in // libxml2. Most notably, when CDATA nodes are adjacent - // to other text nodes. + // to other text nodes. for (int i = 0; i != nodeset->nodeNr; i++) { const Node* node = reinterpret_cast(nodeset->nodeTab[i]->_private); @@ -136,20 +136,20 @@ namespace xml } } } - + return value; } - -//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ double Node::query_number(const std::string& xpath) const { FindNodeset search(cobj, xpath); const xmlXPathObject* result = search; - + double value = 0.0; if (result->type == XPATH_NUMBER) { - value = result->floatval; + value = result->floatval; } else if (result->type == XPATH_STRING) { @@ -164,10 +164,10 @@ namespace xml value = from_string(node->get_value()); } } - + return value; } - + //------------------------------------------------------------------------------ Node::FindNodeset::FindNodeset(xmlNode *const cobj, const std::string &xpath, const xmlXPathObjectType type) @@ -181,7 +181,7 @@ namespace xml xmlXPathFreeContext(ctxt); throw InvalidXPath(xpath); } - + if (type != XPATH_UNDEFINED && result->type != type) { xmlXPathFreeObject(result); diff --git a/include/Node.h b/libxmlmm/Node.h similarity index 87% rename from include/Node.h rename to libxmlmm/Node.h index b1ac9bd..6644cb1 100644 --- a/include/Node.h +++ b/libxmlmm/Node.h @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #pragma once @@ -35,9 +35,9 @@ namespace xml /** * XML DOM Node * - * The Node class is the base class for all DOM elements (except Document). + * The Node class is the base class for all DOM elements (except Document). * It is effectively a wrapper for xmlNode. - **/ + **/ class LIBXMLMM_EXPORT Node { protected: @@ -47,13 +47,13 @@ namespace xml * @param cobj The xmlNode object to wrap. **/ explicit Node(xmlNode* const cobj); - + public: /** * Destructor **/ - virtual ~Node(); - + virtual ~Node(); + /** * Get the node's path * @@ -78,10 +78,10 @@ namespace xml * * @{ **/ - Element* get_parent(); - const Element* get_parent() const; + Element* get_parent(); + const Element* get_parent() const; /** @} **/ - + /** * Find a given node. * @@ -94,7 +94,7 @@ namespace xml Node* find_node(const std::string& xpath); const Node* find_node(const std::string& xpath) const; /** @} **/ - + /** * Find a set of nodes. * @@ -109,7 +109,7 @@ namespace xml std::vector find_nodes(const std::string& xpath); std::vector find_nodes(const std::string& xpath) const; /** @} **/ - + /** * Query a value. * @@ -124,30 +124,30 @@ namespace xml std::string query_string(const std::string& xpath) const; double query_number(const std::string& xpath) const; /** @} **/ - + /** * Get the value of this node. Empty if not found. **/ virtual std::string get_value() const = 0; - protected: + protected: /** The wrapped xmlNode object. **/ xmlNode* cobj; - + // Helper object to keep our xpath search context. - struct FindNodeset + struct FindNodeset { FindNodeset(xmlNode *const cobj, const std::string &xpath, const xmlXPathObjectType type = XPATH_UNDEFINED); ~FindNodeset(); operator xmlXPathObject* () - { - return result; + { + return result; } operator xmlNodeSet* () - { - return result->nodesetval; + { + return result->nodesetval; } private: @@ -156,7 +156,7 @@ namespace xml }; template - NodeType find(const std::string &xpath) const + NodeType find(const std::string &xpath) const { FindNodeset search(cobj, xpath, XPATH_NODESET); const xmlNodeSet* nodeset = search; @@ -168,7 +168,7 @@ namespace xml } template - std::vector find_all(const std::string &xpath) const + std::vector find_all(const std::string &xpath) const { FindNodeset search(cobj, xpath, XPATH_NODESET); const xmlNodeSet* nodeset = search; @@ -186,5 +186,5 @@ namespace xml private: Node(const Node&); Node& operator = (const Node&); - }; + }; } diff --git a/src/ProcessingInstruction.cpp b/libxmlmm/ProcessingInstruction.cpp similarity index 79% rename from src/ProcessingInstruction.cpp rename to libxmlmm/ProcessingInstruction.cpp index ecde4b0..820f991 100644 --- a/src/ProcessingInstruction.cpp +++ b/libxmlmm/ProcessingInstruction.cpp @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include "ProcessingInstruction.h" diff --git a/include/ProcessingInstruction.h b/libxmlmm/ProcessingInstruction.h similarity index 78% rename from include/ProcessingInstruction.h rename to libxmlmm/ProcessingInstruction.h index 9ade1a2..2edaa6a 100644 --- a/include/ProcessingInstruction.h +++ b/libxmlmm/ProcessingInstruction.h @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #pragma once @@ -27,7 +27,7 @@ namespace xml { /** * XML Processing Instruction Node Wrapper - **/ + **/ class LIBXMLMM_EXPORT ProcessingInstruction : public Content { public: @@ -35,6 +35,6 @@ namespace xml * Construct Wrapper **/ explicit ProcessingInstruction(xmlNode* const cobj); - - }; + + }; } diff --git a/src/Text.cpp b/libxmlmm/Text.cpp similarity index 78% rename from src/Text.cpp rename to libxmlmm/Text.cpp index 2d97c17..b3a83e5 100644 --- a/src/Text.cpp +++ b/libxmlmm/Text.cpp @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include "Text.h" diff --git a/include/Text.h b/libxmlmm/Text.h similarity index 78% rename from include/Text.h rename to libxmlmm/Text.h index acf2a81..4ae92ab 100644 --- a/include/Text.h +++ b/libxmlmm/Text.h @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #pragma once @@ -27,7 +27,7 @@ namespace xml { /** * XML Text Node Wrapper - **/ + **/ class LIBXMLMM_EXPORT Text : public Content { public: @@ -35,6 +35,6 @@ namespace xml * Construct Wrapper **/ explicit Text(xmlNode* const cobj); - - }; + + }; } diff --git a/include/defines.h b/libxmlmm/defines.h similarity index 75% rename from include/defines.h rename to libxmlmm/defines.h index 633ca66..4521e0c 100644 --- a/include/defines.h +++ b/libxmlmm/defines.h @@ -1,28 +1,28 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #pragma once #ifdef _WIN32 #define LIBXMLMM_EXPORT __declspec(dllexport) #else -#define LIBXMLMM_EXPORT +#define LIBXMLMM_EXPORT #endif diff --git a/include/exceptions.h b/libxmlmm/exceptions.h similarity index 83% rename from include/exceptions.h rename to libxmlmm/exceptions.h index 9a31272..29d582c 100644 --- a/include/exceptions.h +++ b/libxmlmm/exceptions.h @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #ifndef _LIBXMLMM_EXCEPTIONS_H_ #define _LIBXMLMM_EXCEPTIONS_H_ @@ -34,13 +34,13 @@ namespace xml struct NoRootElement : Exception { - NoRootElement() + NoRootElement() : Exception("No root element") {} }; struct EmptyDocument : Exception { - EmptyDocument() + EmptyDocument() : Exception("Document is empty") {} }; diff --git a/include/libxmlmm.h b/libxmlmm/libxmlmm.h similarity index 71% rename from include/libxmlmm.h rename to libxmlmm/libxmlmm.h index e5b4d07..c8df286 100644 --- a/include/libxmlmm.h +++ b/libxmlmm/libxmlmm.h @@ -1,34 +1,34 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #pragma once -#include "Document.h" +#include "Document.h" #include "Node.h" #include "Element.h" -#include "Content.h" -#include "Text.h" +#include "Content.h" +#include "Text.h" #include "CData.h" -#include "Comment.h" +#include "Comment.h" #include "ProcessingInstruction.h" #include "utils.h" -#include "LibXmlSentry.h" +#include "LibXmlSentry.h" #include "exceptions.h" diff --git a/libxmlmm/libxmlmm.vcxproj b/libxmlmm/libxmlmm.vcxproj new file mode 100644 index 0000000..612adf2 --- /dev/null +++ b/libxmlmm/libxmlmm.vcxproj @@ -0,0 +1,185 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {ab20fad1-392f-4f4c-b835-419e9afbea92} + libxmlmm + 10.0 + + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + DynamicLibrary + true + v142 + Unicode + + + DynamicLibrary + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ + $(PlatformTarget)\$(Configuration)\ + + + false + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ + $(PlatformTarget)\$(Configuration)\ + + + true + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ + $(PlatformTarget)\$(Configuration)\ + + + false + $(SolutionDir)$(PlatformTarget)\$(Configuration)\ + $(PlatformTarget)\$(Configuration)\ + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + stdcpp17 + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/libxmlmm/libxmlmm.vcxproj.filters b/libxmlmm/libxmlmm.vcxproj.filters new file mode 100644 index 0000000..e175035 --- /dev/null +++ b/libxmlmm/libxmlmm.vcxproj.filters @@ -0,0 +1,96 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + Source Files + + + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + Header Files + + + \ No newline at end of file diff --git a/src/utils.cpp b/libxmlmm/utils.cpp similarity index 90% rename from src/utils.cpp rename to libxmlmm/utils.cpp index 525c00a..f12135e 100644 --- a/src/utils.cpp +++ b/libxmlmm/utils.cpp @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #include "utils.h" @@ -50,7 +50,7 @@ namespace xml } } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void wrap_node(xmlNode* const cobj) { switch (cobj->type) @@ -83,7 +83,7 @@ namespace xml case XML_ATTRIBUTE_NODE: { cobj->_private = new Attribute(cobj); - break; + break; } case XML_DOCUMENT_NODE: { @@ -97,7 +97,7 @@ namespace xml } } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ void free_wrapper(xmlNode* const cobj) { switch (cobj->type) @@ -113,7 +113,7 @@ namespace xml delete node; cobj->_private = NULL; break; - } + } case XML_DOCUMENT_NODE: { /* there nodes are not wrapped */ @@ -126,7 +126,7 @@ namespace xml } } -//------------------------------------------------------------------------------ +//------------------------------------------------------------------------------ std::string read_until_eof(std::istream& is) { std::string result; diff --git a/include/utils.h b/libxmlmm/utils.h similarity index 84% rename from include/utils.h rename to libxmlmm/utils.h index e897272..2460ed8 100644 --- a/include/utils.h +++ b/libxmlmm/utils.h @@ -1,23 +1,23 @@ // -// Copyright (c) 2008-2012 Sean Farrell -// -// Permission is hereby granted, free of charge, to any person obtaining a copy of -// this software and associated documentation files (the "Software"), to deal in -// the Software without restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the -// Software, and to permit persons to whom the Software is furnished to do so, +// Copyright (c) 2008-2020 Sean Farrell +// +// Permission is hereby granted, free of charge, to any person obtaining a copy of +// this software and associated documentation files (the "Software"), to deal in +// the Software without restriction, including without limitation the rights to use, +// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the +// Software, and to permit persons to whom the Software is furnished to do so, // subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all +// +// The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, -// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// +// #ifndef _LIBXMLMM_UTILS_H_ #define _LIBXMLMM_UTILS_H_ @@ -28,29 +28,29 @@ #include namespace xml -{ +{ /** * Get the last error as string from libxml. **/ std::string get_last_error(); - + /** * Wrap a node. * * @note This function is used as callback to libxml. **/ void wrap_node(xmlNode* const node); - + /** * Free the wrapper of a node. * * @note This function is used as callback to libxml. **/ void free_wrapper(xmlNode* node); - - /** Read from a stream until EOF. **/ + + /** Read from a stream until EOF. **/ std::string read_until_eof(std::istream& is); - + /** * Convert arbitrary value to string. **/ @@ -61,7 +61,7 @@ namespace xml buff << value; return buff.str(); } - + /** * Convert arbitrary value from string. **/