ACE_Codeset_Registry Class Reference

#include <Codeset_Registry.h>

Collaboration diagram for ACE_Codeset_Registry:

Collaboration graph
[legend]
List of all members.

Public Types

 max_charsets_ = 5
enum  { max_charsets_ = 5 }

Static Public Member Functions

static int locale_to_registry (const ACE_CString &locale, ACE_CDR::ULong &codeset_id, ACE_CDR::UShort *=0, ACE_CDR::UShort **=0)
static int registry_to_locale (ACE_CDR::ULong codeset_id, ACE_CString &locale, ACE_CDR::UShort *=0, ACE_CDR::UShort **=0)
static int is_compatible (ACE_CDR::ULong codeset_id, ACE_CDR::ULong other)
static ACE_CDR::Short get_max_bytes (ACE_CDR::ULong codeset_id)

Static Private Member Functions

static int locale_to_registry_i (const ACE_CString &locale, ACE_CDR::ULong &codeset_id, ACE_CDR::UShort *=0, ACE_CDR::UShort **=0)
static int registry_to_locale_i (ACE_CDR::ULong codeset_id, ACE_CString &locale, ACE_CDR::UShort *=0, ACE_CDR::UShort **=0)
static int is_compatible_i (ACE_CDR::ULong codeset_id, ACE_CDR::ULong other)
static ACE_CDR::Short get_max_bytes_i (ACE_CDR::ULong codeset_id)

Static Private Attributes

static size_t const num_registry_entries_ = 6
static registry_entry const registry_db_ []

Classes

struct  registry_entry

Detailed Description

Definition at line 42 of file Codeset_Registry.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
max_charsets_ 

Definition at line 69 of file Codeset_Registry.h.

00069 {max_charsets_ = 5};


Member Function Documentation

ACE_INLINE ACE_CDR::Short ACE_Codeset_Registry::get_max_bytes ( ACE_CDR::ULong  codeset_id  )  [static]

Return the max number of bytes required to represent a single character. This wraps the rpc_rgy_get_max_bytes function.

Definition at line 90 of file Codeset_Registry.inl.

References get_max_bytes_i().

00091 {
00092 #if defined (ACE_HAS_DCE_CODESET_REGISTRY)
00093   error_status_t result;
00094   short max_bytes;
00095   rpc_rgy_get_max_bytes(codeset_id,&max_bytes,&result);
00096   return (result == rpc_s_ok) ? (short)max_bytes : 0;
00097 #else
00098   return ACE_Codeset_Registry::get_max_bytes_i (codeset_id);
00099 #endif /* ACE_HAS_DCE_CODESET_REGISTRY */
00100 }

ACE_CDR::Short ACE_Codeset_Registry::get_max_bytes_i ( ACE_CDR::ULong  codeset_id  )  [static, private]

Definition at line 103 of file Codeset_Registry.cpp.

References num_registry_entries_, and registry_db_.

Referenced by get_max_bytes().

00104 {
00105   for (size_t i = 0; i < num_registry_entries_; i++)
00106     if (codeset_id == registry_db_[i].codeset_id_)
00107       return registry_db_[i].max_bytes_;
00108   return 0;
00109 }

ACE_INLINE int ACE_Codeset_Registry::is_compatible ( ACE_CDR::ULong  codeset_id,
ACE_CDR::ULong  other 
) [static]

Tell if two codesets are compatible. This wraps the rpc_cs_char_set_compat_check function.

Definition at line 74 of file Codeset_Registry.inl.

References is_compatible_i().

00076 {
00077 #if defined (ACE_HAS_DCE_CODESET_REGISTRY)
00078   error_status_t result;
00079   rpc_cs_char_set_compat_check(codeset_id,other,&result);
00080   return (result == rpc_s_ok) ? 1 : 0;
00081 #else
00082   return ACE_Codeset_Registry::is_compatible_i (codeset_id,other);
00083 #endif /* ACE_HAS_DCE_CODESET_REGISTRY */
00084 }

