rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

List of all members | Public Member Functions
IlvMessageDatabase Class Reference

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 (ILVSTDPREF istream &istr, const IlvDisplay *display=0, const char *fName=0)
 Reads a message database from the input stream. More...
 
IlBoolean read (const char *filename, const IlvDisplay *d=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 (ILVSTDPREF 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...
 

Detailed Description

Message handling class.

Library: display

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.

See Also
IlvDisplay
IlvDisplay::getDatabase()
IlvDisplay::getMessage()
IlvGetMessage().

Member Function Documentation

virtual void IlvMessageDatabase::clean ( )
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.

Parameters
msgidThe message identifier of the message to be retrieved.
languageThe language.
Returns
The message string.
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.

Parameters
msgidThe message identifier.
languageThe language.
valueThe message string.
copyA Boolean value to copy rather than move the string.
virtual IlBoolean IlvMessageDatabase::read ( ILVSTDPREF istream &  istr,
const IlvDisplay display = 0,
const char *  fName = 0 
)
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.

Parameters
istrThe input stream.
Returns
IlFalse if there has been an error loading the message database.
IlBoolean IlvMessageDatabase::read ( const char *  filename,
const IlvDisplay d = 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.

Parameters
filenameThe input file.
displayThe display path to search for a relative filename.
Returns
IlFalse if an error occurred while loading the message database.
virtual void IlvMessageDatabase::remove ( IlSymbol language)
virtual

Removes all messages for a language.

Removes the definition of every message for the language language.

Parameters
languageThe language whose messages are to be removed.
virtual IlBoolean IlvMessageDatabase::removeMessage ( const char *  msgid)
virtual

Removes a message.

Removes every definition of the message identifier msgid.

Parameters
msgidThe message identifier to be removed.
Returns
IlFalse if no such message identifier was found in the database.
virtual void IlvMessageDatabase::write ( ILVSTDPREF ostream &  ostr,
const IlSymbol language = 0,
IlEncoding  encoding = IlNoEncoding 
) const
virtual

Writes the message database to the output stream.

Saves this database to the output stream ostr.

Parameters
ostrThe output stream.
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.

Parameters
filenameThe output file.

© Copyright 2012, 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.