diff --git a/libxmlmm/Attribute.cpp b/libxmlmm/Attribute.cpp index d21427b..14e8041 100644 --- a/libxmlmm/Attribute.cpp +++ b/libxmlmm/Attribute.cpp @@ -1,34 +1,34 @@ // -// 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, +// 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, // 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" namespace xml { - +//------------------------------------------------------------------------------ Attribute::Attribute(xmlNode* const cobj) : Node(cobj) {} - - + +//------------------------------------------------------------------------------ std::string Attribute::get_value() const { const char *const ptr = reinterpret_cast(xmlGetProp(cobj->parent, cobj->name)); @@ -38,8 +38,8 @@ namespace xml } return ""; } - - + +//------------------------------------------------------------------------------ void Attribute::set_value(const std::string& value) { xmlSetProp(cobj->parent, cobj->name, reinterpret_cast(value.c_str())); diff --git a/libxmlmm/Attribute.h b/libxmlmm/Attribute.h index fd498f6..07ef025 100644 --- a/libxmlmm/Attribute.h +++ b/libxmlmm/Attribute.h @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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/libxmlmm/CData.cpp b/libxmlmm/CData.cpp index cecc566..f883ca1 100644 --- a/libxmlmm/CData.cpp +++ b/libxmlmm/CData.cpp @@ -1,29 +1,29 @@ // -// 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, +// 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, // 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" namespace xml { - +//------------------------------------------------------------------------------ CData::CData(xmlNode* const cobj) : Content(cobj) {} diff --git a/libxmlmm/CData.h b/libxmlmm/CData.h index 3bbacd1..60dcf5a 100644 --- a/libxmlmm/CData.h +++ b/libxmlmm/CData.h @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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/libxmlmm/Comment.cpp b/libxmlmm/Comment.cpp index 7bbf5a2..6fbc448 100644 --- a/libxmlmm/Comment.cpp +++ b/libxmlmm/Comment.cpp @@ -1,29 +1,29 @@ // -// 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, +// 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, // 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" namespace xml { - +//------------------------------------------------------------------------------ Comment::Comment(xmlNode* const cobj) : Content(cobj) {} diff --git a/libxmlmm/Comment.h b/libxmlmm/Comment.h index 2422225..3e80d0f 100644 --- a/libxmlmm/Comment.h +++ b/libxmlmm/Comment.h @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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/libxmlmm/Content.cpp b/libxmlmm/Content.cpp index 39f1858..c55ab14 100644 --- a/libxmlmm/Content.cpp +++ b/libxmlmm/Content.cpp @@ -1,34 +1,34 @@ // -// 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, +// 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, // 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" namespace xml { - - Content::Content(xmlNode* cobj) +//------------------------------------------------------------------------------ + Content::Content(xmlNode* cobj) : Node(cobj) {} - - + +//------------------------------------------------------------------------------ std::string Content::get_value() const { if (cobj->content != NULL) @@ -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/libxmlmm/Content.h b/libxmlmm/Content.h index 553e8d5..0e0d12c 100644 --- a/libxmlmm/Content.h +++ b/libxmlmm/Content.h @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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/libxmlmm/Document.cpp b/libxmlmm/Document.cpp index d30e991..8975d6d 100644 --- a/libxmlmm/Document.cpp +++ b/libxmlmm/Document.cpp @@ -1,42 +1,47 @@ // -// 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, +// 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, // 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" +#include + #include +#include +#include +#include #include "utils.h" #include "exceptions.h" namespace xml { - - + +//------------------------------------------------------------------------------ Document::Document() : cobj(xmlNewDoc(BAD_CAST "1.0")) { cobj->_private = this; } - +//------------------------------------------------------------------------------ Document::Document(const std::string &xml) : cobj(xmlNewDoc(BAD_CAST "1.0")) { @@ -44,19 +49,19 @@ namespace xml this->read_from_string(xml); } - +//------------------------------------------------------------------------------ Document::~Document() { xmlFreeDoc(cobj); } - +//------------------------------------------------------------------------------ bool Document::has_root_element() const { - return xmlDocGetRootElement(cobj) != NULL; + return xmlDocGetRootElement(cobj) != NULL; } - +//------------------------------------------------------------------------------ Element* Document::get_root_element() { xmlNode* root = xmlDocGetRootElement(cobj); @@ -67,32 +72,32 @@ namespace xml return reinterpret_cast(root->_private); } - +//------------------------------------------------------------------------------ const Element* Document::get_root_element() const { return const_cast(this)->get_root_element(); } - +//------------------------------------------------------------------------------ Element* Document::create_root_element(const std::string& name) { 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,11 +111,11 @@ namespace xml std::string xml(reinterpret_cast(buffer)); xmlFree(buffer); - + return xml; } - - + +//------------------------------------------------------------------------------ std::string Document::write_to_string(const std::string& encoding) const { xmlChar* buffer = 0; @@ -124,23 +129,23 @@ 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); } - +//------------------------------------------------------------------------------ void Document::write_to_file(const std::string& file) const { int result = xmlSaveFormatFile(file.c_str(), cobj, 1); @@ -150,7 +155,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,38 +164,38 @@ 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); cobj = tmp_cobj; } - +//------------------------------------------------------------------------------ void Document::read_from_stream(std::istream& is) { 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 +207,8 @@ namespace xml throw EmptyDocument(); } } - - + +//------------------------------------------------------------------------------ const Node* Document::find_node(const std::string& xpath) const { try @@ -216,7 +221,7 @@ namespace xml } } - +//------------------------------------------------------------------------------ std::vector Document::find_nodes(const std::string& xpath) { try @@ -228,9 +233,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 +247,7 @@ namespace xml } } - +//------------------------------------------------------------------------------ Element* Document::find_element(const std::string& xpath) { try @@ -254,8 +259,8 @@ namespace xml throw EmptyDocument(); } } - - + +//------------------------------------------------------------------------------ const Element* Document::find_element(const std::string& xpath) const { try @@ -267,8 +272,8 @@ namespace xml throw EmptyDocument(); } } - - + +//------------------------------------------------------------------------------ std::vector Document::find_elements(const std::string& xpath) { try @@ -280,8 +285,8 @@ namespace xml throw EmptyDocument(); } } - - + +//------------------------------------------------------------------------------ std::vector Document::find_elements(const std::string& xpath) const { try @@ -293,10 +298,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 +312,7 @@ namespace xml } } - +//------------------------------------------------------------------------------ double Document::query_number(const std::string& xpath) const { try @@ -319,17 +324,66 @@ namespace xml throw EmptyDocument(); } } + void handleValidationError(void* ctx, const char* format, ...) + { + std::string error_msg("\n"); + va_list args; + va_start(args, format); + const char* msg = va_arg(args, const char*); + va_end(args); + throw ValidationError(msg); + } + void Document::validate(const char* mem_kcd, int len) const + { + int result = 42; + xmlSchemaParserCtxtPtr parserCtxt = NULL; + xmlSchemaPtr schema = NULL; + xmlSchemaValidCtxtPtr validCtxt = NULL; + parserCtxt = xmlSchemaNewMemParserCtxt(mem_kcd, len); + schema = xmlSchemaParse(parserCtxt); + if (schema == NULL) + { + throw ValidationError("could not parse XSD schema"); + } + + validCtxt = xmlSchemaNewValidCtxt(schema); + if (!validCtxt) + { + throw ValidationError("could not create XSD schema validation context"); + } - LIBXMLMM_EXPORT + xmlSetStructuredErrorFunc(NULL, NULL); + xmlSetGenericErrorFunc(NULL, handleValidationError); + xmlThrDefSetStructuredErrorFunc(NULL, NULL); + xmlThrDefSetGenericErrorFunc(NULL, handleValidationError); + + result = xmlSchemaValidateDoc(validCtxt, cobj); + + if (parserCtxt) + { + xmlSchemaFreeParserCtxt(parserCtxt); + } + if (schema) + { + xmlSchemaFree(schema); + } + if (validCtxt) + { + xmlSchemaFreeValidCtxt(validCtxt); + } + } + +//------------------------------------------------------------------------------ + 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/libxmlmm/Document.h b/libxmlmm/Document.h index ff0c5be..805667d 100644 --- a/libxmlmm/Document.h +++ b/libxmlmm/Document.h @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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. * @@ -207,24 +207,26 @@ namespace xml double query_number(const std::string& xpath) const; /** @} **/ + void validate(const char* mem_kcd, int len) 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/libxmlmm/Element.cpp b/libxmlmm/Element.cpp index baec98f..576b3a8 100644 --- a/libxmlmm/Element.cpp +++ b/libxmlmm/Element.cpp @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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,19 +44,19 @@ 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 { const xmlChar* const value = xmlGetProp(cobj, reinterpret_cast(key.c_str())); @@ -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,13 +90,13 @@ namespace xml return std::string(); } - +//------------------------------------------------------------------------------ std::string Element::get_text() const { - return this->get_value(); + return this->get_value(); } - +//------------------------------------------------------------------------------ Content* Element::get_text_node() const { for(xmlNode* child = cobj->children; child; child = child->next) @@ -108,12 +108,12 @@ namespace xml if (child->type == XML_CDATA_SECTION_NODE) { return reinterpret_cast(child->_private); - } + } } return NULL; } - +//------------------------------------------------------------------------------ void Element::set_text(const std::string& text) { Content* node = get_text_node(); @@ -127,22 +127,22 @@ 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,26 +167,26 @@ 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); } - +//------------------------------------------------------------------------------ std::vector Element::find_elements(const std::string& xpath) const { return this->find_all(xpath); diff --git a/libxmlmm/Element.h b/libxmlmm/Element.h index 8134cec..924feaa 100644 --- a/libxmlmm/Element.h +++ b/libxmlmm/Element.h @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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,25 +50,12 @@ 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. - * - * This method will retrive an attribute. - * - * @param id the attribtue id - * @return the attribute value - * - * @throws no_such_attribute if the attibute does not exist on - * this element. - **/ - std::string get_attribute(const std::string& key) const; - + /** * Get a given attribute in given type. * @@ -87,22 +74,35 @@ 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; } + /** + * Get a given attribute. + * + * This method will retrive an attribute. + * + * @param id the attribtue id + * @return the attribute value + * + * @throws no_such_attribute if the attibute does not exist on + * this element. + **/ + std::string get_attribute(const std::string& key) const; + /** * 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/libxmlmm/LibXmlSentry.cpp b/libxmlmm/LibXmlSentry.cpp index a8e8bf6..168beee 100644 --- a/libxmlmm/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" @@ -33,7 +33,7 @@ namespace xml { unsigned int LibXmlSentry::use_count = 0; - +//------------------------------------------------------------------------------ LibXmlSentry::LibXmlSentry() { if (use_count == 0) @@ -46,8 +46,8 @@ namespace xml } use_count++; } - - + +//------------------------------------------------------------------------------ LibXmlSentry::~LibXmlSentry() { use_count--; diff --git a/libxmlmm/LibXmlSentry.h b/libxmlmm/LibXmlSentry.h index 6b9215f..5ada649 100644 --- a/libxmlmm/LibXmlSentry.h +++ b/libxmlmm/LibXmlSentry.h @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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/libxmlmm/Node.cpp b/libxmlmm/Node.cpp index cc8442c..169bb42 100644 --- a/libxmlmm/Node.cpp +++ b/libxmlmm/Node.cpp @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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" @@ -30,20 +30,20 @@ namespace xml { - +//------------------------------------------------------------------------------ Node::Node(xmlNode* const co) : cobj(co) { assert(cobj != NULL); } - - - Node::~Node() + +//------------------------------------------------------------------------------ + Node::~Node() { assert(cobj != NULL); } - +//------------------------------------------------------------------------------ std::string Node::get_path() const { xmlChar* path = xmlGetNodePath(cobj); @@ -51,13 +51,13 @@ 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() { if (cobj->parent != NULL) @@ -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,12 +164,12 @@ namespace xml value = from_string(node->get_value()); } } - + return value; } + - - +//------------------------------------------------------------------------------ Node::FindNodeset::FindNodeset(xmlNode *const cobj, const std::string &xpath, const xmlXPathObjectType type) { ctxt = xmlXPathNewContext(cobj->doc); @@ -181,7 +181,7 @@ namespace xml xmlXPathFreeContext(ctxt); throw InvalidXPath(xpath); } - + if (type != XPATH_UNDEFINED && result->type != type) { xmlXPathFreeObject(result); @@ -190,7 +190,7 @@ namespace xml } } - +//------------------------------------------------------------------------------ Node::FindNodeset::~FindNodeset() { xmlXPathFreeObject(result); diff --git a/libxmlmm/Node.h b/libxmlmm/Node.h index 6644cb1..b1ac9bd 100644 --- a/libxmlmm/Node.h +++ b/libxmlmm/Node.h @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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/libxmlmm/ProcessingInstruction.cpp b/libxmlmm/ProcessingInstruction.cpp index 855f7ec..ecde4b0 100644 --- a/libxmlmm/ProcessingInstruction.cpp +++ b/libxmlmm/ProcessingInstruction.cpp @@ -1,29 +1,29 @@ // -// 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, +// 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, // 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" namespace xml { - +//------------------------------------------------------------------------------ ProcessingInstruction::ProcessingInstruction(xmlNode* const cobj) : Content(cobj) {} diff --git a/libxmlmm/ProcessingInstruction.h b/libxmlmm/ProcessingInstruction.h index 2edaa6a..9ade1a2 100644 --- a/libxmlmm/ProcessingInstruction.h +++ b/libxmlmm/ProcessingInstruction.h @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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/libxmlmm/Text.cpp b/libxmlmm/Text.cpp index 54bf8fe..2d97c17 100644 --- a/libxmlmm/Text.cpp +++ b/libxmlmm/Text.cpp @@ -1,29 +1,29 @@ // -// 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, +// 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, // 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" namespace xml { - +//------------------------------------------------------------------------------ Text::Text(xmlNode* const cobj) : Content(cobj) {} diff --git a/libxmlmm/Text.h b/libxmlmm/Text.h index 4ae92ab..acf2a81 100644 --- a/libxmlmm/Text.h +++ b/libxmlmm/Text.h @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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/libxmlmm/defines.h b/libxmlmm/defines.h index 4521e0c..633ca66 100644 --- a/libxmlmm/defines.h +++ b/libxmlmm/defines.h @@ -1,28 +1,28 @@ // -// 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, +// 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, // 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/libxmlmm/exceptions.h b/libxmlmm/exceptions.h index 29d582c..c66576d 100644 --- a/libxmlmm/exceptions.h +++ b/libxmlmm/exceptions.h @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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") {} }; @@ -55,6 +55,13 @@ namespace xml NoSuchAttribute(const std::string &attribute, const std::string &nodeName) : Exception("There is no attribute '" + attribute + "' on the element '" + nodeName + "'.") {} }; + + struct ValidationError : Exception + { + explicit ValidationError(const std::string& what) + : Exception(what) + {} + }; } #endif diff --git a/libxmlmm/libxmlmm.h b/libxmlmm/libxmlmm.h index c8df286..e5b4d07 100644 --- a/libxmlmm/libxmlmm.h +++ b/libxmlmm/libxmlmm.h @@ -1,34 +1,34 @@ // -// 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, +// 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, // 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/utils.cpp b/libxmlmm/utils.cpp index 24c9db4..525c00a 100644 --- a/libxmlmm/utils.cpp +++ b/libxmlmm/utils.cpp @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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" @@ -36,7 +36,7 @@ namespace xml { - +//------------------------------------------------------------------------------ std::string get_last_error() { const xmlError* const error = xmlGetLastError(); @@ -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/libxmlmm/utils.h b/libxmlmm/utils.h index 2460ed8..e897272 100644 --- a/libxmlmm/utils.h +++ b/libxmlmm/utils.h @@ -1,23 +1,23 @@ // -// 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, +// 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, // 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. **/