Coverage Report

Created: 2026-09-14 06:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/resiprocate/resip/stack/GenericUri.cxx
Line
Count
Source
1
#if defined(HAVE_CONFIG_H)
2
#include "config.h"
3
#endif
4
5
#include "resip/stack/GenericUri.hxx"
6
#include "rutil/Logger.hxx"
7
#include "rutil/ParseBuffer.hxx"
8
//#include "rutil/WinLeakCheck.hxx"  // not compatible with placement new used below
9
10
using namespace resip;
11
using namespace std;
12
13
#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
14
15
16
//====================
17
// GenericUri
18
//====================
19
GenericUri::GenericUri(const Data& uri) :
20
0
   ParserCategory(),
21
0
   mUri(uri)
22
0
{}
23
24
GenericUri::GenericUri(const GenericUri& rhs,
25
                        PoolBase* pool)
26
0
   : ParserCategory(rhs, pool),
27
0
     mUri(rhs.mUri)
28
0
{}
29
30
GenericUri::GenericUri(const HeaderFieldValue& hfv, 
31
                        Headers::Type type,
32
                        PoolBase* pool) 
33
6.64k
   : ParserCategory(hfv, type, pool) 
34
6.64k
{}
35
36
GenericUri&
37
GenericUri::operator=(const GenericUri& rhs)
38
0
{
39
0
   if (this != &rhs)
40
0
   {
41
0
      ParserCategory::operator=(rhs);
42
0
      mUri = rhs.mUri;
43
0
   }
44
0
   return *this;
45
0
}
46
47
Data& 
48
GenericUri::uri()
49
0
{
50
0
   checkParsed();
51
0
   return mUri;
52
0
}
53
54
const Data& 
55
GenericUri::uri() const
56
0
{
57
0
   checkParsed();
58
0
   return mUri;
59
0
}
60
61
void
62
GenericUri::parse(ParseBuffer& pb)
63
6.64k
{
64
6.64k
   pb.skipWhitespace();
65
6.64k
   const char* anchor = pb.skipChar(Symbols::LA_QUOTE[0]);
66
67
6.64k
   pb.skipToChar(Symbols::RA_QUOTE[0]);
68
6.64k
   pb.data(mUri, anchor);
69
6.64k
   pb.skipChar(Symbols::RA_QUOTE[0]);
70
71
6.64k
   pb.skipWhitespace();
72
73
6.64k
   parseParameters(pb);
74
6.64k
}
75
76
ParserCategory* 
77
GenericUri::clone() const
78
0
{
79
0
   return new GenericUri(*this);
80
0
}
81
82
ParserCategory* 
83
GenericUri::clone(void* location) const
84
0
{
85
0
   return new (location) GenericUri(*this);
86
0
}
87
88
ParserCategory* 
89
GenericUri::clone(PoolBase* pool) const
90
0
{
91
0
   return new (pool) GenericUri(*this, pool);
92
0
}
93
94
EncodeStream& 
95
GenericUri::encodeParsed(EncodeStream& str) const
96
0
{
97
0
   str << Symbols::LA_QUOTE[0]
98
0
       << mUri
99
0
       << Symbols::RA_QUOTE[0];
100
101
0
   encodeParameters(str);
102
103
0
   return str;
104
0
}
105
106
ParameterTypes::Factory GenericUri::ParameterFactories[ParameterTypes::MAX_PARAMETER]={0};
107
108
Parameter* 
109
GenericUri::createParam(ParameterTypes::Type type, ParseBuffer& pb, const std::bitset<256>& terminators, PoolBase* pool)
110
397
{
111
397
   if(type > ParameterTypes::UNKNOWN && type < ParameterTypes::MAX_PARAMETER && ParameterFactories[type])
112
194
   {
113
194
      return ParameterFactories[type](type, pb, terminators, pool);
114
194
   }
115
203
   return 0;
116
397
}
117
118
bool 
119
GenericUri::exists(const Param<GenericUri>& paramType) const
120
0
{
121
0
    checkParsed();
122
0
    bool ret = getParameterByEnum(paramType.getTypeNum()) != NULL;
123
0
    return ret;
124
0
}
125
126
void 
127
GenericUri::remove(const Param<GenericUri>& paramType)
128
0
{
129
0
    checkParsed();
130
0
    removeParameterByEnum(paramType.getTypeNum());
131
0
}
132
133
#define defineParam(_enum, _name, _type, _RFC_ref_ignored)                                                      \
134
_enum##_Param::DType&                                                                                           \
135
0
GenericUri::param(const _enum##_Param& paramType)                                                           \
136
0
{                                                                                                               \
137
0
   checkParsed();                                                                                               \
138
0
   _enum##_Param::Type* p =                                                                                     \
139
0
      static_cast<_enum##_Param::Type*>(getParameterByEnum(paramType.getTypeNum()));                            \
140
0
   if (!p)                                                                                                      \
141
0
   {                                                                                                            \
142
0
      p = new _enum##_Param::Type(paramType.getTypeNum());                                                      \
143
0
      mParameters.push_back(p);                                                                                 \
144
0
   }                                                                                                            \
145
0
   return p->value();                                                                                           \
146
0
}                                                                                                               \
Unexecuted instantiation: resip::GenericUri::param(resip::purpose_Param const&)
Unexecuted instantiation: resip::GenericUri::param(resip::alg_Param const&)
Unexecuted instantiation: resip::GenericUri::param(resip::ppt_Param const&)
147
                                                                                                                \
148
const _enum##_Param::DType&                                                                                     \
149
0
GenericUri::param(const _enum##_Param& paramType) const                                                     \
150
0
{                                                                                                               \
151
0
   checkParsed();                                                                                               \
152
0
   _enum##_Param::Type* p =                                                                                     \
153
0
      static_cast<_enum##_Param::Type*>(getParameterByEnum(paramType.getTypeNum()));                            \
154
0
   if (!p)                                                                                                      \
155
0
   {                                                                                                            \
156
0
      InfoLog(<< "Missing parameter " _name " " << ParameterTypes::ParameterNames[paramType.getTypeNum()]);     \
157
0
      DebugLog(<< *this);                                                                                       \
158
0
      throw Exception("Missing parameter " _name, __FILE__, __LINE__);                                          \
159
0
   }                                                                                                            \
160
0
   return p->value();                                                                                           \
161
0
}
Unexecuted instantiation: resip::GenericUri::param(resip::purpose_Param const&) const
Unexecuted instantiation: resip::GenericUri::param(resip::alg_Param const&) const
Unexecuted instantiation: resip::GenericUri::param(resip::ppt_Param const&) const
162
163
defineParam(purpose, "purpose", DataParameter, "RFC 3261");
164
defineParam(alg, "alg", DataParameter, "RFC 8224");
165
defineParam(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
 */