Go to the documentation of this file.
43 using namespace google::protobuf;
46 fileStream(filename.c_str(), ios::out | ios::binary | ios::trunc),
47 wrappedFileStream(NULL), gzipStream(NULL), zeroCopyStream(NULL)
50 panic(
"Could not open %s for writing\n", filename);
56 if (filename.find_last_of(
'.') != string::npos &&
57 filename.substr(filename.find_last_of(
'.') + 1) ==
"gz") {
90 # if GOOGLE_PROTOBUF_VERSION < 3001000
91 auto msg_size = msg.ByteSize();
93 auto msg_size = msg.ByteSizeLong();
95 codedStream.WriteVarint32(msg_size);
98 msg.SerializeWithCachedSizes(&codedStream);
102 fileStream(filename.c_str(), ios::in | ios::binary), fileName(filename),
104 wrappedFileStream(NULL), gzipStream(NULL), zeroCopyStream(NULL)
107 panic(
"Could not open %s for reading\n", filename);
110 unsigned char bytes[2];
139 uint32_t magic_check;
141 if (!codedStream.ReadLittleEndian32(&magic_check) ||
143 panic(
"Input file %s is not a valid gem5 proto format.\n",
190 if (codedStream.ReadVarint32(&size)) {
191 io::CodedInputStream::Limit
limit = codedStream.PushLimit(size);
192 if (msg.ParseFromCodedStream(&codedStream)) {
193 codedStream.PopLimit(
limit);
198 panic(
"Unable to read message from coded stream %s\n",
void write(const google::protobuf::Message &msg)
Write a message to the stream, preprending it with the message size.
google::protobuf::io::ZeroCopyOutputStream * zeroCopyStream
Top-level zero-copy stream, either with compression or not.
google::protobuf::io::OstreamOutputStream * wrappedFileStream
Zero Copy stream wrapping the STL output stream.
ProtoOutputStream(const std::string &filename)
Create an output stream for a given file name.
static const uint32_t magicNumber
Use the ASCII characters gem5 as our magic number.
std::ofstream fileStream
Underlying file output stream.
google::protobuf::io::GzipOutputStream * gzipStream
Optional Gzip stream to wrap the Zero Copy stream.
Overload hash function for BasicBlockRange type.
BitfieldType< SegDescriptorLimit > limit
~ProtoOutputStream()
Destruct the output stream, and also flush and close the underlying file streams and coded streams.
#define panic(...)
This implements a cprintf based panic() function.
Generated on Wed Sep 30 2020 14:02:14 for gem5 by doxygen 1.8.17