1.1 --- a/epoc32/include/wspencoder.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/wspencoder.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,173 @@
1.4 -wspencoder.h
1.5 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// 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
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +
1.21 +
1.22 +/**
1.23 + @file WSPEncoder.h
1.24 + @publishedAll
1.25 + @released
1.26 +*/
1.27 +
1.28 +#ifndef __WSPENCODER_H__
1.29 +#define __WSPENCODER_H__
1.30 +
1.31 +#include <e32base.h>
1.32 +#include <f32file.h> // RFs
1.33 +#include <badesca.h> // arrays etc.
1.34 +#include <stringpool.h>
1.35 +
1.36 +/**
1.37 +enum CodecPanic
1.38 +@publishedAll
1.39 +@released
1.40 +*/
1.41 +enum TWspCodecPanic
1.42 + {
1.43 + /** Due to failure to call StartValueLength function */
1.44 + EWspCodecPanicStartValueLengthNotCalled=0,
1.45 + /** Due to failure to call EndValueLength matching a call to StartValueLength */
1.46 + EWspCodecPanicEndValueLengthNotCalled,
1.47 + /** Due to failure to call StartHeaderL function */
1.48 + EWspCodecPanicStartHeaderLNotCalled,
1.49 + /** Due to StartHeaderL function being called twice without EndHeaderL */
1.50 + EWspCodecPanicStartHeaderCalledTwice,
1.51 + /** Due to parameter Token not having the top bit set */
1.52 + EWspCodecPanicInvalidToken
1.53 + };
1.54 +
1.55 +/**
1.56 +This class can be used to encode one header field at a time,
1.57 +with all its values and parameters.
1.58 +
1.59 +It has no knowledge of encoding the BNF of a particular header field, but
1.60 +the functions provided can be used in combination, producing an 8-bit buffer
1.61 +containing the encoded header.
1.62 +
1.63 +Intended usage would be to call a series of functions. The first one being StartHeader,
1.64 +The final one being EndHeader, which would return a buffer containing
1.65 +the complete encoded header field.
1.66 +eg:
1.67 + encoder->StartHeaderL();
1.68 + encoder->AddLongIntL();
1.69 + encoder->AddTextStringL();
1.70 + HBufC8* output = encoder->EndHeaderL();
1.71 +@publishedAll
1.72 +@released
1.73 +*/
1.74 +class CWspHeaderEncoder : public CBase
1.75 + {
1.76 +public:
1.77 + IMPORT_C static CWspHeaderEncoder* NewL();
1.78 +
1.79 + IMPORT_C static CWspHeaderEncoder* NewLC();
1.80 +
1.81 +
1.82 + IMPORT_C virtual ~CWspHeaderEncoder();
1.83 +
1.84 + IMPORT_C void StartHeaderL(TUint8 aToken);
1.85 +
1.86 +
1.87 + IMPORT_C void StartHeaderL(const TDesC8& aString);
1.88 +
1.89 + IMPORT_C void StartHeaderL(const RStringF aString);
1.90 +
1.91 +
1.92 + IMPORT_C HBufC8* EndHeaderL();
1.93 +
1.94 +
1.95 +
1.96 + IMPORT_C void AddIntegerL(const TUint aInt);
1.97 +
1.98 +
1.99 + IMPORT_C void AddShortIntL(const TUint8 aValue);
1.100 +
1.101 + IMPORT_C void AddShortLengthL(const TUint8 aValue);
1.102 +
1.103 +
1.104 + IMPORT_C void AddLongIntL(const TUint32 aValue);
1.105 +
1.106 +
1.107 + IMPORT_C void AddUintVarL(const TUint aInt);
1.108 +
1.109 +
1.110 + IMPORT_C void AddTextStringL(const RString& aText);
1.111 +
1.112 + IMPORT_C void AddTextStringL(const TDesC8& aText);
1.113 +
1.114 + IMPORT_C void AddDateL(const TDateTime aDate);
1.115 +
1.116 + IMPORT_C void AddTokenL(const TUint8 aToken);
1.117 +
1.118 + IMPORT_C void AddTokenTextL(const TDesC8& aTokenText);
1.119 +
1.120 + IMPORT_C void AddDataL(const TDesC8& aData);
1.121 +
1.122 +
1.123 +
1.124 + IMPORT_C void StartValueLengthL();
1.125 +
1.126 + IMPORT_C void EndValueLengthL();
1.127 +
1.128 +private:
1.129 +
1.130 + CWspHeaderEncoder();
1.131 +
1.132 + void Init();
1.133 +
1.134 +
1.135 + void ConstructL();
1.136 +
1.137 +private:
1.138 + /**
1.139 + Array for storing the partial encoded header.
1.140 + Each time StartValueLength is called a new array
1.141 + element is used. When EndValueLength is called,
1.142 + the array is decremented, data from the last
1.143 + element being added to the one before.
1.144 + */
1.145 + RPointerArray<CDesC8Array> iArray;
1.146 +
1.147 + /**
1.148 + Value incremented as the encoded header increases in size.
1.149 + Used to allocate the buffer for storing the final
1.150 + encoded header, output when EndHeader is called.
1.151 + */
1.152 + TInt iTotalLength;
1.153 + };
1.154 +
1.155 +/**
1.156 +Class encapsulating primitive encoding methods which are defined in the WSP standard.
1.157 +Input will be encoded and returned in an 8 bit buffer.
1.158 +@publishedAll
1.159 +@released
1.160 +*/
1.161 +class TWspPrimitiveEncoder
1.162 + {
1.163 +public:
1.164 + IMPORT_C static TUint8 ShortInt(const TUint8 aValue);
1.165 +
1.166 + IMPORT_C static HBufC8* LongIntL(const TUint32 aValue);
1.167 +
1.168 + IMPORT_C static HBufC8* UintVarL(const TUint32 aInt);
1.169 +
1.170 + IMPORT_C static HBufC8* TextStringL(const RString aText);
1.171 +
1.172 + IMPORT_C static HBufC8* TextStringL(const TDesC8& aText);
1.173 +
1.174 + IMPORT_C static HBufC8* DateL(const TDateTime aDate);
1.175 + };
1.176 +
1.177 +#endif // __WSPENCODER_H__