00001 // -*- C++ -*- 00002 00003 /** 00004 * @file Codecs.h 00005 * 00006 * $Id: Codecs.h,v 1.1.1.1 2003/02/21 18:36:32 chad Exp $ 00007 * 00008 * @author Krishnakumar B <kitty@cs.wustl.edu> 00009 * 00010 * Codecs is a generic wrapper for various encoding and decoding 00011 * mechanisms. Currently it includes Base64 content transfer-encoding as 00012 * specified by RFC 2045, Multipurpose Internet Mail Extensions (MIME) Part 00013 * One: Format of Internet Message Bodies. 00014 * 00015 */ 00016 00017 #ifndef ACE_CODECS_H 00018 #define ACE_CODECS_H 00019 #include "ace/pre.h" 00020 00021 #include "ace/Basic_Types.h" 00022 00023 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00024 # pragma once 00025 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00026 00027 /** 00028 * @class ACE_Base64 00029 * 00030 * @brief Encode/Decode a stream of bytes according to Base64 encoding. 00031 * 00032 * This class provides methods to encode or decode a stream of bytes 00033 * to/from Base64 encoding. It doesn't convert the input stream to a 00034 * canonical form before encoding. 00035 * 00036 */ 00037 class ACE_Export ACE_Base64 00038 { 00039 friend class ace_dewarn_gplusplus; 00040 public: 00041 00042 //@{ 00043 00044 /** 00045 * Encodes a stream of bytes to Base64 data 00046 * 00047 * @param input Binary data in byte stream. 00048 * @param input_len Length of the byte stream. 00049 * @param output_len Length of the encoded Base64 byte stream. 00050 * @return Encoded Base64 data in byte stream or NULL if input data cannot 00051 * be encoded. 00052 */ 00053 00054 static ACE_Byte* encode (const ACE_Byte* input, 00055 const size_t input_len, 00056 size_t* output_len); 00057 /** 00058 * Decodes a stream of Base64 to bytes data 00059 * 00060 * @param input Encoded Base64 data in byte stream. 00061 * @param output_len Length of the binary byte stream. 00062 * @return Binary data in byte stream or NULL if input data cannot 00063 * be encoded. 00064 */ 00065 static ACE_Byte* decode (const ACE_Byte* input, 00066 size_t* output_len); 00067 00068 /** 00069 * Return the length of the encoded input data 00070 * 00071 * @param input Encoded Base64 data in byte stream. 00072 * @return Length of the encoded Base64 data. 00073 * 00074 */ 00075 static size_t length (const ACE_Byte* input); 00076 00077 //@} 00078 00079 private: 00080 00081 /// Initialize the tables for encoding/decoding. 00082 static void init(); 00083 00084 // Prevent construction in any form 00085 ACE_UNIMPLEMENTED_FUNC (ACE_Base64 ()) 00086 ACE_UNIMPLEMENTED_FUNC (ACE_Base64 (const ACE_Base64&)) 00087 00088 /// Symbols which form the Base64 alphabet (Defined as per RFC 2045) 00089 static const ACE_Byte alphabet_[]; 00090 00091 /// Alphabet used for decoding i.e decoder_[alphabet_[i = 0..63]] = i 00092 static ACE_Byte decoder_[]; 00093 00094 /// Alphabet used to check valid range of encoded input i.e 00095 /// member_[alphabet_[0..63]] = 1 00096 static ACE_Byte member_[]; 00097 00098 /// The padding character used in the encoding 00099 static const ACE_Byte pad_; 00100 00101 /// Boolean to denote whether initialization is complete 00102 static int init_; 00103 00104 /// Number of columns per line of encoded output (Can have a max value of 76) 00105 static int max_columns_; 00106 00107 }; 00108 00109 #include "ace/post.h" 00110 #endif /* ACE_CODECS_H */
1.2.14 written by Dimitri van Heesch,
© 1997-2002