diff options
Diffstat (limited to 'src/google/protobuf/message.cc')
-rw-r--r-- | src/google/protobuf/message.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/google/protobuf/message.cc b/src/google/protobuf/message.cc index fddbdcb8..f6c932ff 100644 --- a/src/google/protobuf/message.cc +++ b/src/google/protobuf/message.cc @@ -204,6 +204,10 @@ void Message::SetCachedSize(int size) const { "Must implement one or the other."; } +int Message::SpaceUsed() const { + return GetReflection()->SpaceUsed(*this); +} + bool Message::SerializeToCodedStream(io::CodedOutputStream* output) const { GOOGLE_DCHECK(IsInitialized()) << InitializationErrorMessage("serialize", *this); return SerializePartialToCodedStream(output); @@ -291,6 +295,24 @@ bool Message::SerializePartialToOstream(ostream* output) const { } +string Message::SerializeAsString() const { + // If the compiler implements the (Named) Return Value Optimization, + // the local variable 'result' will not actually reside on the stack + // of this function, but will be overlaid with the object that the + // caller supplied for the return value to be constructed in. + string output; + if (!AppendToString(&output)) + output.clear(); + return output; +} + +string Message::SerializePartialAsString() const { + string output; + if (!AppendPartialToString(&output)) + output.clear(); + return output; +} + Reflection::~Reflection() {} // =================================================================== |