reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
GenericUri.cxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
6#include "rutil/Logger.hxx"
8//#include "rutil/WinLeakCheck.hxx" // not compatible with placement new used below
9
10using namespace resip;
11using namespace std;
12
13#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
14
15
16//====================
17// GenericUri
18//====================
21 mUri(uri)
22{}
23
25 PoolBase* pool)
26 : ParserCategory(rhs, pool),
27 mUri(rhs.mUri)
28{}
29
31 Headers::Type type,
32 PoolBase* pool)
33 : ParserCategory(hfv, type, pool)
34{}
35
38{
39 if (this != &rhs)
40 {
42 mUri = rhs.mUri;
43 }
44 return *this;
45}
46
47Data&
49{
51 return mUri;
52}
53
54const Data&
56{
58 return mUri;
59}
60
61void
63{
64 pb.skipWhitespace();
65 const char* anchor = pb.skipChar(Symbols::LA_QUOTE[0]);
66
68 pb.data(mUri, anchor);
70
71 pb.skipWhitespace();
72
74}
75
78{
79 return new GenericUri(*this);
80}
81
83GenericUri::clone(void* location) const
84{
85 return new (location) GenericUri(*this);
86}
87
90{
91 return new (pool) GenericUri(*this, pool);
92}
93
95GenericUri::encodeParsed(EncodeStream& str) const
96{
97 str << Symbols::LA_QUOTE[0]
98 << mUri
100
101 encodeParameters(str);
102
103 return str;
104}
105
106ParameterTypes::Factory GenericUri::ParameterFactories[ParameterTypes::MAX_PARAMETER]={0};
107
108Parameter*
109GenericUri::createParam(ParameterTypes::Type type, ParseBuffer& pb, const std::bitset<256>& terminators, PoolBase* pool)
110{
111 if(type > ParameterTypes::UNKNOWN && type < ParameterTypes::MAX_PARAMETER && ParameterFactories[type])
112 {
113 return ParameterFactories[type](type, pb, terminators, pool);
114 }
115 return 0;
116}
117
118bool
120{
121 checkParsed();
122 bool ret = getParameterByEnum(paramType.getTypeNum()) != NULL;
123 return ret;
124}
125
126void
128{
129 checkParsed();
131}
132
133#define defineParam(_enum, _name, _type, _RFC_ref_ignored) \
134_enum##_Param::DType& \
135GenericUri::param(const _enum##_Param& paramType) \
136{ \
137 checkParsed(); \
138 _enum##_Param::Type* p = \
139 static_cast<_enum##_Param::Type*>(getParameterByEnum(paramType.getTypeNum())); \
140 if (!p) \
141 { \
142 p = new _enum##_Param::Type(paramType.getTypeNum()); \
143 mParameters.push_back(p); \
144 } \
145 return p->value(); \
146} \
147 \
148const _enum##_Param::DType& \
149GenericUri::param(const _enum##_Param& paramType) const \
150{ \
151 checkParsed(); \
152 _enum##_Param::Type* p = \
153 static_cast<_enum##_Param::Type*>(getParameterByEnum(paramType.getTypeNum())); \
154 if (!p) \
155 { \
156 InfoLog(<< "Missing parameter " _name " " << ParameterTypes::ParameterNames[paramType.getTypeNum()]); \
157 DebugLog(<< *this); \
158 throw Exception("Missing parameter " _name, __FILE__, __LINE__); \
159 } \
160 return p->value(); \
161}
162
163defineParam(purpose, "purpose", DataParameter, "RFC 3261");
164defineParam(alg, "alg", DataParameter, "RFC 8224");
165defineParam(ppt, "ppt", DataParameter, "RFC 8224");
166
167#undef defineParam
168
169/* ====================================================================
170 * The Vovida Software License, Version 1.0
171 *
172 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
173 *
174 * Redistribution and use in source and binary forms, with or without
175 * modification, are permitted provided that the following conditions
176 * are met:
177 *
178 * 1. Redistributions of source code must retain the above copyright
179 * notice, this list of conditions and the following disclaimer.
180 *
181 * 2. Redistributions in binary form must reproduce the above copyright
182 * notice, this list of conditions and the following disclaimer in
183 * the documentation and/or other materials provided with the
184 * distribution.
185 *
186 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
187 * and "Vovida Open Communication Application Library (VOCAL)" must
188 * not be used to endorse or promote products derived from this
189 * software without prior written permission. For written
190 * permission, please contact vocal@vovida.org.
191 *
192 * 4. Products derived from this software may not be called "VOCAL", nor
193 * may "VOCAL" appear in their name, without prior written
194 * permission of Vovida Networks, Inc.
195 *
196 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
197 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
198 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
199 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
200 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
201 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
202 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
203 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
204 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
205 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
206 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
207 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
208 * DAMAGE.
209 *
210 * ====================================================================
211 *
212 * This software consists of voluntary contributions made by Vovida
213 * Networks, Inc. and many individuals on behalf of Vovida Networks,
214 * Inc. For more information on Vovida Networks, Inc., please see
215 * <http://www.vovida.org/>.
216 *
217 */
#define defineParam(_enum, _name, _type, _RFC_ref_ignored)
Definition Auth.cxx:239
Generically represents miscellaneous parameter data.
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
Represents the "absoluteURI" element in the RFC 3261 grammar.
GenericUri & operator=(const GenericUri &)
virtual ParserCategory * clone() const
void remove(const Param< GenericUri > &paramType)
virtual Parameter * createParam(ParameterTypes::Type type, ParseBuffer &pb, const std::bitset< 256 > &terminators, PoolBase *pool)
virtual void parse(ParseBuffer &pb)
bool exists(const Param< GenericUri > &paramType) const
virtual EncodeStream & encodeParsed(EncodeStream &str) const
void checkParsed() const
virtual ParameterTypes::Type getTypeNum() const =0
Parameter *(* Factory)(ParameterTypes::Type, ParseBuffer &, const std::bitset< 256 > &terminators, PoolBase *pool)
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipWhitespace()
CurrentPosition skipToChar(char c)
CurrentPosition skipChar()
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
Base class for all SIP grammar elements that can have parameters.
Parameter * getParameterByEnum(ParameterTypes::Type type) const
ParserCategory & operator=(const ParserCategory &rhs)
void removeParameterByEnum(ParameterTypes::Type type)
void parseParameters(ParseBuffer &pb)
EncodeStream & encodeParameters(EncodeStream &str) const
Encodes parameters as they should appear on the wire.
static const char * LA_QUOTE
Definition Symbols.hxx:27
static const char * RA_QUOTE
Definition Symbols.hxx:28
dcm! – add UnusedChecking(_enum) below;
#define EncodeStream