summaryrefslogtreecommitdiff
path: root/ACE/ace/Codeset_Registry.inl
blob: d24e07cc83bf9c31657c12595434a8769ba87e71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// -*- C++ -*-
//=============================================================================
/**
 *  @file   Codeset_Registry.inl
 *
 *  $Id$
 *
 * ACE wrapper around access functions for the OSF's DCE codeset registry
 * access functions - the inline functions either call the system supplied
 * DCE based codeset regsitry function, or calls the emulation
 *
 *
 *  @author Phil Mesnier <mesnier_p@ociweb.com>
 */
//=============================================================================

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 *num_sets,
                                         ACE_CDR::UShort **char_sets)
{
#if defined (ACE_HAS_DCE_CODESET_REGISTRY)
  error_status_t result;
  dce_cs_loc_to_rgy (locale.c_str(),
                     &codeset_id,
                     num_sets,
                     char_sets,
                     &result);
  return (result == dce_cs_c_ok) ? 1 : 0;
#else
  return ACE_Codeset_Registry::locale_to_registry_i (locale,
                                                     codeset_id,
                                                     num_sets,
                                                     char_sets);
#endif /* ACE_HAS_DCE_CODESET_REGISTRY */
}

// 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.
ACE_INLINE
int
ACE_Codeset_Registry::registry_to_locale(ACE_CDR::ULong codeset_id,
                                         ACE_CString &locale,
                                         ACE_CDR::UShort *num_sets,
                                         ACE_CDR::UShort **char_sets)
{
#if defined (ACE_HAS_DCE_CODESET_REGISTRY)
  error_status_t result;
  char *buffer;
  dce_cs_rgy_to_loc (codeset_id,
                     &buffer,
                     num_sets,
                     char_sets,
                     &result);
  locale.set(buffer); // does a copy :-(
  free (buffer);
  return (result == dce_cs_c_ok) ? 1 : 0;
#else
  return ACE_Codeset_Registry::registry_to_locale_i (codeset_id,
                                                     locale,
                                                     num_sets,
                                                     char_sets);
#endif /* ACE_HAS_DCE_CODESET_REGISTRY */
}

// Tell if two codesets are compatible. This wraps the
// rpc_cs_char_set_compat_check function.
ACE_INLINE
int
ACE_Codeset_Registry::is_compatible (ACE_CDR::ULong codeset_id,
                                     ACE_CDR::ULong other)
{
#if defined (ACE_HAS_DCE_CODESET_REGISTRY)
  error_status_t result;
  rpc_cs_char_set_compat_check(codeset_id,other,&result);
  return (result == rpc_s_ok) ? 1 : 0;
#else
  return ACE_Codeset_Registry::is_compatible_i (codeset_id,other);
#endif /* ACE_HAS_DCE_CODESET_REGISTRY */
}

// Return the max number of bytes required to represent a single character.
// This wraps the rpc_rgy_get_max_bytes function.
ACE_INLINE
ACE_CDR::Short
ACE_Codeset_Registry::get_max_bytes (ACE_CDR::ULong codeset_id)
{
#if defined (ACE_HAS_DCE_CODESET_REGISTRY)
  error_status_t result;
  short max_bytes;
  rpc_rgy_get_max_bytes(codeset_id,&max_bytes,&result);
  return (result == rpc_s_ok) ? (short)max_bytes : 0;
#else
  return ACE_Codeset_Registry::get_max_bytes_i (codeset_id);
#endif /* ACE_HAS_DCE_CODESET_REGISTRY */
}

ACE_END_VERSIONED_NAMESPACE_DECL