reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
IntegerCategory.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// Integer:
17//====================
19 : ParserCategory(),
20 mValue(0),
21 mComment()
22{}
23
25 Headers::Type type,
26 PoolBase* pool)
27 : ParserCategory(hfv, type, pool),
28 mValue(0),
29 mComment()
30{}
31
33 PoolBase* pool)
34 : ParserCategory(rhs, pool),
35 mValue(rhs.mValue),
36 mComment(rhs.mComment)
37{}
38
41{
42 if (this != &rhs)
43 {
45 mValue = rhs.mValue;
46 mComment = rhs.mComment;
47 }
48 return *this;
49}
50
52{
53 return new IntegerCategory(*this);
54}
55
57{
58 return new (location) IntegerCategory(*this);
59}
60
63{
64 return new (pool) IntegerCategory(*this, pool);
65}
66
68{
69 checkParsed();
70 return mValue;
71}
72
73const Data&
75{
76 checkParsed();
77 return mComment;
78}
79
81{
82 checkParsed();
83 return mValue;
84}
85
86Data&
88{
89 checkParsed();
90 return mComment;
91}
92
93
94void
96{
97 const char* start = pb.skipWhitespace();
98 mValue = pb.integer();
99 pb.skipToChar('(');
100 if (!pb.eof())
101 {
102 start = pb.skipChar();
103 pb.skipToEndQuote(')');
104 pb.data(mComment, start);
105 pb.skipChar();
106 }
107 else
108 {
109 pb.reset(start);
110 start = pb.skipNonWhitespace();
111 }
112
113 parseParameters(pb);
114}
115
117IntegerCategory::encodeParsed(EncodeStream& str) const
118{
119 str << mValue;
120
121 if (!mComment.empty())
122 {
123 str << "(" << mComment << ")";
124 }
125
126 encodeParameters(str);
127 return str;
128}
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 */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
bool empty() const noexcept
Checks whether the Data is empty.
Definition Data.hxx:591
Represents a numeric-with-comment header field value.
IntegerCategory & operator=(const IntegerCategory &)
virtual ParserCategory * clone() const
virtual void parse(ParseBuffer &pb)
virtual EncodeStream & encodeParsed(EncodeStream &str) const
void checkParsed() const
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipNonWhitespace()
CurrentPosition skipWhitespace()
CurrentPosition skipToChar(char c)
void reset(const char *pos)
CurrentPosition skipChar()
void data(Data &data, const char *start) const
make the passed in data share memory with the buffer (uses Data::Share)
const char * skipToEndQuote(char quote='"')
Base class for all SIP grammar elements that can have parameters.
ParserCategory & operator=(const ParserCategory &rhs)
void parseParameters(ParseBuffer &pb)
EncodeStream & encodeParameters(EncodeStream &str) const
Encodes parameters as they should appear on the wire.
dcm! – add UnusedChecking(_enum) below;
#define EncodeStream