epoc32/include/bsul/inifile.h
branchSymbian3
changeset 4 837f303aceeb
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Ini file parser header file
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file
       
    20  @internalAll
       
    21 */
       
    22 
       
    23 #ifndef __INIFILE_H__
       
    24 #define __INIFILE_H__
       
    25 
       
    26 #include <e32std.h>
       
    27 #include <e32base.h>
       
    28 
       
    29 //Forward declaration
       
    30 class RFs;
       
    31 
       
    32 namespace BSUL
       
    33 	{
       
    34 
       
    35 class CIniDocument8;
       
    36 class CIniDocument16;
       
    37 
       
    38 class CIniSecIter8Impl;
       
    39 /** 
       
    40 Section iterator for 8 bit ini file. This class provides an iterator
       
    41 to navigate through the settings within a section inside an 8 bit ini file.
       
    42 */
       
    43 NONSHARABLE_CLASS(CIniSecIter8): public CBase
       
    44 {
       
    45 public:
       
    46 	IMPORT_C static CIniSecIter8* NewL(const TDesC8& aSectionName,const CIniDocument8* aIniDocument);
       
    47 	IMPORT_C ~CIniSecIter8();
       
    48 		
       
    49 	IMPORT_C TBool Next(TPtrC8& aKey,TPtrC8& aValue);
       
    50 	IMPORT_C TBool End();
       
    51 	IMPORT_C void Reset();
       
    52 private:
       
    53 	CIniSecIter8();
       
    54 	CIniSecIter8Impl* iImpl;
       
    55 };
       
    56 
       
    57 class CIniDocument8Impl;
       
    58 /**
       
    59 Dom parser for 8 bit ini file. This class provides the functionality to read
       
    60 and write settings of an 8 bit ini file.
       
    61 */
       
    62 NONSHARABLE_CLASS(CIniDocument8): public CBase
       
    63 {
       
    64 public:
       
    65 	IMPORT_C static CIniDocument8* NewL(RFs& aFs,const TDesC& aFileName);
       
    66 	IMPORT_C ~CIniDocument8();
       
    67 	IMPORT_C TInt Externalise(const TDesC& aFileName);
       
    68 
       
    69 	//read api
       
    70 	IMPORT_C TInt GetSectionList(RArray<TPtrC8>& aSectionList) const;
       
    71 	IMPORT_C TInt GetKeyValue(const TDesC8& aSectionName,const TDesC8& aKey,TPtrC8& aValue) const;
       
    72 
       
    73 	//write api
       
    74 	IMPORT_C TInt AddSection(const TDesC8& aSectionName);
       
    75 	IMPORT_C TInt RemoveSection(const TDesC8& aSectionName);
       
    76 	IMPORT_C TInt SetKey(const TDesC8& aSectionName,const TDesC8& aKey,const TDesC8& aValue);
       
    77 	IMPORT_C TInt RemoveKey(const TDesC8& aSectionName,const TDesC8& aKey);
       
    78 	IMPORT_C TBool CompareDocs(CIniDocument8& aDoc);
       
    79 private:
       
    80 	friend class CIniSecIter8Impl;
       
    81 	CIniDocument8();
       
    82 	CIniDocument8Impl* iImpl;
       
    83 };
       
    84 
       
    85 class CIniSecIter16Impl;
       
    86 /** 
       
    87 Section iterator for 16 bit ini file. This class provides an iterator
       
    88 to navigate through the settings within a section inside an 16 bit ini file.
       
    89 */
       
    90 NONSHARABLE_CLASS(CIniSecIter16): public CBase
       
    91 {
       
    92 public:
       
    93 	IMPORT_C static CIniSecIter16* NewL(const TDesC16& aSectionName,const CIniDocument16* aIniDocument);
       
    94 	IMPORT_C ~CIniSecIter16();
       
    95 		
       
    96 	IMPORT_C TBool Next(TPtrC16& aKey,TPtrC16& aValue);
       
    97 	IMPORT_C TBool End();
       
    98 	IMPORT_C void Reset();
       
    99 private:
       
   100 	CIniSecIter16();
       
   101 	CIniSecIter16Impl* iImpl;
       
   102 };
       
   103 
       
   104 class CIniDocument16Impl;
       
   105 /**
       
   106 Dom parser for 16 bit ini file. This class provides the functionality to read
       
   107 and write settings of an 16 bit ini file.
       
   108 */
       
   109 NONSHARABLE_CLASS(CIniDocument16): public CBase
       
   110 {
       
   111 public:
       
   112 	IMPORT_C static CIniDocument16* NewL(RFs& aFs,const TDesC& aFileName);
       
   113 	IMPORT_C ~CIniDocument16();
       
   114 	IMPORT_C TInt Externalise(const TDesC& aFileName);
       
   115 
       
   116 	//read api
       
   117 	IMPORT_C TInt GetSectionList(RArray<TPtrC16>& aSectionList) const;
       
   118 	IMPORT_C TInt GetKeyValue(const TDesC16& aSectionName,const TDesC16& aKey,TPtrC16& aValue) const;
       
   119 
       
   120 	//write api
       
   121 	IMPORT_C TInt AddSection(const TDesC16& aSectionName);
       
   122 	IMPORT_C TInt RemoveSection(const TDesC16& aSectionName);
       
   123 	IMPORT_C TInt SetKey(const TDesC16& aSectionName,const TDesC16& aKey,const TDesC16& aValue);
       
   124 	IMPORT_C TInt RemoveKey(const TDesC16& aSectionName,const TDesC16& aKey);
       
   125 	IMPORT_C TBool CompareDocs(CIniDocument16& aDoc);
       
   126 private:
       
   127 	friend class CIniSecIter16Impl;
       
   128 	CIniDocument16();
       
   129 	CIniDocument16Impl* iImpl;
       
   130 };
       
   131 
       
   132 class CIniFile8Impl;
       
   133 /**
       
   134 A light weight parser for reading setting values from an 8 bit ini file. Note that this does not 
       
   135 guarantee checking that the ini file is wellformed. See CIniFile16 for a class that handles both 
       
   136 8 and 16 bit files.  
       
   137 */
       
   138 NONSHARABLE_CLASS(CIniFile8): public CBase
       
   139 {
       
   140 public:
       
   141 	IMPORT_C static CIniFile8* NewL(RFs& aFs,const TDesC& aFileName);
       
   142 	IMPORT_C ~CIniFile8();
       
   143 	IMPORT_C TInt FindVar(const TDesC8& aSectionName,const TDesC8& aKeyName,TPtrC8& aValue)	const;
       
   144 private:
       
   145 	CIniFile8();
       
   146 	CIniFile8Impl* iImpl;
       
   147 };
       
   148 
       
   149 class CIniFile16Impl;
       
   150 /**
       
   151 A light weight parser for reading setting values from a 16 or 8 bit ini file. The aConvert8To16
       
   152 parameter of NewL controls whether or not 8 bit files are accepted. Note that this does
       
   153 not guarantee checking that the ini file is wellformed.
       
   154 */
       
   155 NONSHARABLE_CLASS(CIniFile16): public CBase
       
   156 {
       
   157 public:
       
   158 	IMPORT_C static CIniFile16* NewL(RFs& aFs,const TDesC& aFileName);
       
   159 	IMPORT_C static CIniFile16* NewL(RFs& aFs,const TDesC& aFileName,TBool aConvert8To16);
       
   160 	IMPORT_C ~CIniFile16();
       
   161 	IMPORT_C TInt FindVar(const TDesC16& aSectionName,const TDesC16& aKeyName,TPtrC16& aValue) const;
       
   162 private:
       
   163 	CIniFile16();
       
   164 	CIniFile16Impl* iImpl;
       
   165 };
       
   166 
       
   167 }//namespace BSUL
       
   168 
       
   169 #endif