Google APIs Client Library for C++
CodecReader Class Reference

A helper class for implementing CodecReaders. More...

#include "client/data/codec.h"

+ Inheritance diagram for CodecReader:

List of all members.

Public Member Functions

 CodecReader (DataReader *source, Closure *deleter, int64 chunk_size, int64 buffer_size, bool encoding)
 Standard constructor.
virtual ~CodecReader ()
 Standard destructor.
virtual util::Status Init ()
 Called when resetting readers (seeking to start)

Protected Member Functions

bool encoding () const
 Returns whether the reader was constructed for encoding or decoding.
virtual int64 DoReadToBuffer (int64 max_bytes, char *storage)
 Reads from internal transformed buffer, replentishing it as necessary.
virtual int64 DoSetOffset (int64 to_offset)
 Implements seeking through the transformed stream.
virtual util::Status EncodeChunk (const StringPiece &from, bool final, char *to, int64 *to_len)=0
 Hook for codecs to encode a chunk.
virtual util::Status DecodeChunk (const StringPiece &from, bool final, char *to, int64 *to_len)=0
 Hook for codecs to decode a chunk.

Detailed Description

A helper class for implementing CodecReaders.

This class assumes bounded transformation sizes for a given input size.


Constructor & Destructor Documentation

CodecReader ( DataReader source,
Closure *  deleter,
int64  chunk_size,
int64  buffer_size,
bool  encoding 
)

Standard constructor.

Parameters:
[in]sourceThe untarnsformed stream the codec is processing.
[in]deleterThe deleter if this is to be a managed stream.
[in]chunk_sizeThe size of source data to accumulate for each transform (until the very last one)
[in]buffer_sizeThe size to allocate for transformed data.
[in]encodingWhether this reader is encoding or decoding determines whether we'll EncodeChunk or DecodeChunk.
virtual ~CodecReader ( ) [virtual]

Standard destructor.


Member Function Documentation

virtual util::Status DecodeChunk ( const StringPiece &  from,
bool  final,
char *  to,
int64 *  to_len 
) [protected, pure virtual]

Hook for codecs to decode a chunk.

Parameters:
[in]fromThe raw chunk from the source stream.
[in]finalTrue if this is the final chunk.
[in]toThe target buffer must be allocated big enough.
[in,out]to_lenThe size of the 'to' buffer on input. The amount of data written into 'to' on output.
virtual int64 DoReadToBuffer ( int64  max_bytes,
char *  storage 
) [protected, virtual]

Reads from internal transformed buffer, replentishing it as necessary.

This method is compliant with the base DataReader::DoReadToBuffer semantics. In particular, results are never non-negative and 0 does not have any special meaning with regard to errors or being done.

Parameters:
[in]max_bytesMax bytes to copy from buffer.
[in]storageThe storage to read into.
Returns:
Number of bytes read will never be more than the constructed buffer_size, at least for the base class.

Implements DataReader.

virtual int64 DoSetOffset ( int64  to_offset) [protected, virtual]

Implements seeking through the transformed stream.

This method is compliant with the base DataReader::DoSetOffset semantics.

Reimplemented from DataReader.

virtual util::Status EncodeChunk ( const StringPiece &  from,
bool  final,
char *  to,
int64 *  to_len 
) [protected, pure virtual]

Hook for codecs to encode a chunk.

Parameters:
[in]fromThe raw chunk from the source stream.
[in]finalTrue if this is the final chunk.
[in]toThe target buffer must be allocated big enough.
[in,out]to_lenThe size of the 'to' buffer on input. The amount of data written into 'to' on output.
bool encoding ( ) const [inline, protected]

Returns whether the reader was constructed for encoding or decoding.

virtual util::Status Init ( ) [virtual]

Called when resetting readers (seeking to start)


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