/[resiprocate]/branches/b-identity-0505/HeaderFieldValueList.cxx
ViewVC logotype

Contents of /branches/b-identity-0505/HeaderFieldValueList.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4598 - (show annotations) (download)
Wed May 11 22:53:07 2005 UTC (14 years, 6 months ago) by derek
File size: 5674 byte(s)
set svn:eol-style to LF
1 #if defined(HAVE_CONFIG_H)
2 #include "resiprocate/config.hxx"
3 #endif
4
5
6 #include <cassert>
7
8 #include "resiprocate/HeaderFieldValue.hxx"
9 #include "resiprocate/HeaderFieldValueList.hxx"
10 #include "resiprocate/ParserContainerBase.hxx"
11 #include "resiprocate/Embedded.hxx"
12 #include "resiprocate/os/WinLeakCheck.hxx"
13
14 using namespace resip;
15
16 HeaderFieldValueList::~HeaderFieldValueList()
17 {
18 for (iterator i = begin(); i != end(); i++)
19 {
20 delete *i;
21 }
22 delete mParserContainer;
23 }
24
25 HeaderFieldValueList::HeaderFieldValueList(const HeaderFieldValueList& rhs)
26 : mHeaders(0),
27 mParserContainer(0)
28 {
29 if (rhs.mParserContainer != 0)
30 {
31 mParserContainer = rhs.mParserContainer->clone();
32 }
33 else
34 {
35 for (const_iterator i = rhs.begin(); i != rhs.end(); i++)
36 {
37 push_back(new HeaderFieldValue(**i));
38 }
39 }
40 }
41
42 std::ostream&
43 HeaderFieldValueList::encode(int headerEnum, std::ostream& str)
44 {
45 const Data& headerName = Headers::getHeaderName(static_cast<Headers::Type>(headerEnum));
46
47 if (getParserContainer() != 0)
48 {
49 getParserContainer()->encode(headerName, str);
50 }
51 else
52 {
53 if (!headerName.empty())
54 {
55 str << headerName << Symbols::COLON[0] << Symbols::SPACE[0];
56 }
57
58 for (HeaderFieldValueList::const_iterator j = begin();
59 j != end(); j++)
60 {
61 if (j != begin())
62 {
63 if (Headers::isCommaEncoding(static_cast<Headers::Type>(headerEnum)))
64 {
65 str << Symbols::COMMA[0] << Symbols::SPACE[0];
66 }
67 else
68 {
69 str << Symbols::CRLF << headerName << Symbols::COLON << Symbols::SPACE;
70 }
71 }
72 (*j)->encode(str);
73 }
74 str << Symbols::CRLF;
75 }
76 return str;
77 }
78
79 std::ostream&
80 HeaderFieldValueList::encode(const Data& headerName, std::ostream& str)
81 {
82 if (getParserContainer() != 0)
83 {
84 getParserContainer()->encode(headerName, str);
85 }
86 else
87 {
88 if (!headerName.empty())
89 {
90 str << headerName << Symbols::COLON << Symbols::SPACE;
91 }
92 for (HeaderFieldValueList::const_iterator j = begin();
93 j != end(); j++)
94 {
95 if (j != begin())
96 {
97 str << Symbols::COMMA[0] << Symbols::SPACE[0];
98 }
99 (*j)->encode(str);
100 }
101 str << Symbols::CRLF;
102 }
103 return str;
104 }
105
106 std::ostream&
107 HeaderFieldValueList::encodeEmbedded(const Data& headerName, std::ostream& str)
108 {
109 assert(!headerName.empty());
110
111 if (getParserContainer() != 0)
112 {
113 getParserContainer()->encodeEmbedded(headerName, str);
114 }
115 else
116 {
117 bool first = true;
118 for (HeaderFieldValueList::const_iterator j = begin();
119 j != end(); j++)
120 {
121 if (first)
122 {
123 first = false;
124 }
125 else
126 {
127 str << Symbols::AMPERSAND;
128 }
129
130 str << headerName << Symbols::EQUALS;
131 Data buf;
132 {
133 DataStream s(buf);
134 (*j)->encode(s);
135 }
136 str << Embedded::encode(buf);
137 }
138 }
139 return str;
140 }
141
142 bool
143 HeaderFieldValueList::parsedEmpty() const
144 {
145 if (mParserContainer)
146 {
147 return mParserContainer->empty();
148 }
149 else
150 {
151 return mHeaders.empty();
152 }
153 }
154
155 /* ====================================================================
156 * The Vovida Software License, Version 1.0
157 *
158 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
159 *
160 * Redistribution and use in source and binary forms, with or without
161 * modification, are permitted provided that the following conditions
162 * are met:
163 *
164 * 1. Redistributions of source code must retain the above copyright
165 * notice, this list of conditions and the following disclaimer.
166 *
167 * 2. Redistributions in binary form must reproduce the above copyright
168 * notice, this list of conditions and the following disclaimer in
169 * the documentation and/or other materials provided with the
170 * distribution.
171 *
172 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
173 * and "Vovida Open Communication Application Library (VOCAL)" must
174 * not be used to endorse or promote products derived from this
175 * software without prior written permission. For written
176 * permission, please contact vocal@vovida.org.
177 *
178 * 4. Products derived from this software may not be called "VOCAL", nor
179 * may "VOCAL" appear in their name, without prior written
180 * permission of Vovida Networks, Inc.
181 *
182 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
183 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
184 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
185 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
186 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
187 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
188 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
189 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
190 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
191 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
192 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
193 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
194 * DAMAGE.
195 *
196 * ====================================================================
197 *
198 * This software consists of voluntary contributions made by Vovida
199 * Networks, Inc. and many individuals on behalf of Vovida Networks,
200 * Inc. For more information on Vovida Networks, Inc., please see
201 * <http://www.vovida.org/>.
202 *
203 */

Properties

Name Value
svn:eol-style LF

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27