Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Codeset_Registry.cpp

Go to the documentation of this file.
00001 //=============================================================================
00002 /**
00003  *  @file   Codeset_Registry.cpp
00004  *
00005  *  $Id: Codeset_Registry.cpp,v 1.1.8.2 2003/04/10 18:11:07 phil Exp $
00006  *
00007  *  emulated codset regstry functions
00008  *
00009  *
00010  *  @author Phil Mesnier <mesnier_p@ociweb.com>
00011  */
00012 //=============================================================================
00013 #include "ace_pch.h"
00014 
00015 #include "ace/Codeset_Registry.h"
00016 
00017 // $Id: Codeset_Registry.cpp,v 1.1.8.2 2003/04/10 18:11:07 phil Exp $
00018 
00019 #if !defined (__ACE_INLINE__)
00020 #include "ace/Codeset_Registry.inl"
00021 #endif /* __ACE_INLINE__ */
00022 
00023 ACE_RCSID(ace, Codeset_Registry, "$Id: Codeset_Registry.cpp,v 1.1.8.2 2003/04/10 18:11:07 phil Exp $");
00024 
00025 
00026 int
00027 ACE_Codeset_Registry::locale_to_registry_i (const ACE_CString &locale,
00028                                             ACE_CDR::ULong &codeset_id,
00029                                             ACE_CDR::UShort *num_sets,
00030                                             ACE_CDR::UShort **char_sets)
00031 {
00032   registry_entry* element = 0;
00033   for (size_t i = 0; element == 0 && i < num_registry_entries_; i++)
00034     if (ACE_OS::strcmp(registry_db_[i].loc_name_,locale.c_str()) == 0)
00035       element = &registry_db_[i];
00036   if (element == 0)
00037     return 0;
00038   codeset_id = element->codeset_id_;
00039   if (num_sets != 0)
00040     *num_sets = element->num_sets_;
00041   if (char_sets != 0)
00042     {
00043       ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0);
00044       ACE_OS::memcpy (element->char_sets_,
00045                       *char_sets,
00046                       element->num_sets_ * sizeof (ACE_CDR::UShort));
00047     }
00048   return 1;
00049 }
00050 
00051 int
00052 ACE_Codeset_Registry::registry_to_locale_i (ACE_CDR::ULong codeset_id,
00053                                             ACE_CString &locale,
00054                                             ACE_CDR::UShort *num_sets,
00055                                             ACE_CDR::UShort **char_sets)
00056 {
00057   registry_entry* element = 0;
00058   for (size_t i = 0; element == 0 && i < num_registry_entries_; i++)
00059     if (codeset_id == registry_db_[i].codeset_id_)
00060       element = &registry_db_[i];
00061   if (element == 0)
00062     return 0;
00063   locale.set(element->loc_name_);
00064   if (num_sets != 0)
00065     *num_sets = element->num_sets_;
00066   if (char_sets != 0)
00067     {
00068       ACE_NEW_RETURN (*char_sets,ACE_CDR::UShort[element->num_sets_],0);
00069       ACE_OS::memcpy (element->char_sets_,
00070                       *char_sets,
00071                       element->num_sets_ * sizeof (ACE_CDR::UShort));
00072     }
00073   return 1;
00074 }
00075 
00076 int
00077 ACE_Codeset_Registry::is_compatible_i (ACE_CDR::ULong codeset_id,
00078                                        ACE_CDR::ULong other)
00079 {
00080   registry_entry* lhs = 0;
00081   registry_entry* rhs = 0;
00082   for (size_t i = 0; (lhs == 0 || rhs == 0) && i < num_registry_entries_; i++)
00083     {
00084       if (codeset_id == registry_db_[i].codeset_id_)
00085         lhs = &registry_db_[i];
00086       if (other == registry_db_[i].codeset_id_)
00087         rhs = &registry_db_[i];
00088     }
00089 
00090   if (lhs == 0 || rhs == 0)
00091     return 0;
00092 
00093   for (ACE_CDR::UShort l = 0; l < lhs->num_sets_; l++)
00094     for (ACE_CDR::UShort r = 0; r < rhs->num_sets_; r++)
00095       if (rhs->char_sets_[r] == lhs->char_sets_[l])
00096         return 1;
00097   return 0;
00098 }
00099 
00100 ACE_CDR::Short
00101 ACE_Codeset_Registry::get_max_bytes_i (ACE_CDR::ULong codeset_id)
00102 {
00103   for (size_t i = 0; i < num_registry_entries_; i++)
00104     if (codeset_id == registry_db_[i].codeset_id_)
00105       return registry_db_[i].max_bytes_;
00106   return 0;
00107 }

Generated on Mon Jun 16 11:19:22 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002