wsdlpull  1.23
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ComplexType.h
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 #ifndef _COMPLEXTYPEH
21 #define _COMPLEXTYPEH
22 
23 #include <list>
25 #include "xmlpull/Qname.h"
26 #include "xmlpull/XmlUtils.h"
27 #include "schemaparser/XSDType.h"
29 #include "schemaparser/Attribute.h"
31 
32 namespace Schema {
33 
35 {
36  public:
37 
38  ComplexType(const std::string& );
39  ~ComplexType();
40 
41  /*
42  * Various getter methods
43  */
44 
45  //virtual function ,always return false for complex types
46  bool isSimple() const;
47 
48  //returns the content type for complex types whose content model is SIMPLE
49  int getContentType() const;
50 
51  //returns the number of attributes ,indices start from 0 to n-1
52  int getNumAttributes() const;
53 
54  //gets the id of the attribute at the position "index"
55  int getAttributeType(int index);
56 
57  //gets the NCName of the attribute
58  std::string getAttributeName(int index)const;
59 
60  //returns the content model structure
61  ContentModel* getContents()const;
62 
63  //returns a pointer to the attribute
64  const Attribute *getAttribute(const std::string & name)const;
65 
66  const Attribute *getAttribute(int index)const;
67  //returns the list of attributes
68  std::list < Attribute > & pAttributeList() ;
69 
70  /*
71  * Various setter methods
72  */
73 
74  void setSimpleContentType(int id);
75 
76  void setContents(ContentModel* ct);
77 
78  void addAttribute(const Attribute &a,
79  bool fwdRef=false);
80  //forward reference to attributeGroup
81  void addAttributeGroupName(const Qname & qn);
82 
83  void matchAttributeRef(const std::string & name, Attribute & a);
84  void matchElementRef(const std::string & name, Element & e);
85  bool checkOccurrences(void);
86  void resetCounters(void);
87 
88 
89 #ifdef LOGGING
90  void print(std::ostream & out);
91 #endif
92 
93  private:
94  std::list < Attribute > attList_;
95  int simpleContentTypeId_; //for simple content
96  ContentModel* cm_;
97  void error(std::string msg) const;
98  bool fwdElemRef_, fwdAttrRef_;
99 };
100 
101 
102 inline
103 int
105 {
106  return simpleContentTypeId_;
107 }
108 
109 inline
110 bool
112 {
113  return false;
114 }
115 
116 inline
117 int
119 {
120  return attList_.size();
121 }
122 
123 inline
124 int
126 {
127  return getAttribute(index)->getType();
128 }
129 
130 inline
131 std::string
133 {
134  return getAttribute(index)->getName();
135 }
136 
137 inline
138 std::list < Attribute > &
140 {
141  return attList_;
142 }
143 
144 
145 inline
146 void
148 {
149  simpleContentTypeId_ = id;
150 }
151 
152 
153 inline
154 ContentModel*
156 {
157  return cm_;
158 
159 }
160 
161 inline
162 void
164 {
165  cm_=ct;
166 }
167 
168 
169 inline
171 {
172  if(cm_)
173  delete cm_;
174 }
175 }
176 #endif /* */
int getNumAttributes() const
Definition: ComplexType.h:118
int getType() const
Definition: Attribute.h:90
std::string getName() const
Definition: Attribute.h:83
void setSimpleContentType(int id)
Definition: ComplexType.h:147
std::string getAttributeName(int index) const
Definition: ComplexType.h:132
Definition: Qname.h:30
void setContents(ContentModel *ct)
Definition: ComplexType.h:163
const Attribute * getAttribute(const std::string &name) const
Definition: ComplexType.cpp:80
int getContentType() const
Definition: ComplexType.h:104
bool isSimple() const
Definition: ComplexType.h:111
#define WSDLPULL_EXPORT
ContentModel * getContents() const
Definition: ComplexType.h:155
std::list< Attribute > & pAttributeList()
Definition: ComplexType.h:139
int getAttributeType(int index)
Definition: ComplexType.h:125