gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
ProtoOutputStream Class Reference

A ProtoOutputStream wraps a coded stream, potentially with compression, based on looking at the file name. More...

#include <protoio.hh>

Inheritance diagram for ProtoOutputStream:
ProtoStream

Public Member Functions

 ProtoOutputStream (const std::string &filename)
 Create an output stream for a given file name. More...
 
 ~ProtoOutputStream ()
 Destruct the output stream, and also flush and close the underlying file streams and coded streams. More...
 
void write (const google::protobuf::Message &msg)
 Write a message to the stream, preprending it with the message size. More...
 

Private Attributes

std::ofstream fileStream
 Underlying file output stream. More...
 
google::protobuf::io::OstreamOutputStream * wrappedFileStream
 Zero Copy stream wrapping the STL output stream. More...
 
google::protobuf::io::GzipOutputStream * gzipStream
 Optional Gzip stream to wrap the Zero Copy stream. More...
 
google::protobuf::io::ZeroCopyOutputStream * zeroCopyStream
 Top-level zero-copy stream, either with compression or not. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ProtoStream
 ProtoStream ()
 Create a ProtoStream. More...
 
- Static Protected Attributes inherited from ProtoStream
static const uint32_t magicNumber = 0x356d6567
 Use the ASCII characters gem5 as our magic number. More...
 

Detailed Description

A ProtoOutputStream wraps a coded stream, potentially with compression, based on looking at the file name.

Writing to the stream is done to enable interaction with the file on a per-message basis to avoid having to deal with huge data structures. The latter is made possible by encoding the length of each message in the stream.

Definition at line 92 of file protoio.hh.

Constructor & Destructor Documentation

ProtoOutputStream::ProtoOutputStream ( const std::string &  filename)

Create an output stream for a given file name.

If the filename ends with .gz then the file will be compressed accordinly.

Parameters
filenamePath to the file to create or truncate

Definition at line 47 of file protoio.cc.

References fileStream, gzipStream, ProtoStream::magicNumber, panic, wrappedFileStream, and zeroCopyStream.

ProtoOutputStream::~ProtoOutputStream ( )

Destruct the output stream, and also flush and close the underlying file streams and coded streams.

Definition at line 74 of file protoio.cc.

References fileStream, gzipStream, and wrappedFileStream.

Member Function Documentation

void ProtoOutputStream::write ( const google::protobuf::Message &  msg)

Member Data Documentation

std::ofstream ProtoOutputStream::fileStream
private

Underlying file output stream.

Definition at line 122 of file protoio.hh.

Referenced by ProtoOutputStream(), and ~ProtoOutputStream().

google::protobuf::io::GzipOutputStream* ProtoOutputStream::gzipStream
private

Optional Gzip stream to wrap the Zero Copy stream.

Definition at line 128 of file protoio.hh.

Referenced by ProtoOutputStream(), and ~ProtoOutputStream().

google::protobuf::io::OstreamOutputStream* ProtoOutputStream::wrappedFileStream
private

Zero Copy stream wrapping the STL output stream.

Definition at line 125 of file protoio.hh.

Referenced by ProtoOutputStream(), and ~ProtoOutputStream().

google::protobuf::io::ZeroCopyOutputStream* ProtoOutputStream::zeroCopyStream
private

Top-level zero-copy stream, either with compression or not.

Definition at line 131 of file protoio.hh.

Referenced by ProtoOutputStream(), and write().


The documentation for this class was generated from the following files:

Generated on Fri Jun 9 2017 13:04:17 for gem5 by doxygen 1.8.6