Encoding_Converter.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=========================================================================
00004 /**
00005  * @file Encoding_Converter.h
00006  *
00007  * Encoding_Converter.h,v 4.1 2006/01/09 15:18:53 elliott_c Exp
00008  *
00009  * This class is the base class for all encoding converters that convert
00010  * to and from UTF-8.
00011  *
00012  * @author Chad Elliott <elliott_c@ociweb.com>
00013  */
00014 //=========================================================================
00015 
00016 #ifndef ACE_ENCODING_CONVERTER_H
00017 #define ACE_ENCODING_CONVERTER_H
00018 
00019 #include /**/ "ace/pre.h"
00020 
00021 #include "ace/Basic_Types.h"
00022 
00023 #if defined (ACE_USES_WCHAR)
00024 #include "ace/ACE_export.h"
00025 
00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00027 
00028 /** The base class for all ACE UTF Encoding Converters.
00029  * This class provides a generic interface that is used to implement
00030  * various UTF encoding conversion classes.
00031  */
00032 class ACE_Export ACE_Encoding_Converter
00033 {
00034 public:
00035   /// This enum describes the various states that can be returned
00036   /// from the to_utf8() and from_utf8() methods which depends on
00037   /// both the source buffer and the size of the target buffer.
00038   enum Result {CONVERSION_OK,
00039                SOURCE_EXHAUSTED,
00040                TARGET_EXHAUSTED,
00041                SOURCE_ILLEGAL
00042               };
00043 
00044   /// This destructor is here (and virtual) because we have virtual
00045   /// functions.
00046   virtual ~ACE_Encoding_Converter (void);
00047 
00048   /// Convert the source (which can be in any encoding) to UTF-8 and
00049   /// store it in the provided target buffer.
00050   virtual Result to_utf8 (const void* source,
00051                           size_t source_size,
00052                           ACE_Byte* target,
00053                           size_t target_size,
00054                           bool strict = true) = 0;
00055 
00056   /// Convert the UTF-8 source into an alternate encoding and store it
00057   /// in the provided target buffer.
00058   virtual Result from_utf8 (const ACE_Byte* source,
00059                             size_t source_size,
00060                             void* target,
00061                             size_t target_size,
00062                             bool strict = true) = 0;
00063 };
00064 
00065 ACE_END_VERSIONED_NAMESPACE_DECL
00066 #endif /* ACE_USES_WCHAR */
00067 
00068 #include /**/ "ace/post.h"
00069 
00070 #endif /* ACE_ENCODING_CONVERTER_H */

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