wsdlpull 1.23
Loading...
Searching...
No Matches
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
23using namespace std;
24
25namespace WsdlPull {
26int
27Message::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
39{
40 return parts[index].refType();
41}
42
44Message::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
54const Part*
55Message::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
63int
64Message::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
74int
75Message::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
84const Part*
85Message::getMessagePart(size_t index)const
86{
87 if(index>=0 && index < parts.size())
88 return &(parts[index]);
89 else
90 return 0;
91}
92
93void
94Message::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
108void
109Part::setPartType(int typeId,int schema)
110{
111 discriminator=Part::Type;
112 type_id=typeId;
113 schema_id=schema;
114}
115
116void
117Part::setPartElement(const Element* el,int schema)
118{
119 discriminator=Part::Elem;
120 this->e=el;
121 schema_id=schema;
122}
123
124
125int
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
136const Element*
138{
139 if(discriminator==Part::Elem)
140 return e;
141 else
142 return 0;
143}
144}
int getType() const
Definition: Element.h:147
int getPartContentSchemaId(int index) const
Definition: Message.h:167
int getPartType(int index) const
Definition: Message.h:174
Part::PartRefType getPartRefType(const std::string &nam) const
Definition: Message.cpp:44
const Part * getMessagePart(size_t index) const
Definition: Message.cpp:85
void addPart(std::string pname, Part::PartRefType reftype, void *d, int schema_id)
Definition: Message.cpp:94
int getPartIndex(std::string &nam) const
Definition: Message.cpp:27
void setPartType(int typeId, int schema)
Definition: Message.cpp:109
const Element * element() const
Definition: Message.cpp:137
int type() const
Definition: Message.cpp:126
const Element * e
Definition: Message.h:57
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