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 Member Functions

static ACEXML_Charencode (const ACEXML_Char *input, size_t *output_len)
static 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 50 of file XML_Codecs.cpp.

{
  if (!input)
    return 0;

  size_t len = ACE_OS::strlen (input);

  ACE_Byte* buf = 0;

  ACE_NEW_RETURN (buf,
                  ACE_Byte[len],
                  0);

  ACE_Auto_Basic_Array_Ptr<ACE_Byte> cleanup (buf);

  for (size_t i = 0; i < len; ++i)
    buf[i] = (ACE_Byte)input[i];

  buf[len] = 0;

  size_t decode_len = 0;

  ACE_Byte* decodedBuf = ACE_Base64::decode (buf, &decode_len);

  if (!decodedBuf)
    return 0;

  ACEXML_Char* result = 0;

  ACE_NEW_RETURN (result,
                  ACEXML_Char[decode_len+1],
                  0);

  for (size_t j = 0; j < decode_len; ++j)
    result[j] = (ACEXML_Char)decodedBuf[j];

  result[decode_len] = 0;

  *output_len = decode_len;
  delete[] decodedBuf;

  return result;
}

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 11 of file XML_Codecs.cpp.

{
  if (!input)
    return 0;
  size_t len = ACE_OS::strlen (input);

  ACE_Byte* buf = 0;
  ACE_NEW_RETURN (buf,
                  ACE_Byte[len],
                  0);
  ACE_Auto_Basic_Array_Ptr<ACE_Byte> cleanup_buf (buf);

  for (size_t i = 0; i < len; ++i)
    buf[i] = (ACE_Byte)input[i];
  buf[len] = 0;

  size_t encode_len = 0;
  ACE_Byte* encodedBuf = ACE_Base64::encode (buf, len, &encode_len);

  if (!encodedBuf)
    return 0;

  ACEXML_Char* result = 0;
  ACE_NEW_RETURN (result,
                  ACEXML_Char[encode_len+1],
                  0);

  for (size_t j = 0; j < encode_len; ++j)
    result[j] = (ACEXML_Char)encodedBuf[j];
  result[encode_len] = 0;

  *output_len = encode_len;
  delete[] encodedBuf;
  return result;
}


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines