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

Derived from TConfigFile, TRegConfigFile is used to maintain configuration settings in the registry. More...

#include <owl/configfl.h>

Inheritance diagram for owl::TRegConfigFile:
owl::TConfigFile

Public Member Functions

 TRegConfigFile (const tstring &name, HKEY hRoot=HKEY_CURRENT_USER)
 This source file implements TRegConfigFile.
 
virtual ~TRegConfigFile ()
 
virtual bool SectionExists (LPCTSTR section) const
 
virtual uint ReadSection (LPCTSTR section, TCHAR *buffer, uint bufSize) const
 Copies all value names of the given section to the specified buffer.
 
virtual uint ReadSections (TCHAR *buffer, uint bufSize) const
 Copies all section names to the specified buffer.
 
virtual bool EraseSection (LPCTSTR section)
 
virtual bool EraseEntry (LPCTSTR section, LPCTSTR entry)
 
virtual void UpdateFile ()
 
virtual int ReadInteger (LPCTSTR section, LPCTSTR entry, int defint=0) const
 
virtual bool WriteInteger (LPCTSTR section, LPCTSTR entry, int value)
 
virtual uint ReadString (LPCTSTR section, LPCTSTR entry, TCHAR *buffer, uint bufSize, LPCTSTR defstr=0) const
 Looks up the value of the given entry of the given section, and if found, copies it to the given buffer.
 
virtual bool WriteString (LPCTSTR section, LPCTSTR entry, LPCTSTR value)
 
virtual bool ReadData (LPCTSTR section, LPCTSTR entry, void *buffer, uint size) const
 This method reads binary data.
 
virtual bool WriteData (LPCTSTR section, LPCTSTR entry, void *buffer, uint size)
 This method writes binary data.
 
virtual bool SectionExists (LPCTSTR section) const
 
bool SectionExists (const tstring &section) const
 
virtual uint ReadSection (LPCTSTR section, TCHAR *buffer, uint bufSize) const=0
 
int ReadSection (const tstring &section, tstring &buffer) const
 
virtual uint ReadSections (TCHAR *sections, uint bufSize) const=0
 
int ReadSections (tstring &sections) const
 
virtual bool EraseSection (LPCTSTR section)=0
 
bool EraseSection (const tstring &section)
 
virtual bool EraseEntry (LPCTSTR section, LPCTSTR entry)=0
 
bool EraseEntry (const tstring &section, const tstring &entry)
 
virtual int ReadInteger (LPCTSTR section, LPCTSTR entry, int defint=0) const
 This method reads an integer.
 
int ReadInteger (const tstring &section, const tstring &entry, int defint=0) const
 
virtual bool WriteInteger (LPCTSTR section, LPCTSTR entry, int value)
 This method writes an integer. We format it as a string.
 
bool WriteInteger (const tstring &section, const tstring &entry, int value)
 
virtual uint ReadString (LPCTSTR section, LPCTSTR entry, TCHAR *buffer, uint bufSize, LPCTSTR defstr=0) const=0
 
uint ReadString (const tstring &section, const tstring &entry, tstring &buffer, LPCTSTR defstr=0) const
 String-aware overload.
 
uint ReadString (const tstring &section, const tstring &entry, tstring &buffer, const tstring &defstr) const
 
virtual bool WriteString (LPCTSTR section, LPCTSTR entry, LPCTSTR value)=0
 
bool WriteString (const tstring &section, const tstring &entry, const tstring &value)
 
virtual bool ReadData (LPCTSTR section, LPCTSTR entry, void *buffer, uint size) const
 This method reads binary data.
 
bool ReadData (const tstring &section, const tstring &entry, void *buffer, uint size) const
 
virtual bool WriteData (LPCTSTR section, LPCTSTR entry, void *buffer, uint size)
 This method writes binary data.
 
bool WriteData (const tstring &section, const tstring &entry, void *buffer, uint size)
 
- Public Member Functions inherited from owl::TConfigFile
 TConfigFile (const tstring &name)
 Constructs instance and sets FileName to name.
 
virtual ~TConfigFile ()
 Destroys the instance.
 
const tstringGetFileName () const
 
virtual void LoadValues (const TConfigFile &file)
 
bool SectionExists (const tstring &section) const
 
