Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
20 @warning : This file contains Rose Model ID comments - please do not delete
23 #ifndef __THTTPHDRVAL_H__
24 #define __THTTPHDRVAL_H__
28 #include <stringpool.h>
31 //##ModelId=3C4C187E027A
34 A representation of a value found in an HTTP header field. Three
35 fundamental types are used in HTTP - integers, strings (which may
36 be free text, 'enumeration values', URIs, etc. or date/times.
38 The class allows any of the three values to be held and the current
39 value (as well as its type) to be determined.
41 THTTPHdrVal instances are used to assign values to header fields, their
42 parts and their associated parameters.
53 KTIntVal = 0x00, /**< the value is an integer*/
54 KStrVal = 0x01, /**< the value is a case-sensitive string*/
55 KDateVal = 0x02, /**< the value is a date/time*/
56 KStrFVal = 0x03, /**< the value is a case-insensitive string*/
57 KNoType = 0x04 /**< no value has yet been set*/
62 // A converter for 'q' parameter values; apparently real numbers in the HTTP RFC but here passed as fixed point
63 //##ModelId=3B1E66F2024E
67 /// Construct from a real number representation of 'q'
68 //##ModelId=3B1E66F20282
71 /// Construct from a fixed-point representation of 'q'
72 //##ModelId=3B1E66F2028C
75 /// Integer cast operator to get the fixed-point representation
76 //##ModelId=3B1E66F20281
77 operator TInt() const;
79 /// TReal cast operator to get the real number representation
80 //##ModelId=3B1E66F20280
81 operator TReal() const;
83 /// The real number q-value
84 //##ModelId=3B1E66F2027A
86 /// The integer fixed-point q-value representation
87 //##ModelId=3B1E66F2026E
92 /** Default constructor
93 Used when constructing an empty header value that is to be filled in by
94 a call to a function. e.g. RHTTPHeaders::GetField
96 IMPORT_C THTTPHdrVal();
98 /** Constructor for an integer field value
99 @param aIntVal The integer value
101 IMPORT_C THTTPHdrVal(TInt aIntVal);
103 /** Constructor for an string value
104 @param aStrVal The string value
106 IMPORT_C THTTPHdrVal(RStringF aStrVal);
107 /** Constructor for an string value
108 @param aStrVal The string value
110 IMPORT_C THTTPHdrVal(RString aStrVal);
112 /** Constructor for an date/time value
113 @param aDateVal The date/time value
115 IMPORT_C THTTPHdrVal(TDateTime aDateVal);
117 /** Obtain a copy of this header value. This is critical when the header contains a string, since
118 a new string reference must be created
119 @return The copied header value
121 //##ModelId=3C4C187E02F3
122 IMPORT_C THTTPHdrVal Copy() const;
124 /** Determine the type of this header field value
125 @return A THTTPValType enumeration describing the value's type
127 //##ModelId=3C4C187E02F2
128 IMPORT_C THTTPValType Type() const;
130 /** Obtain the (integer) value held within
131 Panics if the value is of the wring type
132 @pre Requires that the object was previously set to hold a TInt
133 @return An integer value
135 //##ModelId=3C4C187E02EA
136 IMPORT_C TInt Int() const;
138 /** Cast operator to obtain the HTTP value as an integer.
139 Note this doesn't convert from a different form to integer!
140 Panics if the value is of the wrong type
141 @pre Requires that the object was previously set to hold a TInt
143 //##ModelId=3C4C187E02E9
144 inline operator TInt() const;
146 /** Obtain the (string) value held within
147 Panics if the value is of the wring type
148 @pre Requires that the object was previously set to hold a string
151 //##ModelId=3C4C187E02E8
152 IMPORT_C RStringF StrF() const;
153 //##ModelId=3C4C187E02E0
154 IMPORT_C RString Str() const;
156 /** Cast operator to obtain the HTTP value as a string.
157 Note this doesn't convert from a different form to string!
158 Panics if the value is of the wring type
159 @pre Requires that the object was previously set to hold a string
161 //##ModelId=3C4C187E02DF
162 inline operator RStringF() const;
163 /** Cast operator to obtain the HTTP value as a string.
164 Note this doesn't convert from a different form to string!
165 Panics if the value is of the wring type
166 @pre Requires that the object was previously set to hold a string
168 //##ModelId=3C4C187E02DE
169 inline operator RString() const;
171 /** Obtain the (date/time) value held within.
172 Panics if the value is of the wrong type
173 @pre Requires that the object was previously set to hold a TDateTime
174 @return An date/time value
176 //##ModelId=3C4C187E02D6
177 IMPORT_C TDateTime DateTime() const;
179 /** Cast operator to obtain the HTTP value as an date/time.
180 Note this doesn't convert from a different form to date!
181 Panics if the value is of the wring type
182 @pre Requires that the object was previously set to hold a TDateTime
184 //##ModelId=3C4C187E02D5
185 inline operator TDateTime() const;
187 /** Set the header value to be the supplied integer.
188 @warning Any previous value, or its type, are lost.
189 @param aIntVal The integer value
191 //##ModelId=3C4C187E02CC
192 IMPORT_C void SetInt(TInt aIntVal);
194 /** Set the header value to be the supplied string.
195 @warning Any previous value, or its type, are lost.
196 @param aStrVal The string value
198 //##ModelId=3C4C187E02CA
199 IMPORT_C void SetStrF(RStringF aStrVal);
200 /** Set the header value to be the supplied string. Any previous
201 value, or its type, are lost.
202 @param aStrVal The string value */
203 //##ModelId=3C4C187E02C2
204 IMPORT_C void SetStr(RString aStrVal);
206 /** Set the header value to be the supplied date/time. Any previous value, or its type, are lost.
207 @param aDateVal The date/time value
209 //##ModelId=3C4C187E02C0
210 IMPORT_C void SetDateTime(TDateTime aDateVal);
212 /** Comparison operator. Does a comparison based on the current type.
213 @param aVal The header value to compare. */
214 //##ModelId=3C4C187E02B8
215 IMPORT_C TBool operator==(THTTPHdrVal aVal) const;
217 /** Comparison operator. Does a comparison based on the current type.
218 @param aVal The string to compare. */
219 //##ModelId=3C4C187E02B6
220 IMPORT_C TBool operator!=(THTTPHdrVal aVal) const;
226 //##ModelId=3C4C187E02AC
232 //##ModelId=3C4C187E02A4
234 //##ModelId=3C4C187E029A
238 inline THTTPHdrVal::TQConv::TQConv(TReal aQ)
239 : iQ(aQ), iFQ((TInt)(iQ*1000))
243 inline THTTPHdrVal::TQConv::TQConv(TInt aFQ)
244 : iQ((TReal)(aFQ/1000.)), iFQ(aFQ)
248 inline THTTPHdrVal::TQConv::operator TInt() const
253 inline THTTPHdrVal::TQConv::operator TReal() const
258 inline THTTPHdrVal::operator TInt() const
263 inline THTTPHdrVal::operator RStringF() const
268 inline THTTPHdrVal::operator RString() const
273 inline THTTPHdrVal::operator TDateTime() const
280 #endif // __THTTPHDRVAL_H__