2 //=============================================================================
4 * @file Codeset_Descriptor.cpp
6 * The base for all the translator factories. Translator factories are
7 * responsible for supplying the proper translator on demand.
9 * @author Phil Mesnier <mesnier_p@ociweb.com>
11 //=============================================================================
14 #include "tao/Codeset/Codeset_Descriptor.h"
15 #include "tao/Codeset/Codeset_Translator_Factory.h"
17 #include "ace/Codeset_Registry.h"
18 #include "ace/Log_Msg.h"
19 #include "tao/debug.h"
21 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
23 TAO_Codeset_Descriptor::TAO_Codeset_Descriptor ()
31 TAO_Codeset_Descriptor::~TAO_Codeset_Descriptor ()
33 Translator_Node
*temp
= trans_base_
;
36 temp
= trans_base_
->next_
;
37 // don't need to delete the associated translator factory, it is
38 // owned by the service registry
39 ACE_OS::free (trans_base_
->name_
);
46 TAO_Codeset_Descriptor::ncs (const ACE_TCHAR
*name
)
49 if (ACE_Codeset_Registry::locale_to_registry
50 (ACE_TEXT_ALWAYS_CHAR(name
), n
) == 0)
53 n
= static_cast<ACE_CDR::ULong
> (
54 ACE_OS::strtoul(ACE_TEXT_ALWAYS_CHAR(name
), endPtr
, 0));
60 TAO_Codeset_Descriptor::ncs (ACE_CDR::ULong n
)
63 // Validate the CodesetId
64 this->max_bytes_
= ACE_Codeset_Registry::get_max_bytes(n
);
65 if (this->max_bytes_
== 0)
67 if (TAO_debug_level
> 0)
68 TAOLIB_ERROR((LM_ERROR
,
69 ACE_TEXT("(%P|%t) TAO_Codeset_Descriptor::ncs, ")
70 ACE_TEXT("unknown codeset id 0x%x\n"),
77 TAO_Codeset_Descriptor::ncs () const
83 TAO_Codeset_Descriptor::num_translators () const
85 return this->num_translators_
;
89 TAO_Codeset_Descriptor::max_bytes () const
91 return this->max_bytes_
;
95 TAO_Codeset_Descriptor::add_translator (const ACE_TCHAR
*name
)
97 Translator_Node
*temp
= trans_base_
;
98 if (this->trans_base_
== 0)
100 ACE_NEW (this->trans_base_
, Translator_Node
);
105 while (temp
->next_
!= 0)
107 ACE_NEW (temp
->next_
, Translator_Node
);
112 this->num_translators_
++;
113 temp
->name_
= ACE_OS::strdup (name
);
114 temp
->translator_factory_
= 0;
119 TAO_Codeset_Descriptor::Translator_Node
*
120 TAO_Codeset_Descriptor::translators ()
122 return this->trans_base_
;
125 TAO_END_VERSIONED_NAMESPACE_DECL