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

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

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2