epoc32/include/wspencoder.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     2
// All rights reserved.
williamr@2
     3
// This component and the accompanying materials are made available
williamr@4
     4
// under the terms of "Eclipse Public License v1.0"
williamr@2
     5
// which accompanies this distribution, and is available
williamr@4
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@2
     7
//
williamr@2
     8
// Initial Contributors:
williamr@2
     9
// Nokia Corporation - initial contribution.
williamr@2
    10
//
williamr@2
    11
// Contributors:
williamr@2
    12
//
williamr@2
    13
// Description:
williamr@2
    14
//
williamr@2
    15
williamr@2
    16
/**
williamr@2
    17
 @file WSPEncoder.h
williamr@2
    18
 @publishedAll
williamr@4
    19
 @deprecated
williamr@2
    20
*/
williamr@2
    21
williamr@2
    22
#ifndef __WSPENCODER_H__
williamr@2
    23
#define __WSPENCODER_H__
williamr@2
    24
williamr@2
    25
#include <e32base.h>
williamr@2
    26
#include <f32file.h>		// RFs
williamr@2
    27
#include <badesca.h>		// arrays etc.
williamr@2
    28
#include <stringpool.h>
williamr@2
    29
williamr@2
    30
/**
williamr@2
    31
enum CodecPanic
williamr@2
    32
@publishedAll
williamr@4
    33
@deprecated
williamr@2
    34
*/
williamr@2
    35
enum TWspCodecPanic
williamr@2
    36
	{
williamr@2
    37
	/**  Due to failure to call StartValueLength function */
williamr@2
    38
	EWspCodecPanicStartValueLengthNotCalled=0,
williamr@2
    39
	/** Due to failure to call EndValueLength matching a call to StartValueLength */
williamr@2
    40
	EWspCodecPanicEndValueLengthNotCalled,
williamr@2
    41
	/** Due to failure to call StartHeaderL function */
williamr@2
    42
	EWspCodecPanicStartHeaderLNotCalled,
williamr@2
    43
	/** Due to StartHeaderL function being called twice without EndHeaderL */
williamr@2
    44
	EWspCodecPanicStartHeaderCalledTwice,
williamr@2
    45
	/** Due to parameter Token not having the top bit set */
williamr@2
    46
	EWspCodecPanicInvalidToken
williamr@2
    47
	};
williamr@2
    48
 
williamr@2
    49
/** 
williamr@2
    50
This class can be used to encode one header field at a time,
williamr@2
    51
with all its values and parameters.
williamr@2
    52
williamr@2
    53
It has no knowledge of encoding the BNF of a particular header field, but
williamr@2
    54
the functions provided can be used in combination, producing an 8-bit buffer 
williamr@2
    55
containing the encoded header.
williamr@2
    56
williamr@2
    57
Intended usage would be to call a series of functions. The first one being StartHeader,
williamr@2
    58
The final one being EndHeader, which would return a buffer containing 
williamr@2
    59
the complete encoded header field.
williamr@2
    60
eg:
williamr@2
    61
	encoder->StartHeaderL();
williamr@2
    62
	encoder->AddLongIntL();
williamr@2
    63
	encoder->AddTextStringL();
williamr@2
    64
	HBufC8* output = encoder->EndHeaderL();
williamr@2
    65
@publishedAll
williamr@4
    66
@deprecated
williamr@2
    67
*/
williamr@2
    68
