epoc32/include/iniparser.h
branchSymbian3
changeset 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/iniparser.h	Wed Mar 31 12:33:34 2010 +0100
     1.3 @@ -0,0 +1,97 @@
     1.4 +/*
     1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). 
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* 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
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description:
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +#if !defined(__INIPARSER_H__)
    1.23 +#define __INIPARSER_H__
    1.24 +
    1.25 +#include <e32base.h>
    1.26 +#include <f32file.h>
    1.27 +
    1.28 +_LIT(KUseSystemDrive, "$:");
    1.29 +
    1.30 +class CIniData : public CBase 
    1.31 +/**
    1.32 + *
    1.33 + * @publishedPartner
    1.34 + * @test
    1.35 + *
    1.36 + * Defines the interface to acess to ini data file
    1.37 + *
    1.38 + * The basic functions, FindVar(), SetValue(), AddValue() and WriteToFileL()
    1.39 + * Compulsory to call WriteToFileL() after calling any SetValue() or AddValue()
    1.40 + */
    1.41 +	{
    1.42 +public:
    1.43 +	// Constructor, pass in name of ini file to open
    1.44 +	// Default search path is 'c:\system\data' on target filesystem
    1.45 +	// ie. 'NewL(_L("c:\\system\\data\\ttools.ini"))' is equivalent
    1.46 +	// to 'NewL(_L("ttools.ini"))'
    1.47 +	IMPORT_C static CIniData* NewL(const TDesC& aName);
    1.48 +	IMPORT_C virtual ~CIniData();
    1.49 +
    1.50 +	IMPORT_C TBool FindVar(const TDesC &aKeyName,	// Key to look for
    1.51 +						TPtrC &aResult);			// Buffer to store value
    1.52 +
    1.53 +	IMPORT_C TBool FindVar(const TDesC &aKeyName, 	// Key to look for
    1.54 +						TInt &aResult);				// Int ref to store result
    1.55 +
    1.56 +	IMPORT_C TBool FindVar(const TDesC &aSection,	// Section to look under
    1.57 +						const TDesC &aKeyName,		// Key to look for
    1.58 +						TPtrC &aResult);			// Buffer to store result
    1.59 +
    1.60 +	IMPORT_C TBool FindVar(const TDesC &aSection,	// Section to look under
    1.61 +						const TDesC &aKeyName,		// Key to look for
    1.62 +						TInt &aResult);				// Int ref to store result
    1.63 +
    1.64 +	IMPORT_C TInt SetValue(const TDesC& aKeyName,// Key to look for
    1.65 +						const TDesC& aValue);  // aValue being modified
    1.66 +	IMPORT_C TInt SetValue(const TDesC& aSection, // Section to look under
    1.67 +						const TDesC& aKeyName,  // Key to look for
    1.68 +						const TDesC& aValue);  // aValue being modified
    1.69 +	IMPORT_C TInt AddValue(const TDesC& aSection,  // Section to look under
    1.70 +						const TDesC& aKeyName,   // Key to look for
    1.71 +						const TDesC& aValue);   // aValue being modified
    1.72 +	IMPORT_C TInt AddValue(const TDesC& aKeyName,   // Key to look for
    1.73 +						const TDesC& aValue);  // aValue being modified
    1.74 +	IMPORT_C void WriteToFileL();
    1.75 +	// Overloaded NewL() added to recieve optional system drive letter from the user
    1.76 +	// And expand ${SYSDRIVE} variable. Else, the variable expands to RFs::GetSystemDrive()
    1.77 +	IMPORT_C static CIniData* NewL(const TDesC& aName, const TDesC& aSysDrive);
    1.78 +protected:
    1.79 +	IMPORT_C CIniData();
    1.80 +	IMPORT_C CIniData(const TDesC& aSysDrive);
    1.81 +	IMPORT_C void ConstructL(const TDesC& aName);
    1.82 +public:
    1.83 +	IMPORT_C TBool FindVar(const TDesC &aSection,	// Section to look under
    1.84 +						const TDesC &aKeyName,		// Key to look for
    1.85 +						TInt64 &aResult);			// Int64 ref to store result
    1.86 +
    1.87 +private:
    1.88 +	void UpdateVariablesL();
    1.89 +	TBool FindVar(const TDesC &aSectName,const TDesC &aKeyName,TPtrC &aResult, TPtr& aIniDataPtr);
    1.90 +private:
    1.91 +	HBufC* iName;
    1.92 +	HBufC* iToken;
    1.93 +	HBufC* iIniData;
    1.94 +	TPtr iPtr;
    1.95 +	TPtr iPtrExpandedVars;
    1.96 +	TDriveName iDefaultSysDrive;
    1.97 +	TDriveName iSysDrive;
    1.98 +	};
    1.99 +
   1.100 +#endif