diff --git a/src/util/TransService.cpp b/src/util/TransService.cpp index 9c71ceb7626779188e409d889543264b0a28dc11..b01e0d8e5e6b284e0a91bb8969248636f5b9c702 100644 --- a/src/util/TransService.cpp +++ b/src/util/TransService.cpp @@ -76,6 +76,7 @@ #include <util/TransENameMap.hpp> + // --------------------------------------------------------------------------- // Local, static data // @@ -152,6 +153,18 @@ XMLTransService::~XMLTransService() gMappings = 0; // the it, and so will be deleted by gMapping's destructor. } +// --------------------------------------------------------------------------- +// Allow user specific encodings to be added to the mappings table. +// Should be called after platform init +// --------------------------------------------------------------------------- +void XMLTransService::addEncoding(const XMLCh* const encoding, + ENameMap* const ownMapping) { + + if (gMappings) { + + gMappings->put((void *) encoding, ownMapping); + } +} // --------------------------------------------------------------------------- // XLMTranscoder: Non-virtual API @@ -259,7 +272,6 @@ XMLLCPTranscoder::~XMLLCPTranscoder() { } - // --------------------------------------------------------------------------- // XLMTranscoder: Hidden Init Method // @@ -267,6 +279,7 @@ XMLLCPTranscoder::~XMLLCPTranscoder() // --------------------------------------------------------------------------- void XMLTransService::initTransService() { + // // Create our hash table that we will fill with mappings. The default // is to adopt the elements, which is fine with us. @@ -287,6 +300,7 @@ void XMLTransService::initTransService() gMappings->put((void*)XMLUni::fgUSASCIIEncodingString3, new ENameMapFor<XMLASCIITranscoder>(XMLUni::fgUSASCIIEncodingString3)); gMappings->put((void*)XMLUni::fgUSASCIIEncodingString4, new ENameMapFor<XMLASCIITranscoder>(XMLUni::fgUSASCIIEncodingString4)); + // // Add in our mappings for UTF-8 // @@ -418,4 +432,5 @@ void XMLTransService::initTransService() // this one, so there is just one mapping. // gMappings->put((void*)XMLUni::fgWin1252EncodingString, new ENameMapFor<XMLWin1252Transcoder>(XMLUni::fgWin1252EncodingString)); + } diff --git a/src/util/TransService.hpp b/src/util/TransService.hpp index 4c3e7a6f67c90c59e11b13bdfee78268c48786b8..63cf2a3dc6e321e0f9070eac126d252aabd9f2fd 100644 --- a/src/util/TransService.hpp +++ b/src/util/TransService.hpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.12 2001/01/25 19:19:32 tng + * Let user add their encoding to the intrinsic mapping table. Added by Khaled Noaman. + * * Revision 1.11 2000/04/12 22:57:45 roddey * A couple of fixes to comments and parameter names to make them * more correct. @@ -112,6 +115,7 @@ class XMLPlatformUtils; class XMLLCPTranscoder; class XMLTranscoder; +class ENameMap; // @@ -196,6 +200,17 @@ public : virtual void upperCase(XMLCh* const toUpperCase) const = 0; + // ----------------------------------------------------------------------- + // Allow users to add their own encodings to the intrinsinc mapping + // table + // Usage: + // XMLTransService::addEncoding ( + // gMyEncodingNameString + // , new ENameMapFor<MyTransClassType>(gMyEncodingNameString) + // ); + // ----------------------------------------------------------------------- + static void addEncoding(const XMLCh* const encoding, ENameMap* const ownMapping); + protected : // -----------------------------------------------------------------------