wsdlpull 1.23
Loading...
Searching...
No Matches
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
23#include "schemaparser/Group.h"
24
25namespace Schema {
26void
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);
42 contents_.push_back(c);
43 if (elem.getType() == Schema::XSD_ANY) {
44
45 anyContent_ = true;
46 }
47 nParticles++;
48}
49
50void
51ContentModel::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);
62 contents_.push_back(c);
63}
64
65void
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);
76 contents_.push_back(c);
77}
78
80 :m_compositor(c),
81 nParticles(0),
82 anyContent_(false)
83{
84 contents_.clear();
85
86}
87
88
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
102void
103ContentModel::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}
ContentsIterator begin()
std::pair< ContentType, ContentDiscriminator > ContentHolder
void matchforwardRef(const std::string &name, Element &e)
void addGroup(const Group &e, bool own=false)
void addElement(const Element &e)
ContentsIterator end()
ContentModel(Schema::Compositor)
void addContentModel(const ContentModel *c)
std::list< ContentHolder >::iterator ContentsIterator
int getType() const
Definition Element.h:147
int getMax() const
Definition Element.h:154
std::string getName() const
Definition Element.h:125
void setContents(const ContentModel *cm, bool isRef=false)
Definition Group.h:125
ContentModel * getContents() const
Definition Group.h:117
Compositor
Definition Schema.h:32
@ All
Definition Schema.h:35
@ XSD_ANY
Definition Schema.h:87