All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Choice.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 Choice.cpp
22 
23  \brief This class models the XML Schema choice element.
24 */
25 
26 // TerraLib
27 #include "Any.h"
28 #include "Choice.h"
29 #include "Element.h"
30 
31 te::xsd::Choice::Choice(unsigned int minOccurs, unsigned int maxOccurs, Annotation* ann, std::string* id)
32  : Occurs(minOccurs, maxOccurs),
33  Identifiable(id),
34  Annotated(ann)
35 {
36 }
37 
39  : Occurs(rhs),
40  Identifiable(rhs),
41  Annotated(rhs)
42 {
43  for(std::size_t i = 0; i < rhs.m_elementVec.size(); ++i)
44  m_elementVec.push_back(new Element(rhs.m_elementVec[i]));
45 
46  for(std::size_t i = 0; i < rhs.m_contentVec.size(); ++i)
47  m_contentVec.push_back(rhs.m_contentVec[i].clone());
48 
49  for(std::size_t i = 0; i < rhs.m_anyVec.size(); ++i)
50  m_anyVec.push_back(new Any(rhs.m_anyVec[i]));
51 }
52 
54 {
55 }
56 
58 {
59  if(this != &rhs)
60  {
61  Content::operator=(rhs);
62 
63  Occurs::operator=(rhs);
64 
66 
68 
69  for(std::size_t i = 0; i < rhs.m_elementVec.size(); ++i)
70  m_elementVec.push_back(new Element(rhs.m_elementVec[i]));
71 
72  for(std::size_t i = 0; i < rhs.m_contentVec.size(); ++i)
73  m_contentVec.push_back(rhs.m_contentVec[i].clone());
74 
75  for(std::size_t i = 0; i < rhs.m_anyVec.size(); ++i)
76  m_anyVec.push_back(new Any(rhs.m_anyVec[i]));
77  }
78 
79  return *this;
80 }
81 
82 const boost::ptr_vector<te::xsd::Element>& te::xsd::Choice::getElements() const
83 {
84  return m_elementVec;
85 }
86 
87 const boost::ptr_vector<te::xsd::Content>& te::xsd::Choice::getContents() const
88 {
89  return m_contentVec;
90 }
91 
92 const boost::ptr_vector<te::xsd::Any>& te::xsd::Choice::getAnys() const
93 {
94  return m_anyVec;
95 }
96 
98 {
99  m_elementVec.push_back(e);
100 }
101 
103 {
104  m_contentVec.push_back(c);
105 }
106 
108 {
109  m_anyVec.push_back(a);
110 }
111 
113 {
114  return new Choice(*this);
115 }
A base class for XSD classes that may allow annotation.
Definition: Annotated.h:49
A base class for XSD classes that have occurs attributes.
Definition: Occurs.h:43
~Choice()
Destructor.
Definition: Choice.cpp:53
Annotated & operator=(const Annotated &rhs)
Assignment operator.
Definition: Annotated.cpp:57
This class models the element of a XML Schema.
Definition: Element.h:56
A base class for elements that are not definitions nor declarations. This class is just for creating ...
Definition: Content.h:43
void addContent(Content *c)
It adds a Content element to this Choice element.
Definition: Choice.cpp:102
boost::ptr_vector< Element > m_elementVec
The list of elements.
Definition: Choice.h:145
It models the XML Schema any element.
Definition: Any.h:49
A base class for XSD classes that must provide a unique ID property.
Definition: Identifiable.h:46
This class models the XML Schema choice element.
Definition: Choice.h:57
void addAny(Any *a)
It adds an any to this Choice element.
Definition: Choice.cpp:107
const boost::ptr_vector< Content > & getContents() const
It returns the list of Content elements of Choice.
Definition: Choice.cpp:87
Choice(unsigned int minOccurs=1, unsigned int maxOccurs=1, Annotation *ann=0, std::string *id=0)
Constructor.
Definition: Choice.cpp:31
Identifiable & operator=(const Identifiable &rhs)
Assignment operator.
boost::ptr_vector< Content > m_contentVec
The list of Contents elements (group | choice | sequence).
Definition: Choice.h:146
This class models the XML Schema choice element.
void addElement(Element *e)
It adds an element to this Choice element.
Definition: Choice.cpp:97
const boost::ptr_vector< Element > & getElements() const
It returns the list of elements of Choice.
Definition: Choice.cpp:82
Choice & operator=(const Choice &rhs)
Assignment operator.
Definition: Choice.cpp:57
A class that models a XSD annotation element.
Definition: Annotation.h:55
const boost::ptr_vector< Any > & getAnys() const
It returns the list of any elements of Choice.
Definition: Choice.cpp:92
It models the XML Schema any element.
Content * clone() const
Definition: Choice.cpp:112
boost::ptr_vector< Any > m_anyVec
The list of any elements.
Definition: Choice.h:147
Occurs & operator=(const Occurs &rhs)
Assignment operator.
Definition: Occurs.cpp:71