sl@0
|
1 |
// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// File contains internal classes for Ascii To Base64 converison
|
sl@0
|
15 |
// and vice-versa.
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file TConvBase64.h
|
sl@0
|
21 |
@internalAll
|
sl@0
|
22 |
@released
|
sl@0
|
23 |
*/
|
sl@0
|
24 |
|
sl@0
|
25 |
#ifndef __TCONVBASE64_H__
|
sl@0
|
26 |
#define __TCONVBASE64_H__
|
sl@0
|
27 |
|
sl@0
|
28 |
#include <e32base.h>
|
sl@0
|
29 |
|
sl@0
|
30 |
|
sl@0
|
31 |
const TInt KMaxB64EncodedCharsPerLine = 60;
|
sl@0
|
32 |
// Could be increased to 75 characters for every encoded line if KDecodeLineLength = 675.
|
sl@0
|
33 |
// 60 was chosen to maintain existing behaviour.
|
sl@0
|
34 |
const TInt8 KImcvLookUpStartOffset = 43;
|
sl@0
|
35 |
const TUint8 KImcvConvEquals = '=';
|
sl@0
|
36 |
const TInt8 AsciiToBase64[80]=
|
sl@0
|
37 |
{
|
sl@0
|
38 |
62, -1, -1, -1, 63, 52, 53, 54, 55, 56,
|
sl@0
|
39 |
57, 58, 59, 60, 61, -1, -1, -1, 64, -1,
|
sl@0
|
40 |
-1, -1, 0, 1, 2, 3, 4, 5, 6, 7,
|
sl@0
|
41 |
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
|
sl@0
|
42 |
18, 19, 20, 21, 22, 23, 24, 25, -1, -1,
|
sl@0
|
43 |
-1, -1, -1, -1, 26, 27, 28, 29, 30, 31,
|
sl@0
|
44 |
32, 33, 34, 35, 36, 37, 38, 39, 40, 41,
|
sl@0
|
45 |
42, 43, 44, 45, 46, 47, 48, 49, 50, 51
|
sl@0
|
46 |
};
|
sl@0
|
47 |
const TInt8 Base64ToAscii[65]=
|
sl@0
|
48 |
{
|
sl@0
|
49 |
65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
|
sl@0
|
50 |
75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
|
sl@0
|
51 |
85, 86, 87, 88, 89, 90, 97, 98, 99,100,
|
sl@0
|
52 |
101,102,103,104,105,106,107,108,109,110,
|
sl@0
|
53 |
111,112,113,114,115,116,117,118,119,120,
|
sl@0
|
54 |
121,122, 48, 49, 50, 51, 52, 53, 54, 55,
|
sl@0
|
55 |
56, 57, 43, 47, 61
|
sl@0
|
56 |
};
|
sl@0
|
57 |
|
sl@0
|
58 |
/**
|
sl@0
|
59 |
Base64 encoding and decoding class.
|
sl@0
|
60 |
@internalAll
|
sl@0
|
61 |
@released
|
sl@0
|
62 |
*/
|
sl@0
|
63 |
class TBase64
|
sl@0
|
64 |
{
|
sl@0
|
65 |
private:
|
sl@0
|
66 |
/**
|
sl@0
|
67 |
enum base64 coding defines
|
sl@0
|
68 |
*/
|
sl@0
|
69 |
enum
|
sl@0
|
70 |
{
|
sl@0
|
71 |
/** Padding characters */
|
sl@0
|
72 |
EPadChar = 64
|
sl@0
|
73 |
};
|
sl@0
|
74 |
|
sl@0
|
75 |
/**
|
sl@0
|
76 |
enum for EMaskValues
|
sl@0
|
77 |
*/
|
sl@0
|
78 |
enum EMaskValues
|
sl@0
|
79 |
{
|
sl@0
|
80 |
/** Mask Six bits */
|
sl@0
|
81 |
ESixBitMask = 0x3F,
|
sl@0
|
82 |
/** Mask Eight bits */
|
sl@0
|
83 |
EEightBitMask = 0xFF
|
sl@0
|
84 |
};
|
sl@0
|
85 |
|
sl@0
|
86 |
/**
|
sl@0
|
87 |
enum for EMaskShiftValues
|
sl@0
|
88 |
*/
|
sl@0
|
89 |
enum EMaskShiftValues
|
sl@0
|
90 |
{
|
sl@0
|
91 |
/** enum for 6 */
|
sl@0
|
92 |
ESix = 6,
|
sl@0
|
93 |
/** enum for 4 */
|
sl@0
|
94 |
EFour = 4,
|
sl@0
|
95 |
/** enum for 2 */
|
sl@0
|
96 |
ETwo = 2,
|
sl@0
|
97 |
/** enum for 0 */
|
sl@0
|
98 |
EZero = 0
|
sl@0
|
99 |
};
|
sl@0
|
100 |
|
sl@0
|
101 |
public:
|
sl@0
|
102 |
IMPORT_C TBase64();
|
sl@0
|
103 |
IMPORT_C TInt Encode( const TDesC8& aSrcString, TDes8& rDestString);
|
sl@0
|
104 |
IMPORT_C TBool Decode( const TDesC8& aSrcString, TDes8& rDestString);
|
sl@0
|
105 |
IMPORT_C TInt PortableEncode(const TDesC8& aSrcString, TDes8& aDestString, TInt aLineLength=-1);
|
sl@0
|
106 |
private:
|
sl@0
|
107 |
|
sl@0
|
108 |
TInt iShiftStored;
|
sl@0
|
109 |
TInt iMaskShiftStored;
|
sl@0
|
110 |
};
|
sl@0
|
111 |
|
sl@0
|
112 |
#endif // __TCONVBASE64_H__
|