Codeset_Registry.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //=============================================================================
00003 /**
00004  *  @file   Codeset_Registry.inl
00005  *
00006  *  Codeset_Registry.inl,v 1.4 2005/10/28 16:14:51 ossama Exp
00007  *
00008  * ACE wrapper around access functions for the OSF's DCE codeset registry
00009  * access functions - the inline functions either call the system supplied
00010  * DCE based codeset regsitry function, or calls the emulation
00011  *
00012  *
00013  *  @author Phil Mesnier <mesnier_p@ociweb.com>
00014  */
00015 //=============================================================================
00016 
00017 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00018 
00019 ACE_INLINE
00020 int
00021 ACE_Codeset_Registry::locale_to_registry(const ACE_CString &locale,
00022                                          ACE_CDR::ULong &codeset_id,
00023                                          ACE_CDR::UShort *num_sets,
00024                                          ACE_CDR::UShort **char_sets)
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 }
00041 
00042 // based on a registry value, find the locale string and optional codeset
00043 // collection.  This wraps the dce_cs_rgy_to_loc function, or emulates it.
00044 ACE_INLINE
00045 int
00046 ACE_Codeset_Registry::registry_to_locale(ACE_CDR::ULong codeset_id,
00047                                          ACE_CString &locale,
00048                                          ACE_CDR::UShort *num_sets,
00049                                          ACE_CDR::UShort **char_sets)
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 }
00069 
00070 // Tell if two codesets are compatible. This wraps the
00071 // rpc_cs_char_set_compat_check function.
00072 ACE_INLINE
00073 int
00074 ACE_Codeset_Registry::is_compatible (ACE_CDR::ULong codeset_id,
00075                                      ACE_CDR::ULong other)
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 }
00085 
00086 // Return the max number of bytes required to represent a single character.
00087 // This wraps the rpc_rgy_get_max_bytes function.
00088 ACE_INLINE
00089 ACE_CDR::Short
00090 ACE_Codeset_Registry::get_max_bytes (ACE_CDR::ULong codeset_id)
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 }
00101 
00102 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:48 2006 for ACE by doxygen 1.3.6