|
Robotics Library
0.7.0
|
Go to the documentation of this file.
27 #ifndef RL_XML_DOCUMENT_H
28 #define RL_XML_DOCUMENT_H
32 #include <boost/shared_array.hpp>
33 #include <libxml/parser.h>
34 #include <libxml/xinclude.h>
49 explicit Document(const ::std::string& version =
"1.0") :
50 doc(::xmlNewDoc(reinterpret_cast<const ::xmlChar*>(version.c_str())), ::xmlFreeDoc)
73 ::xmlDocDumpFormatMemory(this->
doc.get(), &mem, &size, format ? 1 : 0);
74 ::boost::shared_array< ::xmlChar> memory(mem, ::xmlFree);
76 return nullptr != memory.get() ?
reinterpret_cast<const char*
>(memory.get()) : ::std::string();
84 ::xmlDocDumpMemory(this->
doc.get(), &mem, &size);
85 ::boost::shared_array< ::xmlChar> memory(mem, ::xmlFree);
87 return nullptr != memory.get() ?
reinterpret_cast<const char*
>(memory.get()) : ::std::string();
90 ::xmlDocPtr
get()
const
92 return this->
doc.get();
97 return this->
doc->compression;
102 return nullptr != this->
doc->encoding ?
reinterpret_cast<const char*
>(this->
doc->encoding) : ::std::string();
107 return nullptr != this->
doc->name ? this->
doc->name : ::std::string();
112 return this->
doc->properties;
117 return Node(::xmlDocGetRootElement(this->
doc.get()));
122 return nullptr != this->
doc->version ?
reinterpret_cast<const char*
>(this->
doc->version) : ::std::string();
127 return 1 == this->
doc->standalone ? true :
false;
132 this->
doc = std::move(other.doc);
143 return this->
doc.release();
146 void save(const ::std::string& filename,
const bool& format =
true)
const
148 ::xmlSaveFormatFile(filename.c_str(), this->doc.get(), format ? 1 : 0);
151 void save(const ::std::string& filename, const ::std::string& encoding,
const bool& format =
true)
const
153 ::xmlSaveFormatFileEnc(filename.c_str(), this->doc.get(), encoding.c_str(), format ? 1 : 0);
158 ::xmlDocSetRootElement(this->
doc.get(), node.
get());
163 int substitutions = ::xmlXIncludeProcessFlags(this->
doc.get(), flags);
165 if (-1 == substitutions)
167 throw Exception(::xmlGetLastError()->message);
170 return substitutions;
176 ::std::unique_ptr< ::xmlDoc, decltype(&::xmlFreeDoc)>
doc;
181 #endif // RL_XML_DOCUMENT_H
Document & operator=(Document &&other)
Definition: Document.h:130
Document(const ::std::string &version="1.0")
Definition: Document.h:49
::std::string getVersion() const
Definition: Document.h:120
::std::unique_ptr< ::xmlDoc, decltype(&::xmlFreeDoc)> doc
Definition: Document.h:176
::xmlDoc & operator*() const
Definition: Document.h:136
::std::string getName() const
Definition: Document.h:105
bool isStandalone() const
Definition: Document.h:125
::std::string dumpMemory() const
Definition: Document.h:79
Definition: Document.h:47
Document(::xmlDocPtr doc)
Definition: Document.h:54
::std::string getEncoding() const
Definition: Document.h:100
::xmlNodePtr get() const
Definition: Node.h:96
::xmlDocPtr get() const
Definition: Document.h:90
Document(Document &&document)
Definition: Document.h:59
int getCompression() const
Definition: Document.h:95
int getProperties() const
Definition: Document.h:110
int substitute(const int &flags=0)
Definition: Document.h:161
void save(const ::std::string &filename, const ::std::string &encoding, const bool &format=true) const
Definition: Document.h:151
::std::string dumpFormatMemory(const bool &format) const
Definition: Document.h:68
~Document()
Definition: Document.h:64
::xmlDocPtr release()
Definition: Document.h:141
void save(const ::std::string &filename, const bool &format=true) const
Definition: Document.h:146
Node getRootElement() const
Definition: Document.h:115
Definition: Exception.h:37
void setRootElement(const Node &node)
Definition: Document.h:156
Robotics Library.
Definition: AnalogInput.cpp:30