1 | #ifndef _XMLLIGHT_H |
---|
2 | #define _XMLLIGHT_H |
---|
3 | |
---|
4 | #include <string> |
---|
5 | #include <map> |
---|
6 | #include "Behavioural/include/ClassicReferenceCounter.h" |
---|
7 | #include "Behavioural/include/XMLLightVector.h" |
---|
8 | |
---|
9 | using std::map; |
---|
10 | using std::basic_string; |
---|
11 | using morpheo::ReferenceCountersUtils::ClassicReferenceCounter; |
---|
12 | |
---|
13 | namespace morpheo { |
---|
14 | namespace XMLUtils { |
---|
15 | |
---|
16 | //*******************************Class Declaration***************************************************// |
---|
17 | |
---|
18 | enum ETEXT_ENCODING { |
---|
19 | ASCII, |
---|
20 | UTF8, |
---|
21 | UTF16, |
---|
22 | // UTF16_LE, |
---|
23 | // UTF16_BE, |
---|
24 | UTF32 |
---|
25 | }; |
---|
26 | |
---|
27 | |
---|
28 | // the main interface for XML parsing used a reference counter class to implement ref counting |
---|
29 | |
---|
30 | template< typename char_type, typename ReferenceCounter = ClassicReferenceCounter> class IXMLLight |
---|
31 | : virtual public ReferenceCounter { |
---|
32 | protected : |
---|
33 | typedef IXMLLight<char_type, ReferenceCounter> XMLLight; |
---|
34 | typedef basic_string<char_type> string; |
---|
35 | public : |
---|
36 | // used to fetch XML Nodes contains inside a XMLLight object with the pattern name |
---|
37 | virtual XMLLightVector<XMLLight> getNodes( const string & pattern = "") = 0; |
---|
38 | //virtual XMLLight & getFirstNode ( const string & pattern ) = 0 ; |
---|
39 | //virtual XMLLight & getRoot ( void ) = 0 ; |
---|
40 | |
---|
41 | // fetch the name of tne node selected |
---|
42 | virtual basic_string<char_type> getName ( void ) = 0 ; |
---|
43 | // fetch the encoding used inside the XML document. |
---|
44 | //virtual ETEXT_ENCODING getEncodingForm ( void ) = 0; |
---|
45 | |
---|
46 | /* |
---|
47 | virtual string & getValue ( void ) = 0 ; |
---|
48 | virtual string & getValue ( const string & firstNodeName ) = 0 ; |
---|
49 | */ |
---|
50 | virtual bool containsAttribute ( const basic_string<char_type> & attributeName ) = 0 ; |
---|
51 | |
---|
52 | virtual map<basic_string<char_type>, basic_string<char_type> > getAttributes ( void ) = 0 ; |
---|
53 | |
---|
54 | virtual basic_string<char_type> getAttributeValue ( const basic_string<char_type> & attributeName ) = 0; |
---|
55 | virtual basic_string<char_type> getInternalString(void) const = 0 ; |
---|
56 | // only instanciated to bring a virtual destructor. |
---|
57 | virtual inline ~IXMLLight( void ) = 0 ; |
---|
58 | |
---|
59 | }; |
---|
60 | |
---|
61 | //*************************************Inline implementation*****************************************// |
---|
62 | |
---|
63 | // implementation of XMLLight virtual destructor. |
---|
64 | template<typename char_type,typename ReferenceCounter> IXMLLight<char_type, ReferenceCounter>::~IXMLLight(void) {} |
---|
65 | |
---|
66 | //******************************** Typedef of multiple XMLLight Interface**********************// |
---|
67 | |
---|
68 | // valid with 32 bits computer only . don't forget use of widen to widening string |
---|
69 | |
---|
70 | typedef IXMLLight<char , ClassicReferenceCounter> IXMLLightASCII; |
---|
71 | typedef IXMLLight<wchar_t, ClassicReferenceCounter> IXMLLightUTF8; |
---|
72 | typedef IXMLLight<wchar_t, ClassicReferenceCounter> IXMLLightUTF16; |
---|
73 | typedef IXMLLight<wchar_t, ClassicReferenceCounter> IXMLLightUTF32; |
---|
74 | |
---|
75 | |
---|
76 | } // end of XMLUtils namespace. |
---|
77 | } // end of morpheo namespace. |
---|
78 | |
---|
79 | #endif // _XMLLIGHT_H |
---|