rwlogo

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 (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...
 

Detailed Description

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.

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 ( std::istream &  istr,
const IlvDisplay display = 0,
const char *  context = 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.
displayA display instance, used for reporting errors.
contextA 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.
Returns
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.

Parameters
filenameThe input file.
displayThe display instance providing the search path to search for a relative filename.
fNameUndocumented parameter.
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 ( std::ostream &  ostr,
const IlSymbol language = 0,
IlEncoding  encoding = IlNoEncoding 
) const
virtual

Writes the message database to the output stream.

Parameters
ostrThe output stream.
languageThe language that is serialized.
encodingThe 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.

Parameters
filenameThe output file.
languageThe language that is serialized.
encodingThe encoding to be used for serialization.

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