int ACE_Codeset_Registry::is_compatible_i ( ACE_CDR::ULong  codeset_id,
ACE_CDR::ULong  other 
) [static, private]

Definition at line 79 of file Codeset_Registry.cpp.

References ACE_Codeset_Registry::registry_entry::char_sets_, num_registry_entries_, ACE_Codeset_Registry::registry_entry::num_sets_, and registry_db_.

Referenced by is_compatible().

00081 {
00082   registry_entry const *lhs = 0;
00083   registry_entry const *rhs = 0;
00084   for (size_t i = 0; (lhs == 0 || rhs == 0) && i < num_registry_entries_; i++)
00085     {
00086       if (codeset_id == registry_db_[i].codeset_id_)
00087         lhs = &registry_db_[i];
00088       if (other == registry_db_[i].codeset_id_)
00089         rhs = &registry_db_[i];
00090     }
00091 
00092   if (lhs == 0 || rhs == 0)
00093     return 0;
00094 
00095   for (ACE_CDR::UShort l = 0; l < lhs->num_sets_; l++)
00096     for (ACE_CDR::UShort r = 0; r < rhs->num_sets_; r++)
00097       if (rhs->char_sets_[r] == lhs->char_sets_[l])
00098         return 1;
00099   return 0;
00100 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_Codeset_Registry::locale_to_registry ( const ACE_CString locale,
ACE_CDR::ULong codeset_id,
ACE_CDR::UShort = 0,
ACE_CDR::UShort **  = 0 
) [static]

Based on a locale string, find the registry value and optional codeset collection. This wraps the dce_cs_loc_to_rgy function, or emulates it.

Definition at line 21 of file Codeset_Registry.inl.

References ACE_String_Base< CHAR >::c_str(), and locale_to_registry_i().

00025 {
00026 #if defined (ACE_HAS_DCE_CODESET_REGISTRY)
00027   error_status_t result;
00028   dce_cs_loc_to_rgy (locale.c_str(),
00029                      &codeset_id,
00030                      num_sets,
00031                      char_sets,
00032                      &result);
00033   return (result == dce_cs_c_ok) ? 1 : 0;
00034 #else
00035   return ACE_Codeset_Registry::locale_to_registry_i (locale,
00036                                                      codeset_id,
00037                                                      num_sets,
00038                                                      char_sets);
00039 #endif /* ACE_HAS_DCE_CODESET_REGISTRY */
00040 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL int ACE_Codeset_Registry::locale_to_registry_i ( const ACE_CString locale,
ACE_CDR::ULong codeset_id,
ACE_CDR::UShort = 0,
ACE_CDR::UShort **  = 0 
) [static, private]

Definition at line 31 of file Codeset_Registry.cpp.

References ACE_NEW_RETURN, ACE_Codeset_Registry::registry_entry::char_sets_, ACE_Codeset_Registry::registry_entry::codeset_id_, ACE_OS::memcpy(), ACE_Codeset_Registry::registry_entry::num_sets_, and ACE_OS::strcmp().

Referenced by locale_to_registry().

00035 {
00036   registry_entry const *element = 0;
00037   for (size_t i = 0; element == 0 && i < num_registry_entries_; i++)
00038     if (ACE_OS::strcmp (registry_db_[i].loc_name_, locale.c_str ()) == 0)
00039       element = &registry_db_[i];
00040   if (element == 0)
00041     return 0;
00042   codeset_id = element->codeset_id_;
00043   if (num_sets != 0)
00044     *num_sets = element->num_sets_;
00045   if (char_sets != 0)
00046     {
00047       ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0);
00048       ACE_OS::memcpy (*char_sets, element->char_sets_,
00049                       element->num_sets_ * sizeof (ACE_CDR::UShort));
00050     }
00051   return 1;
00052 }

ACE_INLINE int ACE_Codeset_Registry::registry_to_locale ( ACE_CDR::ULong  codeset_id,
ACE_CString locale,
ACE_CDR::UShort = 0,
ACE_CDR::UShort **  = 0 
) [static]

Based on a registry value, find the locale string and optional codeset collection. This wraps the dce_cs_rgy_to_loc function, or emulates it.

Definition at line 46 of file Codeset_Registry.inl.

References ACE_OS::free(), registry_to_locale_i(), and ACE_String_Base< CHAR >::set().

00050 {
00051 #if defined (ACE_HAS_DCE_CODESET_REGISTRY)
00052   error_status_t result;
00053   char *buffer;
00054   dce_cs_rgy_to_loc (codeset_id,
00055                      &buffer,
00056                      num_sets,
00057                      char_sets,
00058                      &result);
00059   locale.set(buffer); // does a copy :-(
00060   free (buffer);
00061   return (result == dce_cs_c_ok) ? 1 : 0;
00062 #else
00063   return ACE_Codeset_Registry::registry_to_locale_i (codeset_id,
00064                                                      locale,
00065                                                      num_sets,
00066                                                      char_sets);
00067 #endif /* ACE_HAS_DCE_CODESET_REGISTRY */
00068 }

int ACE_Codeset_Registry::registry_to_locale_i ( ACE_CDR::ULong  codeset_id,
ACE_CString locale,
ACE_CDR::UShort = 0,
ACE_CDR::UShort **  = 0 
) [static, private]

Definition at line 55 of file Codeset_Registry.cpp.

References ACE_NEW_RETURN, ACE_Codeset_Registry::registry_entry::char_sets_, ACE_Codeset_Registry::registry_entry::loc_name_, ACE_OS::memcpy(), num_registry_entries_, ACE_Codeset_Registry::registry_entry::num_sets_, registry_db_, and ACE_String_Base< CHAR >::set().

Referenced by registry_to_locale().

00059 {
00060   registry_entry const *element = 0;
00061   for (size_t i = 0; element == 0 && i < num_registry_entries_; i++)
00062     if (codeset_id == registry_db_[i].codeset_id_)
00063       element = &registry_db_[i];
00064   if (element == 0)
00065     return 0;
00066   locale.set (element->loc_name_);
00067   if (num_sets != 0)
00068     *num_sets = element->num_sets_;
00069   if (char_sets != 0)
00070     {
00071       ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0);
00072       ACE_OS::memcpy (*char_sets, element->char_sets_,
00073                       element->num_sets_ * sizeof (ACE_CDR::UShort));
00074     }
00075   return 1;
00076 }