class CWspHeaderEncoder : public CBase
williamr@2
    69
	{
williamr@2
    70
public:
williamr@2
    71
	IMPORT_C static CWspHeaderEncoder* NewL();
williamr@2
    72
williamr@2
    73
	IMPORT_C static CWspHeaderEncoder* NewLC();
williamr@2
    74
williamr@2
    75
williamr@2
    76
    IMPORT_C virtual ~CWspHeaderEncoder(); 
williamr@2
    77
williamr@2
    78
	IMPORT_C void StartHeaderL(TUint8 aToken);	
williamr@2
    79
williamr@2
    80
williamr@2
    81
	IMPORT_C void StartHeaderL(const TDesC8& aString);	
williamr@2
    82
williamr@2
    83
	IMPORT_C void StartHeaderL(const RStringF aString);	
williamr@2
    84
williamr@2
    85
williamr@2
    86
	IMPORT_C HBufC8* EndHeaderL();
williamr@2
    87
williamr@2
    88
williamr@2
    89
williamr@2
    90
	IMPORT_C void AddIntegerL(const TUint aInt);
williamr@2
    91
williamr@2
    92
	
williamr@2
    93
	IMPORT_C void AddShortIntL(const TUint8 aValue);
williamr@2
    94
williamr@2
    95
	IMPORT_C void AddShortLengthL(const TUint8 aValue);
williamr@2
    96
williamr@2
    97
williamr@2
    98
	IMPORT_C void AddLongIntL(const TUint32 aValue);
williamr@2
    99
	
williamr@2
   100
	
williamr@2
   101
	IMPORT_C void AddUintVarL(const TUint aInt);
williamr@2
   102
williamr@2
   103
	
williamr@2
   104
	IMPORT_C void AddTextStringL(const RString& aText);
williamr@2
   105
williamr@2
   106
	IMPORT_C void AddTextStringL(const TDesC8& aText);
williamr@2
   107
williamr@2
   108
	IMPORT_C void AddDateL(const TDateTime aDate);
williamr@2
   109
williamr@2
   110
	IMPORT_C void AddTokenL(const TUint8 aToken);
williamr@2
   111
williamr@2
   112
	IMPORT_C void AddTokenTextL(const TDesC8& aTokenText);
williamr@2
   113
williamr@2
   114
	IMPORT_C void AddDataL(const TDesC8& aData);
williamr@2
   115
williamr@2
   116
williamr@2
   117
williamr@2
   118
	IMPORT_C void StartValueLengthL();
williamr@2
   119
williamr@2
   120
	IMPORT_C void EndValueLengthL();
williamr@2
   121
williamr@2
   122
private:
williamr@2
   123
williamr@2
   124
	CWspHeaderEncoder();
williamr@2
   125
williamr@2
   126
	void Init();
williamr@2
   127
williamr@2
   128
williamr@2
   129
	void ConstructL();
williamr@2
   130
williamr@2
   131
private:
williamr@2
   132
	/**
williamr@2
   133
	Array for storing the partial encoded header.
williamr@2
   134
	Each time StartValueLength is called a new array
williamr@2
   135
	element is used. When EndValueLength is called,
williamr@2
   136
	the array is decremented, data from the last 
williamr@2
   137
	element being added to the one before.
williamr@2
   138
	*/
williamr@2
   139
	RPointerArray<CDesC8Array> iArray;
williamr@2
   140
williamr@2
   141
	/**
williamr@2
   142
	Value incremented as the encoded header increases in size.
williamr@2
   143
	Used to allocate the buffer for storing the final	
williamr@2
   144
	encoded header, output when EndHeader is called.
williamr@2
   145
	*/
williamr@2
   146
	TInt iTotalLength;
williamr@2
   147
	};
williamr@2
   148
williamr@2
   149
/** 
williamr@2
   150
Class encapsulating primitive encoding methods which are defined in the WSP standard.
williamr@2
   151
Input will be encoded and returned in an 8 bit buffer.
williamr@2
   152
@publishedAll
williamr@4
   153
@deprecated
williamr@2
   154
*/
williamr@2
   155
class TWspPrimitiveEncoder
williamr@2
   156
	{
williamr@2
   157
public:
williamr@2
   158
	IMPORT_C static TUint8  ShortInt(const TUint8 aValue);
williamr@2
   159
williamr@2
   160
	IMPORT_C static HBufC8* LongIntL(const TUint32 aValue);
williamr@2
   161
williamr@2
   162
	IMPORT_C static HBufC8* UintVarL(const TUint32 aInt);
williamr@2
   163
williamr@2
   164
	IMPORT_C static HBufC8* TextStringL(const RString aText);
williamr@2
   165
williamr@2
   166
	IMPORT_C static HBufC8* TextStringL(const TDesC8& aText);
williamr@2
   167
williamr@2
   168
	IMPORT_C static HBufC8* DateL(const TDateTime aDate);
williamr@2
   169
	};
williamr@2
   170
williamr@2
   171
#endif	// __WSPENCODER_H__