rwlogo
Rogue Wave Views 5.6

Rogue Wave Views
Foundation Package API Reference Guide

Product Documentation:

Rogue Wave Views
Documentation Home

IlvMessageDatabase Class Reference

Message handling class. More...

#include <ilviews/base/message.h>

List of all members.

Public Member Functions

virtual void clean ()
 Cleans the message database.
const char * getMessage (const char *msgid, const IlSymbol *language) const
 Gets a message.
void putMessage (const char *msgid, IlSymbol *language, const char *value, IlBoolean copy=((IlBoolean) 1))
 Adds a message.
IlBoolean read (const char *filename, const IlvDisplay *d=0, const char *fName=0)
 Reads a message database from a file.
virtual IlBoolean read (ILVSTDPREF istream &istr, const IlvDisplay *display=0, const char *fName=0)
 Reads a message database from the input stream.
virtual void remove (IlSymbol *language)
 Removes all messages for a language.
virtual IlBoolean removeMessage (const char *msgid)
 Removes a message.
void write (const char *filename, const IlSymbol *language=0, IlEncoding encoding=IlNoEncoding) const
 Writes the message database to a file.
virtual void write (ILVSTDPREF ostream &ostr, const IlSymbol *language=0, IlEncoding encoding=IlNoEncoding) const
 Writes the message database to the output stream.

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:
msgid The message identifier of the message to be retrieved.
language The language.
Returns:
The message string.
void IlvMessageDatabase::putMessage ( const char *  msgid,
IlSymbol language,
const char *  value,
IlBoolean  copy = ((IlBoolean) 1) 
)

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:
msgid The message identifier.
language The language.
value The message string.
copy A Boolean value to copy rather than move the string.
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:
filename The input file.
display The display path to search for a relative filename.
Returns:
IlFalse if an error occurred while loading the message database.
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:
istr The input stream.
Returns:
IlFalse if there has been an error 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:
language The 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:
msgid The message identifier to be removed.
Returns:
IlFalse if no such message identifier was found in the database.
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:
filename The output file.
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:
ostr The output stream.
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

© 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.