src/schemaparser/TypesTable.h

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

Generated on Sun Nov 26 03:04:43 2006 for wsdlpull by  doxygen 1.4.6