wsdlpull
1.23
Toggle main menu visibility
Loading...
Searching...
No Matches
src
schemaparser
ContentModel.cpp
Go to the documentation of this file.
1
/*
2
* wsdlpull - A C++ parser for WSDL (Web services description language)
3
* Copyright (C) 2005-2007 Vivek Krishna
4
*
5
* This library is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU Library General Public
7
* License as published by the Free Software Foundation; either
8
* version 2 of the License, or (at your option) any later version.
9
*
10
* This library 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 GNU
13
* Library General Public License for more details.
14
*
15
* You should have received a copy of the GNU Library General Public
16
* License along with this library; if not, write to the Free
17
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
*
19
*/
20
21
#include "
schemaparser/ContentModel.h
"
22
#include "
schemaparser/Element.h
"
23
#include "
schemaparser/Group.h
"
24
25
namespace
Schema
{
26
void
27
ContentModel::addElement
(
const
Element
& elem)
28
{
29
ContentType
ct;
30
31
if
(m_compositor==
Schema::All
){
32
if
(elem.
getMax
()>1)
33
{
34
SchemaParserException
spe(
"<all> MUST not have multiple occurrences of an element "
+
35
elem.
getName
());
36
throw
spe;
37
}
38
39
}
40
ct.
e
=
new
Element
(elem);
41
ContentHolder
c(ct,
ContentModel::Particle
);
42
contents_.push_back(c);
43
if
(elem.
getType
() ==
Schema::XSD_ANY
) {
44
45
anyContent_ =
true
;
46
}
47
nParticles++;
48
}
49
50
void
51
ContentModel::addGroup
(
const
Group
& g,
bool
isRef)
52
{
53
ContentType
ct;
54
if
(m_compositor==
Schema::All
){
55
56
SchemaParserException
spe(
"<all> MUST have only element "
);
57
throw
spe;
58
}
59
ct.
g
=
new
Group
(g);
60
ct.
g
->
setContents
(g.
getContents
(),isRef);
61
ContentHolder
c(ct,
ContentModel::ParticleGroup
);
62
contents_.push_back(c);
63
}
64
65
void
66
ContentModel::addContentModel
(
const
ContentModel
* container)
67
{
68
if
(m_compositor==
Schema::All
){
69
SchemaParserException
spe(
"<all> MUST have only elements within"
);
70
throw
spe;
71
}
72
73
ContentType
ct;
74
ct.
c
=
const_cast<
ContentModel
*
>
(container);
75
ContentHolder
c(ct,
ContentModel::Container
);
76
contents_.push_back(c);
77
}
78
79
ContentModel::ContentModel
(
Schema::Compositor
c)
80
:m_compositor(c),
81
nParticles(0),
82
anyContent_(false)
83
{
84
contents_.clear();
85
86
}
87
88
89
ContentModel::~ContentModel
()
90
{
91
for
(
ContentsIterator
ci=
begin
();ci!=
end
();ci++){
92
93
if
(ci->second==
ContentModel::Container
)
94
delete
(ci->first).c;
95
else
if
(ci->second==
ContentModel::Particle
)
96
delete
(ci->first).e;
97
else
if
(ci->second==
ContentModel::ParticleGroup
)
98
delete
(ci->first).g;
99
}
100
}
101
102
void
103
ContentModel::matchforwardRef
(
const
std::string &name,
Element
&e)
104
{
105
for
(
ContentsIterator
ci=
begin
();ci!=
end
();ci++){
106
if
(ci->second==
ContentModel::Particle
)
107
if
((ci->first).e->getName()==name){
108
*((ci->first).e)=e;
109
}
110
}
111
}
112
}
ContentModel.h
Element.h
Group.h
Schema::ContentModel::begin
ContentsIterator begin()
Definition
ContentModel.h:91
Schema::ContentModel::ContentHolder
std::pair< ContentType, ContentDiscriminator > ContentHolder
Definition
ContentModel.h:53
Schema::ContentModel::matchforwardRef
void matchforwardRef(const std::string &name, Element &e)
Definition
ContentModel.cpp:103
Schema::ContentModel::addGroup
void addGroup(const Group &e, bool own=false)
Definition
ContentModel.cpp:51
Schema::ContentModel::addElement
void addElement(const Element &e)
Definition
ContentModel.cpp:27
Schema::ContentModel::end
ContentsIterator end()
Definition
ContentModel.h:98
Schema::ContentModel::ContentModel
ContentModel(Schema::Compositor)
Definition
ContentModel.cpp:79
Schema::ContentModel::addContentModel
void addContentModel(const ContentModel *c)
Definition
ContentModel.cpp:66
Schema::ContentModel::ContentsIterator
std::list< ContentHolder >::iterator ContentsIterator
Definition
ContentModel.h:55
Schema::ContentModel::~ContentModel
~ContentModel()
Definition
ContentModel.cpp:89
Schema::ContentModel::Container
@ Container
Definition
ContentModel.h:50
Schema::ContentModel::Particle
@ Particle
Definition
ContentModel.h:48
Schema::ContentModel::ParticleGroup
@ ParticleGroup
Definition
ContentModel.h:49
Schema::Element
Definition
Element.h:31
Schema::Element::getType
int getType() const
Definition
Element.h:147
Schema::Element::getMax
int getMax() const
Definition
Element.h:154
Schema::Element::getName
std::string getName() const
Definition
Element.h:125
Schema::Group
Definition
Group.h:34
Schema::Group::setContents
void setContents(const ContentModel *cm, bool isRef=false)
Definition
Group.h:125
Schema::Group::getContents
ContentModel * getContents() const
Definition
Group.h:117
Schema::SchemaParserException
Definition
SchemaParserException.h:29
Schema
Definition
Annotation.h:27
Schema::Compositor
Compositor
Definition
Schema.h:32
Schema::All
@ All
Definition
Schema.h:35
Schema::XSD_ANY
@ XSD_ANY
Definition
Schema.h:87
Schema::ContentModel::ContentType
Definition
ContentModel.h:41
Schema::ContentModel::ContentType::c
ContentModel * c
Definition
ContentModel.h:44
Schema::ContentModel::ContentType::e
Element * e
Definition
ContentModel.h:42
Schema::ContentModel::ContentType::g
Group * g
Definition
ContentModel.h:43
Generated by
1.17.0