diff --git a/include/common/otherTools.h b/include/common/otherTools.h index 9b3102f9b..212567f86 100644 --- a/include/common/otherTools.h +++ b/include/common/otherTools.h @@ -26,9 +26,12 @@ #include #endif +#include + namespace kiwix { void sleep(unsigned int milliseconds); +std::string nodeToString(pugi::xml_node node); } #endif diff --git a/src/common/otherTools.cpp b/src/common/otherTools.cpp index 0cb852376..b57add752 100644 --- a/src/common/otherTools.cpp +++ b/src/common/otherTools.cpp @@ -27,3 +27,19 @@ void kiwix::sleep(unsigned int milliseconds) usleep(1000 * milliseconds); #endif } + + +struct XmlStringWriter: pugi::xml_writer +{ + std::string result; + virtual void write(const void* data, size_t size){ + result.append(static_cast(data), size); + } +}; + +std::string kiwix::nodeToString(pugi::xml_node node) +{ + XmlStringWriter writer; + node.print(writer, " "); + return writer.result; +} diff --git a/src/opds_dumper.cpp b/src/opds_dumper.cpp index 63dce8542..9aa31bb51 100644 --- a/src/opds_dumper.cpp +++ b/src/opds_dumper.cpp @@ -19,6 +19,9 @@ #include "opds_dumper.h" + +#include + namespace kiwix { /* Constructor */ @@ -31,24 +34,6 @@ OPDSDumper::~OPDSDumper() { } -struct xml_string_writer: pugi::xml_writer -{ - std::string result; - - virtual void write(const void* data, size_t size) - { - result.append(static_cast(data), size); - } -}; - -std::string node_to_string(pugi::xml_node node) -{ - xml_string_writer writer; - node.print(writer, " "); - - return writer.result; -} - std::string gen_date_str() { auto now = time(0); @@ -129,7 +114,7 @@ string OPDSDumper::dumpOPDSFeed() handleBook(book, root_node); } - return node_to_string(root_node); + return nodeToString(root_node); } }