Google APIs Client Library for C++

Provides an interface for encoding and decoding data. More...

#include "client/data/codec.h"

+ Inheritance diagram for Codec:

List of all members.

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 DataReaderNewManagedEncodingReader (DataReader *reader, Closure *deleter, util::Status *status)=0
 Creates a reader that encodes all the output of another reader.
virtual DataReaderNewManagedDecodingReader (DataReader *reader, Closure *deleter, util::Status *status)=0
 Creates a reader that decodes all the output of another reader.
DataReaderNewUnmanagedEncodingReader (DataReader *reader, util::Status *status)
 Creates a reader that encodes the output of another reader.
DataReaderNewUnmanagedDecodingReader (DataReader *reader, util::Status *status)
 Creates a reader that decodes the output of another reader.

Detailed Description

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.


Constructor & Destructor Documentation

Codec ( )

Standard constructor.

virtual ~Codec ( ) [virtual]

Standard destructor.


Member Function Documentation

virtual util::Status Decode ( const StringPiece &  encoded,
string *  unencoded 
) [virtual]

Decodes a string.

Parameters:
[in]encodedThe encoded string to encode is treated as binary data, not a null-terminated c-string.
[out]unencodedThe 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.
Returns:
ok if the string could be decoded.
See also:
Encode
virtual util::Status Encode ( const StringPiece &  decoded,
string *  encoded 
) [virtual]

Encodes a string.

Parameters:
[in]decodedThe unencoded string to encode is treated as binary data, not a null-terminated c-string.
[out]encodedThe 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.
Returns:
ok if the string could be encoded.
See also:
Decode
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.

Parameters:
[in]readerThe caller maintains ownership of reader to decode. However, they may pass ownership to the deleter.
[in]deleterIf not NULL then it will be Run() when the reader is destroyed.
[out]statusok on success, otherwise the reason for error.
Returns:
ownership of a new reader that will return the encoded data. This will never be null, though may be an InvalidDataReader returning the same status on failure.
See also:
NewManagedEnccodingReader

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.

Parameters:
[in]readerThe caller maintains ownership of reader to encode. However, they may pass ownership to the deleter.
[in]deleterIf not NULL then it will be Run() when the reader is destroyed.
[out]statusok on success, otherwise the reason for error.
Returns:
ownership of a new reader that will return the decoded data. This will never be null, though may be an InvalidDataReader returning the same status on failure.
See also:
NewManagedDecodingReader

Implemented in OpenSslCodec, and Base64Codec.

DataReader* NewUnmanagedDecodingReader ( DataReader reader,
util::Status status 
) [inline]

Creates a reader that decodes the output of another reader.

Parameters:
[in]readerThe caller maintains ownership of the raeder to decode.
[out]statusok on success, otherwise the reason for error.
See also:
NewManagedDecodingReader
DataReader* NewUnmanagedEncodingReader ( DataReader reader,
util::Status status 
) [inline]

Creates a reader that encodes the output of another reader.

Parameters:
[in]readerThe caller maintains ownership of the raeder to encode.
[out]statusok on success, otherwise the reason for error.
See also:
NewManagedEncodingReader

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