31 #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__
32 #define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__
39 #include <google/protobuf/stubs/common.h>
40 #include <google/protobuf/type.pb.h>
41 #include <google/protobuf/io/coded_stream.h>
42 #include <google/protobuf/io/zero_copy_stream_impl.h>
43 #include <google/protobuf/descriptor.h>
44 #include <google/protobuf/util/internal/type_info.h>
45 #include <google/protobuf/util/internal/datapiece.h>
46 #include <google/protobuf/util/internal/error_listener.h>
47 #include <google/protobuf/util/internal/structured_objectwriter.h>
48 #include <google/protobuf/util/type_resolver.h>
49 #include <google/protobuf/stubs/bytestream.h>
50 #include <google/protobuf/stubs/status.h>
51 #include <google/protobuf/stubs/hash.h>
52 #include <google/protobuf/stubs/status.h>
55 #include <google/protobuf/port_def.inc>
63 class ObjectLocationTracker;
71 class PROTOBUF_EXPORT ProtoWriter :
public StructuredObjectWriter {
75 strings::ByteSink*
output, ErrorListener* listener);
76 ~ProtoWriter()
override;
79 ProtoWriter* StartObject(StringPiece
name)
override;
80 ProtoWriter* EndObject()
override;
81 ProtoWriter* StartList(StringPiece
name)
override;
82 ProtoWriter* EndList()
override;
106 return RenderDataPiece(
name,
111 return RenderDataPiece(
128 return element_ !=
nullptr ? *element_ : *tracker_;
147 ignore_unknown_fields_ = ignore_unknown_fields;
153 ignore_unknown_enum_values_ = ignore_unknown_enum_values;
157 use_lower_camel_for_enums_ = use_lower_camel_for_enums;
161 case_insensitive_enum_parsing_ = case_insensitive_enum_parsing;
165 bool use_json_name_in_missing_fields) {
166 use_json_name_in_missing_fields_ = use_json_name_in_missing_fields;
170 class PROTOBUF_EXPORT ProtoElement :
public BaseElement,
193 return parent_field_;
204 return static_cast<ProtoElement*
>(BaseElement::parent());
238 std::set<const google::protobuf::Field*> required_fields_;
239 const int size_index_;
246 std::vector<bool> oneof_indices_;
286 void WriteRootMessage();
321 bool use_lower_camel_for_enums,
322 bool case_insensitive_enum_parsing,
323 bool ignore_unknown_values);
337 bool ignore_unknown_fields_;
340 bool ignore_unknown_enum_values_;
344 bool use_lower_camel_for_enums_;
347 bool case_insensitive_enum_parsing_;
357 std::unique_ptr<ProtoElement> element_;
358 std::deque<SizeInfo> size_insert_;
368 std::unique_ptr<io::CodedOutputStream>
stream_;
376 std::unique_ptr<LocationTrackerInterface> tracker_;
386 #include <google/protobuf/port_undef.inc>
388 #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTO_WRITER_H__