int ReadSection (const tstring &section, tstring &buffer) const
 
int ReadSections (tstring &sections) const
 
bool EraseSection (const tstring &section)
 
bool EraseEntry (const tstring &section, const tstring &entry)
 
uint ReadString (const tstring &section, const tstring &entry, tstring &buffer, LPCTSTR defstr=0) const
 String-aware overload.
 
uint ReadString (const tstring &section, const tstring &entry, tstring &buffer, const tstring &defstr) const
 
bool WriteString (const tstring &section, const tstring &entry, const tstring &value)
 
bool ReadData (const tstring &section, const tstring &entry, void *buffer, uint size) const
 
bool WriteData (const tstring &section, const tstring &entry, void *buffer, uint size)
 
int ReadInteger (const tstring &section, const tstring &entry, int defint=0) const
 
bool WriteInteger (const tstring &section, const tstring &entry, int value)
 
double ReadDouble (LPCTSTR section, LPCTSTR entry, double defval=0.0) const
 
bool WriteDouble (LPCTSTR section, LPCTSTR entry, double value)
 This method writes an integer.
 
double ReadDouble (const tstring &section, const tstring &entry, double defval=0.0) const
 
bool WriteDouble (const tstring &section, const tstring &entry, double value)
 
bool ReadBool (LPCTSTR section, LPCTSTR entry, bool defval=false) const
 This method reads a boolean value.
 
bool WriteBool (LPCTSTR section, LPCTSTR entry, bool val)
 This method writes a bool.
 
bool ReadBool (const tstring &section, const tstring &entry, bool defval=false) const
 
bool WriteBool (const tstring &section, const tstring &entry, bool val)
 
bool ReadDate (LPCTSTR section, LPCTSTR entry, TDate &value) const
 
bool WriteDate (LPCTSTR section, LPCTSTR entry, const TDate &val)
 
bool ReadDate (const tstring &section, const tstring &entry, TDate &value) const
 
bool WriteDate (const tstring &section, const tstring &entry, const TDate &val)
 
bool ReadSystemTime (LPCTSTR section, LPCTSTR entry, TSystemTime &val) const
 
bool WriteSystemTime (LPCTSTR section, LPCTSTR entry, const TSystemTime &val)
 
bool ReadSystemTime (const tstring &section, const tstring &entry, TSystemTime &val) const
 
bool WriteSystemTime (const tstring &section, const tstring &entry, const TSystemTime &val)
 
bool ReadTime (LPCTSTR section, LPCTSTR entry, TTime &val) const
 
bool WriteTime (LPCTSTR section, LPCTSTR entry, TTime &val)
 
bool ReadTime (const tstring &section, const tstring &entry, TTime &val) const
 
bool WriteTime (const tstring &section, const tstring &entry, TTime &val)
 
bool ReadFont (LPCTSTR section, LPCTSTR entry, LOGFONT &font) const
 This method will take a profile string of the form:
 
bool WriteFont (LPCTSTR section, LPCTSTR entry, const LOGFONT &font)
 This method writes a font description in the following format:
 
bool ReadFont (const tstring &section, const tstring &entry, LOGFONT &font) const
 
bool WriteFont (const tstring &section, const tstring &entry, const LOGFONT &font)
 
bool ReadColor (LPCTSTR section, LPCTSTR entry, TColor &color) const
 This method reads an RGB color.
 
bool WriteColor (LPCTSTR section, LPCTSTR entry, const TColor &clr)
 This method writes an RGB color.
 
bool ReadColor (const tstring &section, const tstring &entry, TColor &color) const
 
bool WriteColor (const tstring &section, const tstring &entry, const TColor &clr)
 
bool ReadRect (LPCTSTR section, LPCTSTR entry, TRect &val) const
 This method reads a rectangle.
 
bool WriteRect (LPCTSTR section, LPCTSTR entry, const TRect &rc)
 This method writes a rectangle.
 
bool ReadRect (const tstring &section, const tstring &entry, TRect &val) const
 
bool WriteRect (const tstring &section, const tstring &entry, const TRect &rc)
 
bool ReadPoint (LPCTSTR section, LPCTSTR entry, TPoint &val) const
 
bool WritePoint (LPCTSTR section, LPCTSTR entry, const TPoint &point)
 This method writes a TPoint.
 
