/src/resiprocate/resip/stack/ParserContainer.hxx
Line | Count | Source (jump to first uncovered line) |
1 | | #ifndef RESIP_ParserContainer_hxx |
2 | | #define RESIP_ParserContainer_hxx |
3 | | |
4 | | #include <algorithm> |
5 | | #include <iterator> |
6 | | |
7 | | #include "resip/stack/HeaderFieldValueList.hxx" |
8 | | #include "resip/stack/ParserContainerBase.hxx" |
9 | | |
10 | | namespace resip |
11 | | { |
12 | | using std::ptrdiff_t; |
13 | | /** |
14 | | @brief Container class for ParserCategory, used by SipMessage to represent |
15 | | multi-valued headers (Contact, Via, etc). |
16 | | |
17 | | This has an interface that is similar to stl containers, but not as complete. |
18 | | |
19 | | @ingroup resip_crit |
20 | | */ |
21 | | template<class T> |
22 | | class ParserContainer : public ParserContainerBase |
23 | | { |
24 | | public: |
25 | | typedef T value_type; |
26 | | typedef value_type* pointer; |
27 | | typedef const value_type* const_pointer; |
28 | | typedef value_type& reference; |
29 | | typedef const value_type& const_reference; |
30 | | typedef ptrdiff_t difference_type; |
31 | | |
32 | | /** |
33 | | @brief Default c'tor. |
34 | | */ |
35 | | ParserContainer() |
36 | | : ParserContainerBase(Headers::UNKNOWN) |
37 | 0 | {} Unexecuted instantiation: resip::ParserContainer<resip::Token>::ParserContainer() Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::ParserContainer() Unexecuted instantiation: resip::ParserContainer<resip::Auth>::ParserContainer() |
38 | | |
39 | | ParserContainer(PoolBase& pool) |
40 | | : ParserContainerBase(Headers::UNKNOWN,pool) |
41 | | {} |
42 | | |
43 | | /** |
44 | | @internal |
45 | | @brief Used by SipMessage (using this carries a high risk of blowing |
46 | | your feet off). |
47 | | */ |
48 | | ParserContainer(HeaderFieldValueList* hfvs, |
49 | | Headers::Type type = Headers::UNKNOWN) |
50 | | : ParserContainerBase(type) |
51 | 0 | { |
52 | 0 | mParsers.reserve(hfvs->size()); |
53 | 0 | for (HeaderFieldValueList::iterator i = hfvs->begin(); |
54 | 0 | i != hfvs->end(); i++) |
55 | 0 | { |
56 | | // create, store without copying -- |
57 | | // keeps the HeaderFieldValue from reallocating its buffer |
58 | 0 | mParsers.push_back(HeaderKit::Empty); |
59 | 0 | mParsers.back().hfv.init(i->getBuffer(),i->getLength(),false); |
60 | 0 | } |
61 | 0 | } Unexecuted instantiation: resip::ParserContainer<resip::Token>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::StringCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::PrivacyCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::Mime>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::GenericUri>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::UInt32Category>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::ExpiresCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::CallID>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::Auth>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::CSeqCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::DateCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::WarningCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::RAckCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::Via>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) Unexecuted instantiation: resip::ParserContainer<resip::TokenOrQuotedStringCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type) |
62 | | |
63 | | ParserContainer(HeaderFieldValueList* hfvs, |
64 | | Headers::Type type, |
65 | | PoolBase& pool) |
66 | | : ParserContainerBase(type,pool) |
67 | 199 | { |
68 | 199 | mParsers.reserve(hfvs->size()); |
69 | 199 | for (HeaderFieldValueList::iterator i = hfvs->begin(); |
70 | 398 | i != hfvs->end(); i++) |
71 | 199 | { |
72 | | // create, store without copying -- |
73 | | // keeps the HeaderFieldValue from reallocating its buffer |
74 | 199 | mParsers.push_back(HeaderKit::Empty); |
75 | 199 | mParsers.back().hfv.init(i->getBuffer(),i->getLength(),false); |
76 | 199 | } |
77 | 199 | } Unexecuted instantiation: resip::ParserContainer<resip::StringCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::Token>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::PrivacyCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::Mime>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::GenericUri>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) resip::ParserContainer<resip::UInt32Category>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Line | Count | Source | 67 | 199 | { | 68 | 199 | mParsers.reserve(hfvs->size()); | 69 | 199 | for (HeaderFieldValueList::iterator i = hfvs->begin(); | 70 | 398 | i != hfvs->end(); i++) | 71 | 199 | { | 72 | | // create, store without copying -- | 73 | | // keeps the HeaderFieldValue from reallocating its buffer | 74 | 199 | mParsers.push_back(HeaderKit::Empty); | 75 | 199 | mParsers.back().hfv.init(i->getBuffer(),i->getLength(),false); | 76 | 199 | } | 77 | 199 | } |
Unexecuted instantiation: resip::ParserContainer<resip::ExpiresCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::CallID>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::Auth>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::CSeqCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::DateCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::WarningCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::Via>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::RAckCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) Unexecuted instantiation: resip::ParserContainer<resip::TokenOrQuotedStringCategory>::ParserContainer(resip::HeaderFieldValueList*, resip::Headers::Type, resip::PoolBase&) |
78 | | |
79 | | /** |
80 | | @brief Copy c'tor. |
81 | | */ |
82 | | ParserContainer(const ParserContainer& other) |
83 | | : ParserContainerBase(other) |
84 | 0 | {} Unexecuted instantiation: resip::ParserContainer<resip::Token>::ParserContainer(resip::ParserContainer<resip::Token> const&) Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::ParserContainer(resip::ParserContainer<resip::NameAddr> const&) Unexecuted instantiation: resip::ParserContainer<resip::StringCategory>::ParserContainer(resip::ParserContainer<resip::StringCategory> const&) Unexecuted instantiation: resip::ParserContainer<resip::PrivacyCategory>::ParserContainer(resip::ParserContainer<resip::PrivacyCategory> const&) Unexecuted instantiation: resip::ParserContainer<resip::Mime>::ParserContainer(resip::ParserContainer<resip::Mime> const&) Unexecuted instantiation: resip::ParserContainer<resip::GenericUri>::ParserContainer(resip::ParserContainer<resip::GenericUri> const&) Unexecuted instantiation: resip::ParserContainer<resip::UInt32Category>::ParserContainer(resip::ParserContainer<resip::UInt32Category> const&) Unexecuted instantiation: resip::ParserContainer<resip::ExpiresCategory>::ParserContainer(resip::ParserContainer<resip::ExpiresCategory> const&) Unexecuted instantiation: resip::ParserContainer<resip::CallID>::ParserContainer(resip::ParserContainer<resip::CallID> const&) Unexecuted instantiation: resip::ParserContainer<resip::Auth>::ParserContainer(resip::ParserContainer<resip::Auth> const&) Unexecuted instantiation: resip::ParserContainer<resip::CSeqCategory>::ParserContainer(resip::ParserContainer<resip::CSeqCategory> const&) Unexecuted instantiation: resip::ParserContainer<resip::DateCategory>::ParserContainer(resip::ParserContainer<resip::DateCategory> const&) Unexecuted instantiation: resip::ParserContainer<resip::WarningCategory>::ParserContainer(resip::ParserContainer<resip::WarningCategory> const&) Unexecuted instantiation: resip::ParserContainer<resip::RAckCategory>::ParserContainer(resip::ParserContainer<resip::RAckCategory> const&) Unexecuted instantiation: resip::ParserContainer<resip::Via>::ParserContainer(resip::ParserContainer<resip::Via> const&) Unexecuted instantiation: resip::ParserContainer<resip::TokenOrQuotedStringCategory>::ParserContainer(resip::ParserContainer<resip::TokenOrQuotedStringCategory> const&) |
85 | | |
86 | | /** |
87 | | @brief Copy c'tor. |
88 | | */ |
89 | | ParserContainer(const ParserContainer& other, PoolBase& pool) |
90 | | : ParserContainerBase(other, pool) |
91 | | {} |
92 | | |
93 | | /** |
94 | | @brief Assignment operator. |
95 | | */ |
96 | | ParserContainer& operator=(const ParserContainer& other) |
97 | 0 | { |
98 | 0 | return static_cast<ParserContainer&>(ParserContainerBase::operator=(other)); |
99 | 0 | } Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::operator=(resip::ParserContainer<resip::NameAddr> const&) Unexecuted instantiation: resip::ParserContainer<resip::Token>::operator=(resip::ParserContainer<resip::Token> const&) Unexecuted instantiation: resip::ParserContainer<resip::Via>::operator=(resip::ParserContainer<resip::Via> const&) Unexecuted instantiation: resip::ParserContainer<resip::Auth>::operator=(resip::ParserContainer<resip::Auth> const&) |
100 | | |
101 | | /** |
102 | | @brief Returns the first header field value in this container. |
103 | | */ |
104 | | T& front() |
105 | 55.4k | { |
106 | 55.4k | return ensureInitialized(mParsers.front(),this); |
107 | 55.4k | } Unexecuted instantiation: resip::ParserContainer<resip::Token>::front() Unexecuted instantiation: resip::ParserContainer<resip::StringCategory>::front() Unexecuted instantiation: resip::ParserContainer<resip::Mime>::front() Unexecuted instantiation: resip::ParserContainer<resip::GenericUri>::front() Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::front() resip::ParserContainer<resip::UInt32Category>::front() Line | Count | Source | 105 | 55.4k | { | 106 | 55.4k | return ensureInitialized(mParsers.front(),this); | 107 | 55.4k | } |
Unexecuted instantiation: resip::ParserContainer<resip::ExpiresCategory>::front() Unexecuted instantiation: resip::ParserContainer<resip::CallID>::front() Unexecuted instantiation: resip::ParserContainer<resip::Auth>::front() Unexecuted instantiation: resip::ParserContainer<resip::CSeqCategory>::front() Unexecuted instantiation: resip::ParserContainer<resip::DateCategory>::front() Unexecuted instantiation: resip::ParserContainer<resip::RAckCategory>::front() Unexecuted instantiation: resip::ParserContainer<resip::Via>::front() |
108 | | |
109 | | /** |
110 | | @brief Returns the last header field value in this container. |
111 | | */ |
112 | | T& back() |
113 | 0 | { |
114 | 0 | return ensureInitialized(mParsers.back(),this); |
115 | 0 | } |
116 | | |
117 | | /** |
118 | | @brief Returns the first header field value in this container. |
119 | | */ |
120 | | const T& front() const |
121 | 0 | { |
122 | 0 | return ensureInitialized(mParsers.front(),this); |
123 | 0 | } Unexecuted instantiation: resip::ParserContainer<resip::Via>::front() const Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::front() const |
124 | | |
125 | | /** |
126 | | @brief Returns the last header field value in this container. |
127 | | */ |
128 | | const T& back() const |
129 | | { |
130 | | return ensureInitialized(mParsers.back(),this); |
131 | | } |
132 | | |
133 | | /** |
134 | | @brief Inserts a header field value at the front of this container. |
135 | | */ |
136 | | void push_front(const T & t) |
137 | 0 | { |
138 | 0 | mParsers.insert(mParsers.begin(), HeaderKit::Empty); |
139 | 0 | mParsers.front().pc=makeParser(t); |
140 | 0 | } Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::push_front(resip::NameAddr const&) Unexecuted instantiation: resip::ParserContainer<resip::Via>::push_front(resip::Via const&) |
141 | | |
142 | | /** |
143 | | @brief Inserts a header field value at the back of this container. |
144 | | */ |
145 | | void push_back(const T & t) |
146 | 0 | { |
147 | 0 | mParsers.push_back(HeaderKit::Empty); |
148 | 0 | mParsers.back().pc=makeParser(t); |
149 | 0 | } Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::push_back(resip::NameAddr const&) Unexecuted instantiation: resip::ParserContainer<resip::Token>::push_back(resip::Token const&) Unexecuted instantiation: resip::ParserContainer<resip::Via>::push_back(resip::Via const&) Unexecuted instantiation: resip::ParserContainer<resip::WarningCategory>::push_back(resip::WarningCategory const&) Unexecuted instantiation: resip::ParserContainer<resip::Auth>::push_back(resip::Auth const&) |
150 | | |
151 | | /** |
152 | | @brief Returns a copy of this ParserContainer, in reverse order. |
153 | | @todo !bwc! optimize this (we are copying each ParserContainer twice) |
154 | | */ |
155 | | ParserContainer reverse() const |
156 | | { |
157 | | ParserContainer tmp(*this); |
158 | | std::reverse(tmp.mParsers.begin(), tmp.mParsers.end()); |
159 | | return tmp; |
160 | | } |
161 | | |
162 | | typedef ParserContainerBase::Parsers Parsers; |
163 | | // .dlb. these can be partially hoisted as well |
164 | | class const_iterator; |
165 | | |
166 | | /** |
167 | | @brief An iterator class, derived from std::iterator (bidirectional) |
168 | | */ |
169 | | class iterator : public std::iterator<std::bidirectional_iterator_tag, T> |
170 | | { |
171 | | public: |
172 | 0 | iterator(typename Parsers::iterator i,ParserContainer* ref) : mIt(i),mRef(ref){} |
173 | | iterator() : mRef(0) {} |
174 | | iterator(const iterator& orig) : mIt(orig.mIt), mRef(orig.mRef) {} |
175 | | |
176 | | iterator operator++() {iterator it(++mIt,mRef); return it;} |
177 | 0 | iterator operator++(int) {iterator it(mIt++,mRef); return it;} |
178 | | iterator operator--() {iterator it(--mIt,mRef); return it;} |
179 | | iterator operator--(int) {iterator it(mIt--,mRef); return it;} |
180 | 0 | friend bool operator!=(const iterator& lhs, const iterator& rhs) { return lhs.mIt != rhs.mIt; } |
181 | | friend bool operator==(const iterator& lhs, const iterator& rhs) { return lhs.mIt == rhs.mIt; } |
182 | | iterator& operator=(const iterator& rhs) |
183 | | { |
184 | | if (&rhs != this) |
185 | | { |
186 | | mIt = rhs.mIt; |
187 | | mRef = rhs.mRef; |
188 | | } |
189 | | return *this; |
190 | | } |
191 | | T& operator*() {return ensureInitialized(*mIt,mRef);} |
192 | 0 | T* operator->() {return &ensureInitialized(*mIt,mRef);} |
193 | | private: |
194 | | typename Parsers::iterator mIt; |
195 | | ParserContainer* mRef; |
196 | | friend class const_iterator; |
197 | | friend class ParserContainer; |
198 | | }; |
199 | | |
200 | | /** |
201 | | @brief A const_iterator class, derived from std::iterator |
202 | | (bidirectional) |
203 | | */ |
204 | | class const_iterator : public std::iterator<std::bidirectional_iterator_tag, T> |
205 | | { |
206 | | public: |
207 | 0 | const_iterator(Parsers::const_iterator i,const ParserContainer* ref) : mIt(i),mRef(ref){} Unexecuted instantiation: resip::ParserContainer<resip::Token>::const_iterator::const_iterator(std::__1::__wrap_iter<resip::ParserContainerBase::HeaderKit const*>, resip::ParserContainer<resip::Token> const*) Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::const_iterator::const_iterator(std::__1::__wrap_iter<resip::ParserContainerBase::HeaderKit const*>, resip::ParserContainer<resip::NameAddr> const*) Unexecuted instantiation: resip::ParserContainer<resip::Auth>::const_iterator::const_iterator(std::__1::__wrap_iter<resip::ParserContainerBase::HeaderKit const*>, resip::ParserContainer<resip::Auth> const*) Unexecuted instantiation: resip::ParserContainer<resip::Via>::const_iterator::const_iterator(std::__1::__wrap_iter<resip::ParserContainerBase::HeaderKit const*>, resip::ParserContainer<resip::Via> const*) |
208 | | const_iterator(const const_iterator& orig) : mIt(orig.mIt), mRef(orig.mRef) {} |
209 | | const_iterator(const iterator& orig) : mIt(orig.mIt), mRef(orig.mRef) {} |
210 | | const_iterator() : mRef(0) {} |
211 | | |
212 | 0 | const_iterator operator++() {const_iterator it(++mIt,mRef); return it;} |
213 | 0 | const_iterator operator++(int) {const_iterator it(mIt++,mRef); return it;} Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::const_iterator::operator++(int) Unexecuted instantiation: resip::ParserContainer<resip::Auth>::const_iterator::operator++(int) |
214 | | const_iterator operator--() {const_iterator it(--mIt,mRef); return it;} |
215 | 0 | const_iterator operator--(int) {const_iterator it(mIt--,mRef); return it;} |
216 | 0 | friend bool operator!=(const const_iterator& lhs, const const_iterator& rhs) { return lhs.mIt != rhs.mIt; } Unexecuted instantiation: resip::operator!=(resip::ParserContainer<resip::Token>::const_iterator const&, resip::ParserContainer<resip::Token>::const_iterator const&) Unexecuted instantiation: resip::operator!=(resip::ParserContainer<resip::NameAddr>::const_iterator const&, resip::ParserContainer<resip::NameAddr>::const_iterator const&) Unexecuted instantiation: resip::operator!=(resip::ParserContainer<resip::Auth>::const_iterator const&, resip::ParserContainer<resip::Auth>::const_iterator const&) |
217 | 0 | friend bool operator==(const const_iterator& lhs, const const_iterator& rhs) { return lhs.mIt == rhs.mIt; } |
218 | | const_iterator& operator=(const const_iterator& rhs) |
219 | | { |
220 | | if (&rhs != this) |
221 | | { |
222 | | mIt = rhs.mIt; |
223 | | mRef = rhs.mRef; |
224 | | } |
225 | | return *this; |
226 | | } |
227 | | const_iterator& operator=(const iterator& rhs) |
228 | | { |
229 | | mIt = rhs.mIt; |
230 | | mRef = rhs.mRef; |
231 | | return *this; |
232 | | } |
233 | 0 | const T& operator*() {return ensureInitialized(*mIt,mRef);} |
234 | 0 | const T* operator->() {return &ensureInitialized(*mIt,mRef);} Unexecuted instantiation: resip::ParserContainer<resip::Token>::const_iterator::operator->() Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::const_iterator::operator->() Unexecuted instantiation: resip::ParserContainer<resip::Auth>::const_iterator::operator->() Unexecuted instantiation: resip::ParserContainer<resip::Via>::const_iterator::operator->() |
235 | | private: |
236 | | friend class iterator; |
237 | | typename Parsers::const_iterator mIt; |
238 | | const ParserContainer* mRef; |
239 | | }; |
240 | | |
241 | | /** |
242 | | @brief Returns an iterator pointing to the first header field value. |
243 | | */ |
244 | 0 | iterator begin() { return iterator(mParsers.begin(),this); } |
245 | | |
246 | | /** |
247 | | @brief Returns an iterator pointing to the last header field value. |
248 | | */ |
249 | 0 | iterator end() { return iterator(mParsers.end(),this); } |
250 | | |
251 | | /** |
252 | | @brief Erases the header field value pointed to by i. Invalidates all |
253 | | existing iterators. |
254 | | */ |
255 | | iterator erase(iterator i) |
256 | | { |
257 | | freeParser(*i.mIt); |
258 | | return iterator(mParsers.erase(i.mIt),this); |
259 | | } |
260 | | |
261 | | /** |
262 | | @brief Finds the first header field value that matches rhs. |
263 | | */ |
264 | | bool find(const T& rhs) const |
265 | | { |
266 | | for (typename Parsers::const_iterator i = mParsers.begin(); |
267 | | i != mParsers.end(); ++i) |
268 | | { |
269 | | // operator== defined by default, but often not usefully |
270 | | if (rhs.isEqual(ensureInitialized(*i,this))) |
271 | | { |
272 | | return true; |
273 | | } |
274 | | } |
275 | | |
276 | | return false; |
277 | | } |
278 | | |
279 | | /** |
280 | | @brief Triggers a parse of all contained header field values. |
281 | | @throw ParseException if any header field value is malformed. |
282 | | */ |
283 | | virtual void parseAll() |
284 | 0 | { |
285 | 0 | for (typename Parsers::const_iterator i = mParsers.begin(); |
286 | 0 | i != mParsers.end(); ++i) |
287 | 0 | { |
288 | 0 | ensureInitialized(*i,this).checkParsed(); |
289 | 0 | } |
290 | 0 | } Unexecuted instantiation: resip::ParserContainer<resip::Token>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::StringCategory>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::PrivacyCategory>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::Mime>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::GenericUri>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::UInt32Category>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::ExpiresCategory>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::CallID>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::Auth>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::CSeqCategory>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::DateCategory>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::WarningCategory>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::RAckCategory>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::Via>::parseAll() Unexecuted instantiation: resip::ParserContainer<resip::TokenOrQuotedStringCategory>::parseAll() |
291 | | |
292 | | /** |
293 | | @brief Returns a const_iterator pointing to the first header field |
294 | | value. |
295 | | */ |
296 | 0 | const_iterator begin() const { return const_iterator(mParsers.begin(),this); } Unexecuted instantiation: resip::ParserContainer<resip::Token>::begin() const Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::begin() const Unexecuted instantiation: resip::ParserContainer<resip::Auth>::begin() const Unexecuted instantiation: resip::ParserContainer<resip::Via>::begin() const |
297 | | |
298 | | /** |
299 | | @brief Returns a const_iterator pointing to the first header field |
300 | | value. |
301 | | */ |
302 | 0 | const_iterator end() const { return const_iterator(mParsers.end(),this); } Unexecuted instantiation: resip::ParserContainer<resip::Token>::end() const Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::end() const Unexecuted instantiation: resip::ParserContainer<resip::Auth>::end() const Unexecuted instantiation: resip::ParserContainer<resip::Via>::end() const |
303 | | |
304 | | /** |
305 | | @brief Clones this container, and all contained header field values. |
306 | | */ |
307 | | virtual ParserContainerBase* clone() const |
308 | 0 | { |
309 | 0 | return new ParserContainer(*this); |
310 | 0 | } Unexecuted instantiation: resip::ParserContainer<resip::Token>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::StringCategory>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::PrivacyCategory>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::Mime>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::GenericUri>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::UInt32Category>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::ExpiresCategory>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::CallID>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::Auth>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::CSeqCategory>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::DateCategory>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::WarningCategory>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::RAckCategory>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::Via>::clone() const Unexecuted instantiation: resip::ParserContainer<resip::TokenOrQuotedStringCategory>::clone() const |
311 | | |
312 | | private: |
313 | | friend class ParserContainer<T>::iterator; |
314 | | friend class ParserContainer<T>::const_iterator; |
315 | | |
316 | | /** |
317 | | @internal |
318 | | */ |
319 | | static T& ensureInitialized(HeaderKit& kit, ParserContainer* ref) |
320 | 55.4k | { |
321 | 55.4k | if(!kit.pc) |
322 | 199 | { |
323 | 199 | if(ref) |
324 | 199 | { |
325 | 199 | PoolBase* pool(ref->mPool); |
326 | 199 | kit.pc=new (pool) T(kit.hfv, ref->mType, pool); |
327 | 199 | } |
328 | 0 | else |
329 | 0 | { |
330 | 0 | kit.pc=new T(kit.hfv, Headers::NONE); |
331 | 0 | } |
332 | 199 | } |
333 | 55.4k | return *static_cast<T*>(kit.pc); |
334 | 55.4k | } Unexecuted instantiation: resip::ParserContainer<resip::Token>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::Token>*) Unexecuted instantiation: resip::ParserContainer<resip::StringCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::StringCategory>*) Unexecuted instantiation: resip::ParserContainer<resip::Mime>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::Mime>*) Unexecuted instantiation: resip::ParserContainer<resip::GenericUri>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::GenericUri>*) Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::NameAddr>*) resip::ParserContainer<resip::UInt32Category>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::UInt32Category>*) Line | Count | Source | 320 | 55.4k | { | 321 | 55.4k | if(!kit.pc) | 322 | 199 | { | 323 | 199 | if(ref) | 324 | 199 | { | 325 | 199 | PoolBase* pool(ref->mPool); | 326 | 199 | kit.pc=new (pool) T(kit.hfv, ref->mType, pool); | 327 | 199 | } | 328 | 0 | else | 329 | 0 | { | 330 | 0 | kit.pc=new T(kit.hfv, Headers::NONE); | 331 | 0 | } | 332 | 199 | } | 333 | 55.4k | return *static_cast<T*>(kit.pc); | 334 | 55.4k | } |
Unexecuted instantiation: resip::ParserContainer<resip::ExpiresCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::ExpiresCategory>*) Unexecuted instantiation: resip::ParserContainer<resip::CallID>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::CallID>*) Unexecuted instantiation: resip::ParserContainer<resip::Auth>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::Auth>*) Unexecuted instantiation: resip::ParserContainer<resip::CSeqCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::CSeqCategory>*) Unexecuted instantiation: resip::ParserContainer<resip::DateCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::DateCategory>*) Unexecuted instantiation: resip::ParserContainer<resip::RAckCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::RAckCategory>*) Unexecuted instantiation: resip::ParserContainer<resip::Via>::ensureInitialized(resip::ParserContainerBase::HeaderKit&, resip::ParserContainer<resip::Via>*) |
335 | | |
336 | | static const T& ensureInitialized(const HeaderKit& kit, |
337 | | const ParserContainer* ref) |
338 | 0 | { |
339 | 0 | if(!kit.pc) |
340 | 0 | { |
341 | 0 | HeaderKit& nc_kit(const_cast<HeaderKit&>(kit)); |
342 | 0 | if(ref) |
343 | 0 | { |
344 | 0 | ParserContainer* nc_ref(const_cast<ParserContainer*>(ref)); |
345 | 0 | PoolBase* pool(nc_ref->mPool); |
346 | 0 | nc_kit.pc=new (pool) T(kit.hfv, ref->mType, pool); |
347 | 0 | } |
348 | 0 | else |
349 | 0 | { |
350 | 0 | nc_kit.pc=new T(kit.hfv, Headers::NONE); |
351 | 0 | } |
352 | 0 | } |
353 | 0 | return *static_cast<T*>(kit.pc); |
354 | 0 | } Unexecuted instantiation: resip::ParserContainer<resip::Token>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::Token> const*) Unexecuted instantiation: resip::ParserContainer<resip::NameAddr>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::NameAddr> const*) Unexecuted instantiation: resip::ParserContainer<resip::StringCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::StringCategory> const*) Unexecuted instantiation: resip::ParserContainer<resip::PrivacyCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::PrivacyCategory> const*) Unexecuted instantiation: resip::ParserContainer<resip::Mime>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::Mime> const*) Unexecuted instantiation: resip::ParserContainer<resip::GenericUri>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::GenericUri> const*) Unexecuted instantiation: resip::ParserContainer<resip::UInt32Category>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::UInt32Category> const*) Unexecuted instantiation: resip::ParserContainer<resip::ExpiresCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::ExpiresCategory> const*) Unexecuted instantiation: resip::ParserContainer<resip::CallID>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::CallID> const*) Unexecuted instantiation: resip::ParserContainer<resip::Auth>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::Auth> const*) Unexecuted instantiation: resip::ParserContainer<resip::CSeqCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::CSeqCategory> const*) Unexecuted instantiation: resip::ParserContainer<resip::DateCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::DateCategory> const*) Unexecuted instantiation: resip::ParserContainer<resip::WarningCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::WarningCategory> const*) Unexecuted instantiation: resip::ParserContainer<resip::RAckCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::RAckCategory> const*) Unexecuted instantiation: resip::ParserContainer<resip::Via>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::Via> const*) Unexecuted instantiation: resip::ParserContainer<resip::TokenOrQuotedStringCategory>::ensureInitialized(resip::ParserContainerBase::HeaderKit const&, resip::ParserContainer<resip::TokenOrQuotedStringCategory> const*) |
355 | | }; |
356 | | |
357 | | template <class T> |
358 | | EncodeStream& |
359 | | insert(EncodeStream& s, const resip::ParserContainer<T>& c) |
360 | | { |
361 | | s << "["; |
362 | | for (typename resip::ParserContainer <T>::const_iterator i = c.begin(); |
363 | | i != c.end(); i++) |
364 | | { |
365 | | if (i != c.begin()) |
366 | | { |
367 | | s << ", "; |
368 | | } |
369 | | // recurse |
370 | | insert(s, *i); |
371 | | } |
372 | | s << "]"; |
373 | | return s; |
374 | | } |
375 | | |
376 | | } |
377 | | |
378 | | #endif |
379 | | |
380 | | /* ==================================================================== |
381 | | * The Vovida Software License, Version 1.0 |
382 | | * |
383 | | * Copyright (c) 2000-2005 |
384 | | * |
385 | | * Redistribution and use in source and binary forms, with or without |
386 | | * modification, are permitted provided that the following conditions |
387 | | * are met: |
388 | | * |
389 | | * 1. Redistributions of source code must retain the above copyright |
390 | | * notice, this list of conditions and the following disclaimer. |
391 | | * |
392 | | * 2. Redistributions in binary form must reproduce the above copyright |
393 | | * notice, this list of conditions and the following disclaimer in |
394 | | * the documentation and/or other materials provided with the |
395 | | * distribution. |
396 | | * |
397 | | * 3. The names "VOCAL", "Vovida Open Communication Application Library", |
398 | | * and "Vovida Open Communication Application Library (VOCAL)" must |
399 | | * not be used to endorse or promote products derived from this |
400 | | * software without prior written permission. For written |
401 | | * permission, please contact vocal@vovida.org. |
402 | | * |
403 | | * 4. Products derived from this software may not be called "VOCAL", nor |
404 | | * may "VOCAL" appear in their name, without prior written |
405 | | * permission of Vovida Networks, Inc. |
406 | | * |
407 | | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED |
408 | | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
409 | | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND |
410 | | * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA |
411 | | * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES |
412 | | * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, |
413 | | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
414 | | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
415 | | * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
416 | | * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
417 | | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE |
418 | | * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
419 | | * DAMAGE. |
420 | | * |
421 | | * ==================================================================== |
422 | | * |
423 | | * This software consists of voluntary contributions made by Vovida |
424 | | * Networks, Inc. and many individuals on behalf of Vovida Networks, |
425 | | * Inc. For more information on Vovida Networks, Inc., please see |
426 | | * <http://www.vovida.org/>. |
427 | | * |
428 | | */ |