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