tbx  0.7.3
Public Member Functions | List of all members
tbx::MessageFile Class Reference

Class to lookup token translations from a messages file. More...

#include <messagefile.h>

Public Member Functions

 MessageFile ()
 Unused message file constructor. More...
 
 MessageFile (const std::string &file_name)
 Construct and load given file. More...
 
 MessageFile (int *messageFD)
 Construct given an already created message file descriptor block. More...
 
 ~MessageFile ()
 Destructor - close file if opened with constructor or open function.
 
bool open (const std::string &file_name)
 Open a messages file. More...
 
void close ()
 Closes the message file if its has been successfully opened.
 
void attach (int *messageFD)
 Attach this messages file class to the given message file descriptor. More...
 
bool is_open () const
 Returns true if message file is open.
 
bool contains (const std::string &token) const
 Checks to see if the message file contains the given token. More...
 
std::string message (const std::string &token) const
 Get the string with the given token name without argument substitution. More...
 
std::string message (const std::string &token, const std::string &arg0, int max_size=255) const
 Get the string with the given token name and one argument substituted. More...
 
std::string message (const std::string &token, const std::string &arg0, const std::string &arg1, int max_size=255) const
 Get the string with the given token name and two arguments substituted. More...
 
std::string message (const std::string &token, const std::string &arg0, const std::string &arg1, const std::string &arg2, int max_size=255) const
 Get the string with the given token name and three arguments substituted. More...
 
std::string message (const std::string &token, const std::string &arg0, const std::string &arg1, const std::string &arg2, const std::string &arg3, int max_size=255) const
 Get the string with the given token name and four arguments substituted. More...
 
std::string gsmessage (const std::string &token, int max_size=255) const
 Get the string with the given token name and converts it from the GSTrans format. More...
 
std::string gsmessage (const std::string &token, const std::string &arg0, int max_size=255) const
 Get the string with the given token name and one argument substituted and converts it from the GSTrans format. More...
 
std::string gsmessage (const std::string &token, const std::string &arg0, const std::string &arg1, int max_size=255) const
 Get the string with the given token name and two arguments substituted and converts it from the GSTrans format. More...
 
std::string gsmessage (const std::string &token, const std::string &arg0, const std::string &arg1, const std::string &arg2, int max_size=255) const
 Get the string with the given token name and three arguments substituted and converts it from the GSTrans format. More...
 
std::string gsmessage (const std::string &token, const std::string &arg0, const std::string &arg1, const std::string &arg2, const std::string &arg3, int max_size=255) const
 Get the string with the given token name and four arguments substituted and converts it from the GSTrans format. More...
 

Detailed Description

Class to lookup token translations from a messages file.

Constructor & Destructor Documentation

tbx::MessageFile::MessageFile ( )

Unused message file constructor.

call open to open a message file before use

tbx::MessageFile::MessageFile ( const std::string &  file_name)

Construct and load given file.

use is_open to check if the file opened OK

Parameters
file_namename of file to open
tbx::MessageFile::MessageFile ( int *  messageFD)

Construct given an already created message file descriptor block.

This class does not own this block so will not close the file.

Member Function Documentation

void tbx::MessageFile::attach ( int *  messageFD)

Attach this messages file class to the given message file descriptor.

Does not close the given the file in any circumstances.

bool tbx::MessageFile::contains ( const std::string &  token) const

Checks to see if the message file contains the given token.

Parameters
tokenname of token to check
Returns
true if token is in message file.
std::string tbx::MessageFile::gsmessage ( const std::string &  token,
int  max_size = 255 
) const

Get the string with the given token name and converts it from the GSTrans format.

Parameters
tokentoken name to look up in message file. A default message can be added to this parameter by appending to the token name a colon (:) and then the default message.
max_sizeMaximum size for the string that will be returned. defaults to 255 characters
Exceptions
tbx::OsErrorif the message does not exist and no default is given
std::string tbx::MessageFile::gsmessage ( const std::string &  token,
const std::string &  arg0,
int  max_size = 255 
) const

Get the string with the given token name and one argument substituted and converts it from the GSTrans format.

Parameters
tokentoken name to look up in message file. A default message can be added to this parameter by appending to the token name a colon (:) and then the default message.
arg0This string will replace "%0" in the returned message.
max_sizeMaximum size for the string that will be returned. defaults to 255 characters
Exceptions
tbx::OsErrorif the message does not exist and no default is given
std::string tbx::MessageFile::gsmessage ( const std::string &  token,
const std::string &  arg0,
const std::string &  arg1,
int  max_size = 255 
) const

Get the string with the given token name and two arguments substituted and converts it from the GSTrans format.

