OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
owl::TProfile Class Reference

An instance of TProfile encapsulates a setting within a system file, often referred to as a profile or initialization file. More...

#include <owl/profile.h>

Public Member Functions

 TProfile (LPCTSTR section, LPCTSTR filename=0)
 Constructs a TProfile object for the indicated section within the profile file specified by filename.
 
 TProfile (const tstring &section, const tstring &filename=tstring())
 String-aware overload.
 
 ~TProfile ()
 Destroys the TProfile object.
 
int GetInt (LPCTSTR key, int defaultInt=0)
 Looks up and returns the integer value associated with the given string, key.
 
int GetInt (const tstring &key, int defaultInt=0)
 
bool GetString (LPCTSTR key, TCHAR *buff, unsigned buffSize, LPCTSTR defaultString=0)
 Looks up and returns the string value associated with the given key string.
 
bool GetString (const tstring &key, TCHAR *buff, unsigned buffSize, const tstring &defaultString=tstring())
 
tstring GetString (const tstring &key, const tstring &defaultString=tstring())
 
bool WriteInt (LPCTSTR key, int value)
 Looks up the key and replaces its value with the integer value passed (int).
 
bool WriteInt (const tstring &key, int value)
 
bool WriteString (LPCTSTR key, LPCTSTR str)
 Looks up the key and replaces its value with the string value passed (str).
 
bool WriteString (const tstring &key, LPCTSTR str)
 
bool WriteString (const tstring &key, const tstring &str)
 
void Flush ()
 Makes sure that all written profile values are flushed to the actual file.
 

Protected Member Functions

void Init (LPCTSTR section, LPCTSTR filename)
 

Protected Attributes

TCHARSection
 Name of the section to use.
 
TCHARFileName
 File name of the .INI file.
 

Detailed Description

An instance of TProfile encapsulates a setting within a system file, often referred to as a profile or initialization file.

Examples of this type of file include the Windows initialization files SYSTEM.INI and WIN.INI. Within the system file itself, the individual settings are grouped within sections. For example,

For a setting, the value to the left of the equal sign is called the key. The value to the right of the equal sign, the value, can be either an integer or a string data type.

Definition at line 43 of file profile.h.

Constructor & Destructor Documentation

◆ TProfile() [1/2]

owl::TProfile::TProfile ( LPCTSTR section,
LPCTSTR filename = 0 )

Constructs a TProfile object for the indicated section within the profile file specified by filename.

If the file name is not provided, the file defaults to the system profile file; for example, WIN.INI under Windows .

Definition at line 22 of file profile.cpp.

References Init().

◆ TProfile() [2/2]

owl::TProfile::TProfile ( const tstring & section,
const tstring & filename = tstring() )

String-aware overload.

Definition at line 30 of file profile.cpp.

References Init().

◆ ~TProfile()

owl::TProfile::~TProfile ( )

Destroys the TProfile object.

Cleans up buffers

Definition at line 75 of file profile.cpp.

References FileName, and Section.

Member Function Documentation

◆ Flush()

void owl::TProfile::Flush ( )

Makes sure that all written profile values are flushed to the actual file.

Definition at line 164 of file profile.cpp.

References FileName.

◆ GetInt() [1/2]

int owl::TProfile::GetInt ( const tstring & key,
int defaultInt = 0 )
inline

Definition at line 54 of file profile.h.

◆ GetInt() [2/2]

int owl::TProfile::GetInt ( LPCTSTR key,
int defaultInt = 0 )

Looks up and returns the integer value associated with the given string, key.

If key is not found, the default value, defaultInt, is returned.

Definition at line 86 of file profile.cpp.

References FileName, and Section.

◆ GetString() [1/3]

tstring owl::TProfile::GetString ( const tstring & key,
const tstring & defaultString = tstring() )

Definition at line 109 of file profile.cpp.

References _T, FileName, and Section.

◆ GetString() [2/3]

bool owl::TProfile::GetString ( const tstring & key,
TCHAR * buff,
unsigned buffSize,
const tstring & defaultString = tstring() )
inline

Definition at line 61 of file profile.h.

◆ GetString() [3/3]

bool owl::TProfile::GetString ( LPCTSTR key,
TCHAR * buff,
unsigned buffSize,
LPCTSTR defaultString = 0 )

Looks up and returns the string value associated with the given key string.

The string value is copied into buff, up to buffSize bytes. If the key is not found, defaultString provides the default value. If a 0 key is passed, all section values are returned in buff.

Definition at line 100 of file profile.cpp.

References _T, FileName, and Section.

◆ Init()

void owl::TProfile::Init ( LPCTSTR section,
LPCTSTR filename )
protected

Definition at line 37 of file profile.cpp.

References A2W, FileName, Section, strnewdup(), USES_CONVERSION, and W2A.

◆ WriteInt() [1/2]

bool owl::TProfile::WriteInt ( const tstring & key,
int value )
inline

Definition at line 68 of file profile.h.

◆ WriteInt() [2/2]

bool owl::TProfile::WriteInt ( LPCTSTR key,
int value )

Looks up the key and replaces its value with the integer value passed (int).

If the key is not found, WriteInt makes a new entry. Returns true if successful.

Definition at line 137 of file profile.cpp.

References _itot, and WriteString().

◆ WriteString() [1/3]

bool owl::TProfile::WriteString ( const tstring & key,
const tstring & str )
inline

Definition at line 76 of file profile.h.

◆ WriteString() [2/3]

bool owl::TProfile::WriteString ( const tstring & key,
LPCTSTR str )
inline

Definition at line 73 of file profile.h.

◆ WriteString() [3/3]

bool owl::TProfile::WriteString ( LPCTSTR key,
LPCTSTR str )

Looks up the key and replaces its value with the string value passed (str).

If the key is not found, WriteString makes a new entry. Returns true if successful.

Definition at line 153 of file profile.cpp.

References FileName, and Section.

Member Data Documentation

◆ FileName

TCHAR* owl::TProfile::FileName
protected

File name of the .INI file.

Definition at line 83 of file profile.h.

◆ Section

TCHAR* owl::TProfile::Section
protected

Name of the section to use.

Definition at line 82 of file profile.h.


The documentation for this class was generated from the following files: