1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/apputils/bsul/inc/inifile.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,169 @@
1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// Ini file parser header file
1.18 +//
1.19 +//
1.20 +
1.21 +/**
1.22 + @file
1.23 + @internalAll
1.24 +*/
1.25 +
1.26 +#ifndef __INIFILE_H__
1.27 +#define __INIFILE_H__
1.28 +
1.29 +#include <e32std.h>
1.30 +#include <e32base.h>
1.31 +
1.32 +//Forward declaration
1.33 +class RFs;
1.34 +
1.35 +namespace BSUL
1.36 + {
1.37 +
1.38 +class CIniDocument8;
1.39 +class CIniDocument16;
1.40 +
1.41 +class CIniSecIter8Impl;
1.42 +/**
1.43 +Section iterator for 8 bit ini file. This class provides an iterator
1.44 +to navigate through the settings within a section inside an 8 bit ini file.
1.45 +*/
1.46 +NONSHARABLE_CLASS(CIniSecIter8): public CBase
1.47 +{
1.48 +public:
1.49 + IMPORT_C static CIniSecIter8* NewL(const TDesC8& aSectionName,const CIniDocument8* aIniDocument);
1.50 + IMPORT_C ~CIniSecIter8();
1.51 +
1.52 + IMPORT_C TBool Next(TPtrC8& aKey,TPtrC8& aValue);
1.53 + IMPORT_C TBool End();
1.54 + IMPORT_C void Reset();
1.55 +private:
1.56 + CIniSecIter8();
1.57 + CIniSecIter8Impl* iImpl;
1.58 +};
1.59 +
1.60 +class CIniDocument8Impl;
1.61 +/**
1.62 +Dom parser for 8 bit ini file. This class provides the functionality to read
1.63 +and write settings of an 8 bit ini file.
1.64 +*/
1.65 +NONSHARABLE_CLASS(CIniDocument8): public CBase
1.66 +{
1.67 +public:
1.68 + IMPORT_C static CIniDocument8* NewL(RFs& aFs,const TDesC& aFileName);
1.69 + IMPORT_C ~CIniDocument8();
1.70 + IMPORT_C TInt Externalise(const TDesC& aFileName);
1.71 +
1.72 + //read api
1.73 + IMPORT_C TInt GetSectionList(RArray<TPtrC8>& aSectionList) const;
1.74 + IMPORT_C TInt GetKeyValue(const TDesC8& aSectionName,const TDesC8& aKey,TPtrC8& aValue) const;
1.75 +
1.76 + //write api
1.77 + IMPORT_C TInt AddSection(const TDesC8& aSectionName);
1.78 + IMPORT_C TInt RemoveSection(const TDesC8& aSectionName);
1.79 + IMPORT_C TInt SetKey(const TDesC8& aSectionName,const TDesC8& aKey,const TDesC8& aValue);
1.80 + IMPORT_C TInt RemoveKey(const TDesC8& aSectionName,const TDesC8& aKey);
1.81 + IMPORT_C TBool CompareDocs(CIniDocument8& aDoc);
1.82 +private:
1.83 + friend class CIniSecIter8Impl;
1.84 + CIniDocument8();
1.85 + CIniDocument8Impl* iImpl;
1.86 +};
1.87 +
1.88 +class CIniSecIter16Impl;
1.89 +/**
1.90 +Section iterator for 16 bit ini file. This class provides an iterator
1.91 +to navigate through the settings within a section inside an 16 bit ini file.
1.92 +*/
1.93 +NONSHARABLE_CLASS(CIniSecIter16): public CBase
1.94 +{
1.95 +public:
1.96 + IMPORT_C static CIniSecIter16* NewL(const TDesC16& aSectionName,const CIniDocument16* aIniDocument);
1.97 + IMPORT_C ~CIniSecIter16();
1.98 +
1.99 + IMPORT_C TBool Next(TPtrC16& aKey,TPtrC16& aValue);
1.100 + IMPORT_C TBool End();
1.101 + IMPORT_C void Reset();
1.102 +private:
1.103 + CIniSecIter16();
1.104 + CIniSecIter16Impl* iImpl;
1.105 +};
1.106 +
1.107 +class CIniDocument16Impl;
1.108 +/**
1.109 +Dom parser for 16 bit ini file. This class provides the functionality to read
1.110 +and write settings of an 16 bit ini file.
1.111 +*/
1.112 +NONSHARABLE_CLASS(CIniDocument16): public CBase
1.113 +{
1.114 +public:
1.115 + IMPORT_C static CIniDocument16* NewL(RFs& aFs,const TDesC& aFileName);
1.116 + IMPORT_C ~CIniDocument16();
1.117 + IMPORT_C TInt Externalise(const TDesC& aFileName);
1.118 +
1.119 + //read api
1.120 + IMPORT_C TInt GetSectionList(RArray<TPtrC16>& aSectionList) const;
1.121 + IMPORT_C TInt GetKeyValue(const TDesC16& aSectionName,const TDesC16& aKey,TPtrC16& aValue) const;
1.122 +
1.123 + //write api
1.124 + IMPORT_C TInt AddSection(const TDesC16& aSectionName);
1.125 + IMPORT_C TInt RemoveSection(const TDesC16& aSectionName);
1.126 + IMPORT_C TInt SetKey(const TDesC16& aSectionName,const TDesC16& aKey,const TDesC16& aValue);
1.127 + IMPORT_C TInt RemoveKey(const TDesC16& aSectionName,const TDesC16& aKey);
1.128 + IMPORT_C TBool CompareDocs(CIniDocument16& aDoc);
1.129 +private:
1.130 + friend class CIniSecIter16Impl;
1.131 + CIniDocument16();
1.132 + CIniDocument16Impl* iImpl;
1.133 +};
1.134 +
1.135 +class CIniFile8Impl;
1.136 +/**
1.137 +A light weight parser for reading setting values from an 8 bit ini file. Note that this does not
1.138 +guarantee checking that the ini file is wellformed. See CIniFile16 for a class that handles both
1.139 +8 and 16 bit files.
1.140 +*/
1.141 +NONSHARABLE_CLASS(CIniFile8): public CBase
1.142 +{
1.143 +public:
1.144 + IMPORT_C static CIniFile8* NewL(RFs& aFs,const TDesC& aFileName);
1.145 + IMPORT_C ~CIniFile8();
1.146 + IMPORT_C TInt FindVar(const TDesC8& aSectionName,const TDesC8& aKeyName,TPtrC8& aValue) const;
1.147 +private:
1.148 + CIniFile8();
1.149 + CIniFile8Impl* iImpl;
1.150 +};
1.151 +
1.152 +class CIniFile16Impl;
1.153 +/**
1.154 +A light weight parser for reading setting values from a 16 or 8 bit ini file. The aConvert8To16
1.155 +parameter of NewL controls whether or not 8 bit files are accepted. Note that this does
1.156 +not guarantee checking that the ini file is wellformed.
1.157 +*/
1.158 +NONSHARABLE_CLASS(CIniFile16): public CBase
1.159 +{
1.160 +public:
1.161 + IMPORT_C static CIniFile16* NewL(RFs& aFs,const TDesC& aFileName);
1.162 + IMPORT_C static CIniFile16* NewL(RFs& aFs,const TDesC& aFileName,TBool aConvert8To16);
1.163 + IMPORT_C ~CIniFile16();
1.164 + IMPORT_C TInt FindVar(const TDesC16& aSectionName,const TDesC16& aKeyName,TPtrC16& aValue) const;
1.165 +private:
1.166 + CIniFile16();
1.167 + CIniFile16Impl* iImpl;
1.168 +};
1.169 +
1.170 +}//namespace BSUL
1.171 +
1.172 +#endif