reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
HeaderFieldValue.hxx
Go to the documentation of this file.
1#if !defined(RESIP_HEADERFIELDVALUE_HXX)
2#define RESIP_HEADERFIELDVALUE_HXX
3
5#include "rutil/Data.hxx"
7
8#include <iosfwd>
9
10namespace resip
11{
12
13class ParserCategory;
14class UnknownParameter;
15class ParseBuffer;
16
21{
22 public:
23 static const HeaderFieldValue Empty;
24
29
34
36 : mField(0), //this must be initialized to 0 or ParserCategory will parse
37 mFieldLength(0),
38 mMine(false)
39 {}
40 HeaderFieldValue(const char* field, size_t fieldLength);
47
49
50 EncodeStream& encode(EncodeStream& str) const;
51
52 inline void init(const char* field, size_t length, bool own)
53 {
54 if(mMine)
55 {
56 delete [] mField;
57 }
58
59 mField=field;
60 mFieldLength=(unsigned int)length;
61 mMine=own;
62 }
63
64 inline const char* getBuffer() const {return mField;}
65 inline size_t getLength() const {return mFieldLength;}
66 inline void clear()
67 {
68 if (mMine)
69 {
70 delete[] mField;
71 mMine=false;
72 }
73 mField=0;
74 mFieldLength=0;
75 }
76
77 // const because Data::Share implies read-only access
78 void toShareData(Data& data) const
79 {
80 data.setBuf(Data::Share, mField, mFieldLength);
81 }
82
83 // not const because Data::Borrow implies read/write access
84 void toBorrowData(Data& data)
85 {
86 data.setBuf(Data::Borrow, mField, mFieldLength);
87 }
88
89 private:
90
91 const char* mField;
92 size_t mFieldLength;
93 bool mMine;
94
96};
97
99
100}
101
102#endif
103
104/* ====================================================================
105 * The Vovida Software License, Version 1.0
106 *
107 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
108 *
109 * Redistribution and use in source and binary forms, with or without
110 * modification, are permitted provided that the following conditions
111 * are met:
112 *
113 * 1. Redistributions of source code must retain the above copyright
114 * notice, this list of conditions and the following disclaimer.
115 *
116 * 2. Redistributions in binary form must reproduce the above copyright
117 * notice, this list of conditions and the following disclaimer in
118 * the documentation and/or other materials provided with the
119 * distribution.
120 *
121 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
122 * and "Vovida Open Communication Application Library (VOCAL)" must
123 * not be used to endorse or promote products derived from this
124 * software without prior written permission. For written
125 * permission, please contact vocal@vovida.org.
126 *
127 * 4. Products derived from this software may not be called "VOCAL", nor
128 * may "VOCAL" appear in their name, without prior written
129 * permission of Vovida Networks, Inc.
130 *
131 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
132 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
133 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
134 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
135 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
136 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
137 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
138 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
139 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
140 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
141 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
142 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
143 * DAMAGE.
144 *
145 * ====================================================================
146 *
147 * This software consists of voluntary contributions made by Vovida
148 * Networks, Inc. and many individuals on behalf of Vovida Networks,
149 * Inc. For more information on Vovida Networks, Inc., please see
150 * <http://www.vovida.org/>.
151 *
152 * set shiftwidth=3 expandtab:
153 */
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
Definition Data.hxx:90
@ Share
The Data instance will use the buffer in a read-only mode.
Definition Data.hxx:266
@ Borrow
The Data instance is borrowing the memory from the passed in buffer.
Definition Data.hxx:260
Data & setBuf(ShareEnum se, const char *buf, size_type length)
Set the Data to hold {buf} using share type {se}, which may be any of Share (read-only,...
Definition Data.cxx:627
HeaderFieldValue & swap(HeaderFieldValue &orig)
EncodeStream & encode(EncodeStream &str) const
const char * getBuffer() const
static const HeaderFieldValue Empty
void toBorrowData(Data &data)
friend EncodeStream & operator<<(EncodeStream &, HeaderFieldValue &)
void init(const char *field, size_t length, bool own)
HeaderFieldValue & copyWithPadding(const HeaderFieldValue &rhs)
void toShareData(Data &data) const
HeaderFieldValue & operator=(const HeaderFieldValue &)
dcm! – add UnusedChecking(_enum) below;
EncodeStream & operator<<(EncodeStream &strm, const BaseException &e)
#define EncodeStream