wsdlpull svntrunk
Element.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 _ELEMENTH
22#define _ELEMENTH
23
24#include <string>
27
28namespace Schema {
29#define UNBOUNDED INT_MAX
31{
32 public:
33 Element(const std::string & name,
34 const std::string & elemNs,
35 const std::string & typeNs,
36 int type_id,
37 int minimum = 1,
38 int maximum = 1,
39 bool qualified = false,
40 std::string def = "",
41 std::string fixed ="");
42
43 Element(void);
44 void setType(int id);
45 std::string getName() const;
46 void setTypeNamespace(const std::string & ns);
47 std::string getTypeNamespace() const;
48 void setNamespace(const std::string &ns);
49 std::string getNamespace()const;
50 int getType() const;
51 int getMax() const ;
52 int getMin() const;
53 std::string & defaultVal();
54 std::string & fixedVal();
55 bool isQualified() const;
56 Element& operator = (const Element & e);
57 void setMin(int m);
58 void setMax(int m);
59 //add a key/keyref/unique constraint
60 void addConstraint(Constraint* c);
61 Constraint* constraint();
62 const std::list<std::string> & getConstraints(); // Proposed modification: return a list of constraints, every constraint identified by its name.
64
65 private:
66 std::string elemName;
67 std::string dval, fval;
68 int elemType;
69 bool bQualified;
70 int minOccurs, maxOccurs;
71 std::string elemNamespace;//namespace where the element is defined
72 std::string typeNamespace;//namespace where the type of this element is defined
73
74 Constraint* cstr;
75};
76
77#ifdef LOGGING
78std::ostream & operator << (std::ostream & stream, Element & e);
79#endif
80
81inline
82Element::Element(const std::string & name,
83 const std::string & elemNs,
84 const std::string & typeNs,
85 int type_id,
86 int minimum,
87 int maximum,
88 bool qualified,
89 std::string def ,
90 std::string fixed)
91 : nOccurrences(0),
92 elemName(name),
93 dval(def),
94 fval(fixed),
95 elemType(type_id),
96 bQualified(qualified),
97 minOccurs(minimum),
98 maxOccurs(maximum),
99 elemNamespace(elemNs),
100 typeNamespace(typeNs),
101 cstr(0)
102 {
103 }
104
105inline
107 :nOccurrences(0),
108 elemType(0),
109 bQualified (false),
110 minOccurs (1),
111 maxOccurs (1),
112 cstr(0)
113{
114}
115
116inline
117void
119{
120 elemType = id;
121}
122
123inline
124std::string
126{
127 return elemName;
128}
129
130inline
131void
132Element::setTypeNamespace(const std::string& ns)
133{
134 typeNamespace = ns;
135}
136
137inline
138std::string
140{
141 return typeNamespace;
142}
143
144
145inline
146int
148{
149 return elemType;
150}
151
152inline
153int
155{
156 return maxOccurs;
157}
158inline
159int
161{
162 return minOccurs;
163}
164
165inline
166std::string &
168{
169 return dval;
170}
171
172inline
173std::string &
175{
176 return fval;
177}
178
179inline
180bool
182{
183 return bQualified;
184}
185
186inline
187Element&
189{
190 elemName = e.elemName;
191 elemType = e.elemType;
192 bQualified = e.isQualified();
193 dval = e.dval;
194 fval = e.fval;
195 typeNamespace = e.typeNamespace;
196 cstr = e.cstr;
197 return *this;
198 //minimum and maximum are not copied because they are specific to the
199 //occurrence
200}
201inline
202void
204{
205 minOccurs=m;
206}
207
208inline
209void
211{
212 maxOccurs=m;
213}
214
215inline
216void
218{
219 cstr=c;
220}
221
222inline
225{
226 return cstr;
227}
228
229
230inline
231void
232Element::setNamespace(const std::string& ns)
233{
234 elemNamespace = ns;
235}
236
237inline
238std::string
240{
241 return elemNamespace;
242}
243
244
245
246}
247#endif /* */
int getType() const
Definition: Element.h:147
void setNamespace(const std::string &ns)
Definition: Element.h:232
const std::list< std::string > & getConstraints()
int getMax() const
Definition: Element.h:154
std::string & defaultVal()
Definition: Element.h:167
void setMax(int m)
Definition: Element.h:210
void addConstraint(Constraint *c)
Definition: Element.h:217
std::string getName() const
Definition: Element.h:125
Element(void)
Definition: Element.h:106
void setMin(int m)
Definition: Element.h:203
std::string getTypeNamespace() const
Definition: Element.h:139
std::string & fixedVal()
Definition: Element.h:174
Element & operator=(const Element &e)
Definition: Element.h:188
std::string getNamespace() const
Definition: Element.h:239
int getMin() const
Definition: Element.h:160
int nOccurrences
Definition: Element.h:63
Constraint * constraint()
Definition: Element.h:224
void setType(int id)
Definition: Element.h:118
void setTypeNamespace(const std::string &ns)
Definition: Element.h:132
bool isQualified() const
Definition: Element.h:181
std::ostream & operator<<(std::ostream &os, TypeContainer &tc)
#define WSDLPULL_EXPORT