LogCabin
|
Namespaces | |
namespace | Internal |
Classes | |
struct | InputStream |
An abstract stream from which ProtoBufs may be read. More... | |
struct | OutputStream |
An abstract stream to which ProtoBufs may be written. More... | |
Functions | |
std::string | dumpString (const google::protobuf::Message &protoBuf, bool forCopyingIntoTest=false) |
Dumps a protocol buffer message. | |
std::unique_ptr < google::protobuf::Message > | copy (const google::protobuf::Message &protoBuf) |
Copy the contents of a protocol buffer into a new one. | |
bool | parse (const Core::Buffer &from, google::protobuf::Message &to, uint32_t skipBytes=0) |
Parse a protocol buffer message out of a Core::Buffer. | |
void | serialize (const google::protobuf::Message &from, Core::Buffer &to, uint32_t skipBytes=0) |
Serialize a protocol buffer message into a Core::Buffer. | |
template<typename ProtoBuf > | |
ProtoBuf | fromString (const std::string &str) |
Create a protocol buffer message form a text format. |
std::string LogCabin::Core::ProtoBuf::dumpString | ( | const google::protobuf::Message & | protoBuf, |
bool | forCopyingIntoTest = false |
||
) |
Dumps a protocol buffer message.
This is useful for debugging and for testing.
protoBuf | The protocol buffer message to dump out. It is safe to call this even if you haven't filled in all required fields, but the generated string will not be directly parse-able. |
forCopyingIntoTest | If set to true, this will return a string in a format most useful for writing unit tests. You can basically copy and paste this from your terminal into your test file without manual processing. If set to false (default), the output will be nicer to read but harder to copy into a test file. |
Definition at line 90 of file ProtoBuf.cc.
std::unique_ptr< google::protobuf::Message > LogCabin::Core::ProtoBuf::copy | ( | const google::protobuf::Message & | protoBuf | ) |
Copy the contents of a protocol buffer into a new one.
Definition at line 132 of file ProtoBuf.cc.
bool LogCabin::Core::ProtoBuf::parse | ( | const Core::Buffer & | from, |
google::protobuf::Message & | to, | ||
uint32_t | skipBytes = 0 |
||
) |
Parse a protocol buffer message out of a Core::Buffer.
from | The Core::Buffer from which to extract a protocol buffer. | |
[out] | to | The empty protocol buffer to fill in with the contents of the Core::Buffer. |
skipBytes | The number of bytes to skip at the beginning of 'from' (defaults to 0). |
Definition at line 140 of file ProtoBuf.cc.
void LogCabin::Core::ProtoBuf::serialize | ( | const google::protobuf::Message & | from, |
Core::Buffer & | to, | ||
uint32_t | skipBytes = 0 |
||
) |
Serialize a protocol buffer message into a Core::Buffer.
from | The protocol buffer containing the contents to serialize into the Core::Buffer. All required fields must be set or this will PANIC. | |
[out] | to | The Core::Buffer to fill in with the contents of the protocol buffer. |
skipBytes | The number of bytes to allocate at the beginning of 'to' but leave uninitialized for someone else to fill in (defaults to 0). |
Definition at line 157 of file ProtoBuf.cc.
ProtoBuf LogCabin::Core::ProtoBuf::fromString | ( | const std::string & | str | ) |
Create a protocol buffer message form a text format.
This is useful for testing.
ProtoBuf | A derived class of ProtoBuf::Message. |
str | The string representation of the protocol buffer message. Fields that are missing will not throw an error, but the resulting protocol buffer may be less useful. |
Definition at line 81 of file ProtoBuf.h.