sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Ini file parser header file sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @internalAll sl@0: */ sl@0: sl@0: #ifndef __INIFILE_H__ sl@0: #define __INIFILE_H__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: //Forward declaration sl@0: class RFs; sl@0: sl@0: namespace BSUL sl@0: { sl@0: sl@0: class CIniDocument8; sl@0: class CIniDocument16; sl@0: sl@0: class CIniSecIter8Impl; sl@0: /** sl@0: Section iterator for 8 bit ini file. This class provides an iterator sl@0: to navigate through the settings within a section inside an 8 bit ini file. sl@0: */ sl@0: NONSHARABLE_CLASS(CIniSecIter8): public CBase sl@0: { sl@0: public: sl@0: IMPORT_C static CIniSecIter8* NewL(const TDesC8& aSectionName,const CIniDocument8* aIniDocument); sl@0: IMPORT_C ~CIniSecIter8(); sl@0: sl@0: IMPORT_C TBool Next(TPtrC8& aKey,TPtrC8& aValue); sl@0: IMPORT_C TBool End(); sl@0: IMPORT_C void Reset(); sl@0: private: sl@0: CIniSecIter8(); sl@0: CIniSecIter8Impl* iImpl; sl@0: }; sl@0: sl@0: class CIniDocument8Impl; sl@0: /** sl@0: Dom parser for 8 bit ini file. This class provides the functionality to read sl@0: and write settings of an 8 bit ini file. sl@0: */ sl@0: NONSHARABLE_CLASS(CIniDocument8): public CBase sl@0: { sl@0: public: sl@0: IMPORT_C static CIniDocument8* NewL(RFs& aFs,const TDesC& aFileName); sl@0: IMPORT_C ~CIniDocument8(); sl@0: IMPORT_C TInt Externalise(const TDesC& aFileName); sl@0: sl@0: //read api sl@0: IMPORT_C TInt GetSectionList(RArray& aSectionList) const; sl@0: IMPORT_C TInt GetKeyValue(const TDesC8& aSectionName,const TDesC8& aKey,TPtrC8& aValue) const; sl@0: sl@0: //write api sl@0: IMPORT_C TInt AddSection(const TDesC8& aSectionName); sl@0: IMPORT_C TInt RemoveSection(const TDesC8& aSectionName); sl@0: IMPORT_C TInt SetKey(const TDesC8& aSectionName,const TDesC8& aKey,const TDesC8& aValue); sl@0: IMPORT_C TInt RemoveKey(const TDesC8& aSectionName,const TDesC8& aKey); sl@0: IMPORT_C TBool CompareDocs(CIniDocument8& aDoc); sl@0: private: sl@0: friend class CIniSecIter8Impl; sl@0: CIniDocument8(); sl@0: CIniDocument8Impl* iImpl; sl@0: }; sl@0: sl@0: class CIniSecIter16Impl; sl@0: /** sl@0: Section iterator for 16 bit ini file. This class provides an iterator sl@0: to navigate through the settings within a section inside an 16 bit ini file. sl@0: */ sl@0: NONSHARABLE_CLASS(CIniSecIter16): public CBase sl@0: { sl@0: public: sl@0: IMPORT_C static CIniSecIter16* NewL(const TDesC16& aSectionName,const CIniDocument16* aIniDocument); sl@0: IMPORT_C ~CIniSecIter16(); sl@0: sl@0: IMPORT_C TBool Next(TPtrC16& aKey,TPtrC16& aValue); sl@0: IMPORT_C TBool End(); sl@0: IMPORT_C void Reset(); sl@0: private: sl@0: CIniSecIter16(); sl@0: CIniSecIter16Impl* iImpl; sl@0: }; sl@0: sl@0: class CIniDocument16Impl; sl@0: /** sl@0: Dom parser for 16 bit ini file. This class provides the functionality to read sl@0: and write settings of an 16 bit ini file. sl@0: */ sl@0: NONSHARABLE_CLASS(CIniDocument16): public CBase sl@0: { sl@0: public: sl@0: IMPORT_C static CIniDocument16* NewL(RFs& aFs,const TDesC& aFileName); sl@0: IMPORT_C ~CIniDocument16(); sl@0: IMPORT_C TInt Externalise(const TDesC& aFileName); sl@0: sl@0: //read api sl@0: IMPORT_C TInt GetSectionList(RArray& aSectionList) const; sl@0: IMPORT_C TInt GetKeyValue(const TDesC16& aSectionName,const TDesC16& aKey,TPtrC16& aValue) const; sl@0: sl@0: //write api sl@0: IMPORT_C TInt AddSection(const TDesC16& aSectionName); sl@0: IMPORT_C TInt RemoveSection(const TDesC16& aSectionName); sl@0: IMPORT_C TInt SetKey(const TDesC16& aSectionName,const TDesC16& aKey,const TDesC16& aValue); sl@0: IMPORT_C TInt RemoveKey(const TDesC16& aSectionName,const TDesC16& aKey); sl@0: IMPORT_C TBool CompareDocs(CIniDocument16& aDoc); sl@0: private: sl@0: friend class CIniSecIter16Impl; sl@0: CIniDocument16(); sl@0: CIniDocument16Impl* iImpl; sl@0: }; sl@0: sl@0: class CIniFile8Impl; sl@0: /** sl@0: A light weight parser for reading setting values from an 8 bit ini file. Note that this does not sl@0: guarantee checking that the ini file is wellformed. See CIniFile16 for a class that handles both sl@0: 8 and 16 bit files. sl@0: */ sl@0: NONSHARABLE_CLASS(CIniFile8): public CBase sl@0: { sl@0: public: sl@0: IMPORT_C static CIniFile8* NewL(RFs& aFs,const TDesC& aFileName); sl@0: IMPORT_C ~CIniFile8(); sl@0: IMPORT_C TInt FindVar(const TDesC8& aSectionName,const TDesC8& aKeyName,TPtrC8& aValue) const; sl@0: private: sl@0: CIniFile8(); sl@0: CIniFile8Impl* iImpl; sl@0: }; sl@0: sl@0: class CIniFile16Impl; sl@0: /** sl@0: A light weight parser for reading setting values from a 16 or 8 bit ini file. The aConvert8To16 sl@0: parameter of NewL controls whether or not 8 bit files are accepted. Note that this does sl@0: not guarantee checking that the ini file is wellformed. sl@0: */ sl@0: NONSHARABLE_CLASS(CIniFile16): public CBase sl@0: { sl@0: public: sl@0: IMPORT_C static CIniFile16* NewL(RFs& aFs,const TDesC& aFileName); sl@0: IMPORT_C static CIniFile16* NewL(RFs& aFs,const TDesC& aFileName,TBool aConvert8To16); sl@0: IMPORT_C ~CIniFile16(); sl@0: IMPORT_C TInt FindVar(const TDesC16& aSectionName,const TDesC16& aKeyName,TPtrC16& aValue) const; sl@0: private: sl@0: CIniFile16(); sl@0: CIniFile16Impl* iImpl; sl@0: }; sl@0: sl@0: }//namespace BSUL sl@0: sl@0: #endif