LogCabin
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Private Attributes
LogCabin::Storage::SnapshotFile::Reader Class Reference

Assists in reading snapshot files from the local filesystem. More...

#include <SnapshotFile.h>

Inheritance diagram for LogCabin::Storage::SnapshotFile::Reader:
LogCabin::Core::ProtoBuf::InputStream

List of all members.

Public Member Functions

 Reader (const Storage::Layout &storageLayout)
 Constructor.
 ~Reader ()
 Destructor.
uint64_t getSizeBytes ()
 Return the size in bytes for the file.
uint64_t getBytesRead () const
 Return the number of bytes read so far.
std::string readMessage (google::protobuf::Message &message)
 Read a ProtoBuf message from the stream.
uint64_t readRaw (void *data, uint64_t length)
 Read some raw bytes from the stream.

Private Attributes

Storage::FilesystemUtil::File file
 Wraps the raw file descriptor; in charge of closing it when done.
std::unique_ptr
< Storage::FilesystemUtil::FileContents
contents
 Maps the file into memory for reading.
uint64_t bytesRead
 The number of bytes read from the file.

Detailed Description

Assists in reading snapshot files from the local filesystem.

Definition at line 45 of file SnapshotFile.h.


Constructor & Destructor Documentation

Constructor.

Parameters:
storageLayoutThe directories in which to find the snapshot (in a file called "snapshot" in the snapshotDir).
Exceptions:
std::runtime_errorIf the file can't be found.

Definition at line 52 of file SnapshotFile.cc.

Destructor.

Definition at line 68 of file SnapshotFile.cc.


Member Function Documentation

Return the size in bytes for the file.

Definition at line 73 of file SnapshotFile.cc.

Return the number of bytes read so far.

Implements LogCabin::Core::ProtoBuf::InputStream.

Definition at line 80 of file SnapshotFile.cc.

std::string LogCabin::Storage::SnapshotFile::Reader::readMessage ( google::protobuf::Message &  message) [virtual]

Read a ProtoBuf message from the stream.

Returns:
Empty string if successful, otherwise an error message if an error occurred. The stream is probably no longer usable after an error.

Implements LogCabin::Core::ProtoBuf::InputStream.

Definition at line 86 of file SnapshotFile.cc.

uint64_t LogCabin::Storage::SnapshotFile::Reader::readRaw ( void *  data,
uint64_t  length 
) [virtual]

Read some raw bytes from the stream.

Returns:
The number of bytes read before the end of the stream was reached, up to 'length'.

Implements LogCabin::Core::ProtoBuf::InputStream.

Definition at line 131 of file SnapshotFile.cc.


Member Data Documentation

Wraps the raw file descriptor; in charge of closing it when done.

Definition at line 68 of file SnapshotFile.h.

Maps the file into memory for reading.

Definition at line 70 of file SnapshotFile.h.

The number of bytes read from the file.

Definition at line 72 of file SnapshotFile.h.


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