#ifndef EXAMPLE_COMMON_BOOK_XML_H_ #define EXAMPLE_COMMON_BOOK_XML_H_ #include #include #include "pugixml/pugixml.hpp" struct Book; // ----------------------------------------------------------------------------- // Convert the following XML node to a book object. // // 1 // 1984 // 12.3 // bool XmlToBook(pugi::xml_node xbook, Book* book); // Convert a book object to XML and append to the given parent. void BookToXml(const Book& book, pugi::xml_node* xparent); // Convert the following XML node to a list of book objects. // // // 1 // 1984 // 12.3 // // ... // bool XmlToBookList(pugi::xml_node xbooks, std::list* books); // Convert a list of book objects to XML and append to the given parent. void BookListToXml(const std::list& books, pugi::xml_node* xparent); // Convert the following XML string to a book object. // // 1 // 1984 // 12.3 // bool XmlStringToBook(const std::string& xml_string, Book* book); // Convert a book object to XML string. std::string BookToXmlString(const Book& book, bool format_raw = true, const char* indent = ""); // ----------------------------------------------------------------------------- // This example defines its own result XML which will be embedded into the SOAP // envolope as CDATA. The general schema of this result XML is: // // // // The "status" node is mandatory, you should define proper status codes and // messages according to your needs. // Additional data is attached as the sibling of "status" node, e.g., // // // // {book.id} // {book.title} // {book.price} // // // Create a result XML as below: // // // std::string NewResultXml(int code, const char* message); // Create a result XML as below: // // // <{node}> // <{key}>{value} // // std::string NewResultXml(int code, const char* message, const char* node, const char* key, const char* value); // Create a result XML as below: // // // // {book.id} // {book.title} // {book.price} // // std::string NewResultXml(int code, const char* message, const Book& book); // Create a result XML as below: // // // // // {book.id} // {book.title} // {book.price} // // ... // // std::string NewResultXml(int code, const char* message, const std::list& books); #endif // EXAMPLE_COMMON_BOOK_XML_H_