/src/resiprocate/resip/stack/WarningCategory.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/WarningCategory.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 | | // WarningCategory |
17 | | //==================== |
18 | | WarningCategory::WarningCategory() |
19 | | : ParserCategory() |
20 | 0 | {} |
21 | | |
22 | | WarningCategory::WarningCategory(const HeaderFieldValue& hfv, |
23 | | Headers::Type type, |
24 | | PoolBase* pool) |
25 | | : ParserCategory(hfv, type, pool) |
26 | 0 | {} |
27 | | |
28 | | WarningCategory::WarningCategory(const WarningCategory& rhs, |
29 | | PoolBase* pool) |
30 | | : ParserCategory(rhs, pool), |
31 | | mCode(rhs.mCode), |
32 | | mHostname(rhs.mHostname), |
33 | | mText(rhs.mText) |
34 | 0 | {} |
35 | | |
36 | | WarningCategory& |
37 | | WarningCategory::operator=(const WarningCategory& rhs) |
38 | 0 | { |
39 | 0 | if (this != &rhs) |
40 | 0 | { |
41 | 0 | ParserCategory::operator=(rhs); |
42 | 0 | mCode = rhs.mCode; |
43 | 0 | mHostname = rhs.mHostname; |
44 | 0 | mText = rhs.mText; |
45 | 0 | } |
46 | 0 | return *this; |
47 | 0 | } |
48 | | void |
49 | | WarningCategory::parse(ParseBuffer& pb) |
50 | 0 | { |
51 | 0 | pb.skipWhitespace(); |
52 | 0 | mCode = pb.uInt32(); |
53 | |
|
54 | 0 | if(mCode >= 1000 || mCode < 100) |
55 | 0 | { |
56 | 0 | pb.fail(__FILE__,__LINE__,"Warning code does not have exactly three digits."); |
57 | 0 | } |
58 | |
|
59 | 0 | const char* anchor = pb.skipWhitespace(); |
60 | 0 | pb.skipNonWhitespace(); |
61 | 0 | pb.data(mHostname, anchor); |
62 | |
|
63 | 0 | pb.skipWhitespace(); |
64 | 0 | anchor = pb.skipChar(Symbols::DOUBLE_QUOTE[0]); |
65 | 0 | pb.skipToEndQuote(Symbols::DOUBLE_QUOTE[0]); |
66 | 0 | pb.data(mText, anchor); |
67 | 0 | anchor = pb.skipChar(Symbols::DOUBLE_QUOTE[0]); |
68 | 0 | pb.skipWhitespace(); |
69 | 0 | pb.assertEof(); |
70 | 0 | } |
71 | | |
72 | | ParserCategory* |
73 | | WarningCategory::clone() const |
74 | 0 | { |
75 | 0 | return new WarningCategory(*this); |
76 | 0 | } |
77 | | |
78 | | ParserCategory* |
79 | | WarningCategory::clone(void* location) const |
80 | 0 | { |
81 | 0 | return new (location) WarningCategory(*this); |
82 | 0 | } |
83 | | |
84 | | ParserCategory* |
85 | | WarningCategory::clone(PoolBase* pool) const |
86 | 0 | { |
87 | 0 | return new (pool) WarningCategory(*this, pool); |
88 | 0 | } |
89 | | |
90 | | int& |
91 | | WarningCategory::code() |
92 | 0 | { |
93 | 0 | checkParsed(); |
94 | 0 | return mCode; |
95 | 0 | } |
96 | | |
97 | | int |
98 | | WarningCategory::code() const |
99 | 0 | { |
100 | 0 | checkParsed(); |
101 | 0 | return mCode; |
102 | 0 | } |
103 | | |
104 | | Data& |
105 | | WarningCategory::hostname() |
106 | 0 | { |
107 | 0 | checkParsed(); |
108 | 0 | return mHostname; |
109 | 0 | } |
110 | | |
111 | | const Data& |
112 | | WarningCategory::hostname() const |
113 | 0 | { |
114 | 0 | checkParsed(); |
115 | 0 | return mHostname; |
116 | 0 | } |
117 | | |
118 | | Data& |
119 | | WarningCategory::text() |
120 | 0 | { |
121 | 0 | checkParsed(); |
122 | 0 | return mText; |
123 | 0 | } |
124 | | |
125 | | const Data& |
126 | | WarningCategory::text() const |
127 | 0 | { |
128 | 0 | checkParsed(); |
129 | 0 | return mText; |
130 | 0 | } |
131 | | |
132 | | EncodeStream& |
133 | | WarningCategory::encodeParsed(EncodeStream& str) const |
134 | 0 | { |
135 | 0 | str << mCode << Symbols::SPACE[0]; |
136 | 0 | str << mHostname << Symbols::SPACE[0]; |
137 | 0 | str << Symbols::DOUBLE_QUOTE[0] << mText << Symbols::DOUBLE_QUOTE[0]; |
138 | |
|
139 | 0 | return str; |
140 | 0 | } |
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 | | */ |