Skip to content
Snippets Groups Projects
Commit 869471a3 authored by PeiYong Zhang's avatar PeiYong Zhang
Browse files

load resource files using environement vars and base name

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@174271 13f79535-47bb-0310-9956-ffa450edef68
parent a6a75e24
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,9 @@
/*
* $Log$
* Revision 1.4 2002/10/10 21:07:55 peiyongz
* load resource files using environement vars and base name
*
* Revision 1.3 2002/10/02 17:08:50 peiyongz
* XMLString::equals() to replace XMLString::compareString()
*
......@@ -120,7 +123,7 @@
// Public Constructors and Destructor
// ---------------------------------------------------------------------------
ICUMsgLoader::ICUMsgLoader(const XMLCh* const msgDomain)
:fRootBundle(0)
:fLocaleBundle(0)
,fDomainBundle(0)
{
// validation on msgDomain
......@@ -131,28 +134,31 @@ ICUMsgLoader::ICUMsgLoader(const XMLCh* const msgDomain)
XMLPlatformUtils::panic(XMLPlatformUtils::Panic_UnknownMsgDomain);
}
//
// we hardcode the path for "root.res" for now
// assuming that Makefile would copy root.res from $ICUROOT/bin to $XERCESCROOT/bin
//
char tempBuf[1024];
strcpy(tempBuf, getenv("XERCESCROOT"));
strcat(tempBuf, "/bin/root.res");
memset(tempBuf, 0, sizeof tempBuf);
char *location = getenv("XERCESC_RESBUND_PKG_PATH");
if (location)
strcpy(tempBuf, location);
strcat(tempBuf, U_FILE_SEP_STRING);
strcat(tempBuf, "XercescErrMsg");
UErrorCode err = U_ZERO_ERROR;
fRootBundle = ures_open(tempBuf, 0, &err);
if (!U_SUCCESS(err) || fRootBundle == NULL)
fLocaleBundle = ures_open(tempBuf, getenv("XERCESC_RESBUND_PKG_LOCALE"), &err);
if (!U_SUCCESS(err) || fLocaleBundle == NULL)
{
XMLPlatformUtils::panic(XMLPlatformUtils::Panic_CantLoadMsgDomain);
}
//strip off path information, if any
/***
get the resource bundle for the domain
strip off path information, if any
***/
int index = XMLString::lastIndexOf(msgDomain, chForwardSlash);
char *domainName = XMLString::transcode(&(msgDomain[index + 1]));
// get the resource bundle for the domain
fDomainBundle = ures_getByKey(fRootBundle, domainName, NULL, &err);
err = U_ZERO_ERROR;
fDomainBundle = ures_getByKey(fLocaleBundle, domainName, NULL, &err);
delete [] domainName;
if (!U_SUCCESS(err) || fDomainBundle == NULL)
......@@ -165,7 +171,7 @@ ICUMsgLoader::ICUMsgLoader(const XMLCh* const msgDomain)
ICUMsgLoader::~ICUMsgLoader()
{
ures_close(fDomainBundle);
ures_close(fRootBundle);
ures_close(fLocaleBundle);
}
......
......@@ -56,6 +56,9 @@
/*
* $Log$
* Revision 1.3 2002/10/10 21:07:55 peiyongz
* load resource files using environement vars and base name
*
* Revision 1.2 2002/09/30 22:20:40 peiyongz
* Build with ICU MsgLoader
*
......@@ -156,14 +159,17 @@ private :
// -----------------------------------------------------------------------
// Private data members
//
// fRootBundle
// bundle to the 'root' of the specified locale_country
// fLocaleBundle
// pointer to the required locale specific resource bundle,
// or to the default locale resrouce bundle in case the required
// locale specific resource bundle unavailable.
//
// fDomainBundle
// bundle to the resource for the corresponding domain
// pointer to the domain specific resource bundle with in the
// required locale specific (or default locale) resource bundle.
//
// -----------------------------------------------------------------------
UResourceBundle* fRootBundle;
UResourceBundle* fLocaleBundle;
UResourceBundle* fDomainBundle;
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment