wsdlpull  1.23
SimpleType.h
Go to the documentation of this file.
1 /*
2  * wsdlpull - A C++ parser for WSDL (Web services description language)
3  * Copyright (C) 2005-2007 Vivek Krishna
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the Free
17  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  *
20  */
21 #ifndef _SIMPLETYPEH
22 #define _SIMPLETYPEH
23 #include <list>
24 #include <map>
25 #include <vector>
26 
27 #include "schemaparser/XSDType.h"
29 #include "xmlpull/Qname.h"
30 #include "xmlpull/XmlUtils.h"
32 
33 namespace Schema {
34 //union to store the values for various facets
35 typedef union
36 {
37  int length;
38  struct
39  {
40  int minlen, maxlen;
41  } lenRange;
42  int numEnums;
43  int wsp;
44  struct
45  {
46  int maxinc, mininc, maxex, minex;
47  } valRange;
48  int tot;
49  int frac;
50  const char *pattern;
52 
54 {
55  public:
61  SimpleType(const std::string & ns);
62  ~SimpleType();
64 
71  bool isList() const;
76  bool isUnion() const;
81  bool isSimple() const;
82 
83  //facet and restriction methods
84  bool isvalidFacet(std::string facet);
85  bool isValidInt(int val)const;
86  bool isValidFloat(float val)const;
87  bool isValidString(std::string val)const;
88  bool getFacetValue(int facet, void* &val);
89  const std::list<int>* unionTypes()const;
90 
92 
94  void setUnionType(int id);
95  void setListType(int id);
96  void setFacetValue(std::string facet,std::string val);
98 
99  //enum for facet Ids
100  enum
101  {
102  NONE = 0,
103  LENGTH = 0x1,
104  MINLEN = 0x2,
105  MAXLEN = 0x4,
106  ENUM =0x8,
107  WSP = 0x10,
108  MAXINC = 0x20,
109  MININC = 0x40,
110  MAXEX =0x80,
111  MINEX = 0x100,
112  TOTALDIGITS = 0x200,
113  FRAC = 0x400,
114  PATTERN = 0x800
115  };
116 
117  //whitespace values
118  enum
119  {
120  PRESERVE = 1,
122  COLLAPSE
123  };
124 #ifdef LOGGING
125  void print(std::ostream & out);
126 #endif
127  private:
128  std::vector<int> facetId_;
129  std::map<std::string,int> facets_;
130  std::list < std::string > enumValues_;
131  int *validFacets_;
132  facetValueType facetValue_;
133  void error(std::string msg);
134  bool isList_;
135  bool isUnion_;
136  std::list<int> * uTypes_;
137 };
138 
139 inline
140 bool
142 {
143  return isList_;
144 }
145 
146 inline
147 bool
149 {
150  return isUnion_;
151 }
152 
153 inline
154 void
156 {
157  isList_ = true;
158  setBaseType(typeId);
159 }
160 
161 inline
162 void
164 {
165  isUnion_ = true;
166  if(uTypes_ == 0){
167  uTypes_ = new std::list<int>();
168  }
169  uTypes_->push_back(typeId);
170 }
171 
172 inline
173 bool
175 {
176  return true;
177 }
178 inline
179 const std::list<int>*
181 {
182  return uTypes_;
183 }
184 }
185 #endif /* */
void setListType(int id)
Definition: SimpleType.h:155
const std::list< int > * unionTypes() const
Definition: SimpleType.h:180
bool isUnion() const
Definition: SimpleType.h:148
void setUnionType(int id)
Definition: SimpleType.h:163
bool isList() const
Definition: SimpleType.h:141
#define WSDLPULL_EXPORT
void setBaseType(int id, Schema::Derivation type=Schema::Restriction)
Definition: XSDType.h:206
bool isSimple() const
Definition: SimpleType.h:174
const char * pattern
Definition: SimpleType.h:50