1 /*************************************************************************** 2 UlxrIdlParser.h - parse Ulxr idl files 3 ------------------- 4 begin : Sun May 20 2007 5 copyright : (C) 2002-2007 by Ewald Arnold 6 email : ulxmlrpcpp@ewald-arnold.de 7 8 $Id: UlxrIdlParser.h 1007 2007-07-21 13:54:34Z ewald-arnold $ 9 10 ***************************************************************************/ 11 12 /************************************************************************** 13 * 14 * This program is free software; you can redistribute it and/or modify 15 * it under the terms of the GNU Lesser General Public License as 16 * published by the Free Software Foundation; either version 2 of the License, 17 * or (at your option) any later version. 18 * 19 * This program is distributed in the hope that it will be useful, 20 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 * GNU General Public License for more details. 23 * 24 * You should have received a copy of the GNU Lesser General Public License 25 * along with this program; if not, write to the Free Software 26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 27 * 28 ***************************************************************************/ 29 30 #ifndef ULXR_IDL_PARSER_H 31 #define ULXR_IDL_PARSER_H 32 33 #include "xmlparser.h" 34 #include "UlxrIdlClass.h" 35 36 37 /** An xml parser for Ulxr idl files 38 */ 39 class UlxrIdlParser : public XmlParser 40 { 41 public: 42 43 /** Constructs a parser. 44 */ 45 UlxrIdlParser(); 46 47 /** Destroys the parser. 48 */ 49 virtual ~UlxrIdlParser(); 50 51 unsigned numClasses() const; 52 53 UlxrIdlClass getClass(unsigned i) const; 54 55 std::vector<Method> getFunctions() const; 56 57 protected: 58 59 enum IdlState 60 { 61 eIdlParserFirst = XmlParserBase::eXmlParserLast, 62 eUlxrIdl, 63 eSource, 64 eInclude, 65 eClass, 66 eFunction, 67 eName, 68 eLinkScope, 69 eSuper, 70 eMethod, 71 eConstructor, 72 eType, 73 eArg, 74 eIdlParserLast 75 }; 76 77 /** Parses the current opening XML tag. 78 * Used ONLY internally as callback from expat. 79 * @param name the name of the current tag 80 * @param pointer to the current attributs (unused in XML-RPC) 81 */ 82 virtual void startElement(const XML_Char *name, 83 const XML_Char **atts); 84 85 /** Parses the current closing XML tag. 86 * Used ONLY internally as callback from expat. 87 * @param name the name of the current tag 88 * @param pointer to the current attributs (unused in XML-RPC) 89 */ 90 virtual void endElement(const XML_Char* name); 91 92 /** Tests if the current opening tag is to be parsed by this 93 * inheritance level or by the parent. 94 * Used ONLY internally. 95 * @param name the name of the current tag 96 * @param atts pointer to the current attributs (unused in XML-RPC) 97 */ 98 bool testStartElement(const XML_Char *name, 99 const XML_Char **atts); 100 101 /** Tests if the current closing tag is to be parsed by this 102 * inheritance level or by the parent. 103 * Used ONLY internally. 104 * @param name the name of the current tag 105 * @param pointer to the current attributs 106 */ 107 bool testEndElement(const XML_Char *name); 108 109 private: 110 111 bool in_arg; 112 bool in_method; 113 bool in_function; 114 115 UlxrIdlClass theClass; 116 std::vector<Method> functions; 117 Method method; 118 Argument arg; 119 Type type; 120 121 std::vector<UlxrIdlClass> classList; 122 }; 123 124 125 #endif // ULXR_IDL_PARSER_H 126