(file) Return to XmlParser.h CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

  1 martin 1.33 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.34 //
  3 martin 1.33 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.34 //
 10 martin 1.33 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.34 //
 17 martin 1.33 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.34 //
 20 martin 1.33 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.34 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.33 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.34 //
 28 martin 1.33 //////////////////////////////////////////////////////////////////////////
 29 mike   1.11 //
 30             //%/////////////////////////////////////////////////////////////////////////////
 31             
 32             #ifndef Pegasus_XmlParser_h
 33             #define Pegasus_XmlParser_h
 34             
 35             #include <Pegasus/Common/Config.h>
 36 kumpf  1.17 #include <Pegasus/Common/ArrayInternal.h>
 37 kumpf  1.16 #include <Pegasus/Common/InternalException.h>
 38 mike   1.11 #include <Pegasus/Common/Stack.h>
 39 kumpf  1.15 #include <Pegasus/Common/Linkage.h>
 40 mike   1.23 #include <Pegasus/Common/Buffer.h>
 41 mike   1.11 
 42             PEGASUS_NAMESPACE_BEGIN
 43             
 44             class PEGASUS_COMMON_LINKAGE XmlException : public Exception
 45             {
 46             public:
 47             
 48                 enum Code
 49                 {
 50 kumpf  1.28         BAD_START_TAG = 1,
 51                     BAD_END_TAG,
 52                     BAD_ATTRIBUTE_NAME,
 53                     EXPECTED_EQUAL_SIGN,
 54                     BAD_ATTRIBUTE_VALUE,
 55                     MINUS_MINUS_IN_COMMENT,
 56                     UNTERMINATED_COMMENT,
 57                     UNTERMINATED_CDATA,
 58                     UNTERMINATED_DOCTYPE,
 59                     MALFORMED_REFERENCE,
 60                     EXPECTED_COMMENT_OR_CDATA,
 61                     START_END_MISMATCH,
 62                     UNCLOSED_TAGS,
 63                     MULTIPLE_ROOTS,
 64                     VALIDATION_ERROR,
 65 kumpf  1.31         SEMANTIC_ERROR,
 66                     UNDECLARED_NAMESPACE
 67 mike   1.11     };
 68             
 69 chuck  1.18 
 70 mike   1.11     XmlException(
 71 kumpf  1.28         Code code,
 72                     Uint32 lineNumber,
 73                     const String& message = String());
 74             
 75             
 76 chuck  1.18     XmlException(
 77 kumpf  1.28         Code code,
 78                     Uint32 lineNumber,
 79                     MessageLoaderParms& msgParms);
 80 chuck  1.18 
 81 mike   1.11 
 82                 XmlException::Code getCode() const { return _code; }
 83             
 84             private:
 85             
 86                 Code _code;
 87             };
 88             
 89             class PEGASUS_COMMON_LINKAGE XmlValidationError : public XmlException
 90             {
 91             public:
 92             
 93                 XmlValidationError(Uint32 lineNumber, const String& message);
 94 kumpf  1.28     XmlValidationError(Uint32 lineNumber, MessageLoaderParms& msgParms);
 95 mike   1.11 };
 96             
 97             class PEGASUS_COMMON_LINKAGE XmlSemanticError : public XmlException
 98             {
 99             public:
100             
101                 XmlSemanticError(Uint32 lineNumber, const String& message);
102 kumpf  1.28     XmlSemanticError(Uint32 lineNumber, MessageLoaderParms& msgParms);
103 mike   1.11 };
104             
105 kumpf  1.31 struct XmlNamespace
106             {
107                 const char* localName;
108                 const char* extendedName;
109                 int type;
110                 Uint32 scopeLevel;
111             };
112             
113 mike   1.11 struct XmlAttribute
114             {
115 kumpf  1.31     int nsType;
116 mike   1.11     const char* name;
117 kumpf  1.31     const char* localName;
118 mike   1.11     const char* value;
119             };
120             
121             struct PEGASUS_COMMON_LINKAGE XmlEntry
122             {
123 kumpf  1.31     enum XmlEntryType
124 mike   1.11     {
125 kumpf  1.28         XML_DECLARATION,
126                     START_TAG,
127                     EMPTY_TAG,
128                     END_TAG,
129                     COMMENT,
130                     CDATA,
131                     DOCTYPE,
132                     CONTENT
133 mike   1.11     };
134             
135 kumpf  1.31     XmlEntryType type;
136 mike   1.11     const char* text;
137 kumpf  1.31     int nsType;            // Only applies to START_TAG, EMPTY_TAG, and END_TAG
138                 const char* localName; // Only applies to START_TAG, EMPTY_TAG, and END_TAG
139 venkat.puvvada 1.35.2.1     Uint32 textLen; // Only applies to CDATA and CONTENT
140                         
141 kumpf          1.31         Array<XmlAttribute> attributes;
142 mike           1.11     
143                             void print() const;
144                         
145                             const XmlAttribute* findAttribute(const char* name) const;
146                         
147 kumpf          1.32         const XmlAttribute* findAttribute(int attrNsType, const char* name) const;
148 kumpf          1.31     
149 mike           1.11         Boolean getAttributeValue(const char* name, Uint32& value) const;
150                         
151                             Boolean getAttributeValue(const char* name, Real32& value) const;
152                         
153                             Boolean getAttributeValue(const char* name, const char*& value) const;
154                         
155                             Boolean getAttributeValue(const char* name, String& value) const;
156                         };
157                         
158                         inline int operator==(const XmlEntry&, const XmlEntry&)
159                         {
160                             return 0;
161                         }
162                         
163                         class PEGASUS_COMMON_LINKAGE XmlParser
164                         {
165                         public:
166                         
167                             // Warning: this constructor modifies the text.
168                         
169 kumpf          1.31         XmlParser(char* text, XmlNamespace* ns = 0);
170 mike           1.11     
171 kumpf          1.35         /** Comments are returned with entry if includeComment is true else
172 venkat.puvvada 1.29             XmlParser ignores comments. Default is false.
173                             */
174                             Boolean next(XmlEntry& entry, Boolean includeComment = false);
175 mike           1.11     
176                             void putBack(XmlEntry& entry);
177                         
178                             ~XmlParser();
179                         
180                             Uint32 getStackSize() const { return _stack.size(); }
181                         
182                             Uint32 getLine() const { return _line; }
183                         
184 kumpf          1.31         XmlNamespace* getNamespace(int nsType);
185                         
186 mike           1.11     private:
187                         
188 kumpf          1.31         Boolean _getElementName(char*& p, const char*& localName);
189 mike           1.11     
190 kumpf          1.31         Boolean _getOpenElementName(
191                                 char*& p,
192                                 const char*& localName,
193                                 Boolean& openCloseElement);
194 mike           1.11     
195 kumpf          1.31         void _getAttributeNameAndEqual(char*& p, const char*& localName);
196 mike           1.11     
197                             void _getComment(char*& p);
198                         
199                             void _getCData(char*& p);
200                         
201                             void _getDocType(char*& p);
202                         
203                             void _getElement(char*& p, XmlEntry& entry);
204                         
205 kumpf          1.31         int _getNamespaceType(const char* tag);
206                         
207                             int _getSupportedNamespaceType(const char* extendedName);
208                         
209 mike           1.11         Uint32 _line;
210                             char* _current;
211                             char _restoreChar;
212                             Stack<char*> _stack;
213                             Boolean _foundRoot;
214                             Stack<XmlEntry> _putBackStack;
215 kumpf          1.31     
216                             XmlNamespace* _supportedNamespaces;
217                             Stack<XmlNamespace> _nameSpaces;
218                             int _currentUnsupportedNSType;
219 mike           1.11     };
220                         
221                         PEGASUS_COMMON_LINKAGE void XmlAppendCString(
222 kumpf          1.28         Buffer& out,
223 mike           1.11         const char* str);
224                         
225                         PEGASUS_NAMESPACE_END
226                         
227                         #endif /* Pegasus_XmlParser_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2