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