Rogue Wave Views Foundation Package API Reference Guide |
Rogue Wave Views Documentation Home |
Message handling class. More...
#include <ilviews/base/message.h>
Public Member Functions | |
virtual void | clean () |
Cleans the message database. More... | |
const char * | getMessage (const char *msgid, const IlSymbol *language) const |
Gets a message. More... | |
void | putMessage (const char *msgid, IlSymbol *language, const char *value, IlBoolean copy=IlTrue) |
Adds a message. More... | |
virtual IlBoolean | read (std::istream &istr, const IlvDisplay *display=0, const char *context=0) |
Reads a message database from the input stream. More... | |
IlBoolean | read (const char *filename, const IlvDisplay *display=0, const char *fName=0) |
Reads a message database from a file. More... | |
virtual void | remove (IlSymbol *language) |
Removes all messages for a language. More... | |
virtual IlBoolean | removeMessage (const char *msgid) |
Removes a message. More... | |
virtual void | write (std::ostream &ostr, const IlSymbol *language=0, IlEncoding encoding=IlNoEncoding) const |
Writes the message database to the output stream. More... | |
void | write (const char *filename, const IlSymbol *language=0, IlEncoding encoding=IlNoEncoding) const |
Writes the message database to a file. More... | |
Message handling class.
Library: xviews or winviews or mviews (mutually exclusive)
Rogue Wave Views provides a simple mechanism to help you localize applications. The IlvMessageDatabase
class allows to associate several translations strings with single message identifier (one translation per language), and provides a way to retrieve the right translation at runtime, based on the current language.
Each instance of the IlvDisplay
class creates its own message database. It reads the database description from the file name provided in the environment variable ILVDB
, or views.dbm
if this variable is not set. This file is searched for in the display path. You can access this database by calling the member function IlvDisplay::getDatabase()
. Each string that you plan to show in different languages can be stored in the database with its different possible translations. We say that you associate a message identifier with different message strings, depending on the language you target. The language is specified in a symbol.
|
virtual |
Cleans the message database.
Empties the database. Every message is deleted from every language.
const char* IlvMessageDatabase::getMessage | ( | const char * | msgid, |
const IlSymbol * | language | ||
) | const |
Gets a message.
Retrieves the message string associated with the message identifier msgid for the language language. This string should not be modified or deleted by the user.
msgid | The message identifier of the message to be retrieved. |
language | The language. |
void IlvMessageDatabase::putMessage | ( | const char * | msgid, |
IlSymbol * | language, | ||
const char * | value, | ||
IlBoolean | copy = IlTrue |
||
) |
Adds a message.
Associates the message string value with the message identifier msgid for the language language. A copy of value is performed if copy is omitted or set to IlTrue
. Any previous definition is discarded.
msgid | The message identifier. |
language | The language. |
value | The message string. |
copy | A Boolean value to copy rather than move the string. |
|
virtual |
Reads a message database from the input stream.
Reads the description of a database from the input stream istr and appends this description to the current database.
istr | The input stream. |
display | A display instance, used for reporting errors. |
context | A string that, in the case there is an error, will be used in the generated error message to provide some context to the end user. |
IlFalse
if there has been an error loading the message database. IlBoolean IlvMessageDatabase::read | ( | const char * | filename, |
const IlvDisplay * | display = 0 , |
||
const char * | fName = 0 |
||
) |
Reads a message database from a file.
Reads this database from the file filename. If the display parameter is not 0
, the file is searched for in the display path, provided that filename is a relative path name. If you are using the internationalization feature, you should be aware that it will be impossible to read a message database located in a locale directory if the display argument is not provided.
filename | The input file. |
display | The display instance providing the search path to search for a relative filename. |
fName | Undocumented parameter. |
IlFalse
if an error occurred while loading the message database.
|
virtual |
Removes all messages for a language.
Removes the definition of every message for the language language.
language | The language whose messages are to be removed. |
|
virtual |
Removes a message.
Removes every definition of the message identifier msgid.
msgid | The message identifier to be removed. |
IlFalse
if no such message identifier was found in the database.
|
virtual |
Writes the message database to the output stream.
ostr | The output stream. |
language | The language that is serialized. |
encoding | The encoding to be used for serialization. |
void IlvMessageDatabase::write | ( | const char * | filename, |
const IlSymbol * | language = 0 , |
||
IlEncoding | encoding = IlNoEncoding |
||
) | const |
Writes the message database to a file.
Saves this database to the file filename.
filename | The output file. |
language | The language that is serialized. |
encoding | The encoding to be used for serialization. |
© Copyright 2016, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.