Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Unified Diff: third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.h

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.h
diff --git a/third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.h b/third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.h
index cb7e2fb30c4fec5b621f720de734be48250cfbb9..31edc2927ffe38b957ae7648df462f13ebdac69e 100644
--- a/third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.h
+++ b/third_party/protobuf/src/google/protobuf/util/internal/json_objectwriter.h
@@ -93,7 +93,8 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
stream_(out),
sink_(out),
indent_string_(indent_string.ToString()),
- use_websafe_base64_for_bytes_(false) {}
+ use_websafe_base64_for_bytes_(false),
+ empty_name_ok_for_next_key_(false) {}
virtual ~JsonObjectWriter();
// ObjectWriter methods.
@@ -111,11 +112,19 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
virtual JsonObjectWriter* RenderString(StringPiece name, StringPiece value);
virtual JsonObjectWriter* RenderBytes(StringPiece name, StringPiece value);
virtual JsonObjectWriter* RenderNull(StringPiece name);
+ virtual JsonObjectWriter* RenderNullAsEmpty(StringPiece name);
void set_use_websafe_base64_for_bytes(bool value) {
use_websafe_base64_for_bytes_ = value;
}
+ // Whether empty strings should be rendered for the next JSON key. This
+ // setting is only valid until the next key is rendered, after which it gets
+ // reset to false.
+ virtual void empty_name_ok_for_next_key() {
+ empty_name_ok_for_next_key_ = true;
+ }
+
protected:
class LIBPROTOBUF_EXPORT Element : public BaseElement {
public:
@@ -195,6 +204,10 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
// Writes an individual character to the output.
void WriteChar(const char c) { stream_->WriteRaw(&c, sizeof(c)); }
+ // Returns the current value of empty_name_ok_for_next_key_ and resets it to
+ // false.
+ bool GetAndResetEmptyKeyOk();
+
google::protobuf::scoped_ptr<Element> element_;
google::protobuf::io::CodedOutputStream* stream_;
ByteSinkWrapper sink_;
@@ -204,6 +217,11 @@ class LIBPROTOBUF_EXPORT JsonObjectWriter : public StructuredObjectWriter {
// to regular base64 encoding.
bool use_websafe_base64_for_bytes_;
+ // Whether empty strings should be rendered for the next JSON key. This
+ // setting is only valid until the next key is rendered, after which it gets
+ // reset to false.
+ bool empty_name_ok_for_next_key_;
+
GOOGLE_DISALLOW_IMPLICIT_CONSTRUCTORS(JsonObjectWriter);
};

Powered by Google App Engine
This is Rietveld 408576698