All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Attribute.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 Lesser 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 Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser 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 Attribute.cpp
22 
23  \brief It models a XML Schema attribute.
24 */
25 
26 // TerraLib
27 #include "Attribute.h"
28 #include "QName.h"
29 #include "SimpleType.h"
30 
32  : Identifiable(id),
33  Annotated(ann),
34  m_default(0),
35  m_fixed(0),
36  m_form(Unqualified),
37  m_name(0),
38  m_ref(0),
39  m_type(0),
40  m_use(OPTIONAL),
41  m_innerType(0)/*,
42  m_otherAttributes(0)*/
43 {
44 }
45 
47  : Identifiable(rhs),
48  Annotated(rhs),
49  m_default(0),
50  m_fixed(0),
51  m_form(rhs.m_form),
52  m_name(0),
53  m_ref(0),
54  m_type(0),
55  m_use(rhs.m_use),
56  m_innerType(0)
57 {
58  m_default = rhs.m_default ? new std::string(*rhs.m_default) : 0;
59  m_fixed = rhs.m_fixed ? new std::string(*rhs.m_fixed) : 0;
60  m_name = rhs.m_name ? new std::string(*rhs.m_name) : 0;
61  m_ref = rhs.m_ref ? new QName(*rhs.m_ref) : 0;
62  m_type = rhs.m_type ? new QName(*rhs.m_type) : 0;
63  m_innerType = rhs.m_innerType ? new SimpleType(*rhs.m_innerType) : 0;
64 }
65 
67 {
68  delete m_default;
69  delete m_fixed;
70  delete m_name;
71  delete m_ref;
72  delete m_type;
73  delete m_innerType;
74  //delete m_otherAttributes;
75 }
76 
78 {
79  if(this != &rhs)
80  {
82 
84 
85  delete m_default;
86 
87  m_default = rhs.m_default ? new std::string(*rhs.m_default) : 0;
88 
89  delete m_fixed;
90 
91  m_fixed = rhs.m_fixed ? new std::string(*rhs.m_fixed) : 0;
92 
93  m_form = rhs.m_form;
94 
95  delete m_name;
96 
97  m_name = rhs.m_name ? new std::string(*rhs.m_name) : 0;
98 
99  delete m_ref;
100 
101  m_ref = rhs.m_ref ? new QName(*rhs.m_ref) : 0;
102 
103  delete m_type;
104 
105  m_type = rhs.m_type ? new QName(*rhs.m_type) : 0;
106 
107  m_use = rhs.m_use;
108 
109  delete m_innerType;
110 
111  m_innerType = rhs.m_innerType ? new SimpleType(*rhs.m_innerType) : 0;
112  }
113 
114  return *this;
115 }
116 
117 
118 std::string* te::xsd::Attribute::getDefault() const
119 {
120  return m_default;
121 }
122 
123 std::string* te::xsd::Attribute::getFixed() const
124 {
125  return m_fixed;
126 }
127 
129 {
130  return m_form;
131 }
132 
133 std::string* te::xsd::Attribute::getName() const
134 {
135  return m_name;
136 }
137 
139 {
140  return m_ref;
141 }
142 
144 {
145  return m_type;
146 }
147 
149 {
150  return m_use;
151 }
152 
154 {
155  return m_innerType;
156 }
157 
158 //std::map<std::string, std::string>* te::xsd::Attribute::getOtherAttributes() const
159 //{
160 // return m_otherAttributes;
161 //}
162 
163 void te::xsd::Attribute::setDefault(std::string* def)
164 {
165  delete m_default;
166  m_default = def;
167 
168  delete m_fixed;
169  m_fixed = 0;
170 }
171 
172 void te::xsd::Attribute::setFixed(std::string* fix)
173 {
174  delete m_fixed;
175  m_fixed = fix;
176 
177  delete m_default;
178  m_default = 0;
179 }
180 
182 {
183  m_form = f;
184 }
185 
186 void te::xsd::Attribute::setName(std::string* name)
187 {
188  delete m_name;
189  m_name = name;
190 
191  delete m_ref;
192  m_ref = 0;
193 }
194 
196 {
197  delete m_ref;
198  m_ref = ref;
199 
200  delete m_name;
201  m_name = 0;
202 
203  delete m_type;
204  m_type = 0;
205 
206  delete m_innerType;
207  m_innerType = 0;
208 }
209 
211 {
212  delete m_type;
213  m_type = type;
214 
215  delete m_ref;
216  m_ref = 0;
217 
218  delete m_innerType;
219  m_innerType = 0;
220 }
221 
223 {
224  m_use = use;
225 }
226 
228 {
229  delete m_innerType;
230  m_innerType = iType;
231 
232  delete m_ref;
233  m_ref = 0;
234 
235  delete m_type;
236  m_type = 0;
237 }
238 
239 //void te::xsd::Attribute::addOtherAttribute(std::string key, std::string value)
240 //{
241 // if(m_otherAttributes == 0)
242 // m_otherAttributes = new std::map<std::string, std::string>;
243 //
244 // m_otherAttributes->insert(std::pair<std::string, std::string>(key, value));
245 //}
246 
248 {
249  return new Attribute(*this);
250 }
251 
252 
253 
QName * m_type
It specifies a built-in data type or simple type for the attribute. It is NULL if m_ref is present or...
Definition: Attribute.h:248
SimpleType * getInnerType() const
It returns the simpleType element of the attribute.
Definition: Attribute.cpp:153
AttributeUse
It specifies how the attribute is used.
Definition: Enums.h:69
void setRef(QName *ref)
It sets a reference to a named attribute.
Definition: Attribute.cpp:195
A base class for XSD classes that may allow annotation.
Definition: Annotated.h:49
AttributeUse m_use
It specifies how the attribute is used. (Optional)
Definition: Attribute.h:249
QName * getType() const
It returns a built-in data type or simple type for the attribute element.
Definition: Attribute.cpp:143
void setForm(Form f)
It sets the form property of the attribute.
Definition: Attribute.cpp:181
Annotated & operator=(const Annotated &rhs)
Assignment operator.
Definition: Annotated.cpp:57
Form m_form
It specifies if the attribute must be qualified or not. Default = unqualified. (Optional) ...
Definition: Attribute.h:245
AttributeUse getUse() const
It returns a AttributeUse object that specifies how how the attribute is used.
Definition: Attribute.cpp:148
std::string * getDefault() const
It returns the default value for the attribute.
Definition: Attribute.cpp:118
It models a XML Schema SimpleType element.
std::string * m_default
It specifies a default value for the attribute (Optional).
Definition: Attribute.h:243
A class to deal with XML qualified names.
void setUse(AttributeUse use)
It sets how the attribute is used.
Definition: Attribute.cpp:222
void setDefault(std::string *def)
It returns a map with other properties of the attribute element.
Definition: Attribute.cpp:163
This is the base class for XML Schema Attribute classes.
A base class for XSD classes that must provide a unique ID property.
Definition: Identifiable.h:46
It models a XML Schema attribute.
Definition: Attribute.h:61
Form
It specifies the form for the attribute.
Definition: Enums.h:112
void setFixed(std::string *fix)
It sets a fixed value for the attribute.
Definition: Attribute.cpp:172
It indicates that the attribute use is optional. This is the default.
Definition: Enums.h:72
void setName(std::string *name)
It sets a name for the attribute.
Definition: Attribute.cpp:186
void setType(QName *type)
It sets a built-in data type or simple type for the attribute.
Definition: Attribute.cpp:210
Identifiable & operator=(const Identifiable &rhs)
Assignment operator.
SimpleType * m_innerType
It specifies the attribute type as a simple type. It will be NULL if m_ref is present or if m_type is...
Definition: Attribute.h:250
QName * m_ref
It specifies a reference to a named attribute. NULL if m_name is present. (Optional) ...
Definition: Attribute.h:247
Attribute(Annotation *ann=0, std::string *id=0)
Constructor.
Definition: Attribute.cpp:31
Form getForm() const
It returns the form property value of attribute.
Definition: Attribute.cpp:128
QName * getRef() const
It returns the reference to a named attribute element.
Definition: Attribute.cpp:138
~Attribute()
Destructor.
Definition: Attribute.cpp:66
A class to be used to represent XML qualified names.
Definition: QName.h:49
AbstractAttribute * clone() const
Add a property with non-schema namespace to the attribute.
Definition: Attribute.cpp:247
std::string * m_name
It specifies a name for the attribute. It will be NULL if m_ref is present. (Optional) ...
Definition: Attribute.h:246
It indicates that the attribute attribute is not required to be qualified with the namespace prefix a...
Definition: Enums.h:115
Attribute & operator=(const Attribute &rhs)
Assignment operator.
Definition: Attribute.cpp:77
It models a XML Schema attribute.
std::string * m_fixed
It specifies a fixed value for the attribute (Optional).
Definition: Attribute.h:244
A class that models a XSD annotation element.
Definition: Annotation.h:55
It models a XML Schema SimpleType element.
Definition: SimpleType.h:54
std::string * getName() const
It returns the name of the attribute.
Definition: Attribute.cpp:133
std::string * getFixed() const
It returns the fixed value for the attribute.
Definition: Attribute.cpp:123
void setInnerType(SimpleType *iType)
It sets a inner simpleType element for the attribute.
Definition: Attribute.cpp:227