|
1 /* |
|
2 * ============================================================================== |
|
3 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 * All rights reserved. |
|
5 * This component and the accompanying materials are made available |
|
6 * under the terms of "Eclipse Public License v1.0" |
|
7 * which accompanies this distribution, and is available |
|
8 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 * |
|
10 * Initial Contributors: |
|
11 * Nokia Corporation - initial contribution. |
|
12 * |
|
13 * Contributors: |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 * ============================================================================== |
|
18 */ |
|
19 |
|
20 #ifndef UTILS_H_ |
|
21 #define UTILS_H_ |
|
22 |
|
23 // ------------------------------------------------------------------------------------------------ |
|
24 // Includes |
|
25 // ------------------------------------------------------------------------------------------------ |
|
26 #include "ConnMoAdapter.h" |
|
27 |
|
28 class TLuid; |
|
29 |
|
30 /** |
|
31 * Utilities class for ConnMo adapter needs |
|
32 * |
|
33 * Class contains useful helper functions etc. for parsing URI and TLuid |
|
34 */ |
|
35 class CUtils : public CBase |
|
36 { |
|
37 public: |
|
38 |
|
39 virtual ~CUtils(); |
|
40 |
|
41 /** |
|
42 * Returns first segment of URI. |
|
43 * |
|
44 * @param aUri URI to be searched. |
|
45 * @return First segment of URI. |
|
46 */ |
|
47 static TPtrC8 GetFirstURISeg( const TDesC8& aURI ); |
|
48 |
|
49 /** |
|
50 * Returns second segment of URI. |
|
51 * |
|
52 * @param aUri URI to be searched. |
|
53 * @return Second segment of URI. |
|
54 */ |
|
55 static TPtrC8 GetSecondURISeg( const TDesC8& aURI ); |
|
56 |
|
57 /** |
|
58 * Returns last segment of URI. |
|
59 * |
|
60 * @param aUri URI to be searched. |
|
61 * @return Last segment of URI. |
|
62 */ |
|
63 static TPtrC8 GetLastURISeg( const TDesC8& aURI ); |
|
64 |
|
65 /** |
|
66 * Returns the end of URI starting from passed segment. |
|
67 * |
|
68 * @param aUri URI to be parsed. |
|
69 * @param aName Segment to start. |
|
70 * @return End of URI starting from aName. |
|
71 */ |
|
72 static TPtrC8 GetEndOfURIFromSeg( const TDesC8& aURI, const TDesC8& aName ); |
|
73 |
|
74 /** |
|
75 * This function converts string value to 8-bit value. |
|
76 * |
|
77 * @param aSource String to convert. |
|
78 * @return Pointer to 8-bit value. |
|
79 */ |
|
80 static TDesC8& ConvertTo8LC( const TDesC& aSource ); |
|
81 |
|
82 /** |
|
83 * This function converts string value to 16-bit value. |
|
84 * |
|
85 * @param aSource String to convert. |
|
86 * @return Pointer to 16-bit value. |
|
87 */ |
|
88 static TDesC16& ConvertTo16LC( const TDesC8& aSource ); |
|
89 |
|
90 /** |
|
91 * This function sets given information to given node. |
|
92 * |
|
93 * @param aNode Target node. |
|
94 * @param aAccTypes Node's access types. |
|
95 * @param aOccurrence Amount of possible nodes of same type. |
|
96 * @param aScope Describes if node is static or dynamic. |
|
97 * @param aFormat Node's format. |
|
98 * @param aDescription String containing description of the node. |
|
99 * @return Pointer integer value. |
|
100 */ |
|
101 static void FillNodeInfoL( MSmlDmDDFObject& aNode, |
|
102 TSmlDmAccessTypes aAccTypes, |
|
103 MSmlDmDDFObject::TOccurence aOccurrence, |
|
104 MSmlDmDDFObject::TScope aScope, |
|
105 MSmlDmDDFObject::TDFFormat aFormat, |
|
106 const TDesC8& aDescription); |
|
107 |
|
108 /** |
|
109 * This function removes characters that are not allowed in URI from given descriptor. |
|
110 * |
|
111 * @param aString String to be modified. |
|
112 */ |
|
113 static void RemoveIllegalCharsFromURI( TDes8& aString ); |
|
114 |
|
115 /** |
|
116 * This function returns string as bool value. |
|
117 * |
|
118 * @param aSource String to convert. |
|
119 * @param aBool conversion result. |
|
120 * @return TInt32 KErrNone if succesful conversion. |
|
121 */ |
|
122 static TInt32 DesToBool( const TDesC8& aString, TBool& aBool ); |
|
123 |
|
124 /** |
|
125 * This function convert integer value to string presentation. |
|
126 * |
|
127 * @param aObject Int value to convert. |
|
128 * @return TDesC8& Int as string. |
|
129 */ |
|
130 static TDesC8& IntToCharL( const TInt& aObject ); |
|
131 |
|
132 /** |
|
133 * This function takes first segment from uri and adds it to target |
|
134 * |
|
135 * @param aURI Contains source uri. |
|
136 * @param aTarget Target string. |
|
137 * @return TInt Index of first uri delimiter. |
|
138 */ |
|
139 static TInt AppendFirstURISeg( TDes8& aURI, TDes8& aTarget ); |
|
140 |
|
141 static TInt IntLUID(const TDesC8& aLUID); |
|
142 |
|
143 private: |
|
144 |
|
145 //----------------------------------------------------------------------------- |
|
146 // Private functions |
|
147 //----------------------------------------------------------------------------- |
|
148 CUtils(); |
|
149 |
|
150 //----------------------------------------------------------------------------- |
|
151 // Private member variables |
|
152 //----------------------------------------------------------------------------- |
|
153 |
|
154 }; |
|
155 |
|
156 #endif /* UTILS_H_ */ |