wsdlpull  1.23
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 
28 namespace 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
78 std::ostream & operator << (std::ostream & stream, Element & e);
79 #endif
80 
81 inline
82 Element::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 
105 inline
107  :nOccurrences(0),
108  elemType(0),
109  bQualified (false),
110  minOccurs (1),
111  maxOccurs (1),
112  cstr(0)
113 {
114 }
115 
116 inline
117 void
119 {
120  elemType = id;
121 }
122 
123 inline
124 std::string
126 {
127  return elemName;
128 }
129 
130 inline
131 void
132 Element::setTypeNamespace(const std::string& ns)
133 {
134  typeNamespace = ns;
135 }
136 
137 inline
138 std::string
140 {
141  return typeNamespace;
142 }
143 
144 
145 inline
146 int
148 {
149  return elemType;
150 }
151 
152 inline
153 int
155 {
156  return maxOccurs;
157 }
158 inline
159 int
161 {
162  return minOccurs;
163 }
164 
165 inline
166 std::string &
168 {
169  return dval;
170 }
171 
172 inline
173 std::string &
175 {
176  return fval;
177 }
178 
179 inline
180 bool
182 {
183  return bQualified;
184 }
185 
186 inline
187 Element&
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 }
201 inline
202 void
204 {
205  minOccurs=m;
206 }
207 
208 inline
209 void
211 {
212  maxOccurs=m;
213 }
214 
215 inline
216 void
218 {
219  cstr=c;
220 }
221 
222 inline
223 Constraint*
225 {
226  return cstr;
227 }
228 
229 
230 inline
231 void
232 Element::setNamespace(const std::string& ns)
233 {
234  elemNamespace = ns;
235 }
236 
237 inline
238 std::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
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
const std::list< std::string > & getConstraints()
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