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

Codeset_Registry.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //=============================================================================
00003 /**
00004  *  @file   Codeset_Registry.h
00005  *
00006  *  $Id: Codeset_Registry.h,v 1.1.8.1 2003/04/10 14:12:27 phil 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 
00031 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00032 # pragma once
00033 #endif /* ACE_LACKS_PRAGMA_ONCE */
00034 
00035 #if defined (ACE_HAS_DCE_CODESET_REGISTRY)
00036 #include /**/ <dce/rpc.h>
00037 #endif /* ACE_HAS_DCE_CODESET_REGISTRY */
00038 
00039 class ACE_Export ACE_Codeset_Registry
00040 {
00041 public:
00042 
00043   // based on a locale string, find the registry value and optional codeset
00044   // collection. This wraps the dce_cs_loc_to_rgy function, or emulates it.
00045   static int locale_to_registry (const ACE_CString &locale,
00046                                  ACE_CDR::ULong &codeset_id,
00047                                  ACE_CDR::UShort * = 0,
00048                                  ACE_CDR::UShort ** = 0);
00049 
00050   // based on a registry value, find the locale string and optional codeset
00051   // collection.  This wraps the dce_cs_rgy_to_loc function, or emulates it.
00052   static int registry_to_locale (ACE_CDR::ULong codeset_id,
00053                                  ACE_CString &locale,
00054                                  ACE_CDR::UShort * = 0,
00055                                  ACE_CDR::UShort ** = 0);
00056 
00057   // tell if two codesets are compatible. This wraps the
00058   //rpc_cs_char_set_compat_check function.
00059   static int is_compatible (ACE_CDR::ULong codeset_id,
00060                             ACE_CDR::ULong other);
00061 
00062   // return the max number of bytes required to represent a single character.
00063   // This wraps the rpc_rgy_get_max_bytes function.
00064   static ACE_CDR::Short get_max_bytes (ACE_CDR::ULong codeset_id);
00065 
00066   enum {max_charsets_ = 5};
00067 protected:
00068   typedef struct {
00069     const char *     desc_;
00070     const char *     loc_name_;
00071     ACE_CDR::ULong   codeset_id_;
00072     ACE_CDR::UShort  num_sets_;
00073     ACE_CDR::UShort  char_sets_[max_charsets_];
00074     ACE_CDR::UShort  max_bytes_;
00075   } registry_entry;
00076 
00077 private:
00078   static size_t num_registry_entries_;
00079   static registry_entry registry_db_[];
00080 
00081   static int locale_to_registry_i (const ACE_CString &locale,
00082                                    ACE_CDR::ULong &codeset_id,
00083                                    ACE_CDR::UShort * = 0,
00084                                    ACE_CDR::UShort ** = 0);
00085   static int registry_to_locale_i (ACE_CDR::ULong codeset_id,
00086                                    ACE_CString &locale,
00087                                    ACE_CDR::UShort * = 0,
00088                                    ACE_CDR::UShort ** = 0);
00089   static int is_compatible_i (ACE_CDR::ULong codeset_id,
00090                               ACE_CDR::ULong other);
00091   static ACE_CDR::Short get_max_bytes_i (ACE_CDR::ULong codeset_id);
00092 };
00093 
00094 #if defined (__ACE_INLINE__)
00095 #include "ace/Codeset_Registry.inl"
00096 #endif /* __ACE_INLINE__ */
00097 
00098 #include "ace/post.h"
00099 #endif /* ACE_CODESET_REGISTRY_H */

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