version 1.22, 2006/10/25 19:40:24
|
version 1.23, 2006/11/10 18:14:58
|
|
|
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
| |
/** | /** |
* MessageLoaderParms class is basically a stuct class containing public variables that control |
MessageLoaderParms class is basically a stuct class containing public |
* the way MessageLoader behaves. MessageLoader uses the fields in this class to decide where and |
variables that control the way MessageLoader behaves. MessageLoader uses |
* how to load messages from the message resources. |
the fields in this class to decide where and how to load messages from |
|
the message resources. |
*/ | */ |
|
class PEGASUS_COMMON_LINKAGE MessageLoaderParms |
class PEGASUS_COMMON_LINKAGE MessageLoaderParms{ |
{ |
|
|
friend class MessageLoader; |
|
|
|
public: | public: |
| |
/* |
/** |
* String msg_id: unique message identifier for a particular message in a message resource |
String msg_id: unique message identifier for a particular |
|
message in a message resource |
*/ | */ |
String msg_id; | String msg_id; |
| |
/* |
/** |
* String default_msg: the default message to use if a message cannot be loaded from a message resource |
String default_msg: the default message to use if a message |
|
cannot be loaded from a message resource |
*/ | */ |
String default_msg; | String default_msg; |
| |
/* |
/** |
* String msg_src_path: this path tells MessageLoader where to find message resources |
String msg_src_path: this path tells MessageLoader where to |
* it can be empty, fully qualified or relative to $PEGASUS_HOME |
find message resources. |
|
It can be empty, fully qualified or relative to $PEGASUS_HOME |
*/ | */ |
String msg_src_path; | String msg_src_path; |
| |
/* |
/** |
* AcceptLanguageList acceptlanguages: This contains the languages that are acceptable by the caller |
AcceptLanguageList acceptlanguages: This contains the languages |
* of MessageLoader::getMessage() or openMessageFile(). That is, MessageLoader will do its best to return |
that are acceptable by the caller of MessageLoader::getMessage() |
* a message in a language that was specified in this container. This container is naturally ordered |
or openMessageFile(). That is, MessageLoader will do its best to |
* using the quality values attached to the languages and MessageLoader iterates through this container |
return a message in a language that was specified in this container. |
* in its natural ordering. This container is used by MessageLoader to load messages if it is not empty. |
This container is naturally ordered using the quality values |
|
attached to the languages and MessageLoader iterates through this |
|
container in its natural ordering. This container is used by |
|
MessageLoader to load messages if it is not empty. |
*/ | */ |
AcceptLanguageList acceptlanguages; | AcceptLanguageList acceptlanguages; |
| |
/* |
/** |
* ContentLanguageList contentlanguages: This is set by MessageLoader::getMessage() and after a message has |
ContentLanguageList contentlanguages: This is set by |
* been loaded from either a message resource or the default message, or by MessageLoader::openMessageFile() |
MessageLoader::getMessage() and after a message has been loaded |
* after it has identified and opened a message resource. After the call to MessageLoader::getMessage() or |
from either a message resource or the default message, or by |
* MessageLoader::openMessageFile(), the caller can check the MessageLoaderParms.contentlanguages object to |
MessageLoader::openMessageFile() after it has identified and |
* see what MessageLoader set it to. In all cases where a message is returned from MessageLoader::getMessage() |
opened a message resource. After the call to |
* or will be returned from MessageLoader::getMessage2(), this field will be set to match the language that |
MessageLoader::getMessage() or MessageLoader::openMessageFile(), |
* the message was (or will be) found in. |
the caller can check the MessageLoaderParms.contentlanguages |
|
object to see what MessageLoader set it to. In all cases where a |
|
message is returned from MessageLoader::getMessage() or will be |
|
returned from MessageLoader::getMessage2(), this field will be |
|
set to match the language that the message was (or will be) |
|
found in. |
*/ | */ |
ContentLanguageList contentlanguages; | ContentLanguageList contentlanguages; |
| |
/* |
/** |
* Boolean useProcessLocale: Default is false, if true, MessageLoader uses the system default language |
Boolean useProcessLocale: Default is false, if true, MessageLoader |
* to loads messages from. |
uses the system default language to loads messages from. |
*/ | */ |
Boolean useProcessLocale; | Boolean useProcessLocale; |
| |
/* |
/** |
* Boolean useThreadLocale: Default is true, this tells MessageLoader to use the AcceptLanguageList container |
Boolean useThreadLocale: Default is true, this tells |
* from the current Pegasus thread. |
MessageLoader to use the AcceptLanguageList container |
|
from the current Pegasus thread. |
*/ | */ |
Boolean useThreadLocale; | Boolean useThreadLocale; |
| |
/* |
/** |
* Boolean useICUfallback: Default is false. Only relevant if PEGASUS_HAS_ICU is defined. |
Boolean useICUfallback: Default is false. Only relevant if |
* MessageLoader::getMessage() default behaviour is to extract messages for the langauge exactly |
PEGASUS_HAS_ICU is defined. MessageLoader::getMessage() default |
* matching an available message resource. If this is set to true, the MessageLoader is free to extract |
behaviour is to extract messages for the langauge exactly |
* a message from a less specific message resource according to its search algorithm. |
matching an available message resource. If this is set to true, |
|
the MessageLoader is free to extract a message from a less |
|
specific message resource according to its search algorithm. |
*/ | */ |
#ifdef PEGASUS_HAS_ICU | #ifdef PEGASUS_HAS_ICU |
Boolean useICUfallback; | Boolean useICUfallback; |
#endif | #endif |
| |
/* |
/** |
* const Formatter::Arg&0-9: These are assigned the various substitutions necessary to properly format |
const Formatter::Arg&0-9: These are assigned the various |
* the message being extracted. MessageLoader substitutes these in the correct places in the message |
substitutions necessary to properly format the message being |
* being returned from MessageLoader::getMessage() |
extracted. MessageLoader substitutes these in the correct |
|
places in the message being returned from |
|
MessageLoader::getMessage() |
*/ | */ |
Formatter::Arg arg0; | Formatter::Arg arg0; |
Formatter::Arg arg1; | Formatter::Arg arg1; |
|
|
#endif | #endif |
| |
void _init(); | void _init(); |
}; // end MessageLoaderParms |
|
|
|
| |
/* |
friend class MessageLoader; |
* MessageLoader is a static class resposible for looking up messages in message resources. |
}; |
* For specific behaviour details of this class see the Globalization HOWTO. |
|
*/ |
|
| |
class PEGASUS_COMMON_LINKAGE MessageLoader{ |
|
| |
|
/** |
|
MessageLoader is a static class resposible for looking up messages in |
|
message resources. |
|
For specific behaviour details of this class see the Globalization HOWTO. |
|
*/ |
|
class PEGASUS_COMMON_LINKAGE MessageLoader |
|
{ |
public: | public: |
| |
/* |
/** |
* Retrieves a message from a message resource |
Retrieves a message from a message resource |
* @param parms MessageLoaderParms - controls the behaviour of how a message is retrieved |
@param parms MessageLoaderParms - controls the behaviour of how a |
* @return String - the formatted message |
message is retrieved |
|
@return String - the formatted message |
*/ | */ |
static String getMessage(MessageLoaderParms &parms); | static String getMessage(MessageLoaderParms &parms); |
| |
/* |
/** |
* Opens a message resource bundle. |
Opens a message resource bundle. |
* @param parms MessageLoaderParms - controls the behaviour of how a message is retrieved, this |
If this method fails for some reason, it will set parms.resbundl |
* parameter should be used *ONLY* on subsequent calls to getMessage2() and closeMessageFile() |
to NO_ICU_MAGIC, and a subsequent call to getMessage2() will |
* If this method fails for some reason, it will set parms.resbundl to NO_ICU_MAGIC, and a |
result in the default message being formatted. |
* subsequent call to getMessage2() will result in the default message being formatted. |
ATTN: Do we want *real* error codes for this? |
* ATTN: Do we want *real* error codes for this? |
@param parms MessageLoaderParms - controls the behaviour of how a |
|
message is retrieved, this parameter should be used *ONLY* on |
|
subsequent calls to getMessage2() and closeMessageFile(). |
*/ | */ |
static void openMessageFile(MessageLoaderParms &parms); | static void openMessageFile(MessageLoaderParms &parms); |
| |
/* |
/** |
* Closes a message resource bundle. |
Closes a message resource bundle. |
* @param parms MessageLoaderParms - identifies a previously opened resource bundle returned |
@param parms MessageLoaderParms - identifies a previously opened |
* from openMessageFile(). |
resource bundle returned from openMessageFile(). |
*/ | */ |
static void closeMessageFile(MessageLoaderParms &parms); | static void closeMessageFile(MessageLoaderParms &parms); |
| |
/* |
/** |
* Retrieves a message from a message resource previously opened by openMessageFile() |
Retrieves a message from a message resource previously opened by |
* @param parms MessageLoaderParms - controls the behaviour of how a message is retrieved, and |
openMessageFile() |
* is the same MessageLoaderParms parameter that was passed to openMessageFile(). |
@param parms MessageLoaderParms - controls the behaviour of how a |
* @return String - the formatted message |
message is retrieved, and is the same MessageLoaderParms |
|
parameter that was passed to openMessageFile(). |
|
@return String - the formatted message |
*/ | */ |
static String getMessage2(MessageLoaderParms &parms); | static String getMessage2(MessageLoaderParms &parms); |
| |
|
|
#ifdef PEGASUS_HAS_ICU | #ifdef PEGASUS_HAS_ICU |
static void openICUMessageFile(MessageLoaderParms &parms); | static void openICUMessageFile(MessageLoaderParms &parms); |
| |
static String extractICUMessage(UResourceBundle * resbundl, MessageLoaderParms &parms); |
static String extractICUMessage( |
|
UResourceBundle* resbundl, |
static String formatICUMessage(UResourceBundle * resbundl, const UChar *msg, int msg_len, MessageLoaderParms &parms); |
MessageLoaderParms& parms); |
|
|
|
static String formatICUMessage( |
|
UResourceBundle* resbundl, |
|
const UChar* msg, |
|
int msg_len, |
|
MessageLoaderParms& parms); |
| |
static String uChar2String(UChar * uchar_str); | static String uChar2String(UChar * uchar_str); |
| |
|
|
static void xferFormattable(Formatter::Arg& arg, Formattable &formattable); | static void xferFormattable(Formatter::Arg& arg, Formattable &formattable); |
#endif | #endif |
| |
}; // end MessageLoader |
}; |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |
| |