tbx
0.7.5
|
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... | |
Class to lookup token translations from a messages file.
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
file_name | name 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.
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.
token | name of token to check |
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.
token | token 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_size | Maximum size for the string that will be returned. defaults to 255 characters |
tbx::OsError | if 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.
token | token 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. |
arg0 | This string will replace "%0" in the returned message. |
max_size | Maximum size for the string that will be returned. defaults to 255 characters |
tbx::OsError | if 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.
token | token 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. |
arg0 | This string will replace "%0" in the returned message. |
arg1 | This string will replace "%1" in the returned message. |
max_size | Maximum size for the string that will be returned. defaults to 255 characters |
tbx::OsError | if 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.
token | token 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. |
arg0 | This string will replace "%0" in the returned message. |
arg1 | This string will replace "%1" in the returned message. |
arg2 | This string will replace "%2" in the returned message. |
max_size | Maximum size for the string that will be returned. defaults to 255 characters |
tbx::OsError | if 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.
token | token 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. |
arg0 | This string will replace "%0" in the returned message. |
arg1 | This string will replace "%1" in the returned message. |
arg2 | This string will replace "%2" in the returned message. |
arg3 | This string will replace "%2" in the returned message. |
max_size | Maximum size for the string that will be returned. defaults to 255 characters |
tbx::OsError | if 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.
token | token 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. |
tbx::OsError | if 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.
token | token 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. |
arg0 | This string will replace "%0" in the returned message. |
max_size | Maximum size for the string that will be returned. defaults to 255 characters |
tbx::OsError | if 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.
token | token 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. |
arg0 | This string will replace "%0" in the returned message. |
arg1 | This string will replace "%1" in the returned message. |
max_size | Maximum size for the string that will be returned. defaults to 255 characters |
tbx::OsError | if 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.
token | token 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. |
arg0 | This string will replace "%0" in the returned message. |
arg1 | This string will replace "%1" in the returned message. |
arg2 | This string will replace "%2" in the returned message. |
max_size | Maximum size for the string that will be returned. defaults to 255 characters |
tbx::OsError | if 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.
token | token 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. |
arg0 | This string will replace "%0" in the returned message. |
arg1 | This string will replace "%1" in the returned message. |
arg2 | This string will replace "%2" in the returned message. |
arg3 | This string will replace "%2" in the returned message. |
max_size | Maximum size for the string that will be returned. defaults to 255 characters |
tbx::OsError | if the message does not exist and no default is given |
bool tbx::MessageFile::open | ( | const std::string & | file_name | ) |
Open a messages file.
file_name | file name to open |