reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
HeaderFieldValue.cxx
Go to the documentation of this file.
1#if defined(HAVE_CONFIG_H)
2#include "config.h"
3#endif
4
5#include <iostream>
6
13#include "rutil/ParseBuffer.hxx"
14#include "rutil/Logger.hxx"
16
17using namespace std;
18using namespace resip;
19
20
21#define RESIPROCATE_SUBSYSTEM Subsystem::SIP
22
24
25HeaderFieldValue::HeaderFieldValue(const char* field, size_t fieldLength)
26 : mField(field),
27 mFieldLength(fieldLength),
28 mMine(false)
29{}
30
32 : mField(0),
33 mFieldLength(hfv.mFieldLength),
34 mMine(true)
35{
36 if(mFieldLength)
37 {
38 char* newField = new char[mFieldLength];
39 memcpy(newField, hfv.mField, mFieldLength);
40 mField=newField;
41 }
42}
43
46{
47 if(this!=&rhs)
48 {
49 mFieldLength=rhs.mFieldLength;
50 if(mMine) delete [] mField;
51 mMine=true;
52 if(mFieldLength)
53 {
54 char* newField = new char[mFieldLength];
55 memcpy(newField, rhs.mField, mFieldLength);
56 mField=newField;
57 }
58 else
59 {
60 mField=0;
61 }
62 }
63
64 return *this;
65}
66
69{
70 if(this!=&rhs)
71 {
72 mFieldLength=rhs.mFieldLength;
73 if(mMine) delete [] mField;
74 mMine=true;
75 if(mFieldLength)
76 {
77 char* newField = MsgHeaderScanner::allocateBuffer(mFieldLength);
78 memcpy(newField, rhs.mField, mFieldLength);
79 mField=newField;
80 }
81 else
82 {
83 mField=0;
84 }
85 }
86
87 return *this;
88}
89
91 : mField(0),
92 mFieldLength(hfv.mFieldLength),
93 mMine(true)
94{
95 char* newField = MsgHeaderScanner::allocateBuffer(mFieldLength);
96 memcpy(newField, hfv.mField, mFieldLength);
97 mField=newField;
98}
99
101 : mField(hfv.mField),
102 mFieldLength(hfv.mFieldLength),
103 mMine(false)
104{
105 // ?bwc? assert(!hfv.mMine); ?
106}
107
110{
111 if (this != &orig)
112 {
113 std::swap(mField, orig.mField);
114 std::swap(mFieldLength, orig.mFieldLength);
115 std::swap(mMine, orig.mMine);
116 }
117 return *this;
118}
119
121{
122 if (mMine)
123 {
124 delete[] mField;
125 }
126}
127
129HeaderFieldValue::encode(EncodeStream& str) const
130{
131 str.write(mField, mFieldLength);
132 return str;
133}
134
136{
137 hfv.encode(stream);
138 return stream;
139}
140
141/* ====================================================================
142 * The Vovida Software License, Version 1.0
143 *
144 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
145 *
146 * Redistribution and use in source and binary forms, with or without
147 * modification, are permitted provided that the following conditions
148 * are met:
149 *
150 * 1. Redistributions of source code must retain the above copyright
151 * notice, this list of conditions and the following disclaimer.
152 *
153 * 2. Redistributions in binary form must reproduce the above copyright
154 * notice, this list of conditions and the following disclaimer in
155 * the documentation and/or other materials provided with the
156 * distribution.
157 *
158 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
159 * and "Vovida Open Communication Application Library (VOCAL)" must
160 * not be used to endorse or promote products derived from this
161 * software without prior written permission. For written
162 * permission, please contact vocal@vovida.org.
163 *
164 * 4. Products derived from this software may not be called "VOCAL", nor
165 * may "VOCAL" appear in their name, without prior written
166 * permission of Vovida Networks, Inc.
167 *
168 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
169 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
170 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
171 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
172 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
173 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
174 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
175 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
176 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
177 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
178 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
179 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
180 * DAMAGE.
181 *
182 * ====================================================================
183 *
184 * This software consists of voluntary contributions made by Vovida
185 * Networks, Inc. and many individuals on behalf of Vovida Networks,
186 * Inc. For more information on Vovida Networks, Inc., please see
187 * <http://www.vovida.org/>.
188 *
189 */
HeaderFieldValue & swap(HeaderFieldValue &orig)
EncodeStream & encode(EncodeStream &str) const
static const HeaderFieldValue Empty
HeaderFieldValue & copyWithPadding(const HeaderFieldValue &rhs)
HeaderFieldValue & operator=(const HeaderFieldValue &)
static char * allocateBuffer(size_t size)
dcm! – add UnusedChecking(_enum) below;
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)
#define EncodeStream