Use =default for skeleton copy constructor
[ACE_TAO.git] / TAO / tao / Codeset / Codeset_Descriptor.cpp
blob4ebf2cc0c4a6d4e5ab8fdc3b993cd304f9a77290
2 //=============================================================================
3 /**
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 ()
24 :ncs_ (0),
25 max_bytes_ (1),
26 num_translators_ (0),
27 trans_base_(0)
31 TAO_Codeset_Descriptor::~TAO_Codeset_Descriptor ()
33 Translator_Node *temp = trans_base_;
34 while (temp)
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_);
40 delete trans_base_;
41 trans_base_ = temp;
45 void
46 TAO_Codeset_Descriptor::ncs (const ACE_TCHAR *name)
48 ACE_CDR::ULong n = 0;
49 if (ACE_Codeset_Registry::locale_to_registry
50 (ACE_TEXT_ALWAYS_CHAR(name), n) == 0)
52 char **endPtr = 0;
53 n = static_cast<ACE_CDR::ULong> (
54 ACE_OS::strtoul(ACE_TEXT_ALWAYS_CHAR(name), endPtr, 0));
56 this->ncs(n);
59 void
60 TAO_Codeset_Descriptor::ncs (ACE_CDR::ULong n)
62 this->ncs_ = 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"),
71 n));
72 this->ncs_ = 0;
76 ACE_CDR::ULong
77 TAO_Codeset_Descriptor::ncs () const
79 return this->ncs_;
82 int
83 TAO_Codeset_Descriptor::num_translators () const
85 return this->num_translators_;
88 int
89 TAO_Codeset_Descriptor::max_bytes () const
91 return this->max_bytes_;
94 void
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);
101 temp = trans_base_;
103 else
105 while (temp->next_ != 0)
106 temp = temp->next_;
107 ACE_NEW (temp->next_, Translator_Node);
108 temp = temp->next_;
110 if (temp)
112 this->num_translators_ ++;
113 temp->name_ = ACE_OS::strdup (name);
114 temp->translator_factory_ = 0;
115 temp->next_ = 0;
119 TAO_Codeset_Descriptor::Translator_Node *
120 TAO_Codeset_Descriptor::translators ()
122 return this->trans_base_;
125 TAO_END_VERSIONED_NAMESPACE_DECL