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

  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.11 
 46                    PEGASUS_NAMESPACE_BEGIN
 47                    
 48                    class PEGASUS_COMMON_LINKAGE XmlException : public Exception
 49                    {
 50                    public:
 51                    
 52                        enum Code
 53                        {
 54                    	BAD_START_TAG = 1,
 55                    	BAD_END_TAG,
 56                    	BAD_ATTRIBUTE_NAME,
 57                    	EXPECTED_EQUAL_SIGN,
 58                    	BAD_ATTRIBUTE_VALUE,
 59                    	MINUS_MINUS_IN_COMMENT,
 60                    	UNTERMINATED_COMMENT,
 61                    	UNTERMINATED_CDATA,
 62                    	UNTERMINATED_DOCTYPE,
 63                    	TOO_MANY_ATTRIBUTES,
 64                    	MALFORMED_REFERENCE,
 65                    	EXPECTED_COMMENT_OR_CDATA,
 66 mike          1.11 	START_END_MISMATCH,
 67                    	UNCLOSED_TAGS,
 68                    	MULTIPLE_ROOTS,
 69                    	VALIDATION_ERROR,
 70                    	SEMANTIC_ERROR
 71                        };
 72                    
 73 chuck         1.18 
 74 mike          1.11     XmlException(
 75                    	Code code, 
 76                    	Uint32 lineNumber,
 77                    	const String& message = String());
 78 chuck         1.18 	
 79                    	
 80                        XmlException(
 81                    	Code code, 
 82                    	Uint32 lineNumber,
 83                    	MessageLoaderParms& msgParms);
 84                    
 85 mike          1.11 
 86                        XmlException::Code getCode() const { return _code; }
 87                    
 88                    private:
 89                    
 90                        Code _code;
 91                    };
 92                    
 93                    class PEGASUS_COMMON_LINKAGE XmlValidationError : public XmlException
 94                    {
 95                    public:
 96                    
 97                        XmlValidationError(Uint32 lineNumber, const String& message);
 98 chuck         1.18     XmlValidationError(Uint32 lineNumber, MessageLoaderParms& msgParms);     
 99 mike          1.11 };
100                    
101                    class PEGASUS_COMMON_LINKAGE XmlSemanticError : public XmlException
102                    {
103                    public:
104                    
105                        XmlSemanticError(Uint32 lineNumber, const String& message);
106 chuck         1.18     XmlSemanticError(Uint32 lineNumber, MessageLoaderParms& msgParms);    
107 mike          1.11 };
108                    
109                    struct XmlAttribute
110                    {
111                        const char* name;
112                        const char* value;
113                    };
114                    
115                    struct PEGASUS_COMMON_LINKAGE XmlEntry
116                    {
117                        enum CIMType
118                        {
119                    	XML_DECLARATION,
120                    	START_TAG, 
121                    	EMPTY_TAG, 
122                    	END_TAG, 
123                    	COMMENT,
124                    	CDATA,
125                    	DOCTYPE,
126                    	CONTENT
127                        };
128 mike          1.11 
129                        enum { MAX_ATTRIBUTES = 10 };
130                    
131                        CIMType type;
132                        const char* text;
133                        XmlAttribute attributes[MAX_ATTRIBUTES];
134                        Uint32 attributeCount;
135                    
136                        void print() const;
137                    
138                        const XmlAttribute* findAttribute(const char* name) const;
139                    
140                        Boolean getAttributeValue(const char* name, Uint32& value) const;
141                    
142                        Boolean getAttributeValue(const char* name, Real32& value) const;
143                    
144                        Boolean getAttributeValue(const char* name, const char*& value) const;
145                    
146                        Boolean getAttributeValue(const char* name, String& value) const;
147                    };
148                    
149 mike          1.11 inline int operator==(const XmlEntry&, const XmlEntry&)
150                    {
151                        return 0;
152                    }
153                    
154                    #define PEGASUS_ARRAY_T XmlEntry
155 kumpf         1.13 # include <Pegasus/Common/ArrayInter.h>
156 mike          1.11 #undef PEGASUS_ARRAY_T
157                    
158                    class PEGASUS_COMMON_LINKAGE XmlParser
159                    {
160                    public:
161                    
162                        // Warning: this constructor modifies the text.
163                    
164                        XmlParser(char* text);
165                    
166                        Boolean next(XmlEntry& entry);
167                    
168                        void putBack(XmlEntry& entry);
169                    
170                        ~XmlParser();
171                    
172                        Uint32 getStackSize() const { return _stack.size(); }
173                    
174                        Uint32 getLine() const { return _line; }
175                    
176                    private:
177 mike          1.11 
178                        void _skipWhitespace(char*& p);
179                    
180                        Boolean _getElementName(char*& p);
181                    
182                        Boolean _getOpenElementName(char*& p, Boolean& openCloseElement);
183                    
184                        void _getAttributeNameAndEqual(char*& p);
185                    
186                        void _getAttributeValue(char*& p);
187                    
188                        void _getComment(char*& p);
189                    
190                        void _getCData(char*& p);
191                    
192                        void _getDocType(char*& p);
193                    
194                        void _getContent(char*& p);
195                    
196                        void _substituteReferences(char* text);
197                    
198 mike          1.11     void _getElement(char*& p, XmlEntry& entry);
199                    
200                        Uint32 _line;
201                        char* _text;
202                        char* _current;
203                        char _restoreChar;
204                        Stack<char*> _stack;
205                        Boolean _foundRoot;
206                        Stack<XmlEntry> _putBackStack;
207                    };
208                    
209                    PEGASUS_COMMON_LINKAGE void XmlAppendCString(
210 mike          1.22.10.1     Buffer& out, 
211 mike          1.11          const char* str);
212                         
213                         PEGASUS_NAMESPACE_END
214                         
215                         #endif /* Pegasus_XmlParser_h */

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2