Member Data Documentation

size_t const ACE_Codeset_Registry::num_registry_entries_ = 6 [static, private]

Definition at line 81 of file Codeset_Registry.h.

Referenced by get_max_bytes_i(), is_compatible_i(), and registry_to_locale_i().

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Codeset_Registry::registry_entry const ACE_Codeset_Registry::registry_db_ [static, private]

Initial value:

{
  {"ISO/IEC 10646-1:1993; UCS-2, Level 1","UCS-2",0x00010100,1,{0x1000},2},
  {"ISO 8859-1:1987; Latin Alphabet No. 1","ISO8859_1",0x00010001,1,{0x0011},1},
  {"IBM-1047 (CCSID 01047); Latin-1 Open System","EBCDIC",0x10020417,1,{0x0011},1},
  {"ISO/IEC 10646-1:1993; UCS-4, Level 1","UCS-4",0x00010104,1,{0x1000},4},
  {"ISO/IEC 10646-1:1993; UTF-16, UCS Transformation Format 16-bit form","UTF-16",0x00010109,1,{0x1000},2},
  {"X/Open UTF-8; UCS Transformation Format 8 (UTF-8)","UTF-8",0x05010001,1,{0x1000},6}
}

Definition at line 82 of file Codeset_Registry.h.

Referenced by get_max_bytes_i(), is_compatible_i(), and registry_to_locale_i().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:00 2010 for ACE by  doxygen 1.4.7