summaryrefslogtreecommitdiff
path: root/ACE/ace/UTF32_Encoding_Converter.h
blob: ab7b9d14e9ff444ed6f27b529d66025135316061 (plain)
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
// -*- C++ -*-

//=========================================================================
/**
 * @file UTF32_Encoding_Converter.h
 *
 * This class contains declarations for methods that convert between
 * UTF-32 (both BE and LE) and UTF-8
 *
 * @author Chad Elliott <elliott_c@ociweb.com>
 */
//=========================================================================

#ifndef ACE_UTF32_ENCODING_CONVERTER_H
#define ACE_UTF32_ENCODING_CONVERTER_H

#include /**/ "ace/pre.h"

#include "ace/UTF16_Encoding_Converter.h"

#if defined (ACE_USES_WCHAR)
ACE_BEGIN_VERSIONED_NAMESPACE_DECL

/** Convert from UTF-32 to UTF-8 and from UTF-8 to UTF-32.
 * This class implements the ACE_Encoding_Converter interface.
 */
class ACE_UTF32_Encoding_Converter: public ACE_UTF16_Encoding_Converter
{
public:
  /// This class has some similarities to the UTF16 converter, so
  /// we just construct our base class and pass the swap parameter.
  ACE_UTF32_Encoding_Converter (bool swap = false);

  /// This is a do nothing destructor.
  virtual ~ACE_UTF32_Encoding_Converter (void);

  /// Convert the source from UTF-32 to UTF-8 and store it in the
  /// provided target buffer.
  virtual Result to_utf8 (const void* source,
                          size_t source_size,
                          ACE_Byte* target,
                          size_t target_size,
                          bool strict = true);

  /// Convert the UTF-8 source into a UTF-32 encoding and store it
  /// in the provided target buffer.
  virtual Result from_utf8 (const ACE_Byte* source,
                            size_t source_size,
                            void* target,
                            size_t target_size,
                            bool strict = true);

  /// This factory helper method determines if the source stream is UTF-32
  /// encoded.  If it is, allocate an ACE_UTF32_Encoding_Converter and
  /// return it.  The caller then owns the allocated object.
  static ACE_UTF32_Encoding_Converter* encoded (const ACE_Byte* source,
                                                size_t source_size);
};

ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_USES_WCHAR */

#include /**/ "ace/post.h"

#endif /* ACE_UTF32_ENCODING_CONVERTER_H */