Google APIs Client Library for C++
|
Provides an interface for encoding and decoding data. More...
#include "client/data/codec.h"
Public Member Functions | |
Codec () | |
Standard constructor. | |
virtual | ~Codec () |
Standard destructor. | |
virtual util::Status | Encode (const StringPiece &decoded, string *encoded) |
Encodes a string. | |
virtual util::Status | Decode (const StringPiece &encoded, string *unencoded) |
Decodes a string. | |
virtual DataReader * | NewManagedEncodingReader (DataReader *reader, Closure *deleter, util::Status *status)=0 |
Creates a reader that encodes all the output of another reader. | |
virtual DataReader * | NewManagedDecodingReader (DataReader *reader, Closure *deleter, util::Status *status)=0 |
Creates a reader that decodes all the output of another reader. | |
DataReader * | NewUnmanagedEncodingReader (DataReader *reader, util::Status *status) |
Creates a reader that encodes the output of another reader. | |
DataReader * | NewUnmanagedDecodingReader (DataReader *reader, util::Status *status) |
Creates a reader that decodes the output of another reader. |
Provides an interface for encoding and decoding data.
This is a pure abstract class. It needs to be subclassed to provide specific encodings and decodings, including encryption or compression.
Codec | ( | ) |
Standard constructor.
virtual ~Codec | ( | ) | [virtual] |
Standard destructor.
virtual util::Status Decode | ( | const StringPiece & | encoded, |
string * | unencoded | ||
) | [virtual] |
Decodes a string.
[in] | encoded | The encoded string to encode is treated as binary data, not a null-terminated c-string. |
[out] | unencoded | The decoded string should be treated as binary data, not a null-terminated c-string. Use data(), not c_state() to get at the bytes if needed. |
virtual util::Status Encode | ( | const StringPiece & | decoded, |
string * | encoded | ||
) | [virtual] |
Encodes a string.
[in] | decoded | The unencoded string to encode is treated as binary data, not a null-terminated c-string. |
[out] | encoded | The encoded string should be treated as binary data, not a null-terminated c-string. Use data(), not c_state() to get at the bytes if needed. |
virtual DataReader* NewManagedDecodingReader | ( | DataReader * | reader, |
Closure * | deleter, | ||
util::Status * | status | ||
) | [pure virtual] |
Creates a reader that decodes all the output of another reader.
The default method returns an InMemory reader using the Decode method on the input read into one monolithic string.
Specialized decoder/encoders should override this to decode as the reader streams if possible.
[in] | reader | The caller maintains ownership of reader to decode. However, they may pass ownership to the deleter. |
[in] | deleter | If not NULL then it will be Run() when the reader is destroyed. |
[out] | status | ok on success, otherwise the reason for error. |
Implemented in OpenSslCodec, and Base64Codec.
virtual DataReader* NewManagedEncodingReader | ( | DataReader * | reader, |
Closure * | deleter, | ||
util::Status * | status | ||
) | [pure virtual] |
Creates a reader that encodes all the output of another reader.
The default method returns an InMemory reader using the Decode method on the input read into one monolithic string.
Specialized encoder/decoders should override this to encode as the reader streams if possible.
[in] | reader | The caller maintains ownership of reader to encode. However, they may pass ownership to the deleter. |
[in] | deleter | If not NULL then it will be Run() when the reader is destroyed. |
[out] | status | ok on success, otherwise the reason for error. |
Implemented in OpenSslCodec, and Base64Codec.
DataReader* NewUnmanagedDecodingReader | ( | DataReader * | reader, |
util::Status * | status | ||
) | [inline] |
Creates a reader that decodes the output of another reader.
[in] | reader | The caller maintains ownership of the raeder to decode. |
[out] | status | ok on success, otherwise the reason for error. |
DataReader* NewUnmanagedEncodingReader | ( | DataReader * | reader, |
util::Status * | status | ||
) | [inline] |
Creates a reader that encodes the output of another reader.
[in] | reader | The caller maintains ownership of the raeder to encode. |
[out] | status | ok on success, otherwise the reason for error. |