wsdlpull  1.23
Message.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 #include "xmlpull/XmlUtils.h"
21 #include "wsdlparser/Message.h"
22 
23 using namespace std;
24 
25 namespace WsdlPull {
26 int
27 Message::getPartIndex(string & nam) const
28 {
29  for (size_t i = 0; i < parts.size(); i++)
30  {
31  if (parts[i].name() == nam)
32  return i;
33  }
34  return -1;
35 }
36 
38 Message::getPartRefType(int index) const
39 {
40  return parts[index].refType();
41 }
42 
44 Message::getPartRefType(const string & nam) const
45 {
46  const Part* p=getMessagePart(nam);
47  if(p)
48  return p->refType();
49  else
50  return Part::None;
51 }
52 
53 
54 const Part*
55 Message::getMessagePart(const std::string & nam)const
56 {
57  for (size_t i = 0; i < parts.size(); i++)
58  if (parts[i].name() == nam)
59  return &parts[i];
60  return 0;
61 }
62 
63 int
64 Message::getPartType(const std::string & nam) const
65 {
66  const Part* p=getMessagePart(nam);
67  if(p)
68  return p->type();
69  else
70  return 0;
71 }
72 
73 
74 int
75 Message::getPartContentSchemaId(const std::string & nam) const
76 {
77  const Part* p=getMessagePart(nam);
78  if(p)
79  return p->schemaId();
80  else
81  return 0;
82 }
83 
84 const Part*
85 Message::getMessagePart(size_t index)const
86 {
87  if(index>=0 && index < parts.size())
88  return &(parts[index]);
89  else
90  return 0;
91 }
92 
93 void
94 Message::addPart(string pname,
95  Part::PartRefType reftype,
96  void* d,
97  int schema_id)
98 {
99  Part p(pname);
100  if(reftype==Part::Elem) {
101  p.setPartElement((Element*)d,schema_id);
102  }else {
103  p.setPartType(*((int*)d),schema_id);
104  }
105  parts.push_back(p);
106 }
107 
108 void
109 Part::setPartType(int typeId,int schema)
110 {
111  discriminator=Part::Type;
112  type_id=typeId;
113  schema_id=schema;
114 }
115 
116 void
117 Part::setPartElement(const Element* el,int schema)
118 {
119  discriminator=Part::Elem;
120  this->e=el;
121  schema_id=schema;
122 }
123 
124 
125 int
126 Part::type()const
127 {
128  if(discriminator==Part::Type)
129  return type_id;
130  else if(e!=0)
131  return e->getType();
132  else
133  return 0;
134 }
135 
136 const Element*
137 Part::element()const
138 {
139  if(discriminator==Part::Elem)
140  return e;
141  else
142  return 0;
143 }
144 }
int getType() const
Definition: Element.h:147
void setPartType(int typeId, int schema)
Definition: Message.cpp:109
int type() const
Definition: Message.cpp:126
int schemaId() const
Definition: Message.h:212
PartRefType refType() const
Definition: Message.h:199
void setPartElement(const Element *e, int schema)
Definition: Message.cpp:117
@ None
Definition: Schema.h:45
Type
Definition: Schema.h:60