bool ReadPoint (const tstring &section, const tstring &entry, TPoint &val) const
 
bool WritePoint (const tstring &section, const tstring &entry, const TPoint &point)
 
bool ReadSize (LPCTSTR section, LPCTSTR entry, TSize &sz) const
 
bool WriteSize (LPCTSTR section, LPCTSTR entry, const TSize &size)
 This method writes a TSize.
 
bool ReadSize (const tstring &section, const tstring &entry, TSize &sz) const
 
bool WriteSize (const tstring &section, const tstring &entry, const TSize &size)
 

Protected Attributes

TRegKey Root
 
- Protected Attributes inherited from owl::TConfigFile
tstring FileName
 

Additional Inherited Members

- Static Public Member Functions inherited from owl::TConfigFile
static void SetPrecision (int newprec=-1)
 
static int GetPrecision ()
 
- Static Protected Member Functions inherited from owl::TConfigFile
static bool StringToBool (LPCTSTR str, bool *val)
 This static method converts a string to a bool, accepting most common boolean keywords: yes, on, true and 1.
 
static tstring BoolToString (bool val)
 This static method returns yes or no given a boolean value.
 
- Static Protected Attributes inherited from owl::TConfigFile
static int DefaultPrecision = -1
 

Detailed Description

Derived from TConfigFile, TRegConfigFile is used to maintain configuration settings in the registry.

Definition at line 329 of file configfl.h.

Constructor & Destructor Documentation

◆ TRegConfigFile()

owl::TRegConfigFile::TRegConfigFile ( const tstring & name,
HKEY root = HKEY_CURRENT_USER )

This source file implements TRegConfigFile.

This class is derived from TConfigFile and overrides the low-level storage methods to vector them to the registry. TRegConfigFile is not intended to handle all of an app's registry needs, but rather to be used for a convenient wrapper for app preference settings. All data is stored in HKEY_CURRENT_USER, using FileName like so:

FileName should contain the company name and product name to adhere to standard registry practices. Eg:

A version number can also be used to allow multiple versions of the same product to live together:

mFile = "My Company\\Product\\V1.0"
Note
FileName must not end with a backslash!

All sections are created under the subtree as described above. Eg,

Section = "Options"
const tchar * Section
Definition rcntfile.cpp:45

Entries are stored under sections as REG_SZ values (for numbers it is REG_DWORD). Eg,

Definition at line 1361 of file configfl.cpp.

◆ ~TRegConfigFile()

owl::TRegConfigFile::~TRegConfigFile ( )
virtual

Definition at line 1366 of file configfl.cpp.

Member Function Documentation

◆ EraseEntry() [1/3]

bool owl::TConfigFile::EraseEntry ( const tstring & section,
const tstring & entry )
inline

Definition at line 86 of file configfl.h.

◆ EraseEntry() [2/3]

bool owl::TRegConfigFile::EraseEntry ( LPCTSTR section,
LPCTSTR entry )
virtual

Implements owl::TConfigFile.

Definition at line 1447 of file configfl.cpp.

References owl::TConfigFile::FileName, PRECONDITION, and Root.

◆ EraseEntry() [3/3]

virtual bool owl::TConfigFile::EraseEntry ( LPCTSTR section,
LPCTSTR entry )
virtual

Implements owl::TConfigFile.

◆ EraseSection() [1/3]

bool owl::TConfigFile::EraseSection ( const tstring & section)
inline

Definition at line 85 of file configfl.h.

◆ EraseSection() [2/3]

bool owl::TRegConfigFile::EraseSection ( LPCTSTR section)
virtual

Implements owl::TConfigFile.

Definition at line 1441 of file configfl.cpp.

References owl::TConfigFile::FileName, PRECONDITION, and Root.

◆ EraseSection() [3/3]

virtual bool owl::TConfigFile::EraseSection ( LPCTSTR section)
virtual

Implements owl::TConfigFile.

◆ ReadData() [1/3]

bool owl::TConfigFile::ReadData ( const tstring & section,
const tstring & entry,
void * buffer,
uint size ) const
inline

Definition at line 93 of file configfl.h.

◆ ReadData() [2/3]

bool owl::TRegConfigFile::ReadData ( LPCTSTR section,
LPCTSTR entry,
void * buffer,
uint size ) const
virtual

