gem5
v20.1.0.0
|
A ProtoInputStream wraps a coded stream, potentially with decompression, based on looking at the file name. More...
#include <protoio.hh>
Public Member Functions | |
ProtoInputStream (const std::string &filename) | |
Create an input stream for a given file name. More... | |
~ProtoInputStream () | |
Destruct the input stream, and also close the underlying file streams and coded streams. More... | |
bool | read (google::protobuf::Message &msg) |
Read a message from the stream. More... | |
void | reset () |
Reset the input stream and seek to the beginning of the file. More... | |
Private Member Functions | |
void | createStreams () |
Create the internal streams that are wrapping the input file. More... | |
void | destroyStreams () |
Destroy the internal streams that are wrapping the input file. More... | |
Private Attributes | |
std::ifstream | fileStream |
Underlying file input stream. More... | |
const std::string | fileName |
Hold on to the file name for debug messages. More... | |
bool | useGzip |
Boolean flag to remember whether we use gzip or not. More... | |
google::protobuf::io::IstreamInputStream * | wrappedFileStream |
Zero Copy stream wrapping the STL input stream. More... | |
google::protobuf::io::GzipInputStream * | gzipStream |
Optional Gzip stream to wrap the Zero Copy stream. More... | |
google::protobuf::io::ZeroCopyInputStream * | 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... | |
A ProtoInputStream wraps a coded stream, potentially with decompression, based on looking at the file name.
Reading from the stream is done on a per-message basis to avoid having to deal with huge data structures. The latter assumes the length of each message is encoded in the stream when it is written.
Definition at line 140 of file protoio.hh.
ProtoInputStream::ProtoInputStream | ( | const std::string & | filename | ) |
Create an input stream for a given file name.
If the filename ends with .gz then the file will be decompressed accordingly.
filename | Path to the file to read from |
Definition at line 101 of file protoio.cc.
References createStreams(), fileStream, panic, and useGzip.
ProtoInputStream::~ProtoInputStream | ( | ) |
Destruct the input stream, and also close the underlying file streams and coded streams.
Definition at line 162 of file protoio.cc.
References destroyStreams(), and fileStream.
|
private |
Create the internal streams that are wrapping the input file.
Definition at line 122 of file protoio.cc.
References fileName, fileStream, gzipStream, ProtoStream::magicNumber, panic, useGzip, wrappedFileStream, and zeroCopyStream.
Referenced by ProtoInputStream(), and reset().
|
private |
Destroy the internal streams that are wrapping the input file.
Definition at line 148 of file protoio.cc.
References gzipStream, wrappedFileStream, and zeroCopyStream.
Referenced by reset(), and ~ProtoInputStream().
bool ProtoInputStream::read | ( | google::protobuf::Message & | msg | ) |
Read a message from the stream.
msg | Message read from the stream |
return | True if a message was read, false if reading fails |
Definition at line 180 of file protoio.cc.
References fileName, X86ISA::limit, panic, and zeroCopyStream.
Referenced by TraceCPU::FixedRetryGen::InputStream::InputStream(), and TraceCPU::ElasticDataGen::InputStream::InputStream().
void ProtoInputStream::reset | ( | ) |
Reset the input stream and seek to the beginning of the file.
Definition at line 170 of file protoio.cc.
References createStreams(), destroyStreams(), and fileStream.
|
private |
Hold on to the file name for debug messages.
Definition at line 188 of file protoio.hh.
Referenced by createStreams(), and read().
|
private |
Underlying file input stream.
Definition at line 185 of file protoio.hh.
Referenced by createStreams(), ProtoInputStream(), reset(), and ~ProtoInputStream().
|
private |
Optional Gzip stream to wrap the Zero Copy stream.
Definition at line 197 of file protoio.hh.
Referenced by createStreams(), and destroyStreams().
|
private |
Boolean flag to remember whether we use gzip or not.
Definition at line 191 of file protoio.hh.
Referenced by createStreams(), and ProtoInputStream().
|
private |
Zero Copy stream wrapping the STL input stream.
Definition at line 194 of file protoio.hh.
Referenced by createStreams(), and destroyStreams().
|
private |
Top-level zero-copy stream, either with compression or not.
Definition at line 200 of file protoio.hh.
Referenced by createStreams(), destroyStreams(), and read().