wsdlpull
1.23
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
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
}
Generated by
1.8.4