|
1 /* |
|
2 * Copyright (c) 2005-2009 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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #if !defined(__INIPARSER_H__) |
|
20 #define __INIPARSER_H__ |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <f32file.h> |
|
24 |
|
25 _LIT(KUseSystemDrive, "$:"); |
|
26 |
|
27 class CIniData : public CBase |
|
28 /** |
|
29 * |
|
30 * @publishedPartner |
|
31 * @test |
|
32 * |
|
33 * Defines the interface to acess to ini data file |
|
34 * |
|
35 * The basic functions, FindVar(), SetValue(), AddValue() and WriteToFileL() |
|
36 * Compulsory to call WriteToFileL() after calling any SetValue() or AddValue() |
|
37 */ |
|
38 { |
|
39 public: |
|
40 // Constructor, pass in name of ini file to open |
|
41 // Default search path is 'c:\system\data' on target filesystem |
|
42 // ie. 'NewL(_L("c:\\system\\data\\ttools.ini"))' is equivalent |
|
43 // to 'NewL(_L("ttools.ini"))' |
|
44 IMPORT_C static CIniData* NewL(const TDesC& aName); |
|
45 IMPORT_C virtual ~CIniData(); |
|
46 |
|
47 IMPORT_C TBool FindVar(const TDesC &aKeyName, // Key to look for |
|
48 TPtrC &aResult); // Buffer to store value |
|
49 |
|
50 IMPORT_C TBool FindVar(const TDesC &aKeyName, // Key to look for |
|
51 TInt &aResult); // Int ref to store result |
|
52 |
|
53 IMPORT_C TBool FindVar(const TDesC &aSection, // Section to look under |
|
54 const TDesC &aKeyName, // Key to look for |
|
55 TPtrC &aResult); // Buffer to store result |
|
56 |
|
57 IMPORT_C TBool FindVar(const TDesC &aSection, // Section to look under |
|
58 const TDesC &aKeyName, // Key to look for |
|
59 TInt &aResult); // Int ref to store result |
|
60 |
|
61 IMPORT_C TInt SetValue(const TDesC& aKeyName,// Key to look for |
|
62 const TDesC& aValue); // aValue being modified |
|
63 IMPORT_C TInt SetValue(const TDesC& aSection, // Section to look under |
|
64 const TDesC& aKeyName, // Key to look for |
|
65 const TDesC& aValue); // aValue being modified |
|
66 IMPORT_C TInt AddValue(const TDesC& aSection, // Section to look under |
|
67 const TDesC& aKeyName, // Key to look for |
|
68 const TDesC& aValue); // aValue being modified |
|
69 IMPORT_C TInt AddValue(const TDesC& aKeyName, // Key to look for |
|
70 const TDesC& aValue); // aValue being modified |
|
71 IMPORT_C void WriteToFileL(); |
|
72 // Overloaded NewL() added to recieve optional system drive letter from the user |
|
73 // And expand ${SYSDRIVE} variable. Else, the variable expands to RFs::GetSystemDrive() |
|
74 IMPORT_C static CIniData* NewL(const TDesC& aName, const TDesC& aSysDrive); |
|
75 protected: |
|
76 IMPORT_C CIniData(); |
|
77 IMPORT_C CIniData(const TDesC& aSysDrive); |
|
78 IMPORT_C void ConstructL(const TDesC& aName); |
|
79 public: |
|
80 IMPORT_C TBool FindVar(const TDesC &aSection, // Section to look under |
|
81 const TDesC &aKeyName, // Key to look for |
|
82 TInt64 &aResult); // Int64 ref to store result |
|
83 |
|
84 private: |
|
85 void UpdateVariablesL(); |
|
86 TBool FindVar(const TDesC &aSectName,const TDesC &aKeyName,TPtrC &aResult, TPtr& aIniDataPtr); |
|
87 private: |
|
88 HBufC* iName; |
|
89 HBufC* iToken; |
|
90 HBufC* iIniData; |
|
91 TPtr iPtr; |
|
92 TPtr iPtrExpandedVars; |
|
93 TDriveName iDefaultSysDrive; |
|
94 TDriveName iSysDrive; |
|
95 }; |
|
96 |
|
97 #endif |