wsdlpull  1.23
XSDType.h
Go to the documentation of this file.
1 /*
2  * wsdl2cpp - 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 
22 /*
23  * Abstract interface for all xsd types
24  */
25 
26 
27 #ifndef _XSDTYPEH
28 #define _XSDTYPEH
29 
30 #include <string>
31 #include "xmlpull/Qname.h"
33 #include "schemaparser/Schema.h"
34 
35 
36 namespace Schema {
38 {
39  public:
40 
46  XSDType(const std::string & ns);
47  XSDType();
48  virtual ~ XSDType(){};
50 
51 
56  std::string getName() const ;
62  std::string getNamespace() const ;
67  Qname getQname() const;
72  Schema::ContentModelType getContentModel() const ;
73 
78  int getTypeId() const ;
84  int getBaseTypeId()const;
89  Schema::Derivation getBaseDerivation()const;
95  bool isAnonymous() const ;
101  virtual bool isSimple()const =0;
102 
104  virtual void setName(std::string);
105  virtual void setContentModel(Schema::ContentModelType );
106  virtual void setTypeId(int);
107  virtual void setAnonymous(bool);
108  void setBaseType(int id , Schema::Derivation type = Schema::Restriction);
109  void setBaseTypeNamespace(std::string ns);
111 #ifdef LOGGING
112  virtual void print (std::ostream & out) { };
113 #endif
114  private:
115  std::string nsUri_;
116  std::string name_;
117  int typeId_;
118  int baseType_;
119  Schema::Derivation baseDerivation_;
120  Schema::ContentModelType contentModel_;//simple,complex,mixed?
121  bool anonymous_;
122 };
123 
124 inline
125 XSDType::XSDType(const std::string & ns)
126  :nsUri_(ns),
127  typeId_(0),
128  baseType_(Schema::XSD_ANYTYPE),
129  baseDerivation_(Schema::Extension),
130  contentModel_(Schema::None),
131  anonymous_(false)
132 {
133 }
134 
135 inline
137  :nsUri_(Schema::SchemaUri),
138  typeId_(0),
139  baseType_(Schema::XSD_ANYTYPE),
140  baseDerivation_(Schema::Extension),
141  contentModel_(Schema::None),
142  anonymous_(false)
143 {
144 }
145 
146 inline
147 std::string
149 {
150  return name_;
151 }
152 
153 inline
154 Qname
156 {
157  Qname qn(name_);
158  qn.setNamespace(nsUri_);
159  return qn;
160 }
161 
162 inline
165 {
166  return contentModel_;
167 }
168 
169 inline
170 int
172 {
173  return typeId_;
174 }
175 
176 inline
177 bool
179 {
180  return anonymous_;
181 }
182 
183 inline
184 int
186 {
187  return baseType_;
188 }
189 
190 inline
193 {
194  return baseDerivation_;
195 }
196 
197 inline
198 void
200 {
201  typeId_ = id;
202 }
203 
204 inline
205 void
207  Schema::Derivation type)
208 {
209  baseType_=id;
210  baseDerivation_=type;
211 }
212 
213 inline
214 void
216 {
217  anonymous_ = flag;
218 }
219 
220 inline
221 void
222 XSDType::setName(std::string name)
223 {
224  name_ = name;
225 }
226 
227 inline
228 void
230 {
231  contentModel_ = model;
232 }
233 
234 inline
235 std::string
237 {
238  return nsUri_;
239 }
240 }
241 #endif /* */
void setNamespace(std::string uri)
Definition: Qname.h:97
std::string getName() const
Definition: XSDType.h:148
virtual ~ XSDType()
Definition: XSDType.h:48
virtual void setName(std::string)
Definition: XSDType.h:222
std::string getNamespace() const
Definition: XSDType.h:236
Definition: Qname.h:30
ContentModelType
Definition: Schema.h:44
Schema::ContentModelType getContentModel() const
Definition: XSDType.h:164
int getTypeId() const
Definition: XSDType.h:171
virtual void setAnonymous(bool)
Definition: XSDType.h:215
virtual void setContentModel(Schema::ContentModelType)
Definition: XSDType.h:229
int getBaseTypeId() const
Definition: XSDType.h:185
#define WSDLPULL_EXPORT
Derivation
Definition: Schema.h:38
void setBaseType(int id, Schema::Derivation type=Schema::Restriction)
Definition: XSDType.h:206
const std::string SchemaUri
Definition: Schema.h:92
Qname getQname() const
Definition: XSDType.h:155
virtual void setTypeId(int)
Definition: XSDType.h:199
Schema::Derivation getBaseDerivation() const
Definition: XSDType.h:192
bool isAnonymous() const
Definition: XSDType.h:178