Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACEXML_Base64 Class Reference

Encode/Decode a stream of ACEXML_Chars according to Base64 encoding. More...

#include <XML_Codecs.h>

Inheritance diagram for ACEXML_Base64:

Inheritance graph
[legend]
Collaboration diagram for ACEXML_Base64:

Collaboration graph
[legend]
List of all members.

Static Public Methods

ACEXML_Charencode (const ACEXML_Char *input, size_t *output_len)
ACEXML_Chardecode (const ACEXML_Char *input, size_t *output_len)

Detailed Description

Encode/Decode a stream of ACEXML_Chars according to Base64 encoding.

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.


Member Function Documentation

ACEXML_Char * ACEXML_Base64::decode const ACEXML_Char   input,
size_t *    output_len
[static]
 

Decodes a stream of Base64 to octets data

Parameters:
input  Encoded Base64 data in ACEXML_Char stream.
output_len  Length of the binary ACEXML_Char stream.
Returns:
Binary data in ACEXML_Char stream or NULL if input data cannot be encoded.

Definition at line 48 of file XML_Codecs.cpp.

References ACE_Byte, ACE_NEW_RETURN, ACEXML_Char, ACE_Base64::decode, and ACE_OS_String::strlen.

00050 {
00051   if (!input)
00052     return 0;
00053 
00054   size_t len = ACE_OS::strlen (input);
00055 
00056   ACE_Byte* buf = 0;
00057 
00058   ACE_NEW_RETURN (buf,
00059                   ACE_Byte[len],
00060                   0);
00061 
00062   ACE_Auto_Basic_Array_Ptr<ACE_Byte> cleanup (buf);
00063 
00064   for (size_t i = 0; i < len; ++i)
00065     buf[i] = (ACE_Byte)input[i];
00066 
00067   buf[len] = 0;
00068 
00069   size_t decode_len = 0;
00070 
00071   ACE_Byte* decodedBuf = ACE_Base64::decode (buf, &decode_len);
00072 
00073   if (!decodedBuf)
00074     return 0;
00075 
00076   ACEXML_Char* result = 0;
00077 
00078   ACE_NEW_RETURN (result,
00079                   ACEXML_Char[decode_len+1],
00080                   0);
00081 
00082   for (size_t j = 0; j < decode_len; ++j)
00083     result[j] = (ACEXML_Char)decodedBuf[j];
00084 
00085   result[decode_len] = 0;
00086 
00087   *output_len = decode_len;
00088   delete[] decodedBuf;
00089 
00090   return result;
00091 }

ACEXML_Char * ACEXML_Base64::encode const ACEXML_Char   input,
size_t *    output_len
[static]
 

Encodes a stream of octets to Base64 data

Parameters:
input  Binary data in ACEXML_Char stream.
output_len  Length of the encoded Base64 ACEXML_Char stream.
Returns:
Encoded Base64 data in ACEXML_Char stream or NULL if input data cannot be encoded.

Definition at line 9 of file XML_Codecs.cpp.

References ACE_Byte, ACE_NEW_RETURN, ACEXML_Char, ACE_Base64::encode, and ACE_OS_String::strlen.

00011 {
00012   if (!input)
00013     return 0;
00014   size_t len = ACE_OS::strlen (input);
00015 
00016   ACE_Byte* buf = 0;
00017   ACE_NEW_RETURN (buf,
00018                   ACE_Byte[len],
00019                   0);
00020   ACE_Auto_Basic_Array_Ptr<ACE_Byte> cleanup_buf (buf);
00021 
00022   for (size_t i = 0; i < len; ++i)
00023     buf[i] = (ACE_Byte)input[i];
00024   buf[len] = 0;
00025 
00026   size_t encode_len = 0;
00027   ACE_Byte* encodedBuf = ACE_Base64::encode (buf, len, &encode_len);
00028 
00029   if (!encodedBuf)
00030     return 0;
00031 
00032   ACEXML_Char* result = 0;
00033   ACE_NEW_RETURN (result,
00034                   ACEXML_Char[encode_len+1],
00035                   0);
00036 
00037   for (size_t j = 0; j < encode_len; ++j)
00038     result[j] = (ACEXML_Char)encodedBuf[j];
00039   result[encode_len] = 0;
00040 
00041   *output_len = encode_len;
00042   delete[] encodedBuf;
00043   return result;
00044 }


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 13:26:34 2003 for ACEXML by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002