Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "tao/Codeset/Codeset_Descriptor.h"
00018 #include "tao/Codeset/Codeset_Translator_Factory.h"
00019
00020 #include "ace/Codeset_Registry.h"
00021 #include "ace/Log_Msg.h"
00022 #include "tao/debug.h"
00023
00024 ACE_RCSID (Codeset,
00025 Codeset_Manager_i,
00026 "$Id: Codeset_Descriptor.cpp 77041 2007-02-12 15:47:36Z johnnyw $")
00027
00028 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00029
00030 TAO_Codeset_Descriptor::TAO_Codeset_Descriptor ()
00031 :ncs_ (0),
00032 max_bytes_ (1),
00033 num_translators_ (0),
00034 trans_base_(0)
00035 {
00036 }
00037
00038 TAO_Codeset_Descriptor::~TAO_Codeset_Descriptor ()
00039 {
00040 Translator_Node *temp = trans_base_;
00041 while (temp)
00042 {
00043 temp = trans_base_->next_;
00044
00045
00046 ACE_OS::free (trans_base_->name_);
00047 delete trans_base_;
00048 trans_base_ = temp;
00049 }
00050 }
00051
00052 void
00053 TAO_Codeset_Descriptor::ncs (const ACE_TCHAR *name)
00054 {
00055 ACE_CDR::ULong n = 0;
00056 if (ACE_Codeset_Registry::locale_to_registry
00057 (ACE_TEXT_ALWAYS_CHAR(name), n) == 0)
00058 {
00059 char **endPtr = 0;
00060 n = static_cast<ACE_CDR::ULong> (
00061 ACE_OS::strtoul(ACE_TEXT_ALWAYS_CHAR(name), endPtr, 0));
00062 }
00063 this->ncs(n);
00064 }
00065
00066 void
00067 TAO_Codeset_Descriptor::ncs (ACE_CDR::ULong n)
00068 {
00069 this->ncs_ = n;
00070
00071 this->max_bytes_ = ACE_Codeset_Registry::get_max_bytes(n);
00072 if (this->max_bytes_ == 0)
00073 {
00074 if (TAO_debug_level > 0)
00075 ACE_ERROR((LM_ERROR,
00076 ACE_TEXT("(%P|%t) TAO_Codeset_Descriptor::ncs, ")
00077 ACE_TEXT("unknown codeset id 0x%x\n"),
00078 n));
00079 this->ncs_ = 0;
00080 }
00081 }
00082
00083 ACE_CDR::ULong
00084 TAO_Codeset_Descriptor::ncs (void) const
00085 {
00086 return this->ncs_;
00087 }
00088
00089 int
00090 TAO_Codeset_Descriptor::num_translators (void) const
00091 {
00092 return this->num_translators_;
00093 }
00094
00095 int
00096 TAO_Codeset_Descriptor::max_bytes (void) const
00097 {
00098 return this->max_bytes_;
00099 }
00100
00101 void
00102 TAO_Codeset_Descriptor::add_translator (const ACE_TCHAR *name)
00103 {
00104 Translator_Node *temp = trans_base_;
00105 if (this->trans_base_ == 0)
00106 {
00107 ACE_NEW (this->trans_base_, Translator_Node);
00108 temp = trans_base_;
00109 }
00110 else
00111 {
00112 while (temp->next_ != 0)
00113 temp = temp->next_;
00114 ACE_NEW (temp->next_, Translator_Node);
00115 temp = temp->next_;
00116 }
00117 if (temp)
00118 {
00119 this->num_translators_ ++;
00120 temp->name_ = ACE_OS::strdup (name);
00121 temp->translator_factory_ = 0;
00122 temp->next_ = 0;
00123 }
00124 }
00125
00126 TAO_Codeset_Descriptor::Translator_Node *
00127 TAO_Codeset_Descriptor::translators (void)
00128 {
00129 return this->trans_base_;
00130 }
00131
00132 TAO_END_VERSIONED_NAMESPACE_DECL