home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
cset21v1.zip
/
IBMCPP
/
IBMCLASS
/
IMSGTEXT.HPP
< prev
next >
Wrap
Text File
|
1993-09-22
|
7KB
|
112 lines
#ifndef _IMSGTEXT_
#define _IMSGTEXT_
/*******************************************************************************
* FILE NAME: imsgtext.hpp *
* *
* DESCRIPTION: *
* This file contains the declaration(s) of the class(es): *
* IMsgtext - Class for loading message text from .msg files. *
* *
* COPYRIGHT: *
* IBM C/C++ Tools Version 2.01 - Collection Class Library *
* Licensed Materials - Property of IBM *
* (C) Copyright IBM Corporation 1992, 1993 *
* All Rights Reserved *
* US Government Users Restricted Rights - Use, duplication, or disclosure *
* restricted by GSA ADP Schedule Contract with IBM Corp. *
* *
*******************************************************************************/
class IMessageText {
/*******************************************************************************
* The IMessageText class allows you to load message text *
* from a message (.msg) file. *
* *
* Typically, an instance of this class is created when an error condition has *
* been detected, and an exception is going to be thrown. You can use the *
* message text to construct an IException subclass instance. *
* *
* Example: *
* *
* The following example illustrates loading text from a message file and *
* using that text to construct and throw an exception. *
* *
* Boolean bSuccess = someFunction(); *
* if (!bSuccess) *
* { *
* IMessageText myTxt(SOMEFUNCTIONFAIL_ID, "MYMSGFILE"); *
* IInvalidRequest exc(myTxt, SOMEFUNCTIONFAIL_ID); *
* ITHROW(exc); *
* } *
* *
*******************************************************************************/
public:
/*------------------------ Constructor/Destructor -----------------------------
| There is only one way to construct instances of this class. The |
| IMessageText constructor requires two arguments, the message id and the |
| name of the message file to retrieve the message from. The message file |
| name must include the file extension, typically msg. Up to 9 optional |
| text strings can be passed for substitution in the message. The |
| substitution strings will replace occurrences of %1, %2 in the message if |
| the number of substitution strings matches the number of %n occurrences in |
| the message. |
| The message will be loaded from program if it is found in a message segment |
| which has been bound to the .exe. Otherwise it is searched for in the |
| specified message file. The search for this file is as follows: |
| - The system root directory. |
| - The current working directory. |
| - Using the DPATH environment setting. |
| - Using the APPEND environment setting. |
| If the text cannot be loaded from the message file, the following default |
| text is provided: "Unable to load text from message file." |
| A copy constructor is also provided. |
------------------------------------------------------------------------------*/
IMessageText ( unsigned long messageId,
const char* messageFileName,
const char* textInsert1 = 0,
const char* textInsert2 = 0,
const char* textInsert3 = 0,
const char* textInsert4 = 0,
const char* textInsert5 = 0,
const char* textInsert6 = 0,
const char* textInsert7 = 0,
const char* textInsert8 = 0,
const char* textInsert9 = 0 );
IMessageText ( const IMessageText& text );
~IMessageText ( );
/*-------------------------------- Accessors -----------------------------------
| The following conversion operator, = operator and functions provide means |
| of getting and setting the message text from instances of this class: |
| operator const char* - Returns the message text. |
| text - Returns the message text. |
| setDefaultText - Sets the text to a default text string. The |
| text will only be set if the constructor was |
| unable to load the text for the specified |
| message id. |
| operator = - Sets the instance data to the values of the |
| passed IMessageText instance. |
------------------------------------------------------------------------------*/
operator const char* () const;
const char*
text ( ) const;
IMessageText
&setDefaultText ( const char* text ),
&operator= ( const IMessageText& text );
private:
/*--------------------------------- PRIVATE ----------------------------------*/
char
*pClText;
int
bClSuccess;
}; // IMessageText
#endif // _IMSGTEXT_