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