wsdlpull 1.23
|
00001 /* 00002 * wsdlpull - A C++ parser for WSDL (Web services description language) 00003 * Copyright (C) 2005-2007 Vivek Krishna 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License as published by the Free Software Foundation; either 00008 * version 2 of the License, or (at your option) any later version. 00009 * 00010 * This library is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * Library General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU Library General Public 00016 * License along with this library; if not, write to the Free 00017 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00018 * 00019 * 00020 */ 00021 #ifndef _TYPESTABLEH 00022 #define _TYPESTABLEH 00023 00024 #include <string> 00025 #include <vector> 00026 #include <map> 00027 #include <sstream> 00028 #include "xmlpull/wsdlpull_export.h" 00029 #include "xmlpull/XmlUtils.h" 00030 #include "schemaparser/SimpleType.h" 00031 #include "schemaparser/ComplexType.h" 00032 00033 namespace Schema { 00034 //List of all XSD types 00035 class WSDLPULL_EXPORT TypesTable 00036 { 00037 public: 00038 00039 TypesTable(); 00040 ~TypesTable(); 00041 00042 //Realease all the memory 00043 void clean(); 00044 00045 //add a new type and returns its id 00046 int addType(XSDType * type); 00047 int addExtType(XSDType * type, int id); 00048 00049 //get the type id of a type 00050 int getTypeId(const Qname & name, bool create = false); 00051 std::string getAtomicTypeName(Schema::Type t)const; 00052 00053 //store an external reference to another schema 00054 int addExternalTypeId(const Qname & type, const XSDType * pType); 00055 int getNumExtRefs() { 00056 return extRefs_.size(); 00057 } 00058 00059 Qname & getExtRefName(int index) { 00060 return extRefs_[index].qname; 00061 } 00062 00063 int getExtRefType(int index){ 00064 00065 return extRefs_[index].localTypeId; 00066 } 00067 00068 void resolveForwardElementRefs(const std::string & name, Element & e); 00069 void resolveForwardAttributeRefs(const std::string & name, Attribute & a); 00070 00071 //get the path to the descendant element 00072 int getCompleteXpath(int elemId, std::string & childName, int *xPath, 00073 int limits, int &offset); 00074 00075 //returns the pointer to a type whose id is given 00076 XSDType *getTypePtr(int id) const; 00077 int getNumTypes(void) const 00078 { 00079 return numTypes; 00080 } 00081 bool detectUndefinedTypes(void); 00082 void setTargetNamespace(std::string Uri) 00083 { 00084 m_tnsUri = Uri; 00085 } 00086 std::string getTargetNamespace(void) 00087 { 00088 return m_tnsUri; 00089 } 00090 void printUndefinedTypes(std::ostream & out); 00091 00092 #ifdef LOGGING 00093 //for logging purposes 00094 void printTypes(std::ostream & out); 00095 #endif 00096 private: 00097 //contains a pointer to the actual type 00098 XSDType ** typesArray; 00099 00100 //maintains a std::map of all user defined type names and their ids 00101 std::map < std::string, int >Id; 00102 00103 //This is a std::map of all types defined in XML Schema 00104 std::map < std::string, int >basicTypes; 00105 int currentId; 00106 int numTypes, nSize; 00107 std::string m_tnsUri; 00108 00109 typedef struct 00110 { 00111 int localTypeId; 00112 Qname qname; 00113 }extRefs; 00114 std::vector<extRefs> extRefs_; 00115 void ensureCapacity(); 00116 }; 00117 } 00118 #endif /* */