Codeset_Registry.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //=============================================================================
00003 /**
00004  *  @file   Codeset_Registry.h
00005  *
00006  *  Codeset_Registry.h,v 1.6 2005/10/26 19:34:31 ossama Exp
00007  *
00008  * ACE wrapper around access functions for the OSF's DCE codeset registry
00009  * access functions
00010  *
00011  * For environments that intrinsicly support the DCE defined access functions,
00012  * the methods in this class are simply wrappers. On other platforms, emulation
00013  * is provided. The motivation for this class is to support interoperability
00014  * via translators and the CDR streams, primarily in TAO, but this capability
00015  * is not restricted to CORBA.
00016  *
00017  * The emulated functionalty supports Open Group RFC #40, currently RFC 40.2,
00018  * www.opengroup.org/tech/rfc/rfc40.2.html
00019  *
00020  *  @author Phil Mesnier <mesnier_p@ociweb.com>
00021  */
00022 //=============================================================================
00023 
00024 #ifndef ACE_CODESET_REGISTRY_H
00025 #define ACE_CODESET_REGISTRY_H
00026 
00027 #include /**/ "ace/pre.h"
00028 #include "ace/SString.h"
00029 #include "ace/CDR_Base.h"
00030 #include "ace/Codeset_Symbols.h"
00031 
00032 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00033 # pragma once
00034 #endif /* ACE_LACKS_PRAGMA_ONCE */
00035 
00036 #if defined (ACE_HAS_DCE_CODESET_REGISTRY)
00037 #include /**/ <dce/rpc.h>
00038 #endif /* ACE_HAS_DCE_CODESET_REGISTRY */
00039 
00040 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00041 
00042 class ACE_Export ACE_Codeset_Registry
00043 {
00044 public:
00045 
00046   /// Based on a locale string, find the registry value and optional codeset
00047   /// collection. This wraps the dce_cs_loc_to_rgy function, or emulates it.
00048   static int locale_to_registry (const ACE_CString &locale,
00049                                  ACE_CDR::ULong &codeset_id,
00050                                  ACE_CDR::UShort * = 0,
00051                                  ACE_CDR::UShort ** = 0);
00052 
00053   /// Based on a registry value, find the locale string and optional codeset
00054   /// collection.  This wraps the dce_cs_rgy_to_loc function, or emulates it.
00055   static int registry_to_locale (ACE_CDR::ULong codeset_id,
00056                                  ACE_CString &locale,
00057                                  ACE_CDR::UShort * = 0,
00058                                  ACE_CDR::UShort ** = 0);
00059 
00060   /// Tell if two codesets are compatible. This wraps the
00061   /// rpc_cs_char_set_compat_check function.
00062   static int is_compatible (ACE_CDR::ULong codeset_id,
00063                             ACE_CDR::ULong other);
00064 
00065   /// Return the max number of bytes required to represent a single character.
00066   /// This wraps the rpc_rgy_get_max_bytes function.
00067   static ACE_CDR::Short get_max_bytes (ACE_CDR::ULong codeset_id);
00068 
00069   enum {max_charsets_ = 5};
00070 protected:
00071   typedef struct {
00072     const char *     desc_;
00073     const char *     loc_name_;
00074     ACE_CDR::ULong   codeset_id_;
00075     ACE_CDR::UShort  num_sets_;
00076     ACE_CDR::UShort  char_sets_[max_charsets_];
00077     ACE_CDR::UShort  max_bytes_;
00078   } registry_entry;
00079 
00080 private:
00081   static size_t const num_registry_entries_;
00082   static registry_entry const registry_db_[];
00083 
00084   static int locale_to_registry_i (const ACE_CString &locale,
00085                                    ACE_CDR::ULong &codeset_id,
00086                                    ACE_CDR::UShort * = 0,
00087                                    ACE_CDR::UShort ** = 0);
00088   static int registry_to_locale_i (ACE_CDR::ULong codeset_id,
00089                                    ACE_CString &locale,
00090                                    ACE_CDR::UShort * = 0,
00091                                    ACE_CDR::UShort ** = 0);
00092   static int is_compatible_i (ACE_CDR::ULong codeset_id,
00093                               ACE_CDR::ULong other);
00094   static ACE_CDR::Short get_max_bytes_i (ACE_CDR::ULong codeset_id);
00095 };
00096 
00097 ACE_END_VERSIONED_NAMESPACE_DECL
00098 
00099 #if defined (__ACE_INLINE__)
00100 #include "ace/Codeset_Registry.inl"
00101 #endif /* __ACE_INLINE__ */
00102 
00103 #include /**/ "ace/post.h"
00104 #endif /* ACE_CODESET_REGISTRY_H */

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