Remove dynamic exceptions
[anna.git] / include / anna / xml / DTD.hpp
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_DTD_hpp
10 #define anna_xml_DTD_hpp
11
12 struct _xmlDtd;
13 struct _xmlValidCtxt;
14 struct _xmlDoc;
15
16 #include <anna/core/mt/Mutex.hpp>
17 #include <anna/core/RuntimeException.hpp>
18
19 namespace anna {
20
21 namespace xml {
22
23 class Parser;
24
25 /**
26    Clase base para manejar la DTD.
27
28    A continuacion podemos ver un estracto de la DTD que definirias las reglas
29    de formacion del documento XML mostrado como ejemplo en Parser.
30
31    \code
32    <?xml version="1.0" encoding="UTF-8"?>
33    <!ELEMENT xvc (broadcast, ethernet, real, unreal)>
34    <!ATTLIST xvc HeartBeat CDATA "2000">
35
36    <!-- broadcast -->
37    <!ELEMENT broadcast (INetAddress+)>
38    <!ELEMENT INetAddress EMPTY>
39    <!ATTLIST INetAddress Address CDATA #REQUIRED>
40    <!ATTLIST INetAddress Port CDATA #REQUIRED>
41
42    <!-- ethernet -->
43    <!ELEMENT ethernet (Input, Output)>
44    <!ATTLIST ethernet Mode (raw|ethernet) #REQUIRED>
45    <!ATTLIST ethernet VirtualAddress CDATA #REQUIRED>
46    <!ELEMENT Input EMPTY>
47    <!ATTLIST Input Device CDATA #REQUIRED>
48    <!ATTLIST Input PhysicalAccessPoint CDATA #REQUIRED>
49    <!ATTLIST Input MAC CDATA #REQUIRED>
50    <!ELEMENT Output EMPTY>
51    <!ATTLIST Output Device CDATA #REQUIRED>
52    <!ATTLIST Output PhysicalAccessPoint CDATA #REQUIRED>
53    <!ATTLIST Output MAC CDATA #REQUIRED>
54    \endcode
55 */
56 class DTD {
57 public:
58   /**
59      Destructor.
60   */
61   virtual ~DTD();
62
63   /**
64      Inicializa la DTD con un nuevo contenido.
65      \param content Contenido de la DTD, depedendiendo del tipo de DTD hara referencia
66      a un nombre de archivo, una URI o a una cadena.
67   */
68   void initialize(const char* content) noexcept(false);
69
70 protected:
71   /**
72      Constructor.
73   */
74   DTD() : a_handle(NULL) {;}
75
76 private:
77   Mutex a_mutex;
78   _xmlDtd* a_handle;
79
80   void validate(_xmlValidCtxt* context, _xmlDoc* document) const noexcept(false);
81   virtual _xmlDtd* parse(const char* content) const noexcept(false) = 0;
82
83   friend class Parser;
84 };
85
86 }
87 }
88
89 #endif