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

Generated by  doxygen 1.6.2