Open CASCADE Technology  7.4.0
Static Public Member Functions

Message_MsgFile Class Reference

A tool providing facility to load definitions of message strings from resource file(s). More...

#include <Message_MsgFile.hxx>

Static Public Member Functions

static Standard_Boolean Load (const Standard_CString theDirName, const Standard_CString theFileName)
 Load message file <theFileName> from directory <theDirName> or its sub-directory. More...
 
static Standard_Boolean LoadFile (const Standard_CString theFName)
 Load the messages from the given file, additive to any previously loaded messages. Messages with same keywords, if already present, are replaced with the new ones. More...
 
theLangExt language file name extension
Returns
TRUE on success
static Standard_Boolean LoadFromEnv (const Standard_CString theEnvName, const Standard_CString theFileName, const Standard_CString theLangExt="")
 Loads the messages from the given text buffer. More...
 
static Standard_Boolean LoadFromString (const Standard_CString theContent, const Standard_Integer theLength=-1)
 Loads the messages from the given text buffer. More...
 
static Standard_Boolean AddMsg (const TCollection_AsciiString &key, const TCollection_ExtendedString &text)
 Adds new message to the map. Parameter <key> gives the key of the message, <text> defines the message itself. If there already was defined the message identified by the same keyword, it is replaced with the new one. More...
 
static Standard_Boolean HasMsg (const TCollection_AsciiString &key)
 Returns True if message with specified keyword is registered. More...
 
static const TCollection_ExtendedStringMsg (const Standard_CString key)
 Loads the messages from the given text buffer. More...
 
static const TCollection_ExtendedStringMsg (const TCollection_AsciiString &key)
 Gives the text for the message identified by the keyword <key> If there are no messages with such keyword defined, the error message is returned. In that case reference to static string is returned, it can be chenged with next call(s) to Msg(). Note: The error message is constructed like 'Unknown message: <key>', and can itself be customized by defining message with key Message_Msg_BadKeyword. More...
 

Detailed Description

A tool providing facility to load definitions of message strings from resource file(s).

The message file is an ASCII file which defines a set of messages. Each message is identified by its keyword (string).

All lines in the file starting with the exclamation sign (perhaps preceeding by spaces and/or tabs) are ignored as comments.

Each line in the file starting with the dot character "." (perhaps preceeding by spaces and/or tabs) defines the keyword. The keyword is a string starting from the next symbol after dot and ending at the symbol preceeding ending newline character "\n".

All the lines in the file after the keyword and before next keyword (and which are not comments) define the message for that keyword. If the message consists of several lines, the message string will contain newline symbols "\n" between parts (but not at the end).

The experimental support of Unicode message files is provided. These are distinguished by two bytes FF.FE or FE.FF at the beginning.

The loaded messages are stored in static data map; all methods of that class are also static.

Member Function Documentation

◆ AddMsg()

static Standard_Boolean Message_MsgFile::AddMsg ( const TCollection_AsciiString key,
const TCollection_ExtendedString text 
)
static

Adds new message to the map. Parameter <key> gives the key of the message, <text> defines the message itself. If there already was defined the message identified by the same keyword, it is replaced with the new one.

◆ HasMsg()

static Standard_Boolean Message_MsgFile::HasMsg ( const TCollection_AsciiString key)
static

Returns True if message with specified keyword is registered.

◆ Load()

static Standard_Boolean Message_MsgFile::Load ( const Standard_CString  theDirName,
const Standard_CString  theFileName 
)
static

Load message file <theFileName> from directory <theDirName> or its sub-directory.

◆ LoadFile()

static Standard_Boolean Message_MsgFile::LoadFile ( const Standard_CString  theFName)
static

Load the messages from the given file, additive to any previously loaded messages. Messages with same keywords, if already present, are replaced with the new ones.

◆ LoadFromEnv()

static Standard_Boolean Message_MsgFile::LoadFromEnv ( const Standard_CString  theEnvName,
const Standard_CString  theFileName,
const Standard_CString  theLangExt = "" 
)
static

Loads the messages from the given text buffer.

Parameters
theContentstring containing the messages
theLengthlength of the buffer; when -1 specified - theContent will be considered as NULL-terminated string

◆ LoadFromString()

static Standard_Boolean Message_MsgFile::LoadFromString ( const Standard_CString  theContent,
const Standard_Integer  theLength = -1 
)
static

Loads the messages from the given text buffer.

Parameters
theContentstring containing the messages
theLengthlength of the buffer; when -1 specified - theContent will be considered as NULL-terminated string

◆ Msg() [1/2]

static const TCollection_ExtendedString& Message_MsgFile::Msg ( const Standard_CString  key)
static

Loads the messages from the given text buffer.

Parameters
theContentstring containing the messages
theLengthlength of the buffer; when -1 specified - theContent will be considered as NULL-terminated string

◆ Msg() [2/2]

static const TCollection_ExtendedString& Message_MsgFile::Msg ( const TCollection_AsciiString key)
static

Gives the text for the message identified by the keyword <key> If there are no messages with such keyword defined, the error message is returned. In that case reference to static string is returned, it can be chenged with next call(s) to Msg(). Note: The error message is constructed like 'Unknown message: <key>', and can itself be customized by defining message with key Message_Msg_BadKeyword.


The documentation for this class was generated from the following file: