KrProfile

Description
#include "krprof.hpp"

Using this class, you can read and write data from/to os2.ini, os2sys.ini, or any other OS/2 style ini file that you choose, using the common < > operators.

Derivation
KrProfile inherits from iostream. It also inherits from the non-public class _KrProfileBase, but this is only for technical reasons.

Constructors
You can construct and destruct objects of this class.

Overload 1 public: KrProfile (const IString & aApp, profile aProfile = user,           Boolean iBuffered = false);

Use this constructor to open the system ini file aProfile for reading and writing data of the application which is identified by the name aApp in the ini file.

By default, the object acts like a unit-buffered iostream, i.e. you can simply do your input output using the operators < >. If you want to avoid the slight overhead created by unit-buffering, and you want full buffering instead, set iBuffered=true If you do so, however, don't forget that you are now responsible for flushing the stream yourself using the manipulator flush.

Overload 2 public: KrProfile (const IString & aApp, const IString & aProfile,          Boolean iBuffered = false);

This is identical to overload 1, except that aProfile is now not necessarily a system ini file, but the file name of any ini file. If it doesn't already exist, this constructor creates this ini file.

exists
Returns true if any data of the application already exists in the ini file, and false otherwise.

public: Boolean exists ;

removeApp
Removes all data of the application from the ini file.

public: void removeApp ;

KrProfile
You can construct and destruct objects of this class.

Overload 1 public: KrProfile (const IString & aApp, profile aProfile = user,          Boolean iBuffered = false);

Use this constructor to open the system ini file aProfile for reading and writing data of the application which is identified by the name aApp in the ini file.

By default, the object acts like a unit-buffered iostream, i.e. you can simply do your input output using the operators < >. If you want to avoid the slight overhead created by unit-buffering, and you want full buffering instead, set iBuffered=true If you do so, however, don't forget that you are now responsible for flushing the stream yourself using the manipulator flush.

Overload 2 public: KrProfile (const IString & aApp, const IString & aProfile,          Boolean iBuffered = false);

This is identical to overload 1, except that aProfile is now not necessarily a system ini file, but the file name of any ini file. If it doesn't already exist, this constructor creates this ini file.

~KrProfile
public: ~KrProfile ;

clearBuffer
Do not use this function, since it might become private in a later version. Use the manipulator clear instead. public: void clearBuffer ;

readData
This function appends the contents of the ini file associated to the current key to the stream. Its direct use may be confusing; it is recommended to use the >> operator instead, which will call this function only when necessary. This function may become private in a later version. public: virtual void readData ;

writeData
Do not use this function, since it might become private in a later version. Use the manipulator flush instead.

public: virtual void writeData (Boolean callFromBuff);

existsKey
Returns true if any data associated to the current key already exists in the ini file, and false otherwise.

public: Boolean existsKey ;

key
Returns the currently set key.

public: IString & key ;

removeKey
Removes all data associated to the currently set key from the ini file.

public: void removeKey ;

setKey
Clears the stream and sets a new key. Before setKey is called for the first time, the key "Default" is set.

public: void setKey (const IString & aKey = "Default");

good
Returns true if the ini file was successfully opened, and false otherwise.

public: Boolean good ;

size
Returns the number of bytes currently stored in the ini file under the current key.

public: long size ;

Profile
public: enum profile { system, user, both };

If a system ini file is to be opened, a member of this enumeration should be passed to the constructor. These are their meanings:

system    Read and write to the OS/2 system ini file (usually called os2sys.ini)

user      Read and write to the OS/2 user ini file (usually            called os2.ini)

both      Read from both above ini files, write to the OS/2 user ini file.

clear
Use this manipulator to clear the stream. This is necessary if you have already read from or written to the stream, but want to discard that data and write completely new data to that key instead of appending to the old data.

public: KrProfile & clear (KrProfile & aProfile);

flush
Use this manipulator to flush the stream. This is only necessary if you have constructed the KrProfile object as a fully buffered stream.

public: KrProfile & flush (KrProfile & aProfile);

remove
This manipulator is a convenient way to call removeKey. public: KrProfile & remove (KrProfile & aProfile);