31 #ifndef GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__
32 #define GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__
36 #include <unordered_map>
37 #include <unordered_set>
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/proto_writer.h>
48 #include <google/protobuf/util/internal/structured_objectwriter.h>
49 #include <google/protobuf/util/type_resolver.h>
50 #include <google/protobuf/stubs/bytestream.h>
51 #include <google/protobuf/stubs/status.h>
52 #include <google/protobuf/stubs/hash.h>
54 #include <google/protobuf/port_def.inc>
61 class ObjectLocationTracker;
68 class PROTOBUF_EXPORT ProtoStreamObjectWriter :
public ProtoWriter {
80 bool struct_integers_as_strings;
85 bool ignore_unknown_fields;
88 bool ignore_unknown_enum_values;
92 bool use_lower_camel_for_enums;
95 bool case_insensitive_enum_parsing;
99 bool ignore_null_value_map_entry;
126 : struct_integers_as_strings(
false),
127 ignore_unknown_fields(
false),
128 ignore_unknown_enum_values(
false),
129 use_lower_camel_for_enums(
false),
130 case_insensitive_enum_parsing(
false),
131 ignore_null_value_map_entry(
false),
132 use_legacy_json_map_format(
false),
133 disable_implicit_message_list(
false),
134 suppress_implicit_message_list_error(
false),
135 disable_implicit_scalar_list(
false),
136 suppress_implicit_scalar_list_error(
false),
137 suppress_object_to_scalar_error(
false),
138 use_json_name_in_missing_fields(
false) {}
197 class PROTOBUF_EXPORT Event {
204 RENDER_DATA_PIECE = 4,
255 std::unique_ptr<ProtoStreamObjectWriter> ow_;
277 bool is_well_known_type_;
278 TypeRenderer* well_known_type_render_;
281 std::vector<Event> uninterpreted_events_;
286 class PROTOBUF_EXPORT
Item :
public BaseElement {
297 bool is_placeholder,
bool is_list);
300 Item(
Item* parent, ItemType item_type,
bool is_placeholder,
bool is_list);
306 bool IsMap() {
return item_type_ == MAP; }
307 bool IsAny() {
return item_type_ == ANY; }
312 return static_cast<Item*
>(BaseElement::parent());
320 bool InsertMapKeyIfNotPresent(
StringPiece map_key);
331 std::unique_ptr<AnyWriter> any_;
338 std::unique_ptr<std::unordered_set<std::string> > map_keys_;
342 bool is_placeholder_;
397 static void InitRendererMap();
398 static void DeleteRendererMap();
416 bool is_placeholder,
bool is_list);
425 void PopOneElement();
430 static std::unordered_map<std::string, TypeRenderer>* renderers_;
450 #include <google/protobuf/port_undef.inc>
452 #endif // GOOGLE_PROTOBUF_UTIL_CONVERTER_PROTOSTREAM_OBJECTWRITER_H__