Use override/default for RTPortableServer
[ACE_TAO.git] / ACE / ace / Encoding_Converter_Factory.cpp
blob85f139fc11ea8b6a29dc8116f5451545a99747bd
1 #include "ace/Encoding_Converter_Factory.h"
3 #if defined (ACE_USES_WCHAR)
4 #include "ace/UTF32_Encoding_Converter.h"
5 #include "ace/UTF16_Encoding_Converter.h"
6 #include "ace/UTF8_Encoding_Converter.h"
7 #include "ace/OS_Memory.h"
9 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
11 ACE_Encoding_Converter*
12 ACE_Encoding_Converter_Factory::create (
13 const ACE_Byte* source,
14 size_t source_size,
15 ACE_Encoding_Converter_Factory::Encoding_Hint hint)
17 #if defined (ACE_BIG_ENDIAN)
18 bool const convert_for_bigendian = true;
19 #else
20 bool const convert_for_bigendian = false;
21 #endif /* ACE_BIG_ENDIAN */
22 ACE_Encoding_Converter* converter = 0;
24 switch (hint)
26 case ACE_UTF_32BE:
27 ACE_NEW_RETURN (converter,
28 ACE_UTF32_Encoding_Converter (!convert_for_bigendian),
29 0);
30 break;
31 case ACE_UTF_32LE:
32 ACE_NEW_RETURN (converter,
33 ACE_UTF32_Encoding_Converter (convert_for_bigendian),
34 0);
35 break;
36 case ACE_UTF_16BE:
37 ACE_NEW_RETURN (converter,
38 ACE_UTF16_Encoding_Converter (!convert_for_bigendian),
39 0);
40 break;
41 case ACE_UTF_16LE:
42 ACE_NEW_RETURN (converter,
43 ACE_UTF16_Encoding_Converter (convert_for_bigendian),
44 0);
45 break;
46 case ACE_UTF_8:
47 ACE_NEW_RETURN (converter,
48 ACE_UTF8_Encoding_Converter,
49 0);
50 break;
51 default:
52 // First check for ASCII since much of ASCII text will appear to
53 // convert from UTF-16 to UTF-8.
54 converter = ACE_UTF8_Encoding_Converter::encoded (source, source_size);
55 if (converter != 0)
56 return converter;
58 // Check for UTF-32
59 converter = ACE_UTF32_Encoding_Converter::encoded (source, source_size);
60 if (converter != 0)
61 return converter;
63 // Check for UTF-16
64 converter = ACE_UTF16_Encoding_Converter::encoded (source, source_size);
65 if (converter != 0)
66 return converter;
69 return converter;
72 ACE_END_VERSIONED_NAMESPACE_DECL
73 #endif /* ACE_USES_WCHAR */