OSB_LIB::Setting Class Reference

Collaboration diagram for OSB_LIB::Setting:

Collaboration graph
[legend]
List of all members.

Detailed Description

This class handles osb setting.

The setting has four parts: module name, Username, password and database.
They will be stored in a text file. Each part will be separated by a colon.
Module name is regarded as the primary key here. The password is encrypted.

Definition at line 64 of file setting.h.

Public Types

Public Member Functions

Read access to data members
Modify data members

Private Member Functions

Private Attributes

Static Private Attributes


Member Enumeration Documentation

enum OSB_LIB::Setting::RetValue

Enumerator:
rvSuccess 
rvDirReadOnly 
rvFileReadOnly 

Definition at line 66 of file setting.h.


Constructor & Destructor Documentation

OSB_LIB::Setting::Setting ( const std::string &  module  )  [inline, explicit]

Constructor with module name.

Definition at line 72 of file setting.h.


Member Function Documentation

void OSB_LIB::Setting::append ( std::fstream &  f  )  const [private]

Append module name, Username, password and database into file stream.

Parameters:
f Destination file stream.

int OSB_LIB::Setting::checkModule ( std::fstream &  f  )  [private]

Check whether the module is in the setting file.

Parameters:
f Source file stream.
Returns:
0 for not found,
else is the line number of the found module.

const std::string& OSB_LIB::Setting::database (  )  const [inline]

Access database of setting.

Definition at line 88 of file setting.h.

References database_.

void OSB_LIB::Setting::delSetting (  ) 

Delete the setting from the configuration file.

The file path must be set before calling this method (By calling getWritePath()). User also should confirm if the path is correct by check the return value of the getWritePath(). This method will not check whether there is any error when open the file.

RetValue OSB_LIB::Setting::getWritePath ( const std::string &  path  ) 

Get the path of the osb.cfg to be wrote.

It will create a new file if it does not exist.

Parameters:
path The path (with filename) of the config file.
Returns:
rvSuccess if success,
rvDirReadOnly if can not create a new osb.cfg for dir may read only,
rvFileReadOnly if the existing osb.cfg is read only.

const std::string& OSB_LIB::Setting::moduleName (  )  const [inline]

Access module name of setting.

Definition at line 79 of file setting.h.

References moduleName_.

const std::string& OSB_LIB::Setting::password (  )  const [inline]

Access password of setting.

Definition at line 85 of file setting.h.

References password_.

const std::string& OSB_LIB::Setting::path (  )  const

Access path of the file which stores the setting.

Path includes file name.

void OSB_LIB::Setting::readSetting (  ) 

Read the setting from setting file based on the given module name.

Exceptions:
OsbException if the configuration file is not found in any of the possible directories.
OsbException if the module is not found.
OsbException if username is empty.
OsbException if database is empty.
OsbException if password is corrupted.
The function always throws if it can not find the setting for moduleName_ in any of the searched configuration files.

void OSB_LIB::Setting::removeLine ( std::fstream &  f,
int  line 
) [private]

Remove a specific line of setting.

Parameters:
f Source file stream.
line Number of the line to be removed.

void OSB_LIB::Setting::replaceLine ( std::fstream &  f,
int  line 
) [private]

Replace the specific line for new setting.

Parameters:
f Source file stream.
line Number of the line to be replaced.

void OSB_LIB::Setting::setDatabase ( const std::string &  db  )  [inline]

Set database of setting.

Definition at line 104 of file setting.h.

References database_.

void OSB_LIB::Setting::setDir ( Directories dirs  ) 

Set all the possible paths of the file which stores the setting.

Parameters:
dirs Directories of the file.

void OSB_LIB::Setting::setModuleName ( const std::string &  mn  )  [inline]

Set module name of setting.

Definition at line 98 of file setting.h.

References moduleName_.

void OSB_LIB::Setting::setPassword ( const std::string &  pw  )  [inline]

Set password of setting.

Definition at line 102 of file setting.h.

References password_.

void OSB_LIB::Setting::setUserName ( const std::string &  un  )  [inline]

Set Username of setting.

Definition at line 100 of file setting.h.

References userName_.

void OSB_LIB::Setting::showDir ( std::ostream &  os  )  const

Write the file name and a list of all directories searched to write it to.

Parameters:
os output stream to write to.

const std::string& OSB_LIB::Setting::userName (  )  const [inline]

Access Username of setting.

Definition at line 82 of file setting.h.

References userName_.

void OSB_LIB::Setting::writeSetting (  ) 

Write the setting into setting file.

The file path must be set before calling this method (By calling getWritePath()). User also should confirm if the path is correct by check the return value of the getWritePath(). This method will not check whether there is any error when open the file.


Member Data Documentation

std::string OSB_LIB::Setting::database_ [private]

Database of setting.

Definition at line 179 of file setting.h.

Referenced by database(), and setDatabase().

const std::string OSB_LIB::Setting::fileName_ [static, private]

Name of the file which stores the setting.

We define name as "osb.cfg" here.

Definition at line 185 of file setting.h.

std::string OSB_LIB::Setting::moduleName_ [private]

Module name of setting.

Definition at line 176 of file setting.h.

Referenced by moduleName(), and setModuleName().

std::string OSB_LIB::Setting::password_ [private]

Password of setting.

Definition at line 178 of file setting.h.

Referenced by password(), and setPassword().

std::string OSB_LIB::Setting::path_ [private]

Path of the file which stores the setting, including file name.

Definition at line 182 of file setting.h.

std::string OSB_LIB::Setting::userName_ [private]

Username of setting.

Definition at line 177 of file setting.h.

Referenced by setUserName(), and userName().


The documentation for this class was generated from the following file:
Generated on Sat Sep 2 14:13:05 2006 for OSB Library by  doxygen 1.4.7