/src/resiprocate/resip/stack/HeaderFieldValue.hxx
Line | Count | Source (jump to first uncovered line) |
1 | | #if !defined(RESIP_HEADERFIELDVALUE_HXX) |
2 | | #define RESIP_HEADERFIELDVALUE_HXX |
3 | | |
4 | | #include "rutil/ParseException.hxx" |
5 | | #include "rutil/Data.hxx" |
6 | | #include "resip/stack/ParameterTypes.hxx" |
7 | | |
8 | | #include <iosfwd> |
9 | | |
10 | | namespace resip |
11 | | { |
12 | | |
13 | | class ParserCategory; |
14 | | class UnknownParameter; |
15 | | class ParseBuffer; |
16 | | |
17 | | /** |
18 | | @internal |
19 | | */ |
20 | | class HeaderFieldValue |
21 | | { |
22 | | public: |
23 | | static const HeaderFieldValue Empty; |
24 | | |
25 | | enum CopyPaddingEnum |
26 | | { |
27 | | CopyPadding |
28 | | }; |
29 | | |
30 | | enum NoOwnershipEnum |
31 | | { |
32 | | NoOwnership |
33 | | }; |
34 | | |
35 | | HeaderFieldValue() |
36 | 41.6k | : mField(0), //this must be initialized to 0 or ParserCategory will parse |
37 | 41.6k | mFieldLength(0), |
38 | 41.6k | mMine(false) |
39 | 41.6k | {} |
40 | | HeaderFieldValue(const char* field, size_t fieldLength); |
41 | | HeaderFieldValue(const HeaderFieldValue& hfv); |
42 | | HeaderFieldValue(const HeaderFieldValue& hfv, CopyPaddingEnum); |
43 | | HeaderFieldValue(const HeaderFieldValue& hfv, NoOwnershipEnum); |
44 | | HeaderFieldValue& operator=(const HeaderFieldValue&); |
45 | | HeaderFieldValue& copyWithPadding(const HeaderFieldValue& rhs); |
46 | | HeaderFieldValue& swap(HeaderFieldValue& orig); |
47 | | |
48 | | ~HeaderFieldValue(); |
49 | | |
50 | | EncodeStream& encode(EncodeStream& str) const; |
51 | | |
52 | | inline void init(const char* field, size_t length, bool own) |
53 | 926k | { |
54 | 926k | if(mMine) |
55 | 904k | { |
56 | 904k | delete [] mField; |
57 | 904k | } |
58 | | |
59 | 926k | mField=field; |
60 | 926k | mFieldLength=(unsigned int)length; |
61 | 926k | mMine=own; |
62 | 926k | } |
63 | | |
64 | 302k | inline const char* getBuffer() const {return mField;} |
65 | 151k | inline size_t getLength() const {return mFieldLength;} |
66 | | inline void clear() |
67 | 463k | { |
68 | 463k | if (mMine) |
69 | 75.4k | { |
70 | 75.4k | delete[] mField; |
71 | 75.4k | mMine=false; |
72 | 75.4k | } |
73 | 463k | mField=0; |
74 | 463k | mFieldLength=0; |
75 | 463k | } |
76 | | |
77 | | // const because Data::Share implies read-only access |
78 | | void toShareData(Data& data) const |
79 | 0 | { |
80 | 0 | data.setBuf(Data::Share, mField, mFieldLength); |
81 | 0 | } |
82 | | |
83 | | // not const because Data::Borrow implies read/write access |
84 | | void toBorrowData(Data& data) |
85 | 0 | { |
86 | 0 | data.setBuf(Data::Borrow, mField, mFieldLength); |
87 | 0 | } |
88 | | |
89 | | private: |
90 | | |
91 | | const char* mField; |
92 | | size_t mFieldLength; |
93 | | bool mMine; |
94 | | |
95 | | friend EncodeStream& operator<<(EncodeStream&, HeaderFieldValue&); |
96 | | }; |
97 | | |
98 | | EncodeStream& operator<<(EncodeStream& stream, HeaderFieldValue& hList); |
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 | | */ |