3 //=============================================================================
5 * @file UTF16_BOM_Factory.cpp
7 * Loader for an instance of the UTF16_BOM_Translator.
9 * @author Phil Mesnier <mesnier_p@ociweb.com>
11 //=============================================================================
13 #include "tao/debug.h"
14 #include "tao/Codeset/UTF16_BOM_Factory.h"
15 #include "ace/OS_NS_strings.h"
16 #include "ace/Dynamic_Service.h"
17 #include "ace/Log_Msg.h"
19 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
21 ACE_STATIC_SVC_DEFINE (TAO_UTF16_BOM_Factory
,
22 ACE_TEXT ("UTF16_BOM_Factory"),
24 &ACE_SVC_NAME (TAO_UTF16_BOM_Factory
),
25 ACE_Service_Type::DELETE_THIS
26 | ACE_Service_Type::DELETE_OBJ
,
28 ACE_FACTORY_DEFINE (TAO_Codeset
, TAO_UTF16_BOM_Factory
)
30 TAO_UTF16_BOM_Factory::~TAO_UTF16_BOM_Factory ()
32 delete this->translator_
;
36 TAO_UTF16_BOM_Factory::init (int argc
, ACE_TCHAR
*argv
[])
38 TAO_Codeset_Translator_Factory::init (argc
, argv
);
40 for (int narg
= 0; narg
< argc
;)
42 int consumed
= parse_one_arg (argc
- narg
, &argv
[narg
]);
49 TAOLIB_ERROR ((LM_ERROR
,
50 ACE_TEXT ("(%P|%t)TAO_UTF16_BOM_Factory parameter error: %s\n")
51 ACE_TEXT ("Usage: TAO_UTF16_BOM_Factory \"-forceBE\"\n")
61 TAO_UTF16_BOM_Factory::parse_one_arg (int argc
, ACE_TCHAR
*argv
[])
64 if ((argc
> 0) && (ACE_OS::strcasecmp (argv
[0], ACE_TEXT("-forcebe")) == 0))
66 this->forceBE_
= true;
73 TAO_UTF16_BOM_Factory::ncs () const
76 return this->translator_
->ncs();
80 TAO_UTF16_BOM_Factory::tcs () const
83 return this->translator_
->tcs();
86 // Assign either a reference to the existing translator or a new translator
87 // for input CDR streams
89 TAO_UTF16_BOM_Factory::assign (TAO_InputCDR
*cdr
) const
94 this->assign_i (cdr
, this->translator_
);
98 // Assign either a reference to the existing translator or a new translator
99 // for output CDR streams
101 TAO_UTF16_BOM_Factory::assign (TAO_OutputCDR
*cdr
) const
105 create_translator ();
106 this->assign_i (cdr
, this->translator_
);
111 TAO_UTF16_BOM_Factory::create_translator () const
113 if (this->translator_
== 0)
115 TAO_UTF16_BOM_Factory
* pthis
= const_cast<TAO_UTF16_BOM_Factory
*> (this);
116 ACE_NEW (pthis
->translator_
, TAO_UTF16_BOM_Translator (this->forceBE_
));
117 if (this->translator_
== 0)
120 TAOLIB_ERROR ((LM_ERROR
,
121 ACE_TEXT ("TAO (%P|%t) - UTF16_BOM_Factory: ")
122 ACE_TEXT ("Cannot create translator\n")
128 TAO_END_VERSIONED_NAMESPACE_DECL