All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AttributeGroup.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 AttributeGroup.cpp
22 
23  \brief It models a XML Schema attribute group.
24 */
25 
26 // TerraLib
27 #include "AnyAttribute.h"
28 #include "AttributeGroup.h"
29 #include "QName.h"
30 
32  : Identifiable(id),
33  Annotated(ann),
34  m_name(0),
35  m_ref(0),
36  m_anyAttr(0)
37 {
38 }
39 
41  : Identifiable(rhs),
42  Annotated(rhs),
43  m_name(0),
44  m_ref(0),
45  m_anyAttr(0)
46 {
47  m_name = rhs.m_name ? new std::string(*rhs.m_name) : 0;
48  m_ref = rhs.m_ref ? new QName(*rhs.m_ref) : 0;
49 
50  for(std::size_t i = 0; i < rhs.m_attributeVec.size(); ++i)
51  m_attributeVec.push_back(rhs.m_attributeVec[i].clone());
52 
53  m_anyAttr = rhs.m_anyAttr ? new AnyAttribute(*rhs.m_anyAttr) : 0;
54 }
55 
57 {
58  delete m_name;
59  delete m_ref;
60  delete m_anyAttr;
61 }
62 
64 {
65  if(this != &rhs)
66  {
68 
70 
71  delete m_name;
72 
73  m_name = rhs.m_name ? new std::string(*rhs.m_name) : 0;
74 
75  delete m_ref;
76 
77  m_ref = rhs.m_ref ? new QName(*rhs.m_ref) : 0;
78 
79  for(std::size_t i = 0; i < rhs.m_attributeVec.size(); ++i)
80  m_attributeVec.push_back(rhs.m_attributeVec[i].clone());
81 
82  delete m_anyAttr;
83 
84  m_anyAttr = rhs.m_anyAttr ? new AnyAttribute(*rhs.m_anyAttr) : 0;
85  }
86 
87  return *this;
88 }
89 
91 {
92  return m_name;
93 }
94 
96 {
97  return m_ref;
98 }
99 
101 {
102  return m_anyAttr;
103 }
104 
105 void te::xsd::AttributeGroup::setName(std::string* name)
106 {
107  delete m_name;
108  m_name = name;
109 
110  delete m_ref;
111  m_ref = 0;
112 }
113 
115 {
116  delete m_ref;
117  m_ref = ref;
118 
119  delete m_name;
120  m_name = 0;
121 }
122 
124 {
125  m_attributeVec.push_back(a);
126 }
127 
129 {
130  delete m_anyAttr;
131  m_anyAttr = a;
132 }
133 
135 {
136  return new AttributeGroup(*this);
137 }
AttributeGroup & operator=(const AttributeGroup &rhs)
Assignment operator.
void setAnyAttribute(AnyAttribute *a)
It sets the anyAttribute to this attribute group element.
~AttributeGroup()
Destructor.
It models a XML Schema attribute group.
A base class for XSD classes that may allow annotation.
Definition: Annotated.h:49
void setName(std::string *name)
It sets a name for the attribute group.
AnyAttribute * getAnyAttribute() const
It returns the anyAttribute defined on this attribute group element.
Annotated & operator=(const Annotated &rhs)
Assignment operator.
Definition: Annotated.cpp:57
QName * m_ref
It specifies a reference to a named attribute group. Name and ref attributes cannot both be present...
std::string * m_name
It specifies a name for the attribute group. (Optional)
A class to deal with XML qualified names.
It models an XML anyAttribute element.
Definition: AnyAttribute.h:49
AttributeGroup(Annotation *ann=0, std::string *id=0)
Constructor.
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
boost::ptr_vector< AbstractAttribute > m_attributeVec
The list of attributes, references or nested attribute groups. (Optional)
Identifiable & operator=(const Identifiable &rhs)
Assignment operator.
AbstractAttribute * clone() const
It models an XML anyAttribute element.
std::string * getName() const
It returns the name of the attribute group.
A class to be used to represent XML qualified names.
Definition: QName.h:49
QName * getRef() const
It returns the reference to a named attribute element.
void addAttribute(AbstractAttribute *a)
It adds an attrbitue to this attribute group element.
A class that models a XSD annotation element.
Definition: Annotation.h:55
void setRef(QName *ref)
It sets a reference to a named attribute.
AnyAttribute * m_anyAttr
It enables the author to extend the XML document with attributes not specified by the schema...