reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
WarningCategory.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// WarningCategory
17//====================
21
23 Headers::Type type,
24 PoolBase* pool)
25 : ParserCategory(hfv, type, pool)
26{}
27
29 PoolBase* pool)
30 : ParserCategory(rhs, pool),
31 mCode(rhs.mCode),
32 mHostname(rhs.mHostname),
33 mText(rhs.mText)
34{}
35
38{
39 if (this != &rhs)
40 {
42 mCode = rhs.mCode;
43 mHostname = rhs.mHostname;
44 mText = rhs.mText;
45 }
46 return *this;
47}
48void
50{
51 pb.skipWhitespace();
52 mCode = pb.uInt32();
53
54 if(mCode >= 1000 || mCode < 100)
55 {
56 pb.fail(__FILE__,__LINE__,"Warning code does not have exactly three digits.");
57 }
58
59 const char* anchor = pb.skipWhitespace();
61 pb.data(mHostname, anchor);
62
63 pb.skipWhitespace();
64 anchor = pb.skipChar(Symbols::DOUBLE_QUOTE[0]);
66 pb.data(mText, anchor);
67 anchor = pb.skipChar(Symbols::DOUBLE_QUOTE[0]);
68 pb.skipWhitespace();
69 pb.assertEof();
70}
71
74{
75 return new WarningCategory(*this);
76}
77
79WarningCategory::clone(void* location) const
80{
81 return new (location) WarningCategory(*this);
82}
83
86{
87 return new (pool) WarningCategory(*this, pool);
88}
89
90int&
92{
94 return mCode;
95}
96
97int
99{
100 checkParsed();
101 return mCode;
102}
103
104Data&
106{
107 checkParsed();
108 return mHostname;
109}
110
111const Data&
113{
114 checkParsed();
115 return mHostname;
116}
117
118Data&
120{
121 checkParsed();
122 return mText;
123}
124
125const Data&
127{
128 checkParsed();
129 return mText;
130}
131
133WarningCategory::encodeParsed(EncodeStream& str) const
134{
135 str << mCode << Symbols::SPACE[0];
136 str << mHostname << Symbols::SPACE[0];
137 str << Symbols::DOUBLE_QUOTE[0] << mText << Symbols::DOUBLE_QUOTE[0];
138
139 return str;
140}
141
142
143/* ====================================================================
144 * The Vovida Software License, Version 1.0
145 *
146 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
147 *
148 * Redistribution and use in source and binary forms, with or without
149 * modification, are permitted provided that the following conditions
150 * are met:
151 *
152 * 1. Redistributions of source code must retain the above copyright
153 * notice, this list of conditions and the following disclaimer.
154 *
155 * 2. Redistributions in binary form must reproduce the above copyright
156 * notice, this list of conditions and the following disclaimer in
157 * the documentation and/or other materials provided with the
158 * distribution.
159 *
160 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
161 * and "Vovida Open Communication Application Library (VOCAL)" must
162 * not be used to endorse or promote products derived from this
163 * software without prior written permission. For written
164 * permission, please contact vocal@vovida.org.
165 *
166 * 4. Products derived from this software may not be called "VOCAL", nor
167 * may "VOCAL" appear in their name, without prior written
168 * permission of Vovida Networks, Inc.
169 *
170 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
171 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
172 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
173 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
174 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
175 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
176 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
177 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
178 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
179 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
180 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
181 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
182 * DAMAGE.
183 *
184 * ====================================================================
185 *
186 * This software consists of voluntary contributions made by Vovida
187 * Networks, Inc. and many individuals on behalf of Vovida Networks,
188 * Inc. For more information on Vovida Networks, Inc., please see
189 * <http://www.vovida.org/>.
190 *
191 */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
void checkParsed() const
Provides string-parsing functionality with protection from buffer overflow.
CurrentPosition skipNonWhitespace()
uint32_t uInt32()
dcm! – merge these, ask about length checks
CurrentPosition skipWhitespace()
CurrentPosition skipChar()
void fail(const char *file, unsigned int line, const Data &errmsg=Data::Empty) const
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='"')
void assertEof() const
Base class for all SIP grammar elements that can have parameters.
ParserCategory & operator=(const ParserCategory &rhs)
static const char * SPACE
Definition Symbols.hxx:34
static const char * DOUBLE_QUOTE
Definition Symbols.hxx:26
Represents the "warning-value" element in the RFC 3261 grammar.
virtual EncodeStream & encodeParsed(EncodeStream &str) const
virtual ParserCategory * clone() const
virtual void parse(ParseBuffer &pb)
WarningCategory & operator=(const WarningCategory &)
dcm! – add UnusedChecking(_enum) below;
#define EncodeStream