diff options
author | Feng Xiao <xfxyjwf@gmail.com> | 2018-08-08 17:00:41 -0700 |
---|---|---|
committer | Feng Xiao <xfxyjwf@gmail.com> | 2018-08-08 17:00:41 -0700 |
commit | 6bbe197e9c1b6fc38cbdc45e3bf83fa7ced792a3 (patch) | |
tree | e575738adf52d24b883cca5e8928a5ded31caba1 /src/google/protobuf/util/json_util.h | |
parent | e7746f487cb9cca685ffb1b3d7dccc5554b618a4 (diff) | |
download | protobuf-6bbe197e9c1b6fc38cbdc45e3bf83fa7ced792a3.tar.gz protobuf-6bbe197e9c1b6fc38cbdc45e3bf83fa7ced792a3.tar.bz2 protobuf-6bbe197e9c1b6fc38cbdc45e3bf83fa7ced792a3.zip |
Down-integrate from google3.
Diffstat (limited to 'src/google/protobuf/util/json_util.h')
-rw-r--r-- | src/google/protobuf/util/json_util.h | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/google/protobuf/util/json_util.h b/src/google/protobuf/util/json_util.h index e7868307..96809a4f 100644 --- a/src/google/protobuf/util/json_util.h +++ b/src/google/protobuf/util/json_util.h @@ -37,6 +37,7 @@ #include <google/protobuf/util/type_resolver.h> #include <google/protobuf/stubs/bytestream.h> + namespace google { namespace protobuf { namespace io { @@ -77,9 +78,9 @@ struct JsonPrintOptions { // DEPRECATED. Use JsonPrintOptions instead. typedef JsonPrintOptions JsonOptions; -// Converts from protobuf message to JSON. This is a simple wrapper of -// BinaryToJsonString(). It will use the DescriptorPool of the passed-in -// message to resolve Any types. +// Converts from protobuf message to JSON and appends it to |output|. This is a +// simple wrapper of BinaryToJsonString(). It will use the DescriptorPool of the +// passed-in message to resolve Any types. LIBPROTOBUF_EXPORT util::Status MessageToJsonString(const Message& message, string* output, const JsonOptions& options); @@ -92,11 +93,10 @@ inline util::Status MessageToJsonString(const Message& message, // Converts from JSON to protobuf message. This is a simple wrapper of // JsonStringToBinary(). It will use the DescriptorPool of the passed-in // message to resolve Any types. -LIBPROTOBUF_EXPORT util::Status JsonStringToMessage(const string& input, - Message* message, +LIBPROTOBUF_EXPORT util::Status JsonStringToMessage(StringPiece input, Message* message, const JsonParseOptions& options); -inline util::Status JsonStringToMessage(const string& input, +inline util::Status JsonStringToMessage(StringPiece input, Message* message) { return JsonStringToMessage(input, message, JsonParseOptions()); } @@ -158,18 +158,16 @@ inline util::Status JsonToBinaryStream( JsonParseOptions()); } -LIBPROTOBUF_EXPORT util::Status JsonToBinaryString( - TypeResolver* resolver, - const string& type_url, - const string& json_input, - string* binary_output, - const JsonParseOptions& options); +LIBPROTOBUF_EXPORT util::Status JsonToBinaryString(TypeResolver* resolver, + const string& type_url, + StringPiece json_input, + string* binary_output, + const JsonParseOptions& options); -inline util::Status JsonToBinaryString( - TypeResolver* resolver, - const string& type_url, - const string& json_input, - string* binary_output) { +inline util::Status JsonToBinaryString(TypeResolver* resolver, + const string& type_url, + StringPiece json_input, + string* binary_output) { return JsonToBinaryString(resolver, type_url, json_input, binary_output, JsonParseOptions()); } @@ -182,7 +180,7 @@ class LIBPROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink { : stream_(stream), buffer_(NULL), buffer_size_(0) {} ~ZeroCopyStreamByteSink(); - virtual void Append(const char* bytes, size_t len) override; + void Append(const char* bytes, size_t len) override; private: io::ZeroCopyOutputStream* stream_; @@ -195,6 +193,6 @@ class LIBPROTOBUF_EXPORT ZeroCopyStreamByteSink : public strings::ByteSink { } // namespace util } // namespace protobuf - } // namespace google + #endif // GOOGLE_PROTOBUF_UTIL_JSON_UTIL_H__ |