1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
// $Id$
// ============================================================================
//
// = LIBRARY
// TAO/tao/Codeset
//
// = FILENAME
// Codeset_Translator_Factory.cpp
//
// = DESCRIPTION
// The base for all the translator factories. Translator factories are
// responsible for supplying the proper translator on demand.
//
// = AUTHORS
// Phil Mesnier <mesnier_p@ociweb.com>
//
// ============================================================================
#include "Codeset_Descriptor.h"
#include "Codeset_Translator_Factory.h"
#include "ace/Codeset_Registry.h"
#include "ace/Log_Msg.h"
#include "tao/debug.h"
ACE_RCSID (Codeset,
Codeset_Manager_i,
"$Id$")
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
TAO_Codeset_Descriptor::TAO_Codeset_Descriptor ()
:ncs_ (0),
max_bytes_ (1),
num_translators_ (0),
trans_base_(0)
{
}
TAO_Codeset_Descriptor::~TAO_Codeset_Descriptor ()
{
Translator_Node *temp = trans_base_;
while (temp)
{
temp = trans_base_->next_;
// don't need to delete the associated translator factory, it is
// owned by the service registry
ACE_OS::free (trans_base_->name_);
delete trans_base_;
trans_base_ = temp;
}
}
void
TAO_Codeset_Descriptor::ncs (const ACE_TCHAR *name)
{
ACE_CDR::ULong n = 0;
if (ACE_Codeset_Registry::locale_to_registry
(ACE_TEXT_ALWAYS_CHAR(name), n) == 0)
{
char **endPtr =0;
n = ACE_OS::strtoul(ACE_TEXT_ALWAYS_CHAR(name),
endPtr, 0);
}
this->ncs(n);
}
void
TAO_Codeset_Descriptor::ncs (ACE_CDR::ULong n)
{
this->ncs_ = n;
// Validate the CodesetId
this->max_bytes_ = ACE_Codeset_Registry::get_max_bytes(n);
if (this->max_bytes_ == 0)
{
if (TAO_debug_level > 0)
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) TAO_Codeset_Descriptor::ncs, ")
ACE_TEXT("unknown codeset id 0x%x\n"),
n));
this->ncs_ = 0;
}
}
ACE_CDR::ULong
TAO_Codeset_Descriptor::ncs (void) const
{
return this->ncs_;
}
int
TAO_Codeset_Descriptor::num_translators (void) const
{
return this->num_translators_;
}
int
TAO_Codeset_Descriptor::max_bytes (void) const
{
return this->max_bytes_;
}
void
TAO_Codeset_Descriptor::add_translator (const ACE_TCHAR *name)
{
Translator_Node *temp = trans_base_;
if (this->trans_base_ == 0)
{
ACE_NEW (this->trans_base_, Translator_Node);
temp = trans_base_;
}
else
{
while (temp->next_ != 0)
temp = temp->next_;
ACE_NEW (temp->next_, Translator_Node);
temp = temp->next_;
}
if (temp)
{
this->num_translators_ ++;
temp->name_ = ACE_OS::strdup (name);
temp->translator_factory_ = 0;
temp->next_ = 0;
}
}
TAO_Codeset_Descriptor::Translator_Node *
TAO_Codeset_Descriptor::translators (void)
{
return this->trans_base_;
}
TAO_END_VERSIONED_NAMESPACE_DECL
|