This method reads binary data.

Reimplemented from owl::TConfigFile.

Definition at line 1506 of file configfl.cpp.

References owl::TConfigFile::FileName, owl::TRegKey::GetSubkey(), PRECONDITION, and Root.

◆ ReadData() [3/3]

bool owl::TConfigFile::ReadData ( LPCTSTR section,
LPCTSTR entry,
void * buffer,
uint size ) const
virtual

This method reads binary data.

Reimplemented from owl::TConfigFile.

Definition at line 76 of file configfl.cpp.

◆ ReadInteger() [1/3]

int owl::TConfigFile::ReadInteger ( const tstring & section,
const tstring & entry,
int defint = 0 ) const
inline

Definition at line 96 of file configfl.h.

◆ ReadInteger() [2/3]

int owl::TRegConfigFile::ReadInteger ( LPCTSTR section,
LPCTSTR entry,
int defint = 0 ) const
virtual

Reimplemented from owl::TConfigFile.

Definition at line 1458 of file configfl.cpp.

References owl::TConfigFile::FileName, owl::TRegKey::GetSubkey(), PRECONDITION, and Root.

◆ ReadInteger() [3/3]

int owl::TConfigFile::ReadInteger ( LPCTSTR section,
LPCTSTR entry,
int defint = 0 ) const
virtual

This method reads an integer.

Reimplemented from owl::TConfigFile.

Definition at line 79 of file configfl.cpp.

◆ ReadSection() [1/3]

int owl::TConfigFile::ReadSection ( const tstring & section,
tstring & buffer ) const

Definition at line 83 of file configfl.cpp.

◆ ReadSection() [2/3]

uint owl::TRegConfigFile::ReadSection ( LPCTSTR section,
TCHAR * buffer,
uint bufSize ) const
virtual

Copies all value names of the given section to the specified buffer.

Each string is null-terminated, and the buffer is then terminated with a trailing null. Returns the number of characters written, excluding the trailing null-terminators. If the buffer is too small, the last string copied to the buffer may be truncated.

Implements owl::TConfigFile.

Definition at line 1382 of file configfl.cpp.

References _T, _tcslen, _tcsncpy, owl::TConfigFile::FileName, PRECONDITION, and Root.

◆ ReadSection() [3/3]

virtual uint owl::TConfigFile::ReadSection ( LPCTSTR section,
TCHAR * buffer,
uint bufSize ) const
virtual

Implements owl::TConfigFile.

◆ ReadSections() [1/3]

uint owl::TRegConfigFile::ReadSections ( TCHAR * buffer,
uint bufSize ) const
virtual

Copies all section names to the specified buffer.

Each string is null-terminated, and the buffer is then terminated with a trailing null. Returns the number of characters written, excluding the trailing null-terminators. If the buffer is too small, the last string copied to the buffer may be truncated.

Implements owl::TConfigFile.

Definition at line 1414 of file configfl.cpp.

References _T, _tcslen, _tcsncpy, owl::TConfigFile::FileName, PRECONDITION, and Root.

◆ ReadSections() [2/3]

virtual uint owl::TConfigFile::ReadSections ( TCHAR * sections,
uint bufSize ) const
virtual

Implements owl::TConfigFile.

◆ ReadSections() [3/3]

int owl::TConfigFile::ReadSections ( tstring & sections) const

Definition at line 84 of file configfl.cpp.

◆ ReadString() [1/4]

uint owl::TConfigFile::ReadString ( const tstring & section,
const tstring & entry,
tstring & buffer,
const tstring & defstr ) const
inline

Definition at line 89 of file configfl.h.

◆ ReadString() [2/4]

uint owl::TConfigFile::ReadString ( const tstring & section,
const tstring & entry,
tstring & buffer,
LPCTSTR defstr = 0 ) const

String-aware overload.

Definition at line 88 of file configfl.cpp.

◆ ReadString() [3/4]

uint owl::TRegConfigFile::ReadString ( LPCTSTR section,
LPCTSTR entry,
TCHAR * buffer,
uint bufSize,
LPCTSTR defstr = 0 ) const
virtual

Looks up the value of the given entry of the given section, and if found, copies it to the given buffer.

If not found, the given default value defstr is copied to the buffer, unless defstr is null, in which case an empty string is copied to the buffer.

