reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
HeaderFieldValueList.hxx
Go to the documentation of this file.
1#if !defined(RESIP_HEADERFIELDVALUELIST_HXX)
2#define RESIP_HEADERFIELDVALUELIST_HXX
3
4#include <iosfwd>
5#include <vector>
6
8#include "rutil/PoolBase.hxx"
9
10namespace resip
11{
12
13class Data;
14class ParserContainerBase;
15class HeaderFieldValue;
16
44{
45 public:
47
49 : mHeaders(),
50 mPool(0),
51 mParserContainer(0)
52 {}
53
55 : mHeaders(StlPoolAllocator<HeaderFieldValue, PoolBase>(&pool)),
56 mPool(&pool),
57 mParserContainer(0)
58 {}
59
64
65 inline void setParserContainer(ParserContainerBase* parser) {mParserContainer = parser;}
66 inline ParserContainerBase* getParserContainer() const {return mParserContainer;}
67
68 EncodeStream& encode(int headerEnum, EncodeStream& str) const;
69 EncodeStream& encode(const Data& headerName, EncodeStream& str) const;
70 EncodeStream& encodeEmbedded(const Data& headerName, EncodeStream& str) const;
71
72 bool empty() const {return mHeaders.empty();}
73 size_t size() const {return mHeaders.size();}
74 void clear();
75 //void push_front(HeaderFieldValue* header) {mHeaders.push_front(header);}
76
89 void push_back(const char* buffer, size_t length, bool own)
90 {
91 mHeaders.push_back(HeaderFieldValue::Empty);
92 mHeaders.back().init(buffer,length,own);
93 }
94
95 //void pop_front() {mHeaders.pop_front();}
96 void pop_back() {mHeaders.pop_back();};
97 HeaderFieldValue* front() {return &mHeaders.front();}
98 HeaderFieldValue* back() {return &mHeaders.back();}
99 const HeaderFieldValue* front() const {return &mHeaders.front();}
100 const HeaderFieldValue* back() const {return &mHeaders.back();}
101
102 inline void reserve(size_t size)
103 {
104 mHeaders.reserve(size);
105 }
106
107 bool parsedEmpty() const;
108
109 size_t getNumHeaderValues() const;
110 bool getHeaderValueByIndex(size_t index, Data& headerValue) const;
111
112 private:
113 typedef std::vector<HeaderFieldValue, StlPoolAllocator<HeaderFieldValue, PoolBase > > ListImpl;
114 public:
115 typedef ListImpl::iterator iterator;
116 typedef ListImpl::const_iterator const_iterator;
117
118 iterator begin() {return mHeaders.begin();}
119 iterator end() {return mHeaders.end();}
120 const_iterator begin() const {return mHeaders.begin();}
121 const_iterator end() const {return mHeaders.end();}
122
123 private:
124 ListImpl mHeaders;
125 PoolBase* mPool;
126 ParserContainerBase* mParserContainer;
127
128 void freeParserContainer();
129};
130
131}
132
133#endif
134
135/* ====================================================================
136 * The Vovida Software License, Version 1.0
137 *
138 * Copyright (c) 2023 SIP Spectrum, Inc. www.sipspectrum.com
139 * Copyright (c) 2000 Vovida Networks, Inc.
140 * All rights reserved.
141 *
142 * Redistribution and use in source and binary forms, with or without
143 * modification, are permitted provided that the following conditions
144 * are met:
145 *
146 * 1. Redistributions of source code must retain the above copyright
147 * notice, this list of conditions and the following disclaimer.
148 *
149 * 2. Redistributions in binary form must reproduce the above copyright
150 * notice, this list of conditions and the following disclaimer in
151 * the documentation and/or other materials provided with the
152 * distribution.
153 *
154 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
155 * and "Vovida Open Communication Application Library (VOCAL)" must
156 * not be used to endorse or promote products derived from this
157 * software without prior written permission. For written
158 * permission, please contact vocal@vovida.org.
159 *
160 * 4. Products derived from this software may not be called "VOCAL", nor
161 * may "VOCAL" appear in their name, without prior written
162 * permission of Vovida Networks, Inc.
163 *
164 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
165 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
166 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
167 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
168 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
169 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
170 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
171 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
172 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
173 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
174 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
175 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
176 * DAMAGE.
177 *
178 * ====================================================================
179 *
180 * This software consists of voluntary contributions made by Vovida
181 * Networks, Inc. and many individuals on behalf of Vovida Networks,
182 * Inc. For more information on Vovida Networks, Inc., please see
183 * <http://www.vovida.org/>.
184 *
185 */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
const HeaderFieldValue * back() const
void setParserContainer(ParserContainerBase *parser)
bool getHeaderValueByIndex(size_t index, Data &headerValue) const
EncodeStream & encodeEmbedded(const Data &headerName, EncodeStream &str) const
HeaderFieldValueList & operator=(const HeaderFieldValueList &rhs)
const HeaderFieldValue * front() const
ParserContainerBase * getParserContainer() const
ListImpl::const_iterator const_iterator
EncodeStream & encode(int headerEnum, EncodeStream &str) const
void push_back(const char *buffer, size_t length, bool own)
READ THIS CAREFULLY BEFORE USING THIS FUNCTION.
static const HeaderFieldValueList Empty
static const HeaderFieldValue Empty
Abstract Base class implemented in derived class ParserContainer.
A dirt-simple lightweight stl pool allocator meant for use in short-lifetime objects.
dcm! – add UnusedChecking(_enum) below;
#define EncodeStream