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

Unified Diff: third_party/protobuf/src/google/protobuf/util/internal/default_value_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/default_value_objectwriter.h
diff --git a/third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h b/third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h
index 1d85bed85f8a4f9a5c522db1893867369aee340f..dc4551c943d86215ed1fb6138e7733e43649ae55 100644
--- a/third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h
+++ b/third_party/protobuf/src/google/protobuf/util/internal/default_value_objectwriter.h
@@ -122,6 +122,10 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
// field_scrub_callback pointer is also transferred to this class
void RegisterFieldScrubCallBack(FieldScrubCallBackPtr field_scrub_callback);
+ // If set to true, empty lists are suppressed from output when default values
+ // are written.
+ void set_suppress_empty_list(bool value) { suppress_empty_list_ = value; }
+
private:
enum NodeKind {
PRIMITIVE = 0,
@@ -135,7 +139,8 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
class LIBPROTOBUF_EXPORT Node {
public:
Node(const string& name, const google::protobuf::Type* type, NodeKind kind,
- const DataPiece& data, bool is_placeholder, const vector<string>& path,
+ const DataPiece& data, bool is_placeholder,
+ const std::vector<string>& path, bool suppress_empty_list,
FieldScrubCallBack* field_scrub_callback);
virtual ~Node() {
for (int i = 0; i < children_.size(); ++i) {
@@ -162,7 +167,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
// Accessors
const string& name() const { return name_; }
- const vector<string>& path() const { return path_; }
+ const std::vector<string>& path() const { return path_; }
const google::protobuf::Type* type() const { return type_; }
@@ -212,6 +217,9 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
// Path of the field of this node
std::vector<string> path_;
+ // Whether to suppress empty list output.
+ bool suppress_empty_list_;
+
// Pointer to function for determining whether a field needs to be scrubbed
// or not. This callback is owned by the creator of this node.
FieldScrubCallBack* field_scrub_callback_;
@@ -248,7 +256,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
// google::protobuf::Type of the root message type.
const google::protobuf::Type& type_;
// Holds copies of strings passed to RenderString.
- vector<string*> string_values_;
+ std::vector<string*> string_values_;
// The current Node. Owned by its parents.
Node* current_;
@@ -257,6 +265,9 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter {
// The stack to hold the path of Nodes from current_ to root_;
std::stack<Node*> stack_;
+ // Whether to suppress output of empty lists.
+ bool suppress_empty_list_;
+
// Unique Pointer to function for determining whether a field needs to be
// scrubbed or not.
FieldScrubCallBackPtr field_scrub_callback_;

Powered by Google App Engine
This is Rietveld 408576698