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