/* MIT Licence Copyright (c) 2002 Seairth Jacobs Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ //--------------------------------------------------------------------------- #ifndef ONXEventParser_H #define ONXEventParser_H //--------------------------------------------------------------------------- // Error Types: #define ONX_INVALID_ROOTNODE 0 #define ONX_INVALID_NAME 1 #define ONX_INVALID_NODE 2 #define ONX_INVALID_VALUENODE 3 #define ONX_INVALID_ESCAPE_SEQUENCE 5 // this is used as the basic structure of values in a ValueNode. // An array of these structures are passed to the ValueNode event // handler with an additional parameter indicating the length of // the array. struct ONXValueNodeValue { char * value; unsigned int length; }; class ONXEventHandler { public: // "event" methods. Return value indicate whether the event parser should continue or not. virtual bool EnterContainerNode(char * /*name*/) {return true;}; virtual bool ExitContainerNode(char * /*name*/) {return true;}; virtual bool ValueNode(char * /*name*/, ONXValueNodeValue * /*array of values*/, unsigned int /*length of array*/) {return true;}; virtual bool Error(unsigned int /*error#*/, unsigned int /*offset*/) {return false;}; }; class ONXEventParser { public: // properties bool bDelayedEvents; // methods ONXEventParser(ONXEventHandler * pEvHandler = NULL); ~ONXEventParser(); bool Parse(char *); ONXEventHandler * GetEventHandler() {return pEventHandler;}; protected: ONXEventHandler * pEventHandler; }; #endif