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

Generated on Mon Feb 6 23:02:42 2006 for wsdlpull by  doxygen 1.3.9.1