Parameters
tokentoken name to look up in message file. A default message can be added to this parameter by appending to the token name a colon (:) and then the default message.
arg0This string will replace "%0" in the returned message.
arg1This string will replace "%1" in the returned message.
max_sizeMaximum size for the string that will be returned. defaults to 255 characters
Exceptions
tbx::OsErrorif the message does not exist and no default is given
std::string tbx::MessageFile::gsmessage ( const std::string &  token,
const std::string &  arg0,
const std::string &  arg1,
const std::string &  arg2,
int  max_size = 255 
) const

Get the string with the given token name and three arguments substituted and converts it from the GSTrans format.

Parameters
tokentoken name to look up in message file. A default message can be added to this parameter by appending to the token name a colon (:) and then the default message.
arg0This string will replace "%0" in the returned message.
arg1This string will replace "%1" in the returned message.
arg2This string will replace "%2" in the returned message.
max_sizeMaximum size for the string that will be returned. defaults to 255 characters
Exceptions
tbx::OsErrorif the message does not exist and no default is given
std::string tbx::MessageFile::gsmessage ( const std::string &  token,
const std::string &  arg0,
const std::string &  arg1,
const std::string &  arg2,
const std::string &  arg3,
int  max_size = 255 
) const

Get the string with the given token name and four arguments substituted and converts it from the GSTrans format.

Parameters
tokentoken name to look up in message file. A default message can be added to this parameter by appending to the token name a colon (:) and then the default message.
arg0This string will replace "%0" in the returned message.
arg1This string will replace "%1" in the returned message.
arg2This string will replace "%2" in the returned message.
arg3This string will replace "%2" in the returned message.
max_sizeMaximum size for the string that will be returned. defaults to 255 characters
Exceptions
tbx::OsErrorif the message does not exist and no default is given
std::string tbx::MessageFile::message ( const std::string &  token) const

Get the string with the given token name without argument substitution.

Parameters
tokentoken name to look up in message file. A default message can be added to this parameter by appending to the token name a colon (:) and then the default message.
Exceptions
tbx::OsErrorif the message does not exist and no default is given
std::string tbx::MessageFile::message ( const std::string &  token,
const std::string &  arg0,
int  max_size = 255 
) const

Get the string with the given token name and one argument substituted.

Parameters
tokentoken name to look up in message file. A default message can be added to this parameter by appending to the token name a colon (:) and then the default message.
arg0This string will replace "%0" in the returned message.
max_sizeMaximum size for the string that will be returned. defaults to 255 characters
Exceptions
tbx::OsErrorif the message does not exist and no default is given
std::string tbx::MessageFile::message ( const std::string &  token,
const std::string &  arg0,
const std::string &  arg1,
int  max_size = 255 
) const

Get the string with the given token name and two arguments substituted.

Parameters
tokentoken name to look up in message file. A default message can be added to this parameter by appending to the token name a colon (:) and then the default message.
arg0This string will replace "%0" in the returned message.
arg1This string will replace "%1" in the returned message.
max_sizeMaximum size for the string that will be returned. defaults to 255 characters
Exceptions
tbx::OsErrorif the message does not exist and no default is given
std::string tbx::MessageFile::message ( const std::string &  token,
const std::string &  arg0,
const std::string &  arg1,
const std::string &  arg2,
int  max_size = 255 
) const

Get the string with the given token name and three arguments substituted.

Parameters
tokentoken name to look up in message file. A default message can be added to this parameter by appending to the token name a colon (:) and then the default message.
arg0This string will replace "%0" in the returned message.
arg1This string will replace "%1" in the returned message.
arg2This string will replace "%2" in the returned message.
max_sizeMaximum size for the string that will be returned. defaults to 255 characters
Exceptions
tbx::OsErrorif the message does not exist and no default is given
std::string tbx::MessageFile::message ( const std::string &  token,
const std::string &  arg0,
const std::string &  arg1,
const std::string &  arg2,
const std::string &  arg3,
int  max_size = 255 
) const

Get the string with the given token name and four arguments substituted.

Parameters
tokentoken name to look up in message file. A default message can be added to this parameter by appending to the token name a colon (:) and then the default message.
arg0This string will replace "%0" in the returned message.
arg1This string will replace "%1" in the returned message.
arg2This string will replace "%2" in the returned message.
arg3This string will replace "%2" in the returned message.
max_sizeMaximum size for the string that will be returned. defaults to 255 characters
Exceptions
tbx::OsErrorif the message does not exist and no default is given
bool tbx::MessageFile::open ( const std::string &  file_name)

Open a messages file.

Parameters
file_namefile name to open
Returns
true if message file opened OK

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