All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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),
60  m_substitutionGroup(0),
61  m_default(0),
62  m_fixed(0),
63  m_form(Qualified),
64  m_nillable(false),
65  m_abstract(false),
66  m_block(UNKNOWN),
67  m_final(UNKNOWN),
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;
180  m_substitutionGroup = g;
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.
Definition: Element.cpp:188
void setAsAbstract(bool v)
It specifies whether the element can be used in an instance document.
Definition: Element.cpp:138
void setSubstitutionGroup(QName *g)
It sets the substitution group.
Definition: Element.cpp:177
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: 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.
Definition: Element.cpp:194
Element & operator=(const Element &rhs)
Assignment operator.
Definition: Element.cpp:80
This class models the element of a XML Schema.
Definition: 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: Element.cpp:85
A class to deal with XML qualified names.
bool isNillable()
If the element is "nillable" or not.
Definition: Element.cpp:100
It indicates that the attribute attribute must be qualified with the namespace prefix and the no-colo...
Definition: Enums.h:114
void setDefaultValue(std::string *v)
It sets the default value for the element.
Definition: Element.cpp:121
void setBlock(int v)
It prevents an element with a specified type of derivation from being used in place of this element...
Definition: Element.cpp:143
A base class for XSD classes that must provide a unique ID property.
Definition: Identifiable.h:46
~Element()
Destructor.
Definition: Element.cpp:72
std::string * getFixedValue() const
It returns the fixed value for the element.
Definition: Element.cpp:95
void setAsNillable(bool v)
It specifies whether an explicit null value can be assigned to the element.
Definition: Element.cpp:133
void setFixedValue(std::string *v)
It sets a fixed value for the element.
Definition: Element.cpp:127
int getBlock()
It returns the block value for the element. It prevents an element with a specified type of derivatio...
Definition: Element.cpp:110
QName * getRef() const
It returns the reference to a name of another element.
Definition: Element.cpp:153
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.
Definition: Element.cpp:183
std::string * getName() const
It returns the element name or NULL if it doesn't have one.
Definition: Element.cpp:148
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.
Definition: Element.cpp:167
bool isAbstract()
If the element is "abstract" or not.
Definition: Element.cpp:105
A class that models a XSD annotation element.
Definition: Annotation.h:55
void setType(QName *t)
It sets the element type.
Definition: Element.cpp:115
void setName(std::string *name)
It sets the element name.
Definition: Element.cpp:158
std::string * getDefaultValue() const
It returns the default value for the element.
Definition: 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