Fixed typos
[ACE_TAO.git] / ACE / ace / Codecs.h
blob6440e7dad8c53a62bb5d5a6364a681d90a7f227c
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Codecs.h
7 * @author Krishnakumar B <kitty@cs.wustl.edu>
9 * Codecs is a generic wrapper for various encoding and decoding
10 * mechanisms. Currently it includes Base64 content transfer-encoding as
11 * specified by RFC 2045, Multipurpose Internet Mail Extensions (MIME) Part
12 * One: Format of Internet Message Bodies.
14 //=============================================================================
16 #ifndef ACE_CODECS_H
17 #define ACE_CODECS_H
19 #include /**/ "ace/pre.h"
21 #include /**/ "ace/ACE_export.h"
23 #if !defined (ACE_LACKS_PRAGMA_ONCE)
24 # pragma once
25 #endif /* ACE_LACKS_PRAGMA_ONCE */
27 #include "ace/Basic_Types.h"
28 #include "ace/Global_Macros.h"
30 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
32 /**
33 * @class ACE_Base64
35 * @brief Encode/Decode a stream of bytes according to Base64 encoding.
37 * This class provides methods to encode or decode a stream of bytes
38 * to/from Base64 encoding. It doesn't convert the input stream to a
39 * canonical form before encoding.
41 class ACE_Export ACE_Base64
43 public:
44 //@{
46 /**
47 * Encodes a stream of bytes to Base64 data
49 * @param input Binary data in byte stream.
50 * @param input_len Length of the byte stream.
51 * @param output_len Length of the encoded Base64 byte stream.
52 * @param is_chunked If true, terminate 72 character blocks with newline
53 * @return Encoded Base64 data in byte stream or NULL if input data cannot
54 * be encoded.
56 static ACE_Byte* encode (const ACE_Byte* input,
57 const size_t input_len,
58 size_t* output_len,
59 bool is_chunked = true);
60 /**
61 * Decodes a stream of Base64 to bytes data
63 * @param input Encoded Base64 data in byte stream.
64 * @param output_len Length of the binary byte stream.
65 * @return Binary data in byte stream or NULL if input data cannot
66 * be encoded.
68 static ACE_Byte* decode (const ACE_Byte* input,
69 size_t* output_len);
71 /**
72 * Return the length of the encoded input data
74 * @param input Encoded Base64 data in byte stream.
75 * @return Length of the encoded Base64 data.
78 static size_t length (const ACE_Byte* input);
80 //@}
82 protected:
83 // Prevent default construction.
84 ACE_Base64 (void) {}
86 private:
87 // Preventing copying and assignment.
88 ACE_Base64 (ACE_Base64 const &);
89 ACE_Base64 & operator= (ACE_Base64 const &);
91 /// Initialize the tables for encoding/decoding.
92 static void init (void);
94 private:
95 /// Alphabet used for decoding i.e decoder_[alphabet_[i = 0..63]] = i
96 static ACE_Byte decoder_[];
98 /// Alphabet used to check valid range of encoded input i.e
99 /// member_[alphabet_[0..63]] = 1
100 static ACE_Byte member_[];
102 /// Boolean to denote whether initialization is complete
103 static bool init_;
106 ACE_END_VERSIONED_NAMESPACE_DECL
108 #include /**/ "ace/post.h"
110 #endif /* ACE_CODECS_H */