ANNA Suite  2020b
Multipurpose development suite for Telco applications
Document.hpp
Go to the documentation of this file.
1 // ANNA - Anna is Not Nothingness Anymore //
2 // //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
4 // //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7 
8 
9 #ifndef anna_xml_Document_hpp
10 #define anna_xml_Document_hpp
11 
12 struct _xmlDoc;
13 struct _xmlValidCtxt;
14 struct _xmlDoc;
15 
16 #include <anna/core/DataBlock.hpp>
18 
19 namespace anna {
20 
21 namespace xml {
22 
23 class Parser;
24 class XPath;
25 class DTD;
26 class Node;
27 
50 public:
54  virtual ~Document();
55 
61  void initialize(const char* content) noexcept(false);
62 
67  void initialize(const DataBlock& content) noexcept(false);
68 
73  const char* getEncoding() const ;
74 
79  const char* getVersion() const ;
80 
85  virtual const DataBlock& getContent() const noexcept(false) { return *this; }
86 
91  const char* getContentAsCString() const noexcept(false);
92 
97  void setEncoding(const char* encoding) ;
98 
103  void setVersion(const char* version) ;
104 
110  const xml::Node* parse() noexcept(false);
111 
119  const xml::Node* parse(const DTD& dtd) noexcept(false);
120 
121 protected:
125  Document();
126 
130  void clear() ;
131 
132  /*
133  * Establece el contenido de este documento XML.
134  * \param content Buffer que contiene una C-String con la que inciar este documento XML.
135  */
136  void setContent(const char* content) {
138  DataBlock::append(content, anna_strlen(content) + 1);
139  a_contentIsCString = true;
140  }
141 
142  /*
143  * Establece el contenido de este documento XML.
144  * \param content Buffer que apunta al contenido con la que inciar este documento XML.
145  * \param size Longitud del buffer.
146  * \warning Sólo uso interno
147  */
148  void setContent(const char* content, const int size) {
150  DataBlock::append(content, size);
151  a_contentIsCString = false;
152  }
153 
154  /*
155  * Establece el contenido de este documento XML.
156  * \param content Bloque de datos del que copiar el valor para iniciar este documento XML.
157  */
158  void setContent(const DataBlock& content) {
159  DataBlock::operator= (content);
160  a_contentIsCString = false;
161  }
162 
163 private:
164  _xmlDoc* a_handle;
165  std::string* a_encoding;
166  std::string* a_version;
167  bool a_contentIsCString;
168  DataBlock* a_asCString;
169  Parser* a_parser;
170 
171  Document(const Document&);
172 
173  virtual _xmlDoc* do_initialize(const char* content) noexcept(false) = 0;
174  virtual _xmlDoc* do_initialize(const DataBlock& content) noexcept(false) = 0;
175 
176  friend class Parser;
177  friend class XPath;
178 };
179 
180 }
181 }
182 
183 #endif
const char * getVersion() const
DataBlock & operator=(const DataBlock &right) noexcept(false)
Definition: Document.hpp:49
const xml::Node * parse() noexcept(false)
Definition: Node.hpp:56
Definition: DTD.hpp:56
void setContent(const char *content)
Definition: Document.hpp:136
#define anna_strlen(a)
Definition: defines.hpp:50
const char * getContentAsCString() const noexcept(false)
void setVersion(const char *version)
Definition: Parser.hpp:63
virtual const DataBlock & getContent() const noexcept(false)
Definition: Document.hpp:85
const char * getEncoding() const
xml::Node Node
Definition: Node.hpp:21
void clear() noexcept(false)
Definition: DataBlock.hpp:240
Definition: app.hpp:12
void append(const char *data, const int len) noexcept(false)
void setContent(const DataBlock &content)
Definition: Document.hpp:158
void setContent(const char *content, const int size)
Definition: Document.hpp:148
Definition: DataBlock.hpp:24
Definition: XPath.hpp:33
void setEncoding(const char *encoding)
void initialize(const char *content) noexcept(false)