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