|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef NcdPROTOCOLUTILS_H |
|
20 #define NcdPROTOCOLUTILS_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include "ncdprotocoltypes.h" |
|
24 |
|
25 class NcdProtocolUtils |
|
26 { |
|
27 public: |
|
28 static void AssignEmptyDesL( HBufC16*& aDes ); |
|
29 static void AssignEmptyDesL( HBufC8*& aDes ); |
|
30 static void AssignDesL( HBufC16*& aDes, const TDesC16& aSource ); |
|
31 // Does UTF8->unicode conversion: |
|
32 static void AssignDesL( HBufC16*& aDes, const TDesC8& aSource ); |
|
33 static void AssignDesL( HBufC8*& aDes, const TDesC8& aSource ); |
|
34 static HBufC16* ConvertUtf8ToUnicodeL( const TDesC8& aUtfText ); |
|
35 static HBufC16* ConvertUtf8ToUnicodeLC( const TDesC8& aUtfText ); |
|
36 static HBufC8* ConvertUnicodeToUtf8L( const TDesC16& aUnicodeText ); |
|
37 static TBool IsWhitespace( const TDesC8& aUtfText ); |
|
38 static TInt DesDecToIntL( const TDesC8& aDes ); |
|
39 static TInt DesDecToIntL( const TDesC16& aDes ); |
|
40 static TInt DesDecToInt( const TDesC8& aDes, TInt& aValue ); |
|
41 static TInt DesDecToInt( const TDesC16& aDes, TInt& aValue ); |
|
42 |
|
43 static TReal32 DesDecToRealL( const TDesC8& aDes ); |
|
44 |
|
45 static void DesToBool( TBool& aBool, const TDesC8& aDes ); |
|
46 static void DesToBool( TBool& aBool, const TDesC16& aDes ); |
|
47 static void DesToNcdBool( TNcdBool& aBool, const TDesC8& aDes ); |
|
48 static void DesToNcdBool( TNcdBool& aBool, const TDesC16& aDes ); |
|
49 /** |
|
50 * Parses xs:dateTime. If KNullDesC8 parameter is given, |
|
51 * the returned TTime value will be zero. Malformed input |
|
52 * will cause a leave. |
|
53 * @param aDes xs:dateTime format string |
|
54 */ |
|
55 // static TTime TimeStampL( const TDesC8& aDes ); |
|
56 |
|
57 static void BoolToStringL(TXmlEngString& aString, const TBool aValue); |
|
58 static void NcdBoolToStringL(TXmlEngString& aString, const TNcdBool aValue); |
|
59 static const TDesC8& BoolToDes( TBool aValue ); |
|
60 static const TDesC8& NcdBoolToDes( TNcdBool aValue ); |
|
61 static void DesToStringL(TXmlEngString& aString, const TDesC& aValue); |
|
62 static void DesToStringL(TXmlEngString& aString, const TDesC8& aValue); |
|
63 static void IntToStringL(TXmlEngString& aString, TInt aValue); |
|
64 |
|
65 static void NewAttributeL( |
|
66 TXmlEngElement& aParent, const TDesC8& aKey, const TDesC8& aValue); |
|
67 static void NewAttributeL( |
|
68 TXmlEngElement& aParent, const TDesC8& aKey, const TDesC& aValue); |
|
69 static void NewBoolAttributeL( |
|
70 TXmlEngElement& aParent, const TDesC8& aKey, const TBool aValue); |
|
71 static void NewNcdBoolAttributeL( |
|
72 TXmlEngElement& aParent, const TDesC8& aKey, const TNcdBool aValue); |
|
73 static void NewAttributeL( |
|
74 TXmlEngElement& aParent, const TDesC8& aKey, const TInt aValue); |
|
75 static void NewAttributeL( |
|
76 TXmlEngElement& aParent, const TDesC8& aKey, const TXmlEngString& aValue); |
|
77 |
|
78 static TXmlEngElement NewElementL( RXmlEngDocument& aDocument, |
|
79 TXmlEngElement& aParent, const TDesC8& aName, const TXmlEngString& aPrefix); |
|
80 static TXmlEngElement NewElementL( RXmlEngDocument& aDocument, |
|
81 TXmlEngElement& aParent, const TDesC8& aName, |
|
82 const TDesC8& aPrefix = KNullDesC8); |
|
83 |
|
84 static TXmlEngElement NewElementL( |
|
85 RXmlEngDocument& aDocument, const TDesC8& aName, const TXmlEngString& aPrefix); |
|
86 static TXmlEngElement NewElementL( |
|
87 RXmlEngDocument& aDocument, const TDesC8& aName, |
|
88 const TDesC8& aPrefix = KNullDesC8); |
|
89 /** |
|
90 * Decodes base64 encoded data into a descriptor. |
|
91 * @param Base64 data |
|
92 * @return HBufC8* Decoded data |
|
93 */ |
|
94 static HBufC8* DecodeBase64L( const TDesC8& aData ); |
|
95 /** |
|
96 * Decodes base64 encoded data into a descriptor. |
|
97 * @param Base64 data |
|
98 * @return HBufC8* Decoded data |
|
99 */ |
|
100 static HBufC8* DecodeBase64LC( const TDesC8& aData ); |
|
101 |
|
102 static TTime DesToTimeL(const TDesC8& aDes); |
|
103 static TTime DesToTimeL(const TDesC16& aDes); |
|
104 static void TimeToDesL(const TTime aTime, HBufC16*& aDes); |
|
105 |
|
106 private: |
|
107 NcdProtocolUtils(); |
|
108 ~NcdProtocolUtils(); |
|
109 |
|
110 /** |
|
111 * Decodes data. |
|
112 * @param aData Input buffer |
|
113 * @param aOutput Output buffer |
|
114 * @param aCalculateLength ETrue to only calculate decoded length |
|
115 * @return TInt Decoded length |
|
116 */ |
|
117 static TInt DecodeBase64L( const TDesC8& aData, |
|
118 TDes8& aOutput, |
|
119 TBool aCalculateLength ); |
|
120 /** |
|
121 * Decodes a character |
|
122 * @param c |
|
123 * @return TInt |
|
124 */ |
|
125 static TInt DecodeBase64L( TInt c ); |
|
126 |
|
127 }; |
|
128 |
|
129 #endif |