1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericservices/httputils/inc/WSPDecoder.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,244 @@
1.4 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +/**
1.20 + @file WSPDecoder.h
1.21 + @publishedAll
1.22 + @deprecated
1.23 +*/
1.24 +
1.25 +#ifndef __WSPDECODER_H__
1.26 +#define __WSPDECODER_H__
1.27 +
1.28 +#include <e32base.h>
1.29 +#include <stringpool.h>
1.30 +
1.31 +
1.32 +/**
1.33 +* This file contains the following classes:
1.34 +* TWspField
1.35 +* TWspHeaderSegmenter
1.36 +* TWspPrimitiveDecoder
1.37 +*
1.38 +*/
1.39 +
1.40 +
1.41 +/**
1.42 +enum DecoderPanic
1.43 +@publishedAll
1.44 +@deprecated
1.45 +*/
1.46 +enum TWspDecoderPanic
1.47 + {
1.48 + /**
1.49 + LongIntOverflow
1.50 + */
1.51 + EWspDecoderLongIntOverflow,
1.52 + /**
1.53 + DateOverflow
1.54 + */
1.55 + EWspDecoderDateOverflow
1.56 + };
1.57 +
1.58 +/**
1.59 +TWspField class holds the pair <HeaderName, ValueBuffer>
1.60 +This is a simple class that associates these values.
1.61 +No ownership is handed to this class. It is up to user of this class to
1.62 +open and close all resources used.
1.63 +@publishedAll
1.64 +@deprecated
1.65 +*/
1.66 +class TWspField
1.67 + {
1.68 +public:
1.69 +
1.70 + inline TWspField();
1.71 +
1.72 + inline TWspField(RStringF aHdrName, TPtrC8 aValBuf);
1.73 +
1.74 + /**
1.75 + The header name of a opened RStringF - *Not Owned*
1.76 + This is externally opened. It must be externally
1.77 + closed.
1.78 + */
1.79 + RStringF iHdrName;
1.80 +
1.81 + /** The raw value buffer - Note: Not owned by this */
1.82 + TPtrC8 iValBuffer;
1.83 + };
1.84 +
1.85 +/**
1.86 +TWspHeaderSegmenter segments a WSP buffer into WSP header/value pairs.
1.87 +It detects boundaries between header/values based on the WAP-WSP spec.
1.88 + - To construct, buffer and string pool is passed in
1.89 + - Call to NextL() to iterate through the buffer - this returns a TWspField
1.90 + - NextL() returns KErrNotFound when done
1.91 +
1.92 +@publishedAll
1.93 +@deprecated
1.94 +*/
1.95 +class TWspHeaderSegmenter
1.96 + {
1.97 +public:
1.98 +
1.99 + inline TWspHeaderSegmenter(RStringPool aPool, const TStringTable& aStringTable, TPtrC8 aBuffer);
1.100 +
1.101 + IMPORT_C TInt NextL(TWspField& aWspHeader);
1.102 +
1.103 + inline TInt Offset() const;
1.104 +
1.105 +private:
1.106 + /** Raw buffer that will be segmented - Not Owned */
1.107 + TPtrC8 iBuffer;
1.108 +
1.109 + /** Segment offset into the buffer. */
1.110 + TInt iOffset;
1.111 +
1.112 + /** Opened string pool to use with the string table already loaded - Not Owned */
1.113 + RStringPool iPool;
1.114 +
1.115 + /** The string table to use in the string pool - Not Owned */
1.116 + const TStringTable& iStringTable;
1.117 + };
1.118 +
1.119 +/**
1.120 +Decoder for WSP Primitves - WAP-WSP Section 8.4.1
1.121 +@publishedAll
1.122 +@deprecated
1.123 +*/
1.124 +class TWspPrimitiveDecoder
1.125 + {
1.126 + public:
1.127 +
1.128 + /**
1.129 + * TWspHeaderType describe the types from WAP-WSP Section 8.4.1.2
1.130 + */
1.131 + enum TWspHeaderType
1.132 + {
1.133 + /**
1.134 + The type has not been set
1.135 + */
1.136 + ENotSet,
1.137 + /**
1.138 + 0-31 - octet is a value length
1.139 + */
1.140 + ELengthVal,
1.141 + /**
1.142 + 34 - value is a quoted text string, terminated by a Null
1.143 + */
1.144 + EQuotedString,
1.145 + /**
1.146 + 32-127 - value is a text string, terminated by a Null
1.147 + */
1.148 + EString,
1.149 + /**
1.150 + 128-255 - encoded 7 bit value, this header has no more data
1.151 + */
1.152 + E7BitVal
1.153 + };
1.154 +
1.155 +
1.156 + inline TWspPrimitiveDecoder(TPtrC8 aBuffer);
1.157 +
1.158 + IMPORT_C TWspHeaderType VarType() const;
1.159 +
1.160 + IMPORT_C TInt LengthVal(TInt& aVal);
1.161 +
1.162 + IMPORT_C TInt String(TPtrC8& aString);
1.163 +
1.164 +
1.165 + IMPORT_C TInt Val7Bit(TUint8& aVal);
1.166 +
1.167 + IMPORT_C TInt Integer(TUint32& aVal);
1.168 +
1.169 + IMPORT_C TInt LongInt(TUint32& aVal);
1.170 +
1.171 + IMPORT_C TInt UintVar(TUint32& aVal);
1.172 +
1.173 + IMPORT_C TInt VersionL(RStringPool aPool, RStringF& aVer);
1.174 +
1.175 + IMPORT_C TInt Date(TDateTime& aDateTime);
1.176 +
1.177 + private:
1.178 + /** The raw buffer */
1.179 + TPtrC8 iBuffer;
1.180 +
1.181 + /** The current offset */
1.182 + TInt iOffset;
1.183 + };
1.184 +
1.185 +/**
1.186 + Constructor
1.187 +
1.188 + */
1.189 +inline TWspField::TWspField()
1.190 + {
1.191 + }
1.192 +
1.193 +/**
1.194 + Constructor
1.195 +
1.196 + @param aHdrName In - The Header Name. This must be an opened RStringF
1.197 + @param aValBuf In - the Buffer containing the header value in its raw format
1.198 +*/
1.199 +inline TWspField::TWspField(RStringF aHdrName, TPtrC8 aValBuf) :
1.200 + iHdrName(aHdrName),
1.201 + iValBuffer(aValBuf)
1.202 + {
1.203 + }
1.204 +
1.205 +/**
1.206 + Constructor
1.207 +
1.208 + @param aPool In - an opened RStringPool - owned by the caller
1.209 + @param aStringTable In - the string table in the string pool to use
1.210 + @param aBuffer In - the buffer containing the WSP header data - owned by the caller
1.211 + @pre The string table must be opened with the WSP Sting constants table
1.212 +*/
1.213 +inline TWspHeaderSegmenter::TWspHeaderSegmenter(RStringPool aPool, const TStringTable& aStringTable, TPtrC8 aBuffer) :
1.214 + iBuffer(aBuffer),
1.215 + iOffset(0),
1.216 + iPool(aPool),
1.217 + iStringTable(aStringTable)
1.218 + {
1.219 + }
1.220 +
1.221 +/**
1.222 + Offset returns the current offset into the buffer being parsed.
1.223 +
1.224 + @return TInt offset value. It will point to beginning of next segmented field.
1.225 + If NextL has not been called it will be set to 0. The beginning of the buffer.
1.226 + If buffer has been completely parsed, will return KErrNotFound.
1.227 +*/
1.228 +inline TInt TWspHeaderSegmenter::Offset() const
1.229 + {
1.230 + return (iOffset < iBuffer.Length()) ? iOffset : KErrNotFound;
1.231 + }
1.232 +
1.233 +/**
1.234 + Constructor
1.235 +
1.236 + @param aBuffer In - the buffer containing the value in its raw format
1.237 +*/
1.238 +inline TWspPrimitiveDecoder::TWspPrimitiveDecoder(TPtrC8 aBuffer) :
1.239 + iBuffer(aBuffer),
1.240 + iOffset(0)
1.241 + {
1.242 + }
1.243 +
1.244 +
1.245 +#endif // __WSPDECODER_H__
1.246 +
1.247 +