Returns
The number of characters written to the output buffer (excluding the null-terminator, which is also written). If an error occurs, e.g. registry access is denied, a TXRegistry exception is thrown.
Note
If the buffer is too small to hold the whole string, the string is truncated to (bufSize - 1) characters and null-terminated.

Implements owl::TConfigFile.

Definition at line 1483 of file configfl.cpp.

References _T, owl::TConfigFile::FileName, owl::TRegKey::GetSubkey(), PRECONDITION, and Root.

◆ ReadString() [4/4]

virtual uint owl::TConfigFile::ReadString ( LPCTSTR section,
LPCTSTR entry,
TCHAR * buffer,
uint bufSize,
LPCTSTR defstr = 0 ) const
virtual

Implements owl::TConfigFile.

◆ SectionExists() [1/3]

bool owl::TConfigFile::SectionExists ( const tstring & section) const
inline

Definition at line 82 of file configfl.h.

◆ SectionExists() [2/3]

bool owl::TRegConfigFile::SectionExists ( LPCTSTR section) const
virtual

Reimplemented from owl::TConfigFile.

Definition at line 1370 of file configfl.cpp.

References owl::TConfigFile::FileName, owl::TRegKey::HasSubkey(), PRECONDITION, and Root.

◆ SectionExists() [3/3]

bool owl::TConfigFile::SectionExists ( LPCTSTR section) const
virtual

Reimplemented from owl::TConfigFile.

Definition at line 66 of file configfl.cpp.

◆ UpdateFile()

void owl::TRegConfigFile::UpdateFile ( )
virtual

Implements owl::TConfigFile.

Definition at line 1453 of file configfl.cpp.

◆ WriteData() [1/3]

bool owl::TConfigFile::WriteData ( const tstring & section,
const tstring & entry,
void * buffer,
uint size )
inline

Definition at line 94 of file configfl.h.

◆ WriteData() [2/3]

bool owl::TRegConfigFile::WriteData ( LPCTSTR section,
LPCTSTR entry,
void * buffer,
uint size )
virtual

This method writes binary data.

Reimplemented from owl::TConfigFile.

Definition at line 1518 of file configfl.cpp.

References owl::TConfigFile::FileName, PRECONDITION, and Root.

◆ WriteData() [3/3]

bool owl::TConfigFile::WriteData ( LPCTSTR section,
LPCTSTR entry,
void * buffer,
uint size )
virtual

This method writes binary data.

Reimplemented from owl::TConfigFile.

Definition at line 77 of file configfl.cpp.

◆ WriteInteger() [1/3]

bool owl::TConfigFile::WriteInteger ( const tstring & section,
const tstring & entry,
int value )
inline

Definition at line 97 of file configfl.h.

◆ WriteInteger() [2/3]

bool owl::TRegConfigFile::WriteInteger ( LPCTSTR section,
LPCTSTR entry,
int value )
virtual

Reimplemented from owl::TConfigFile.

Definition at line 1465 of file configfl.cpp.

References owl::TConfigFile::FileName, PRECONDITION, and Root.

◆ WriteInteger() [3/3]

bool owl::TConfigFile::WriteInteger ( LPCTSTR section,
LPCTSTR entry,
int value )
virtual

This method writes an integer. We format it as a string.

Reimplemented from owl::TConfigFile.

Definition at line 80 of file configfl.cpp.

◆ WriteString() [1/3]

bool owl::TConfigFile::WriteString ( const tstring & section,
const tstring & entry,
const tstring & value )
inline

Definition at line 91 of file configfl.h.

◆ WriteString() [2/3]

bool owl::TRegConfigFile::WriteString ( LPCTSTR section,
LPCTSTR entry,
LPCTSTR value )
virtual

Implements owl::TConfigFile.

Definition at line 1496 of file configfl.cpp.

References owl::TConfigFile::FileName, PRECONDITION, and Root.

◆ WriteString() [3/3]

virtual bool owl::TConfigFile::WriteString ( LPCTSTR section,
LPCTSTR entry,
LPCTSTR value )
virtual

Implements owl::TConfigFile.

Member Data Documentation

◆ Root

TRegKey owl::TRegConfigFile::Root
protected

Definition at line 366 of file configfl.h.


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