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

SimpleType.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 _SIMPLETYPEH
00022 #define _SIMPLETYPEH
00023 #include <list>
00024 #include <map>
00025 #include <vector>
00026 
00027 #include <schemaparser/XSDType.h>
00028 #include <xmlpull/Qname.h>
00029 #include  <xmlpull/XmlUtils.h>
00030 #include <schemaparser/SchemaParserException.h>
00031 
00032 
00033 //union to store the values for various facets
00034 typedef union
00035 {
00036   int length;
00037   struct
00038   {
00039     int minlen, maxlen;
00040   } lenRange;
00041   int numEnums;
00042   int wsp;
00043   struct
00044   {
00045     int maxinc, mininc, maxex, minex;
00046   } valRange;
00047   int tot;
00048   int frac;
00049   const char *pattern;
00050 } facetValueType;
00051 
00052 class SimpleType:public XSDType
00053 {
00054  public:
00060   SimpleType(const std::string & ns);
00061   ~SimpleType();
00063     
00070   bool isList() const;
00075   bool isUnion() const;
00080   bool isSimple() const;
00081 
00082   //facet and restriction methods
00083   bool isvalidFacet(std::string facet);
00084   bool isValidInt(int val)const;
00085   bool isValidFloat(float val)const;
00086   bool isValidString(std::string val)const;
00087   bool getFacetValue(int facet, void **val);
00088   const std::list<int>* unionTypes()const;
00089 
00091 
00093   void setUnionType(int id);
00094   void setListType(int id);
00095   void setFacetValue(std::string facet,std::string val);
00097     
00098   //enum for facet Ids
00099   enum
00100     {
00101       NONE = 0,
00102       LENGTH = 0x1,
00103       MINLEN = 0x2,
00104       MAXLEN = 0x4,
00105       ENUM =0x8,
00106       WSP = 0x10,
00107       MAXINC = 0x20,
00108       MININC = 0x40,
00109       MAXEX =0x80,
00110       MINEX = 0x100,
00111       TOTALDIGITS = 0x200,
00112       FRAC = 0x400,
00113       PATTERN = 0x800
00114     };
00115 
00116   //whitespace values
00117   enum
00118     {
00119       PRESERVE,
00120       REPLACE,
00121       COLLAPSE
00122     };
00123 #ifdef LOGGING
00124   void print(ostream & out);
00125 #endif
00126  private:
00127   std::vector<int> facetId_;
00128   std::map<std::string,int> facets_;
00129   list < std::string > enumValues_;
00130   int *validFacets_;
00131   facetValueType facetValue_;
00132   void error(std::string msg);
00133   bool isList_;
00134   bool isUnion_;
00135   std::list<int> * uTypes_;
00136 };
00137 
00138 inline
00139 bool
00140 SimpleType::isList() const
00141 {
00142   return isList_;
00143 }
00144 
00145 inline
00146 bool
00147 SimpleType::isUnion() const
00148 {
00149   return isUnion_;
00150 }
00151 
00152 inline
00153 void
00154 SimpleType::setListType(int typeId)
00155 {
00156   isList_ = true;
00157   setBaseType(typeId);
00158 }
00159 
00160 inline
00161 void
00162 SimpleType::setUnionType(int typeId)
00163 {
00164   isUnion_ = true;
00165   if(uTypes_ == 0){
00166     uTypes_ = new std::list<int>();
00167   }
00168   uTypes_->push_back(typeId);
00169 }
00170 
00171 inline
00172 bool
00173 SimpleType::isSimple() const
00174 {
00175   return true;
00176 }
00177 inline
00178 const std::list<int>*
00179 SimpleType::unionTypes()const
00180 {
00181   return uTypes_;
00182 }
00183 #endif                                            /*  */

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