UTF8_Encoding_Converter.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=========================================================================
00004 /**
00005  * @file UTF8_Encoding_Converter.h
00006  *
00007  * UTF8_Encoding_Converter.h,v 4.1 2006/01/09 15:18:53 elliott_c Exp
00008  *
00009  * This class contains declarations for methods that convert between
00010  * UTF-8 and the native ACE_TCHAR representation.
00011  *
00012  * @author Chad Elliott <elliott_c@ociweb.com>
00013  */
00014 //=========================================================================
00015 
00016 #ifndef ACE_UTF8_ENCODING_CONVERTER_H
00017 #define ACE_UTF8_ENCODING_CONVERTER_H
00018 
00019 #include /**/ "ace/pre.h"
00020 
00021 #include "ace/Encoding_Converter.h"
00022 
00023 #if defined (ACE_USES_WCHAR)
00024 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00025 
00026 /** Convert from UTF-16 or UTF-32 to UTF-8.
00027  * This class implements the ACE_Encoding_Converter interface.
00028  */
00029 class ACE_UTF8_Encoding_Converter: public ACE_Encoding_Converter
00030 {
00031 public:
00032   /// Allocate the converter to be used by the from_utf8() method based
00033   /// on the size of the native wide character.
00034   ACE_UTF8_Encoding_Converter (void);
00035 
00036   /// De-allocate the native converter.
00037   virtual ~ACE_UTF8_Encoding_Converter (void);
00038 
00039   /// Since the source *must be* UTF-8, there is no conversion required.
00040   /// This method just copies the source to the target given that there
00041   /// is enough space.
00042   virtual Result to_utf8 (const void* source,
00043                           size_t source_size,
00044                           ACE_Byte* target,
00045                           size_t target_size,
00046                           bool strict = true);
00047 
00048   /// Utilize the native converter to convert the UTF-8 source into an
00049   /// alternate encoding and store it in the provided target buffer.
00050   virtual Result from_utf8 (const ACE_Byte* source,
00051                             size_t source_size,
00052                             void* target,
00053                             size_t target_size,
00054                             bool strict = true);
00055 
00056 
00057   /// This factory helper method determines if the source stream is UTF-8
00058   /// encoded.  If it is, allocate an ACE_UTF8_Encoding_Converter and
00059   /// return it.  The caller then owns the allocated object.
00060   static ACE_UTF8_Encoding_Converter* encoded (const ACE_Byte* source,
00061                                                size_t source_size);
00062 
00063 private:
00064   ACE_Encoding_Converter* native_;
00065 };
00066 
00067 ACE_END_VERSIONED_NAMESPACE_DECL
00068 #endif /* ACE_USES_WCHAR */
00069 
00070 #include /**/ "ace/post.h"
00071 
00072 #endif /* ACE_UTF8_ENCODING_CONVERTER_H */

Generated on Thu Nov 9 09:42:09 2006 for ACE by doxygen 1.3.6