xsd/Element.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib 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
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file Element.cpp
22 
23  \brief This class models the element of a XML Schema.
24 */
25 
26 // TerraLib
27 #include "../common/STLUtils.h"
28 #include "Element.h"
29 #include "Enums.h"
30 #include "IdentityConstraint.h"
31 #include "Type.h"
32 #include "QName.h"
33 
34 te::xsd::Element::Element(unsigned int minOccurs, unsigned int maxOccurs, Annotation* ann, std::string* id)
35  : Occurs(minOccurs, maxOccurs),
36  Identifiable(id),
37  Annotated(ann),
38  m_name(0),
39  m_ref(0),
40  m_type(0),
41  m_substitutionGroup(0),
42  m_default(0),
43  m_fixed(0),
44  m_form(Qualified),
45  m_nillable(false),
46  m_abstract(false),
47  m_block(UNKNOWN),
48  m_final(UNKNOWN),
49  m_contentType(0)
50 {
51 }
52 
54  : Occurs(rhs),
55  Identifiable(rhs),
56  Annotated(rhs),
57  m_name(0),
58  m_ref(0),
59  m_type(0),
61  m_default(0),
62  m_fixed(0),
64  m_nillable(false),
65  m_abstract(false),
68  m_contentType(0)
69 {
70 }
71 
73 {
74  delete m_type;
75  delete m_default;
76  delete m_fixed;
77  delete m_contentType;
78 }
79 
81 {
82  return *this;
83 }
84 
86 {
87  return m_type;
88 }
89 
91 {
92  return m_default;
93 }
94 
95 std::string* te::xsd::Element::getFixedValue() const
96 {
97  return m_fixed;
98 }
99 
101 {
102  return m_nillable;
103 }
104 
106 {
107  return m_abstract;
108 }
109 
111 {
112  return m_block;
113 }
114 
116 {
117  delete m_type;
118  m_type = t;
119 }
120 
122 {
123  delete m_default;
124  m_default = v;
125 }
126 
128 {
129  delete m_fixed;
130  m_fixed = v;
131 }
132 
134 {
135  m_nillable = v;
136 }
137 
139 {
140  m_abstract = v;
141 }
142 
144 {
145  m_block = v;
146 }
147 
148 std::string* te::xsd::Element::getName() const
149 {
150  return m_name;
151 }
152 
154 {
155  return m_ref;
156 }
157 
158 void te::xsd::Element::setName(std::string* name)
159 {
160  delete m_name;
161  m_name = name;
162 
163  delete m_ref;
164  m_ref = 0;
165 }
166 
168 {
169  delete m_ref;
170  m_ref = ref;
171 
172  delete m_name;
173  m_name = 0;
174 }
175 
176 
178 {
179  delete m_substitutionGroup;
181 }
182 
184 {
185  m_final = v;
186 }
187 
189 {
190  delete m_contentType;
191  m_contentType = t;
192 }
193 
195 {
196  m_identityConstraintVec.push_back(ic);
197 }
void setContentType(Type *t)
It sets the content type of the element.
void setAsAbstract(bool v)
It specifies whether the element can be used in an instance document.
void setSubstitutionGroup(QName *g)
It sets the substitution group.
An abstract class for modeling the definition of a new XML Schema Type.
A base class for XSD classes that may allow annotation.
Definition: Annotated.h:49
Element(unsigned int minOccurs=1, unsigned int maxOccurs=1, Annotation *ann=0, std::string *id=0)
Constructor.
Definition: xsd/Element.cpp:34
A base class for XSD classes that have occurs attributes.
Definition: Occurs.h:43
void addIdentityConstraint(IdentityConstraint *ic)
It adds an IdentityConstraint to the element.
Element & operator=(const Element &rhs)
Assignment operator.
Definition: xsd/Element.cpp:80
This class models the element of a XML Schema.
Definition: xsd/Element.h:56
QName * getType() const
It returns the name of a built-in data type, or the name of a simpleType or complexType element...
Definition: xsd/Element.cpp:85
Type * m_contentType
A content of this element. A simpleType or complexType element can be present as a child only if both...
Definition: xsd/Element.h:265
A class to deal with XML qualified names.
bool m_nillable
It specifies whether an explicit null value can be assigned to the element. True enables an instance ...
Definition: xsd/Element.h:261
bool isNillable()
If the element is "nillable" or not.
It indicates that the attribute attribute must be qualified with the namespace prefix and the no-colo...
std::string * m_fixed
It ensures that the elements are set to particular value.
Definition: xsd/Element.h:259
boost::ptr_vector< IdentityConstraint > m_identityConstraintVec
The list of elements related to identity constraint - (key | keyref | unique)*. (Optional) ...
Definition: xsd/Element.h:266
void setDefaultValue(std::string *v)
It sets the default value for the element.
QName * m_ref
It refers to the name of another element. The ref attribute can include a namespace prefix...
Definition: xsd/Element.h:255
QName * m_type
It specifies either the name of a built-in data type, or the name of a simpleType or complexType elem...
Definition: xsd/Element.h:256
void setBlock(int v)
It prevents an element with a specified type of derivation from being used in place of this element...
A base class for XSD classes that must provide a unique ID property.
Definition: Identifiable.h:46
bool m_abstract
It specifies whether the element can be used in an instance document. True indicates that the element...
Definition: xsd/Element.h:262
~Element()
Destructor.
Definition: xsd/Element.cpp:72
std::string * getFixedValue() const
It returns the fixed value for the element.
Definition: xsd/Element.cpp:95
void setAsNillable(bool v)
It specifies whether an explicit null value can be assigned to the element.
void setFixedValue(std::string *v)
It sets a fixed value for the element.
Form m_form
Here, "unqualified" indicates that this attribute is not required to be qualified with the namespace ...
Definition: xsd/Element.h:260
int getBlock()
It returns the block value for the element. It prevents an element with a specified type of derivatio...
QName * getRef() const
It returns the reference to a name of another element.
This is the base class for XML Schema elements that are related to identity constraint.
void setFinal(int v)
It sets the default value of the final attribute on the element element.
std::string * m_name
It specifies a name for the element. (Optional)
Definition: xsd/Element.h:254
std::string * getName() const
It returns the element name or NULL if it doesn&#39;t have one.
A class to be used to represent XML qualified names.
Definition: QName.h:49
void setRef(QName *ref)
It sets a reference to a name of another element.
bool isAbstract()
If the element is "abstract" or not.
int m_block
It prevents an element with a specified type of derivation from being used in place of this element...
Definition: xsd/Element.h:263
A class that models a XSD annotation element.
Definition: Annotation.h:55
void setType(QName *t)
It sets the element type.
void setName(std::string *name)
It sets the element name.
QName * m_substitutionGroup
It specifies the element that can be substituted with this element.
Definition: xsd/Element.h:257
int m_final
It sets the default value of the final attribute on the element element.
Definition: xsd/Element.h:264
std::string * m_default
It specifies a default value for the element (can only be used if the element&#39;s content is a simple t...
Definition: xsd/Element.h:258
std::string * getDefaultValue() const
It returns the default value for the element.
Definition: xsd/Element.cpp:90
This is the base class for XML Schema elements that are related to identity constraint.
An abstract class for modeling the definition of a new XML Schema Type.
Definition: Type.h:65