Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

TypesTable.h

Go to the documentation of this file.
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/XmlUtils.h>
00029 #include <schemaparser/SimpleType.h>
00030 #include <schemaparser/ComplexType.h>
00031 
00032 //List of all XSD types
00033 class TypesTable
00034 {
00035  public:
00036 
00037   TypesTable();
00038   ~TypesTable();
00039 
00040   //Realease all the memory
00041   void clean();
00042 
00043   //add a new type and returns its id
00044   int addType(XSDType * type);
00045   int addExtType(XSDType * type, int id);
00046 
00047   //get the type id of a type
00048   int getTypeId(const Qname & name, bool create = false);
00049 
00050   //store an external reference to another schema
00051   int addExternalTypeId(const Qname & type, XSDType * pType);
00052   int getNumExtRefs()
00053     {
00054       return extRefs_.size();
00055     }
00056   Qname & getExtRefName(int index)
00057     {
00058       return extRefs_[index].qname;
00059     }
00060   int getExtRefType(int index)
00061     {
00062       return extRefs_[index].localTypeId;
00063     }
00064   void resolveForwardElementRefs(const string & name, Element & e);
00065   void resolveForwardAttributeRefs(const string & name, Attribute & a);
00066 
00067   //get the path to the descendant element
00068   int getCompleteXpath(int elemId, string & childName, int *xPath,
00069                        int limits, int &offset);
00070 
00071   //returns the pointer to a type whose id is given
00072   XSDType *getTypePtr(int id) const
00073     {
00074 
00075       // this is a basic XSD type
00076       if (id < Schema::ANYURI + 1 || id > Schema::ANYURI + numTypes)
00077         return 0;
00078       return typesArray[id - (Schema::ANYURI + 1)];
00079     }
00080   int getNumTypes(void) const
00081     {
00082       return numTypes;
00083     } bool detectUndefinedTypes(void);
00084   void setTargetNamespace(string Uri)
00085     {
00086       m_tnsUri = Uri;
00087     }
00088   string getTargetNamespace(void)
00089     {
00090       return m_tnsUri;
00091     }
00092   void printUndefinedTypes(ostream & out);
00093 
00094 #ifdef LOGGING
00095   //for logging purposes
00096   void printTypes(ostream & out);
00097 #endif 
00098  private:
00099   //contains a pointer to the actual type
00100   XSDType ** typesArray;
00101 
00102   //maintains a map of all user defined type names and their ids
00103   map < string, int >Id;
00104 
00105   //This is a map of all types defined in XML Schema
00106   map < string, int >basicTypes;
00107   int currentId;
00108   int numTypes, nSize;
00109   string m_tnsUri;
00110   
00111   typedef struct 
00112   {
00113     int localTypeId;
00114     Qname qname;
00115   }extRefs;
00116   std::vector<extRefs> extRefs_;
00117   void ensureCapacity();
00118 };
00119 #endif                                            /*  */

Generated on Sun Oct 16 10:11:52 2005 for wsdlpull by  doxygen 1.3.9.1