wsdlpull
1.23
Toggle main menu visibility
Loading...
Searching...
No Matches
src
schemaparser
TypeContainer.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
//This class is a recursive storage container for any xml data type
21
//It stores the actual values occuring in an XML Schema Instance ,
22
//for a given type defined in the SchemaParser
23
24
#ifndef _TYPECONTAINERH
25
#define _TYPECONTAINERH
26
#include <map>
27
28
#include "
xmlpull/wsdlpull_export.h
"
29
#include "
xmlpull/XmlUtils.h
"
30
#include "
schemaparser/SchemaParser.h
"
31
32
33
namespace
Schema
{
34
class
TypeContainer
;
35
36
37
typedef
struct
{
38
std::vector<TypeContainer *>
tc
;
39
int
count
;
//Count maintains the last accessed container
40
int
num
;
//num is the number of occurrences of this child
41
}
Containers
;
42
43
class
WSDLPULL_EXPORT
TypeContainer
44
{
45
public
:
46
TypeContainer
(
int
typeId,
const
SchemaParser
* sp);
47
TypeContainer
(
ContentModel
* cm,
const
SchemaParser
* sp,
int
typeId);
48
//type id is the complex type in which this content model is created
49
50
~TypeContainer
();
51
TypeContainer
*
getAttributeContainer
(std::string attName,
52
bool
create=
false
);
53
TypeContainer
*
getBaseTypeContainer
(
bool
create=
false
);
54
55
TypeContainer
*
getChildContainer
(std::string elemName,
56
bool
create =
false
);
57
58
TypeContainer
*
getChildContainer
(
ContentModel
* cm,
59
bool
create=
false
);
60
61
//If this is a container for simple type this method
62
//returns a void* to the type .The actual type must be found using getTypeId()
63
void
*
getValue
();
64
65
//Set position markers for this TypeContainer and all its' children to the start
66
//TODO add an iterator interface to typecontainer
67
void
rewind
();
68
69
//This method searches the xml instance for an element whose name is specified
70
//and is a simple type.If the return value is non null then type has the actual
71
//type of the returned value which can be used for type casting
72
void
*
getValue
(
const
std::string & name,
Schema::Type
& type);
73
74
const
SchemaParser
*
schemaParser
()
const
;
75
bool
isValueValid
()
const
;
76
//return the type which the container instanciates
77
//The typeId is 0 if this is a container for an anonymous content model
78
int
getTypeId
()
const
;
79
//return the content model which the container instanciates
80
//The content model is null if this is a container instanciates a schema defined type
81
ContentModel
*
getContentModel
()
const
;
82
83
//Various set methods
84
void
setValue
(
const
std::string &
sValue
,
bool
valid=
true
);
85
void
setValue
(
int
iValue
,
bool
valid=
true
);
86
void
setValue
(
char
cValue
,
bool
valid=
true
);
87
void
setValue
(
long
lValue
,
bool
valid=
true
);
88
void
setValue
(
unsigned
long
ulValue
,
bool
valid=
true
);
89
void
setValue
(
float
fValue
,
bool
valid=
true
);
90
void
setValue
(
double
dbValue
,
bool
valid=
true
);
91
void
setValue
(
bool
bValue
,
bool
valid=
true
);
92
void
setValue
(
Qname
&
qnValue
,
bool
valid=
true
);
93
94
//if the container actually stores atomic data,return its type
95
void
setValAsString
(
const
std::string &v);
//set a value without validating
96
void
print
(std::ostream & os);
97
friend
std::ostream &
operator<<
(std::ostream &os,
TypeContainer
&tc);
98
static
bool
printTypeNames_
;
99
friend
class
SchemaValidator
;
100
private
:
101
//The unique id of the type for which this holds data
102
Schema::Type
typeId_;
103
ContentModel
* cm_;
104
std::map < std::string, Containers *> particleContainers_;
//Type containers for particles
105
std::map<ContentModel*,TypeContainer* >cmContainers_;
//Type container for the content models
106
std::map < std::string, TypeContainer *> attributeContainers_;
//TypeContainers for attributes
107
const
SchemaParser
*sParser_;
108
TypeContainer
* baseContainer_;
109
110
union
111
{
112
std::string *
sValue
;
113
int
*
iValue
;
114
unsigned
int
*
uiValue
;
115
long
*
lValue
;
116
unsigned
long
*
ulValue
;
117
short
*
shValue
;
118
unsigned
short
*
usValue
;
119
float
*
fValue
;
120
double
*
dbValue
;
121
bool
*
bValue
;
122
char
*
cValue
;
123
124
// Date *dValue;
125
// DateTime *dtValue;
126
// Time *tValue;
127
Qname
*
qnValue
;
128
129
// Uri *uriValue ;
130
} Value;
131
bool
isValueValid_;
//is the atomic date type valid
132
std::string strVal;
133
std::vector<TypeContainer*> tcTable;
134
135
void
deleteValue();
136
void
printComplexType (std::ostream & os);
137
void
printSimpleType (std::ostream & os);
138
void
printContentModel(std::ostream & os);
139
140
//Set position markers for this TypeContainer to the start
141
void
rewindParticleContainers(std::map < std::string, Containers *> &particleContainers);
142
};
143
144
inline
145
void
146
TypeContainer::setValue
(
const
std::string &
sValue
,
bool
valid)
147
{
148
deleteValue();
149
Value.sValue =
new
std::string(
sValue
);
150
isValueValid_=valid;
151
}
152
153
inline
154
void
155
TypeContainer::setValue
(
int
iValue
,
bool
valid)
156
{
157
deleteValue();
158
Value.iValue =
new
int (
iValue
);
159
isValueValid_=valid;
160
}
161
162
inline
163
void
164
TypeContainer::setValue
(
char
cValue
,
bool
valid)
165
{
166
deleteValue();
167
Value.cValue =
new
char (
cValue
);
168
isValueValid_=valid;
169
}
170
171
inline
172
void
173
TypeContainer::setValue
(
long
lValue
,
bool
valid)
174
{
175
deleteValue();
176
Value.lValue =
new
long (
lValue
);
177
isValueValid_=valid;
178
}
179
180
inline
181
void
182
TypeContainer::setValue
(
unsigned
long
ulValue
,
bool
valid)
183
{
184
deleteValue();
185
Value.ulValue =
new
unsigned
long (
ulValue
);
186
isValueValid_=valid;
187
}
188
189
inline
190
void
191
TypeContainer::setValue
(
float
fValue
,
bool
valid)
192
{
193
deleteValue();
194
Value.fValue =
new
float;
195
*(Value.fValue) =
fValue
;
196
isValueValid_=valid;
197
}
198
199
inline
200
void
201
TypeContainer::setValue
(
double
dbValue
,
bool
valid)
202
{
203
deleteValue();
204
Value.dbValue =
new
double;
205
*(Value.dbValue) =
dbValue
;
206
isValueValid_=valid;
207
}
208
209
inline
210
void
211
TypeContainer::setValue
(
bool
bValue
,
bool
valid)
212
{
213
deleteValue();
214
Value.bValue =
new
bool;
215
*(Value.bValue) =
bValue
;
216
isValueValid_=valid;
217
}
218
219
inline
220
void
221
TypeContainer::setValue
(
Qname
&
qnValue
,
bool
valid)
222
{
223
deleteValue();
224
Value.qnValue =
new
Qname
(
qnValue
);
225
isValueValid_=valid;
226
}
227
228
inline
229
int
230
TypeContainer::getTypeId
()
const
231
{
232
return
typeId_;
233
}
234
235
inline
236
ContentModel
*
237
TypeContainer::getContentModel
()
const
238
{
239
return
cm_;
240
}
241
242
inline
243
void
244
TypeContainer::setValAsString
(
const
std::string&v)
245
{
246
strVal=v;
247
}
248
/*
249
inline
250
void
251
TypeContainer::setValidity(bool b )
252
{
253
isValueValid_ = b;
254
}
255
*/
256
257
258
inline
259
bool
260
TypeContainer::isValueValid
()
const
261
{
262
return
isValueValid_;
263
}
264
}
265
#endif
/* */
operator<<
std::ostream & operator<<(std::ostream &os, const ConfigFile &cf)
Definition
ConfigFile.cpp:73
SchemaParser.h
XmlUtils.h
Qname
Definition
Qname.h:31
Schema::ContentModel
Definition
ContentModel.h:37
Schema::SchemaParser
Definition
SchemaParser.h:43
Schema::TypeContainer
Definition
TypeContainer.h:44
Schema::TypeContainer::shValue
short * shValue
Definition
TypeContainer.h:117
Schema::TypeContainer::getChildContainer
TypeContainer * getChildContainer(std::string elemName, bool create=false)
Definition
TypeContainer.cpp:127
Schema::TypeContainer::getContentModel
ContentModel * getContentModel() const
Definition
TypeContainer.h:237
Schema::TypeContainer::getBaseTypeContainer
TypeContainer * getBaseTypeContainer(bool create=false)
Definition
TypeContainer.cpp:202
Schema::TypeContainer::getAttributeContainer
TypeContainer * getAttributeContainer(std::string attName, bool create=false)
Definition
TypeContainer.cpp:94
Schema::TypeContainer::dbValue
double * dbValue
Definition
TypeContainer.h:120
Schema::TypeContainer::qnValue
Qname * qnValue
Definition
TypeContainer.h:127
Schema::TypeContainer::printTypeNames_
static bool printTypeNames_
Definition
TypeContainer.h:98
Schema::TypeContainer::print
void print(std::ostream &os)
Definition
TypeContainer.cpp:340
Schema::TypeContainer::cValue
char * cValue
Definition
TypeContainer.h:122
Schema::TypeContainer::schemaParser
const SchemaParser * schemaParser() const
Definition
TypeContainer.cpp:291
Schema::TypeContainer::uiValue
unsigned int * uiValue
Definition
TypeContainer.h:114
Schema::TypeContainer::ulValue
unsigned long * ulValue
Definition
TypeContainer.h:116
Schema::TypeContainer::rewind
void rewind()
resets the access counters so that all access starts from first child
Definition
TypeContainer.cpp:506
Schema::TypeContainer::setValAsString
void setValAsString(const std::string &v)
Definition
TypeContainer.h:244
Schema::TypeContainer::bValue
bool * bValue
Definition
TypeContainer.h:121
Schema::TypeContainer::sValue
std::string * sValue
Definition
TypeContainer.h:112
Schema::TypeContainer::getTypeId
int getTypeId() const
Definition
TypeContainer.h:230
Schema::TypeContainer::iValue
int * iValue
Definition
TypeContainer.h:113
Schema::TypeContainer::fValue
float * fValue
Definition
TypeContainer.h:119
Schema::TypeContainer::getValue
void * getValue()
Definition
TypeContainer.cpp:255
Schema::TypeContainer::isValueValid
bool isValueValid() const
Definition
TypeContainer.h:260
Schema::TypeContainer::usValue
unsigned short * usValue
Definition
TypeContainer.h:118
Schema::TypeContainer::setValue
void setValue(const std::string &sValue, bool valid=true)
Definition
TypeContainer.h:146
Schema::TypeContainer::SchemaValidator
friend class SchemaValidator
Definition
TypeContainer.h:99
Schema::TypeContainer::lValue
long * lValue
Definition
TypeContainer.h:115
Schema::TypeContainer::TypeContainer
TypeContainer(int typeId, const SchemaParser *sp)
Definition
TypeContainer.cpp:27
Schema
Definition
Annotation.h:27
Schema::Type
Type
Definition
Schema.h:60
Schema::Containers
Definition
TypeContainer.h:37
Schema::Containers::tc
std::vector< TypeContainer * > tc
Definition
TypeContainer.h:38
Schema::Containers::count
int count
Definition
TypeContainer.h:39
Schema::Containers::num
int num
Definition
TypeContainer.h:40
wsdlpull_export.h
WSDLPULL_EXPORT
#define WSDLPULL_EXPORT
Definition
wsdlpull_export.h:30
Generated by
1.17.0