#include <XML_Codecs.h>
Inheritance diagram for ACEXML_Base64:
Static Public Member Functions | |
ACEXML_Char * | encode (const ACEXML_Char *input, size_t *output_len) |
ACEXML_Char * | decode (const ACEXML_Char *input, size_t *output_len) |
This class provides methods to encode or decode a stream of ACEXML_Chars to/from Base64 encoding. It doesn't convert the input stream to a canonical form before encoding.
Definition at line 39 of file XML_Codecs.h.
|
Decodes a stream of Base64 to octets data
Definition at line 50 of file XML_Codecs.cpp. References ACE_Byte, ACE_NEW_RETURN, ACEXML_Char, ACE_Base64::decode(), and ACE_OS::strlen().
00052 { 00053 if (!input) 00054 return 0; 00055 00056 size_t len = ACE_OS::strlen (input); 00057 00058 ACE_Byte* buf = 0; 00059 00060 ACE_NEW_RETURN (buf, 00061 ACE_Byte[len], 00062 0); 00063 00064 ACE_Auto_Basic_Array_Ptr<ACE_Byte> cleanup (buf); 00065 00066 for (size_t i = 0; i < len; ++i) 00067 buf[i] = (ACE_Byte)input[i]; 00068 00069 buf[len] = 0; 00070 00071 size_t decode_len = 0; 00072 00073 ACE_Byte* decodedBuf = ACE_Base64::decode (buf, &decode_len); 00074 00075 if (!decodedBuf) 00076 return 0; 00077 00078 ACEXML_Char* result = 0; 00079 00080 ACE_NEW_RETURN (result, 00081 ACEXML_Char[decode_len+1], 00082 0); 00083 00084 for (size_t j = 0; j < decode_len; ++j) 00085 result[j] = (ACEXML_Char)decodedBuf[j]; 00086 00087 result[decode_len] = 0; 00088 00089 *output_len = decode_len; 00090 delete[] decodedBuf; 00091 00092 return result; 00093 } |
|
Encodes a stream of octets to Base64 data
Definition at line 11 of file XML_Codecs.cpp. References ACE_Byte, ACE_NEW_RETURN, ACEXML_Char, ACE_Base64::encode(), and ACE_OS::strlen().
00013 { 00014 if (!input) 00015 return 0; 00016 size_t len = ACE_OS::strlen (input); 00017 00018 ACE_Byte* buf = 0; 00019 ACE_NEW_RETURN (buf, 00020 ACE_Byte[len], 00021 0); 00022 ACE_Auto_Basic_Array_Ptr<ACE_Byte> cleanup_buf (buf); 00023 00024 for (size_t i = 0; i < len; ++i) 00025 buf[i] = (ACE_Byte)input[i]; 00026 buf[len] = 0; 00027 00028 size_t encode_len = 0; 00029 ACE_Byte* encodedBuf = ACE_Base64::encode (buf, len, &encode_len); 00030 00031 if (!encodedBuf) 00032 return 0; 00033 00034 ACEXML_Char* result = 0; 00035 ACE_NEW_RETURN (result, 00036 ACEXML_Char[encode_len+1], 00037 0); 00038 00039 for (size_t j = 0; j < encode_len; ++j) 00040 result[j] = (ACEXML_Char)encodedBuf[j]; 00041 result[encode_len] = 0; 00042 00043 *output_len = encode_len; 00044 delete[] encodedBuf; 00045 return result; 00046 } |