1 karl 1.26 //%2006////////////////////////////////////////////////////////////////////////
|
2 mike 1.11 //
|
3 karl 1.20 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 karl 1.19 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.20 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.22 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.26 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 mike 1.11 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
|
15 kumpf 1.14 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
18 mike 1.11 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
20 //
|
21 kumpf 1.14 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
|
22 mike 1.11 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
24 kumpf 1.14 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
27 mike 1.11 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 //%/////////////////////////////////////////////////////////////////////////////
33
34 #ifndef Pegasus_XmlParser_h
35 #define Pegasus_XmlParser_h
36
37 #include <Pegasus/Common/Config.h>
|
38 kumpf 1.17 #include <Pegasus/Common/ArrayInternal.h>
|
39 kumpf 1.16 #include <Pegasus/Common/InternalException.h>
|
40 mike 1.11 #include <Pegasus/Common/Stack.h>
|
41 kumpf 1.15 #include <Pegasus/Common/Linkage.h>
|
42 mike 1.23 #include <Pegasus/Common/Buffer.h>
|
43 mike 1.11
44 PEGASUS_NAMESPACE_BEGIN
45
46 class PEGASUS_COMMON_LINKAGE XmlException : public Exception
47 {
48 public:
49
50 enum Code
51 {
|
52 kumpf 1.28 BAD_START_TAG = 1,
53 BAD_END_TAG,
54 BAD_ATTRIBUTE_NAME,
55 EXPECTED_EQUAL_SIGN,
56 BAD_ATTRIBUTE_VALUE,
57 MINUS_MINUS_IN_COMMENT,
58 UNTERMINATED_COMMENT,
59 UNTERMINATED_CDATA,
60 UNTERMINATED_DOCTYPE,
61 TOO_MANY_ATTRIBUTES,
62 MALFORMED_REFERENCE,
63 EXPECTED_COMMENT_OR_CDATA,
64 START_END_MISMATCH,
65 UNCLOSED_TAGS,
66 MULTIPLE_ROOTS,
67 VALIDATION_ERROR,
68 SEMANTIC_ERROR
|
69 mike 1.11 };
70
|
71 chuck 1.18
|
72 mike 1.11 XmlException(
|
73 kumpf 1.28 Code code,
74 Uint32 lineNumber,
75 const String& message = String());
76
77
|
78 chuck 1.18 XmlException(
|
79 kumpf 1.28 Code code,
80 Uint32 lineNumber,
81 MessageLoaderParms& msgParms);
|
82 chuck 1.18
|
83 mike 1.11
84 XmlException::Code getCode() const { return _code; }
85
86 private:
87
88 Code _code;
89 };
90
91 class PEGASUS_COMMON_LINKAGE XmlValidationError : public XmlException
92 {
93 public:
94
95 XmlValidationError(Uint32 lineNumber, const String& message);
|
96 kumpf 1.28 XmlValidationError(Uint32 lineNumber, MessageLoaderParms& msgParms);
|
97 mike 1.11 };
98
99 class PEGASUS_COMMON_LINKAGE XmlSemanticError : public XmlException
100 {
101 public:
102
103 XmlSemanticError(Uint32 lineNumber, const String& message);
|
104 kumpf 1.28 XmlSemanticError(Uint32 lineNumber, MessageLoaderParms& msgParms);
|
105 mike 1.11 };
106
107 struct XmlAttribute
108 {
109 const char* name;
110 const char* value;
111 };
112
113 struct PEGASUS_COMMON_LINKAGE XmlEntry
114 {
115 enum CIMType
116 {
|
117 kumpf 1.28 XML_DECLARATION,
118 START_TAG,
119 EMPTY_TAG,
120 END_TAG,
121 COMMENT,
122 CDATA,
123 DOCTYPE,
124 CONTENT
|
125 mike 1.11 };
126
127 enum { MAX_ATTRIBUTES = 10 };
128
129 CIMType type;
130 const char* text;
131 XmlAttribute attributes[MAX_ATTRIBUTES];
132 Uint32 attributeCount;
133
134 void print() const;
135
136 const XmlAttribute* findAttribute(const char* name) const;
137
138 Boolean getAttributeValue(const char* name, Uint32& value) const;
139
140 Boolean getAttributeValue(const char* name, Real32& value) const;
141
142 Boolean getAttributeValue(const char* name, const char*& value) const;
143
144 Boolean getAttributeValue(const char* name, String& value) const;
145 };
146 mike 1.11
147 inline int operator==(const XmlEntry&, const XmlEntry&)
148 {
149 return 0;
150 }
151
152 class PEGASUS_COMMON_LINKAGE XmlParser
153 {
154 public:
155
156 // Warning: this constructor modifies the text.
157
158 XmlParser(char* text);
159
|
160 venkat.puvvada 1.29 /** Comments are returned with entry if includeComment is true else
161 XmlParser ignores comments. Default is false.
162 */
163 Boolean next(XmlEntry& entry, Boolean includeComment = false);
|
164 mike 1.11
165 void putBack(XmlEntry& entry);
166
167 ~XmlParser();
168
169 Uint32 getStackSize() const { return _stack.size(); }
170
171 Uint32 getLine() const { return _line; }
172
173 private:
174
175 Boolean _getElementName(char*& p);
176
177 Boolean _getOpenElementName(char*& p, Boolean& openCloseElement);
178
179 void _getAttributeNameAndEqual(char*& p);
180
181 void _getComment(char*& p);
182
183 void _getCData(char*& p);
184
185 mike 1.11 void _getDocType(char*& p);
186
187 void _getElement(char*& p, XmlEntry& entry);
188
189 Uint32 _line;
190 char* _text;
191 char* _current;
192 char _restoreChar;
193 Stack<char*> _stack;
194 Boolean _foundRoot;
195 Stack<XmlEntry> _putBackStack;
196 };
197
198 PEGASUS_COMMON_LINKAGE void XmlAppendCString(
|
199 kumpf 1.28 Buffer& out,
|
200 mike 1.11 const char* str);
201
202 PEGASUS_NAMESPACE_END
203
204 #endif /* Pegasus_XmlParser_h */
|