[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / Codeset_Registry.cpp
blobc23ef37231a52b8e3f1a6e51c4c3c967e29ab1f1
1 //=============================================================================
2 /**
3 * @file Codeset_Registry.cpp
5 * $Id: Codeset_Registry.cpp 80826 2008-03-04 14:51:23Z wotte $
7 * emulated codset regstry functions
10 * @author Phil Mesnier <mesnier_p@ociweb.com>
12 //=============================================================================
14 #include "ace/Codeset_Registry.h"
15 #include "ace/OS_Memory.h"
16 #include "ace/OS_NS_string.h"
18 // $Id: Codeset_Registry.cpp 80826 2008-03-04 14:51:23Z wotte $
20 #if !defined (__ACE_INLINE__)
21 #include "ace/Codeset_Registry.inl"
22 #endif /* __ACE_INLINE__ */
24 ACE_RCSID (ace,
25 Codeset_Registry,
26 "$Id: Codeset_Registry.cpp 80826 2008-03-04 14:51:23Z wotte $")
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 int
31 ACE_Codeset_Registry::locale_to_registry_i (const ACE_CString &locale,
32 ACE_CDR::ULong &codeset_id,
33 ACE_CDR::UShort *num_sets,
34 ACE_CDR::UShort **char_sets)
36 registry_entry const *element = 0;
37 for (size_t i = 0; element == 0 && i < num_registry_entries_; i++)
38 if (ACE_OS::strcmp (registry_db_[i].loc_name_, locale.c_str ()) == 0)
39 element = &registry_db_[i];
40 if (element == 0)
41 return 0;
42 codeset_id = element->codeset_id_;
43 if (num_sets != 0)
44 *num_sets = element->num_sets_;
45 if (char_sets != 0)
47 ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0);
48 ACE_OS::memcpy (*char_sets, element->char_sets_,
49 element->num_sets_ * sizeof (ACE_CDR::UShort));
51 return 1;
54 int
55 ACE_Codeset_Registry::registry_to_locale_i (ACE_CDR::ULong codeset_id,
56 ACE_CString &locale,
57 ACE_CDR::UShort *num_sets,
58 ACE_CDR::UShort **char_sets)
60 registry_entry const *element = 0;
61 for (size_t i = 0; element == 0 && i < num_registry_entries_; i++)
62 if (codeset_id == registry_db_[i].codeset_id_)
63 element = &registry_db_[i];
64 if (element == 0)
65 return 0;
66 locale.set (element->loc_name_);
67 if (num_sets != 0)
68 *num_sets = element->num_sets_;
69 if (char_sets != 0)
71 ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0);
72 ACE_OS::memcpy (*char_sets, element->char_sets_,
73 element->num_sets_ * sizeof (ACE_CDR::UShort));
75 return 1;
78 int
79 ACE_Codeset_Registry::is_compatible_i (ACE_CDR::ULong codeset_id,
80 ACE_CDR::ULong other)
82 registry_entry const *lhs = 0;
83 registry_entry const *rhs = 0;
84 for (size_t i = 0; (lhs == 0 || rhs == 0) && i < num_registry_entries_; i++)
86 if (codeset_id == registry_db_[i].codeset_id_)
87 lhs = &registry_db_[i];
88 if (other == registry_db_[i].codeset_id_)
89 rhs = &registry_db_[i];
92 if (lhs == 0 || rhs == 0)
93 return 0;
95 for (ACE_CDR::UShort l = 0; l < lhs->num_sets_; l++)
96 for (ACE_CDR::UShort r = 0; r < rhs->num_sets_; r++)
97 if (rhs->char_sets_[r] == lhs->char_sets_[l])
98 return 1;
99 return 0;
102 ACE_CDR::Short
103 ACE_Codeset_Registry::get_max_bytes_i (ACE_CDR::ULong codeset_id)
105 for (size_t i = 0; i < num_registry_entries_; i++)
106 if (codeset_id == registry_db_[i].codeset_id_)
107 return registry_db_[i].max_bytes_;
108 return 0;
111 ACE_END_VERSIONED_NAMESPACE_DECL