diff options
Diffstat (limited to 'src/google/protobuf/util/internal/default_value_objectwriter.h')
-rw-r--r-- | src/google/protobuf/util/internal/default_value_objectwriter.h | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/src/google/protobuf/util/internal/default_value_objectwriter.h b/src/google/protobuf/util/internal/default_value_objectwriter.h index 7d245c9c..7a8863ca 100644 --- a/src/google/protobuf/util/internal/default_value_objectwriter.h +++ b/src/google/protobuf/util/internal/default_value_objectwriter.h @@ -44,6 +44,8 @@ #include <google/protobuf/util/type_resolver.h> #include <google/protobuf/stubs/stringpiece.h> +#include <google/protobuf/port_def.inc> + namespace google { namespace protobuf { namespace util { @@ -55,7 +57,7 @@ namespace converter { // ObjectWriter when EndObject() is called on the root object. It also writes // out all non-repeated primitive fields that haven't been explicitly rendered // with their default values (0 for numbers, "" for strings, etc). -class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { +class PROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { public: // A Callback function to check whether a field needs to be scrubbed. // @@ -69,7 +71,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // // The Field* should point to the google::protobuf::Field of "c". typedef ResultCallback2<bool /*return*/, - const std::vector<string>& /*path of the field*/, + const std::vector<std::string>& /*path of the field*/, const google::protobuf::Field* /*field*/> FieldScrubCallBack; @@ -83,37 +85,41 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { virtual ~DefaultValueObjectWriter(); // ObjectWriter methods. - virtual DefaultValueObjectWriter* StartObject(StringPiece name) override; + DefaultValueObjectWriter* StartObject(StringPiece name) override; - virtual DefaultValueObjectWriter* EndObject() override; + DefaultValueObjectWriter* EndObject() override; - virtual DefaultValueObjectWriter* StartList(StringPiece name) override; + DefaultValueObjectWriter* StartList(StringPiece name) override; - virtual DefaultValueObjectWriter* EndList() override; + DefaultValueObjectWriter* EndList() override; - virtual DefaultValueObjectWriter* RenderBool(StringPiece name, bool value) override; + DefaultValueObjectWriter* RenderBool(StringPiece name, + bool value) override; - virtual DefaultValueObjectWriter* RenderInt32(StringPiece name, int32 value) override; + DefaultValueObjectWriter* RenderInt32(StringPiece name, + int32 value) override; - virtual DefaultValueObjectWriter* RenderUint32(StringPiece name, + DefaultValueObjectWriter* RenderUint32(StringPiece name, uint32 value) override; - virtual DefaultValueObjectWriter* RenderInt64(StringPiece name, int64 value) override; + DefaultValueObjectWriter* RenderInt64(StringPiece name, + int64 value) override; - virtual DefaultValueObjectWriter* RenderUint64(StringPiece name, + DefaultValueObjectWriter* RenderUint64(StringPiece name, uint64 value) override; - virtual DefaultValueObjectWriter* RenderDouble(StringPiece name, + DefaultValueObjectWriter* RenderDouble(StringPiece name, double value) override; - virtual DefaultValueObjectWriter* RenderFloat(StringPiece name, float value) override; + DefaultValueObjectWriter* RenderFloat(StringPiece name, + float value) override; - virtual DefaultValueObjectWriter* RenderString(StringPiece name, + DefaultValueObjectWriter* RenderString(StringPiece name, StringPiece value) override; - virtual DefaultValueObjectWriter* RenderBytes(StringPiece name, + DefaultValueObjectWriter* RenderBytes(StringPiece name, StringPiece value) override; - virtual DefaultValueObjectWriter* RenderNull(StringPiece name) override; + virtual DefaultValueObjectWriter* RenderNull(StringPiece name); // Register the callback for scrubbing of fields. Owership of // field_scrub_callback pointer is also transferred to this class @@ -130,9 +136,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // If set to true, enums are rendered as ints from output when default values // are written. - void set_print_enums_as_ints(bool value) { - use_ints_for_enums_ = value; - } + void set_print_enums_as_ints(bool value) { use_ints_for_enums_ = value; } protected: enum NodeKind { @@ -144,15 +148,11 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // "Node" represents a node in the tree that holds the input of // DefaultValueObjectWriter. - class LIBPROTOBUF_EXPORT Node { + class PROTOBUF_EXPORT Node { public: - Node(const string& name, const google::protobuf::Type* type, NodeKind kind, - const DataPiece& data, bool is_placeholder, - const std::vector<string>& path, bool suppress_empty_list, - FieldScrubCallBack* field_scrub_callback); - Node(const string& name, const google::protobuf::Type* type, NodeKind kind, + Node(const std::string& name, const google::protobuf::Type* type, NodeKind kind, const DataPiece& data, bool is_placeholder, - const std::vector<string>& path, bool suppress_empty_list, + const std::vector<std::string>& path, bool suppress_empty_list, bool preserve_proto_field_names, bool use_ints_for_enums, FieldScrubCallBack* field_scrub_callback); virtual ~Node() { @@ -178,9 +178,9 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { virtual void WriteTo(ObjectWriter* ow); // Accessors - const string& name() const { return name_; } + const std::string& name() const { return name_; } - const std::vector<string>& path() const { return path_; } + const std::vector<std::string>& path() const { return path_; } const google::protobuf::Type* type() const { return type_; } @@ -210,7 +210,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { void WriteChildren(ObjectWriter* ow); // The name of this node. - string name_; + std::string name_; // google::protobuf::Type of this node. Owned by TypeInfo. const google::protobuf::Type* type_; // The kind of this node. @@ -228,7 +228,7 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { bool is_placeholder_; // Path of the field of this node - std::vector<string> path_; + std::vector<std::string> path_; // Whether to suppress empty list output. bool suppress_empty_list_; @@ -248,18 +248,10 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { }; // Creates a new Node and returns it. Caller owns memory of returned object. - virtual Node* CreateNewNode(const string& name, - const google::protobuf::Type* type, NodeKind kind, - const DataPiece& data, bool is_placeholder, - const std::vector<string>& path, - bool suppress_empty_list, - FieldScrubCallBack* field_scrub_callback); - - // Creates a new Node and returns it. Caller owns memory of returned object. - virtual Node* CreateNewNode(const string& name, + virtual Node* CreateNewNode(const std::string& name, const google::protobuf::Type* type, NodeKind kind, const DataPiece& data, bool is_placeholder, - const std::vector<string>& path, + const std::vector<std::string>& path, bool suppress_empty_list, bool preserve_proto_field_names, bool use_ints_for_enums, @@ -267,7 +259,14 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { // Creates a DataPiece containing the default value of the type of the field. static DataPiece CreateDefaultDataPieceForField( - const google::protobuf::Field& field, const TypeInfo* typeinfo, bool use_ints_for_enums); + const google::protobuf::Field& field, const TypeInfo* typeinfo) { + return CreateDefaultDataPieceForField(field, typeinfo, false); + } + + // Same as the above but with a flag to use ints instead of enum names. + static DataPiece CreateDefaultDataPieceForField( + const google::protobuf::Field& field, const TypeInfo* typeinfo, + bool use_ints_for_enums); protected: // Returns a pointer to current Node in tree. @@ -300,7 +299,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. - std::vector<string*> string_values_; + std::vector<std::string*> string_values_; // The current Node. Owned by its parents. Node* current_; @@ -330,6 +329,8 @@ class LIBPROTOBUF_EXPORT DefaultValueObjectWriter : public ObjectWriter { } // namespace converter } // namespace util } // namespace protobuf - } // namespace google + +#include <google/protobuf/port_undef.inc> + #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_DEFAULT_VALUE_OBJECTWRITER_H__ |