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
136
137
138
139
140
141
142
143
144
145
146
147
148
|
// -*- C++ -*-
//
// $Id$
#include "CodecFactory_impl.h"
#include "CDR_Encaps_Codec.h"
#include "tao/SystemException.h"
#include "tao/ORB_Constants.h"
#include "tao/ORB_Core.h"
#include "tao/Codeset_Manager.h"
#include "ace/Codeset_Symbols.h"
ACE_RCSID (CodecFactory_impl,
CodecFactory,
"$Id$")
TAO_CodecFactory::TAO_CodecFactory (TAO_ORB_Core * orb_core)
: orb_core_ (orb_core)
{
}
IOP::Codec_ptr
TAO_CodecFactory::create_codec_with_codesets (const IOP::Encoding_1_2 & enc
ACE_ENV_ARG_DECL_WITH_DEFAULTS)
ACE_THROW_SPEC ((CORBA::SystemException,
IOP::CodecFactory::UnknownEncoding,
IOP::CodecFactory::UnsupportedCodeset))
{
TAO_Codeset_Translator_Base *char_trans = 0;
TAO_Codeset_Translator_Base *wchar_trans = 0;
CONV_FRAME::CodeSetId ncsc;
CONV_FRAME::CodeSetId ncsw;
TAO_Codeset_Manager *csm = this->orb_core_->codeset_manager ();
if (csm)
{
char_trans = csm->get_char_trans (enc.char_codeset);
wchar_trans = csm->get_wchar_trans (enc.wchar_codeset);
csm->get_ncs (ncsc,ncsw); // pass by reference
}
else
{
// No codeset manager, so also raise an unsupported codeset
ACE_THROW_RETURN (IOP::CodecFactory::UnsupportedCodeset (
enc.wchar_codeset),
IOP::Codec::_nil ());
}
if (wchar_trans == 0 &&
enc.wchar_codeset != ACE_CODESET_ID_ISO_UTF_16 &&
enc.wchar_codeset != ncsw)
{
ACE_THROW_RETURN (IOP::CodecFactory::UnsupportedCodeset (
enc.wchar_codeset),
IOP::Codec::_nil ());
}
if (char_trans == 0 &&
enc.char_codeset != ncsc)
{
ACE_THROW_RETURN (IOP::CodecFactory::UnsupportedCodeset (
enc.char_codeset),
IOP::Codec::_nil ());
}
return this->create_codec_i (enc.major_version,
enc.minor_version,
enc.format,
char_trans,
wchar_trans
ACE_ENV_ARG_PARAMETER);
}
IOP::Codec_ptr
TAO_CodecFactory::create_codec (const IOP::Encoding & enc
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
IOP::CodecFactory::UnknownEncoding))
{
return this->create_codec_i (enc.major_version,
enc.minor_version,
enc.format,
0,
0
ACE_ENV_ARG_PARAMETER);
}
IOP::Codec_ptr
TAO_CodecFactory::create_codec_i (CORBA::Octet major,
CORBA::Octet minor,
IOP::EncodingFormat encoding_format,
TAO_Codeset_Translator_Base * char_trans,
TAO_Codeset_Translator_Base * wchar_trans
ACE_ENV_ARG_DECL)
ACE_THROW_SPEC ((CORBA::SystemException,
IOP::CodecFactory::UnknownEncoding))
{
// @todo: Ideally we should have some sort of CodecFactory
// registry to make it possible to add factories
// dynamically. However, there currently isn't a need to
// support anything other than CDR encapsulations yet so we
// hardcode its Codec. This may change once TAO starts to
// support messaging formats other than GIOP.
IOP::Codec_ptr codec = IOP::Codec::_nil ();
switch (encoding_format)
{
// @@ MSVC 6 gets confused and thinks that
// IOP::ENCODING_CDR_ENCAPS is not a constant, so its actual
// value (0) is used instead.
case 0 /* IOP::ENCODING_CDR_ENCAPS */:
if (major < 1)
{
// There is no such thing as a "0.x" CDR encapsulation.
ACE_THROW_RETURN (CORBA::BAD_PARAM (
CORBA::SystemException::_tao_minor_code (
0,
EINVAL),
CORBA::COMPLETED_NO),
IOP::Codec::_nil ());
}
ACE_NEW_THROW_EX (codec,
TAO_CDR_Encaps_Codec (major,
minor,
this->orb_core_,
char_trans,
wchar_trans),
CORBA::NO_MEMORY (
CORBA::SystemException::_tao_minor_code (
0,
ENOMEM),
CORBA::COMPLETED_MAYBE));
ACE_CHECK_RETURN (IOP::Codec::_nil ());
break;
default:
ACE_THROW_RETURN (IOP::CodecFactory::UnknownEncoding (),
IOP::Codec::_nil ());
}
return codec;
}
|