wsdlpull 1.23
ComplexType.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
23
24namespace Schema {
25
26ComplexType::ComplexType(const std::string & ns)
27 :XSDType(ns),
28 simpleContentTypeId_ (0),
29 cm_(0),
30 fwdElemRef_(false),
31 fwdAttrRef_(false)
32{
33
35}
36
37void
39 bool ref)
40{
41 fwdAttrRef_=ref;
42
44 if(at){
45 *at=a;
46 }else{
47 attList_.push_back(a);
48 }
49}
50
51
52void
54{
55 //TODO
56 //store the attribute group and add all attributes later
57 //by calling addAttribute()
58}
59
60void
61ComplexType::matchElementRef(const std::string & name, Element & e)
62{
63 if(cm_) {
64 cm_->matchforwardRef(name,e);
65 }
66}
67
68void
69ComplexType::matchAttributeRef(const std::string & nam,
70 Attribute & a)
71{
72 if (fwdAttrRef_) {
73 Attribute *at = (Attribute*)getAttribute(nam);
74 if (at)
75 *at = a;
76 }
77}
78
79const Attribute *
80ComplexType::getAttribute(const std::string & nam) const
81{
82 std::list < Attribute >::const_iterator pAttr = attList_.begin();
83 while (pAttr != attList_.end())
84 {
85 if (pAttr->getName() == nam)
86 return &(*pAttr);
87 pAttr++;
88 }
89 return 0;
90}
91
92
93void ComplexType::error(std::string msg) const
94{
95 msg+="Complex Type "+ getName() +msg;
96 SchemaParserException spe(msg);
97 throw spe;
98 return;
99}
100
101const Attribute *
103{
104
105 int i=0;
106 for (std::list<Attribute>::const_iterator ali=attList_.begin();
107 ali!=attList_.end();ali++,i++) {
108 if(i==index)
109 return &(*ali);
110 }
111 return 0;
112
113}
114}
Definition: Qname.h:31
std::string getName() const
Definition: Attribute.h:83
void matchAttributeRef(const std::string &name, Attribute &a)
Definition: ComplexType.cpp:69
ComplexType(const std::string &)
Definition: ComplexType.cpp:26
void addAttributeGroupName(const Qname &qn)
Definition: ComplexType.cpp:53
void addAttribute(const Attribute &a, bool fwdRef=false)
Definition: ComplexType.cpp:38
void matchElementRef(const std::string &name, Element &e)
Definition: ComplexType.cpp:61
const Attribute * getAttribute(const std::string &name) const
Definition: ComplexType.cpp:80
void matchforwardRef(const std::string &name, Element &e)
std::string getName() const
Definition: XSDType.h:148
virtual void setContentModel(Schema::ContentModelType)
Definition: XSDType.h:229
@ Complex
Definition: Schema.h:47