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   std::string getAtomicTypeName(Schema::Type t)const;
00050 
00051   //store an external reference to another schema
00052   int addExternalTypeId(const Qname & type, XSDType * pType);
00053   int getNumExtRefs()
00054     {
00055       return extRefs_.size();
00056     }
00057   Qname & getExtRefName(int index)
00058     {
00059       return extRefs_[index].qname;
00060     }
00061   int getExtRefType(int index)
00062     {
00063       return extRefs_[index].localTypeId;
00064     }
00065   void resolveForwardElementRefs(const string & name, Element & e);
00066   void resolveForwardAttributeRefs(const string & name, Attribute & a);
00067 
00068   //get the path to the descendant element
00069   int getCompleteXpath(int elemId, string & childName, int *xPath,
00070                        int limits, int &offset);
00071 
00072   //returns the pointer to a type whose id is given
00073   XSDType *getTypePtr(int id) const
00074     {
00075 
00076       // this is a basic XSD type
00077       if (id < Schema::ANYURI + 1 || id > Schema::ANYURI + numTypes)
00078         return 0;
00079       return typesArray[id - (Schema::ANYURI + 1)];
00080     }
00081   int getNumTypes(void) const
00082     {
00083       return numTypes;
00084     } bool detectUndefinedTypes(void);
00085   void setTargetNamespace(string Uri)
00086     {
00087       m_tnsUri = Uri;
00088     }
00089   string getTargetNamespace(void)
00090     {
00091       return m_tnsUri;
00092     }
00093   void printUndefinedTypes(ostream & out);
00094 
00095 #ifdef LOGGING
00096   //for logging purposes
00097   void printTypes(ostream & out);
00098 #endif 
00099  private:
00100   //contains a pointer to the actual type
00101   XSDType ** typesArray;
00102 
00103   //maintains a map of all user defined type names and their ids
00104   map < string, int >Id;
00105 
00106   //This is a map of all types defined in XML Schema
00107   map < string, int >basicTypes;
00108   int currentId;
00109   int numTypes, nSize;
00110   string m_tnsUri;
00111   
00112   typedef struct 
00113   {
00114     int localTypeId;
00115     Qname qname;
00116   }extRefs;
00117   std::vector<extRefs> extRefs_;
00118   void ensureCapacity();
00119 };
00120 #endif                                            /*  */

Generated on Sat Oct 29 13:08:56 2005 for wsdlpull by  doxygen 1.3.9.1