Coverage Report

Created: 2023-06-07 06:03

/src/resiprocate/resip/stack/IntegerCategory.cxx
Line
Count
Source (jump to first uncovered line)
1
#if defined(HAVE_CONFIG_H)
2
#include "config.h"
3
#endif
4
5
#include "resip/stack/IntegerCategory.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
// Integer:
17
//====================
18
IntegerCategory::IntegerCategory()
19
   : ParserCategory(), 
20
     mValue(0), 
21
     mComment() 
22
0
{}
23
24
IntegerCategory::IntegerCategory(const HeaderFieldValue& hfv, 
25
                                 Headers::Type type,
26
                                 PoolBase* pool)
27
   : ParserCategory(hfv, type, pool), 
28
     mValue(0), 
29
     mComment() 
30
6.52k
{}
31
32
IntegerCategory::IntegerCategory(const IntegerCategory& rhs,
33
                                 PoolBase* pool)
34
   : ParserCategory(rhs, pool),
35
     mValue(rhs.mValue),
36
     mComment(rhs.mComment)
37
0
{}
38
39
IntegerCategory&
40
IntegerCategory::operator=(const IntegerCategory& rhs)
41
0
{
42
0
   if (this != &rhs)
43
0
   {
44
0
      ParserCategory::operator=(rhs);
45
0
      mValue = rhs.mValue;
46
0
      mComment = rhs.mComment;
47
0
   }
48
0
   return *this;
49
0
}
50
51
ParserCategory* IntegerCategory::clone() const
52
0
{
53
0
   return new IntegerCategory(*this);
54
0
}
55
56
ParserCategory* IntegerCategory::clone(void* location) const
57
0
{
58
0
   return new (location) IntegerCategory(*this);
59
0
}
60
61
ParserCategory* 
62
IntegerCategory::clone(PoolBase* pool) const
63
0
{
64
0
   return new (pool) IntegerCategory(*this, pool);
65
0
}
66
67
int IntegerCategory::value() const 
68
0
{
69
0
   checkParsed(); 
70
0
   return mValue;
71
0
}
72
73
const Data& 
74
IntegerCategory::comment() const 
75
0
{
76
0
   checkParsed(); 
77
0
   return mComment;
78
0
}
79
80
int& IntegerCategory::value()
81
0
{
82
0
   checkParsed(); 
83
0
   return mValue;
84
0
}
85
86
Data& 
87
IntegerCategory::comment()
88
0
{
89
0
   checkParsed(); 
90
0
   return mComment;
91
0
}
92
93
94
void
95
IntegerCategory::parse(ParseBuffer& pb)
96
6.52k
{
97
6.52k
   const char* start = pb.skipWhitespace();
98
6.52k
   mValue = pb.integer();
99
6.52k
   pb.skipToChar('(');
100
6.52k
   if (!pb.eof())
101
23
   {
102
23
      start = pb.skipChar();
103
23
      pb.skipToEndQuote(')');
104
23
      pb.data(mComment, start);
105
23
      pb.skipChar();
106
23
   }
107
6.50k
   else
108
6.50k
   {
109
6.50k
      pb.reset(start);
110
6.50k
      start = pb.skipNonWhitespace();
111
6.50k
   }
112
   
113
6.52k
   parseParameters(pb);
114
6.52k
}
115
116
EncodeStream& 
117
IntegerCategory::encodeParsed(EncodeStream& str) const
118
0
{
119
0
  str << mValue;
120
121
0
  if (!mComment.empty())
122
0
  {
123
0
     str << "(" << mComment << ")";
124
0
  }
125
  
126
0
  encodeParameters(str);
127
0
  return str;
128
0
}
129
130
131
/* ====================================================================
132
 * The Vovida Software License, Version 1.0 
133
 * 
134
 * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
135
 * 
136
 * Redistribution and use in source and binary forms, with or without
137
 * modification, are permitted provided that the following conditions
138
 * are met:
139
 * 
140
 * 1. Redistributions of source code must retain the above copyright
141
 *    notice, this list of conditions and the following disclaimer.
142
 * 
143
 * 2. Redistributions in binary form must reproduce the above copyright
144
 *    notice, this list of conditions and the following disclaimer in
145
 *    the documentation and/or other materials provided with the
146
 *    distribution.
147
 * 
148
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
149
 *    and "Vovida Open Communication Application Library (VOCAL)" must
150
 *    not be used to endorse or promote products derived from this
151
 *    software without prior written permission. For written
152
 *    permission, please contact vocal@vovida.org.
153
 *
154
 * 4. Products derived from this software may not be called "VOCAL", nor
155
 *    may "VOCAL" appear in their name, without prior written
156
 *    permission of Vovida Networks, Inc.
157
 * 
158
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
159
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
160
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
161
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
162
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
163
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
164
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
165
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
166
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
167
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
168
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
169
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
170
 * DAMAGE.
171
 * 
172
 * ====================================================================
173
 * 
174
 * This software consists of voluntary contributions made by Vovida
175
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
176
 * Inc.  For more information on Vovida Networks, Inc., please see
177
 * <http://www.vovida.org/>.
178
 *
179
 */