default_value_objectwriter.cc
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
32 
33 #include <unordered_map>
34 
38 
39 namespace google {
40 namespace protobuf {
41 namespace util {
42 using util::Status;
43 using util::StatusOr;
44 namespace converter {
45 
46 namespace {
47 // Helper function to convert string value to given data type by calling the
48 // passed converter function on the DataPiece created from "value" argument.
49 // If value is empty or if conversion fails, the default_value is returned.
50 template <typename T>
51 T ConvertTo(StringPiece value,
52  StatusOr<T> (DataPiece::*converter_fn)() const, T default_value) {
53  if (value.empty()) return default_value;
54  StatusOr<T> result = (DataPiece(value, true).*converter_fn)();
55  return result.ok() ? result.ValueOrDie() : default_value;
56 }
57 } // namespace
58 
61  ObjectWriter* ow)
62  : typeinfo_(TypeInfo::NewTypeInfo(type_resolver)),
63  own_typeinfo_(true),
64  type_(type),
65  current_(nullptr),
66  root_(nullptr),
67  suppress_empty_list_(false),
68  preserve_proto_field_names_(false),
69  use_ints_for_enums_(false),
70  field_scrub_callback_(nullptr),
71  ow_(ow) {}
72 
74  if (own_typeinfo_) {
75  delete typeinfo_;
76  }
77 }
78 
80  StringPiece name, bool value) {
81  if (current_ == nullptr) {
83  } else {
85  }
86  return this;
87 }
88 
91  if (current_ == nullptr) {
93  } else {
95  }
96  return this;
97 }
98 
101  if (current_ == nullptr) {
103  } else {
105  }
106  return this;
107 }
108 
111  if (current_ == nullptr) {
113  } else {
115  }
116  return this;
117 }
118 
121  if (current_ == nullptr) {
123  } else {
125  }
126  return this;
127 }
128 
130  StringPiece name, double value) {
131  if (current_ == nullptr) {
133  } else {
135  }
136  return this;
137 }
138 
140  StringPiece name, float value) {
141  if (current_ == nullptr) {
143  } else {
145  }
146  return this;
147 }
148 
151  if (current_ == nullptr) {
153  } else {
154  // Since StringPiece is essentially a pointer, takes a copy of "value" to
155  // avoid ownership issues.
156  string_values_.emplace_back(new std::string(value));
157  RenderDataPiece(name, DataPiece(*string_values_.back(), true));
158  }
159  return this;
160 }
161 
164  if (current_ == nullptr) {
166  } else {
167  // Since StringPiece is essentially a pointer, takes a copy of "value" to
168  // avoid ownership issues.
169  string_values_.emplace_back(new std::string(value));
170  RenderDataPiece(name, DataPiece(*string_values_.back(), false, true));
171  }
172  return this;
173 }
174 
176  StringPiece name) {
177  if (current_ == nullptr) {
178  ow_->RenderNull(name);
179  } else {
181  }
182  return this;
183 }
184 
186  FieldScrubCallBackPtr field_scrub_callback) {
187  field_scrub_callback_.reset(field_scrub_callback.release());
188 }
189 
191  const std::string& name, const google::protobuf::Type* type, NodeKind kind,
192  const DataPiece& data, bool is_placeholder,
193  const std::vector<std::string>& path, bool suppress_empty_list,
194  bool preserve_proto_field_names, bool use_ints_for_enums,
195  FieldScrubCallBack* field_scrub_callback) {
196  return new Node(name, type, kind, data, is_placeholder, path,
197  suppress_empty_list, preserve_proto_field_names,
198  use_ints_for_enums, field_scrub_callback);
199 }
200 
202  const std::string& name, const google::protobuf::Type* type, NodeKind kind,
203  const DataPiece& data, bool is_placeholder,
204  const std::vector<std::string>& path, bool suppress_empty_list,
205  bool preserve_proto_field_names, bool use_ints_for_enums,
206  FieldScrubCallBack* field_scrub_callback)
207  : name_(name),
208  type_(type),
209  kind_(kind),
210  is_any_(false),
211  data_(data),
212  is_placeholder_(is_placeholder),
213  path_(path),
214  suppress_empty_list_(suppress_empty_list),
215  preserve_proto_field_names_(preserve_proto_field_names),
216  use_ints_for_enums_(use_ints_for_enums),
217  field_scrub_callback_(field_scrub_callback) {}
218 
220  StringPiece name) {
221  if (name.empty() || kind_ != OBJECT) {
222  return nullptr;
223  }
224  for (int i = 0; i < children_.size(); ++i) {
225  Node* child = children_[i];
226  if (child->name() == name) {
227  return child;
228  }
229  }
230  return nullptr;
231 }
232 
234  if (kind_ == PRIMITIVE) {
236  return;
237  }
238 
239  // Render maps. Empty maps are rendered as "{}".
240  if (kind_ == MAP) {
241  ow->StartObject(name_);
242  WriteChildren(ow);
243  ow->EndObject();
244  return;
245  }
246 
247  // Write out lists. If we didn't have any list in response, write out empty
248  // list.
249  if (kind_ == LIST) {
250  // Suppress empty lists if requested.
251  if (suppress_empty_list_ && is_placeholder_) return;
252 
253  ow->StartList(name_);
254  WriteChildren(ow);
255  ow->EndList();
256  return;
257  }
258 
259  // If is_placeholder_ = true, we didn't see this node in the response, so
260  // skip output.
261  if (is_placeholder_) return;
262 
263  ow->StartObject(name_);
264  WriteChildren(ow);
265  ow->EndObject();
266 }
267 
269  for (int i = 0; i < children_.size(); ++i) {
270  Node* child = children_[i];
271  child->WriteTo(ow);
272  }
273 }
274 
276  const google::protobuf::Type& found_type, const TypeInfo* typeinfo) {
277  // If this field is a map, we should use the type of its "Value" as
278  // the type of the child node.
279  for (int i = 0; i < found_type.fields_size(); ++i) {
280  const google::protobuf::Field& sub_field = found_type.fields(i);
281  if (sub_field.number() != 2) {
282  continue;
283  }
284  if (sub_field.kind() != google::protobuf::Field_Kind_TYPE_MESSAGE) {
285  // This map's value type is not a message type. We don't need to
286  // get the field_type in this case.
287  break;
288  }
290  typeinfo->ResolveTypeUrl(sub_field.type_url());
291  if (!sub_type.ok()) {
292  GOOGLE_LOG(WARNING) << "Cannot resolve type '" << sub_field.type_url() << "'.";
293  } else {
294  return sub_type.ValueOrDie();
295  }
296  break;
297  }
298  return nullptr;
299 }
300 
302  const TypeInfo* typeinfo) {
303  // Ignores well known types that don't require automatically populating their
304  // primitive children. For type "Any", we only populate its children when the
305  // "@type" field is set.
306  // TODO(tsun): remove "kStructValueType" from the list. It's being checked
307  // now because of a bug in the tool-chain that causes the "oneof_index"
308  // of kStructValueType to not be set correctly.
309  if (type_ == nullptr || type_->name() == kAnyType ||
310  type_->name() == kStructType || type_->name() == kTimestampType ||
311  type_->name() == kDurationType || type_->name() == kStructValueType) {
312  return;
313  }
314  std::vector<Node*> new_children;
315  std::unordered_map<std::string, int> orig_children_map;
316 
317  // Creates a map of child nodes to speed up lookup.
318  for (int i = 0; i < children_.size(); ++i) {
319  InsertIfNotPresent(&orig_children_map, children_[i]->name_, i);
320  }
321 
322  for (int i = 0; i < type_->fields_size(); ++i) {
323  const google::protobuf::Field& field = type_->fields(i);
324 
325  // This code is checking if the field to be added to the tree should be
326  // scrubbed or not by calling the field_scrub_callback_ callback function.
327  std::vector<std::string> path;
328  if (!path_.empty()) {
329  path.insert(path.begin(), path_.begin(), path_.end());
330  }
331  path.push_back(field.name());
332  if (field_scrub_callback_ != nullptr &&
333  field_scrub_callback_->Run(path, &field)) {
334  continue;
335  }
336 
337  std::unordered_map<std::string, int>::iterator found =
338  orig_children_map.find(field.name());
339  // If the child field has already been set, we just add it to the new list
340  // of children.
341  if (found != orig_children_map.end()) {
342  new_children.push_back(children_[found->second]);
343  children_[found->second] = nullptr;
344  continue;
345  }
346 
347  const google::protobuf::Type* field_type = nullptr;
348  bool is_map = false;
349  NodeKind kind = PRIMITIVE;
350 
352  kind = OBJECT;
354  typeinfo->ResolveTypeUrl(field.type_url());
355  if (!found_result.ok()) {
356  // "field" is of an unknown type.
357  GOOGLE_LOG(WARNING) << "Cannot resolve type '" << field.type_url() << "'.";
358  } else {
359  const google::protobuf::Type* found_type = found_result.ValueOrDie();
360  is_map = IsMap(field, *found_type);
361 
362  if (!is_map) {
363  field_type = found_type;
364  } else {
365  // If this field is a map, we should use the type of its "Value" as
366  // the type of the child node.
367  field_type = GetMapValueType(*found_type, typeinfo);
368  kind = MAP;
369  }
370  }
371  }
372 
373  if (!is_map &&
374  field.cardinality() ==
376  kind = LIST;
377  }
378 
379  // If oneof_index() != 0, the child field is part of a "oneof", which means
380  // the child field is optional and we shouldn't populate its default
381  // primitive value.
382  if (field.oneof_index() != 0 && kind == PRIMITIVE) continue;
383 
384  // If the child field is of primitive type, sets its data to the default
385  // value of its type.
386  std::unique_ptr<Node> child(
387  new Node(preserve_proto_field_names_ ? field.name() : field.json_name(),
388  field_type, kind,
390  field, typeinfo, use_ints_for_enums_)
394  new_children.push_back(child.release());
395  }
396  // Adds all leftover nodes in children_ to the beginning of new_child.
397  for (int i = 0; i < children_.size(); ++i) {
398  if (children_[i] == nullptr) {
399  continue;
400  }
401  new_children.insert(new_children.begin(), children_[i]);
402  children_[i] = nullptr;
403  }
404  children_.swap(new_children);
405 }
406 
408  // If this is an "Any" node with "@type" already given and no other children
409  // have been added, populates its children.
410  if (node != nullptr && node->is_any() && node->type() != nullptr &&
411  node->type()->name() != kAnyType && node->number_of_children() == 1) {
413  }
414 }
415 
417  const google::protobuf::Field& field, const TypeInfo* typeinfo,
418  bool use_ints_for_enums) {
419  if (!field.default_value().empty())
420  return DataPiece(field.default_value(), true);
421 
423  typeinfo->GetEnumByTypeUrl(field.type_url());
424  if (!enum_type) {
425  GOOGLE_LOG(WARNING) << "Could not find enum with type '" << field.type_url()
426  << "'";
427  return DataPiece::NullData();
428  }
429  // We treat the first value as the default if none is specified.
430  return enum_type->enumvalue_size() > 0
431  ? (use_ints_for_enums
432  ? DataPiece(enum_type->enumvalue(0).number())
433  : DataPiece(enum_type->enumvalue(0).name(), true))
435 }
436 
438  const google::protobuf::Field& field, const TypeInfo* typeinfo,
439  bool use_ints_for_enums) {
440  switch (field.kind()) {
442  return DataPiece(ConvertTo<double>(
443  field.default_value(), &DataPiece::ToDouble, static_cast<double>(0)));
444  }
446  return DataPiece(ConvertTo<float>(
447  field.default_value(), &DataPiece::ToFloat, static_cast<float>(0)));
448  }
452  return DataPiece(ConvertTo<int64>(
453  field.default_value(), &DataPiece::ToInt64, static_cast<int64>(0)));
454  }
457  return DataPiece(ConvertTo<uint64>(
458  field.default_value(), &DataPiece::ToUint64, static_cast<uint64>(0)));
459  }
463  return DataPiece(ConvertTo<int32>(
464  field.default_value(), &DataPiece::ToInt32, static_cast<int32>(0)));
465  }
467  return DataPiece(
468  ConvertTo<bool>(field.default_value(), &DataPiece::ToBool, false));
469  }
471  return DataPiece(field.default_value(), true);
472  }
474  return DataPiece(field.default_value(), false, true);
475  }
478  return DataPiece(ConvertTo<uint32>(
479  field.default_value(), &DataPiece::ToUint32, static_cast<uint32>(0)));
480  }
482  return FindEnumDefault(field, typeinfo, use_ints_for_enums);
483  }
484  default: {
485  return DataPiece::NullData();
486  }
487  }
488 }
489 
491  StringPiece name) {
492  if (current_ == nullptr) {
493  std::vector<std::string> path;
494  root_.reset(CreateNewNode(
497  field_scrub_callback_.get()));
498  root_->PopulateChildren(typeinfo_);
499  current_ = root_.get();
500  return this;
501  }
504  if (current_->kind() == LIST || current_->kind() == MAP || child == nullptr) {
505  // If current_ is a list or a map node, we should create a new child and use
506  // the type of current_ as the type of the new child.
507  std::unique_ptr<Node> node(
509  ((current_->kind() == LIST || current_->kind() == MAP)
510  ? current_->type()
511  : nullptr),
512  OBJECT, DataPiece::NullData(), false,
513  child == nullptr ? current_->path() : child->path(),
516  child = node.get();
517  current_->AddChild(node.release());
518  }
519 
520  child->set_is_placeholder(false);
521  if (child->kind() == OBJECT && child->number_of_children() == 0) {
522  child->PopulateChildren(typeinfo_);
523  }
524 
525  stack_.push(current_);
526  current_ = child;
527  return this;
528 }
529 
531  if (stack_.empty()) {
532  // The root object ends here. Writes out the tree.
533  WriteRoot();
534  return this;
535  }
536  current_ = stack_.top();
537  stack_.pop();
538  return this;
539 }
540 
542  StringPiece name) {
543  if (current_ == nullptr) {
544  std::vector<std::string> path;
545  root_.reset(CreateNewNode(
548  field_scrub_callback_.get()));
549  current_ = root_.get();
550  return this;
551  }
554  if (child == nullptr || child->kind() != LIST) {
555  std::unique_ptr<Node> node(CreateNewNode(
556  std::string(name), nullptr, LIST, DataPiece::NullData(), false,
557  child == nullptr ? current_->path() : child->path(),
559  field_scrub_callback_.get()));
560  child = node.get();
561  current_->AddChild(node.release());
562  }
563  child->set_is_placeholder(false);
564 
565  stack_.push(current_);
566  current_ = child;
567  return this;
568 }
569 
571  root_->WriteTo(ow_);
572  root_.reset(nullptr);
573  current_ = nullptr;
574 }
575 
577  if (stack_.empty()) {
578  WriteRoot();
579  return this;
580  }
581  current_ = stack_.top();
582  stack_.pop();
583  return this;
584 }
585 
587  const DataPiece& data) {
589  if (current_->type() != nullptr && current_->type()->name() == kAnyType &&
590  name == "@type") {
591  util::StatusOr<std::string> data_string = data.ToString();
592  if (data_string.ok()) {
593  const std::string& string_value = data_string.ValueOrDie();
594  // If the type of current_ is "Any" and its "@type" field is being set
595  // here, sets the type of current_ to be the type specified by the
596  // "@type".
598  typeinfo_->ResolveTypeUrl(string_value);
599  if (!found_type.ok()) {
600  GOOGLE_LOG(WARNING) << "Failed to resolve type '" << string_value << "'.";
601  } else {
602  current_->set_type(found_type.ValueOrDie());
603  }
604  current_->set_is_any(true);
605  // If the "@type" field is placed after other fields, we should populate
606  // other children of primitive type now. Otherwise, we should wait until
607  // the first value field is rendered before we populate the children,
608  // because the "value" field of a Any message could be omitted.
609  if (current_->number_of_children() > 1 && current_->type() != nullptr) {
611  }
612  }
613  }
615  if (child == nullptr || child->kind() != PRIMITIVE) {
616  // No children are found, creates a new child.
617  std::unique_ptr<Node> node(
618  CreateNewNode(std::string(name), nullptr, PRIMITIVE, data, false,
619  child == nullptr ? current_->path() : child->path(),
622  current_->AddChild(node.release());
623  } else {
624  child->set_data(data);
625  child->set_is_placeholder(false);
626  }
627 }
628 
629 } // namespace converter
630 } // namespace util
631 } // namespace protobuf
632 } // namespace google
google::protobuf::util::converter::DefaultValueObjectWriter::suppress_empty_list_
bool suppress_empty_list_
Definition: default_value_objectwriter.h:312
google::protobuf::util::converter::DefaultValueObjectWriter::CreateNewNode
virtual Node * CreateNewNode(const std::string &name, const google::protobuf::Type *type, NodeKind kind, const DataPiece &data, bool is_placeholder, const std::vector< std::string > &path, bool suppress_empty_list, bool preserve_proto_field_names, bool use_ints_for_enums, FieldScrubCallBack *field_scrub_callback)
Definition: default_value_objectwriter.cc:190
google::protobuf::util::converter::DefaultValueObjectWriter::Node::set_type
void set_type(const google::protobuf::Type *type)
Definition: default_value_objectwriter.h:187
name
GLuint const GLchar * name
Definition: glcorearb.h:3055
data_
StringPiece data_
Definition: bytestream_unittest.cc:60
google::protobuf::util::converter::kTimestampType
const char kTimestampType[]
Definition: constants.h:81
google::protobuf::util::converter::DefaultValueObjectWriter
Definition: default_value_objectwriter.h:60
map_util.h
google::protobuf::util::converter::ObjectWriter::StartList
virtual ObjectWriter * StartList(StringPiece name)=0
Field_Kind_TYPE_SFIXED64
@ Field_Kind_TYPE_SFIXED64
Definition: type.pb.h:103
google::protobuf::Enum
google::protobuf::util::converter::kAnyType
const char kAnyType[]
Definition: constants.h:90
google::protobuf::util::converter::DefaultValueObjectWriter::StartObject
DefaultValueObjectWriter * StartObject(StringPiece name) override
Definition: default_value_objectwriter.cc:490
google::protobuf::util::converter::DefaultValueObjectWriter::RenderNull
virtual DefaultValueObjectWriter * RenderNull(StringPiece name)
Definition: default_value_objectwriter.cc:175
google::protobuf::util::StatusOr::ValueOrDie
const T & ValueOrDie() const
Definition: statusor.h:251
google::protobuf::int64
int64_t int64
Definition: protobuf/src/google/protobuf/stubs/port.h:151
field_type
zend_class_entry * field_type
Definition: php/ext/google/protobuf/message.c:2028
google::protobuf::util::converter::DefaultValueObjectWriter::NodeKind
NodeKind
Definition: default_value_objectwriter.h:142
google::protobuf::util::converter::TypeInfo::GetEnumByTypeUrl
virtual const google::protobuf::Enum * GetEnumByTypeUrl(StringPiece type_url) const =0
google::protobuf::util::converter::DefaultValueObjectWriter::Node::set_is_any
void set_is_any(bool is_any)
Definition: default_value_objectwriter.h:197
google::protobuf::util::converter::DefaultValueObjectWriter::CreateDefaultDataPieceForField
static DataPiece CreateDefaultDataPieceForField(const google::protobuf::Field &field, const TypeInfo *typeinfo)
Definition: default_value_objectwriter.h:261
Field_Kind_TYPE_FIXED32
@ Field_Kind_TYPE_FIXED32
Definition: type.pb.h:94
Field_Kind_TYPE_SFIXED32
@ Field_Kind_TYPE_SFIXED32
Definition: type.pb.h:102
google::protobuf::util::converter::kStructValueType
const char kStructValueType[]
Definition: constants.h:75
google::protobuf::util::converter::ObjectWriter::RenderUint64
virtual ObjectWriter * RenderUint64(StringPiece name, uint64 value)=0
google::protobuf::util::converter::DataPiece::ToInt64
util::StatusOr< int64 > ToInt64() const
Definition: datapiece.cc:144
google::protobuf::util::converter::DefaultValueObjectWriter::typeinfo_
const TypeInfo * typeinfo_
Definition: default_value_objectwriter.h:296
google::protobuf::uint32
uint32_t uint32
Definition: protobuf/src/google/protobuf/stubs/port.h:155
Field_Kind_TYPE_MESSAGE
@ Field_Kind_TYPE_MESSAGE
Definition: type.pb.h:98
Field_Kind_TYPE_UINT32
@ Field_Kind_TYPE_UINT32
Definition: type.pb.h:100
google::protobuf::util::converter::DefaultValueObjectWriter::field_scrub_callback_
FieldScrubCallBackPtr field_scrub_callback_
Definition: default_value_objectwriter.h:322
google::protobuf::util::converter::DefaultValueObjectWriter::Node::PopulateChildren
virtual void PopulateChildren(const TypeInfo *typeinfo)
Definition: default_value_objectwriter.cc:301
google::protobuf::util::converter::ObjectWriter
Definition: object_writer.h:60
google::protobuf::util::converter::DefaultValueObjectWriter::LIST
@ LIST
Definition: default_value_objectwriter.h:145
google::protobuf::util::converter::DefaultValueObjectWriter::Node::AddChild
void AddChild(Node *child)
Definition: default_value_objectwriter.h:165
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
Field_Kind_TYPE_DOUBLE
@ Field_Kind_TYPE_DOUBLE
Definition: type.pb.h:88
google::protobuf::util::converter::DefaultValueObjectWriter::RenderString
DefaultValueObjectWriter * RenderString(StringPiece name, StringPiece value) override
Definition: default_value_objectwriter.cc:149
google::protobuf::util::converter::DefaultValueObjectWriter::Node::number_of_children
int number_of_children() const
Definition: default_value_objectwriter.h:191
google::protobuf::util::converter::DefaultValueObjectWriter::string_values_
std::vector< std::unique_ptr< std::string > > string_values_
Definition: default_value_objectwriter.h:302
enum_type
zend_class_entry * enum_type
Definition: php/ext/google/protobuf/message.c:1904
utility.h
found
return found
Definition: socket_poller.cpp:456
google::protobuf::ResultCallback2
Definition: callback.h:109
google::protobuf::util::converter::DefaultValueObjectWriter::EndList
DefaultValueObjectWriter * EndList() override
Definition: default_value_objectwriter.cc:576
T
#define T(upbtypeconst, upbtype, ctype, default_value)
google::protobuf::util::converter::TypeInfo::ResolveTypeUrl
virtual util::StatusOr< const google::protobuf::Type * > ResolveTypeUrl(StringPiece type_url) const =0
google::protobuf::util::converter::ObjectWriter::RenderDataPieceTo
static void RenderDataPieceTo(const DataPiece &data, StringPiece name, ObjectWriter *ow)
Definition: object_writer.cc:41
google::protobuf::util::converter::DefaultValueObjectWriter::~DefaultValueObjectWriter
virtual ~DefaultValueObjectWriter()
Definition: default_value_objectwriter.cc:73
google::protobuf::util::converter::ObjectWriter::RenderDouble
virtual ObjectWriter * RenderDouble(StringPiece name, double value)=0
Field_Kind_TYPE_SINT64
@ Field_Kind_TYPE_SINT64
Definition: type.pb.h:105
google::protobuf::util::converter::DefaultValueObjectWriter::OBJECT
@ OBJECT
Definition: default_value_objectwriter.h:144
google::protobuf::util::converter::DataPiece::ToDouble
util::StatusOr< double > ToDouble() const
Definition: datapiece.cc:169
google::protobuf::util::converter::DataPiece::ToInt32
util::StatusOr< int32 > ToInt32() const
Definition: datapiece.cc:119
google::protobuf::util::converter::DataPiece::NullData
static DataPiece NullData()
Definition: datapiece.h:111
google::protobuf::util::converter::DefaultValueObjectWriter::RenderFloat
DefaultValueObjectWriter * RenderFloat(StringPiece name, float value) override
Definition: default_value_objectwriter.cc:139
google::protobuf::util::converter::DataPiece::ToFloat
util::StatusOr< float > ToFloat() const
Definition: datapiece.cc:189
google::protobuf::util::converter::DefaultValueObjectWriter::FindEnumDefault
static DataPiece FindEnumDefault(const google::protobuf::Field &field, const TypeInfo *typeinfo, bool use_ints_for_enums)
Definition: default_value_objectwriter.cc:416
google::protobuf::util::converter::ObjectWriter::RenderBool
virtual ObjectWriter * RenderBool(StringPiece name, bool value)=0
google::protobuf::int32
int32_t int32
Definition: protobuf/src/google/protobuf/stubs/port.h:150
Field_Kind_TYPE_SINT32
@ Field_Kind_TYPE_SINT32
Definition: type.pb.h:104
google::protobuf::util::converter::ObjectWriter::RenderInt32
virtual ObjectWriter * RenderInt32(StringPiece name, int32 value)=0
Field_Kind_TYPE_INT64
@ Field_Kind_TYPE_INT64
Definition: type.pb.h:90
google::protobuf::util::converter::ObjectWriter::StartObject
virtual ObjectWriter * StartObject(StringPiece name)=0
google::protobuf::util::TypeResolver
Definition: type_resolver.h:52
path
GLsizei const GLchar ** path
Definition: glcorearb.h:3658
google::protobuf::util::converter::DefaultValueObjectWriter::Node::path
const std::vector< std::string > & path() const
Definition: default_value_objectwriter.h:183
google::protobuf::StringPiece
Definition: stringpiece.h:180
google::protobuf::util::converter::DefaultValueObjectWriter::current_
Node * current_
Definition: default_value_objectwriter.h:305
google::protobuf::util::converter::DefaultValueObjectWriter::RenderBytes
DefaultValueObjectWriter * RenderBytes(StringPiece name, StringPiece value) override
Definition: default_value_objectwriter.cc:162
google::protobuf::util::converter::DefaultValueObjectWriter::EndObject
DefaultValueObjectWriter * EndObject() override
Definition: default_value_objectwriter.cc:530
Field_Kind_TYPE_INT32
@ Field_Kind_TYPE_INT32
Definition: type.pb.h:92
google::protobuf::util::converter::DataPiece::ToUint32
util::StatusOr< uint32 > ToUint32() const
Definition: datapiece.cc:131
google::protobuf::util::converter::IsMap
bool IsMap(const google::protobuf::Field &field, const google::protobuf::Type &type)
Definition: utility.cc:360
Field_Kind_TYPE_BOOL
@ Field_Kind_TYPE_BOOL
Definition: type.pb.h:95
GOOGLE_LOG
#define GOOGLE_LOG(LEVEL)
Definition: logging.h:146
google::protobuf::util::converter::ObjectWriter::EndList
virtual ObjectWriter * EndList()=0
google::protobuf::util::converter::DefaultValueObjectWriter::FieldScrubCallBackPtr
std::unique_ptr< FieldScrubCallBack > FieldScrubCallBackPtr
Definition: default_value_objectwriter.h:79
google::protobuf::util::converter::TypeInfo
Definition: type_info.h:49
googletest-filter-unittest.child
child
Definition: googletest-filter-unittest.py:62
google::protobuf::uint64
uint64_t uint64
Definition: protobuf/src/google/protobuf/stubs/port.h:156
Field_Kind_TYPE_FIXED64
@ Field_Kind_TYPE_FIXED64
Definition: type.pb.h:93
Field_Cardinality_CARDINALITY_REPEATED
@ Field_Cardinality_CARDINALITY_REPEATED
Definition: type.pb.h:132
google::protobuf::util::converter::DefaultValueObjectWriter::RenderInt32
DefaultValueObjectWriter * RenderInt32(StringPiece name, int32 value) override
Definition: default_value_objectwriter.cc:89
google::protobuf::WARNING
static const LogLevel WARNING
Definition: protobuf/src/google/protobuf/testing/googletest.h:71
google::protobuf::util::converter::DefaultValueObjectWriter::preserve_proto_field_names_
bool preserve_proto_field_names_
Definition: default_value_objectwriter.h:315
google::protobuf::util::converter::DefaultValueObjectWriter::PRIMITIVE
@ PRIMITIVE
Definition: default_value_objectwriter.h:143
google::protobuf::util::converter::DefaultValueObjectWriter::Node::is_any
bool is_any() const
Definition: default_value_objectwriter.h:195
google::protobuf::util::converter::DefaultValueObjectWriter::RenderUint64
DefaultValueObjectWriter * RenderUint64(StringPiece name, uint64 value) override
Definition: default_value_objectwriter.cc:119
name_
string name_
Definition: googletest.cc:182
default_value_objectwriter.h
google::protobuf::util::converter::DefaultValueObjectWriter::type_
const google::protobuf::Type & type_
Definition: default_value_objectwriter.h:300
field
const FieldDescriptor * field
Definition: parser_unittest.cc:2694
google::protobuf::util::converter::DefaultValueObjectWriter::Node::FindChild
Node * FindChild(StringPiece name)
Definition: default_value_objectwriter.cc:219
google::protobuf::util::converter::DefaultValueObjectWriter::root_
std::unique_ptr< Node > root_
Definition: default_value_objectwriter.h:307
google::protobuf::util::converter::DefaultValueObjectWriter::RenderBool
DefaultValueObjectWriter * RenderBool(StringPiece name, bool value) override
Definition: default_value_objectwriter.cc:79
google::protobuf::util::converter::DefaultValueObjectWriter::WriteRoot
void WriteRoot()
Definition: default_value_objectwriter.cc:570
google::protobuf::util::StatusOr
Definition: statusor.h:99
aditof::Status
Status
Status of any operation that the TOF sdk performs.
Definition: status_definitions.h:48
Field_Kind_TYPE_UINT64
@ Field_Kind_TYPE_UINT64
Definition: type.pb.h:91
google::protobuf::util::converter::ObjectWriter::RenderBytes
virtual ObjectWriter * RenderBytes(StringPiece name, StringPiece value)=0
i
int i
Definition: gmock-matchers_test.cc:764
google::protobuf::util::converter::DefaultValueObjectWriter::use_ints_for_enums_
bool use_ints_for_enums_
Definition: default_value_objectwriter.h:318
Field
struct Field Field
Definition: php/ext/google/protobuf/protobuf.h:638
type
GLenum type
Definition: glcorearb.h:2695
google::protobuf::util::converter::ObjectWriter::RenderNull
virtual ObjectWriter * RenderNull(StringPiece name)=0
google::protobuf::util::converter::DefaultValueObjectWriter::Node::GetMapValueType
const google::protobuf::Type * GetMapValueType(const google::protobuf::Type &entry_type, const TypeInfo *typeinfo)
Definition: default_value_objectwriter.cc:275
google::protobuf::util::converter::DefaultValueObjectWriter::ow_
ObjectWriter * ow_
Definition: default_value_objectwriter.h:324
google::protobuf::util::converter::ObjectWriter::RenderString
virtual ObjectWriter * RenderString(StringPiece name, StringPiece value)=0
google::protobuf::util::converter::DefaultValueObjectWriter::MAP
@ MAP
Definition: default_value_objectwriter.h:146
google::protobuf::util::converter::DataPiece::ToBool
util::StatusOr< bool > ToBool() const
Definition: datapiece.cc:204
google::protobuf::util::converter::kDurationType
const char kDurationType[]
Definition: constants.h:84
constants.h
google::protobuf::util::converter::DefaultValueObjectWriter::DefaultValueObjectWriter
DefaultValueObjectWriter(TypeResolver *type_resolver, const google::protobuf::Type &type, ObjectWriter *ow)
Definition: default_value_objectwriter.cc:59
google::protobuf::util::converter::DefaultValueObjectWriter::own_typeinfo_
bool own_typeinfo_
Definition: default_value_objectwriter.h:298
Field_Kind_TYPE_STRING
@ Field_Kind_TYPE_STRING
Definition: type.pb.h:96
google::protobuf::util::converter::DefaultValueObjectWriter::Node::WriteTo
virtual void WriteTo(ObjectWriter *ow)
Definition: default_value_objectwriter.cc:233
default_value
def default_value(type_)
google::protobuf::util::converter::DefaultValueObjectWriter::StartList
DefaultValueObjectWriter * StartList(StringPiece name) override
Definition: default_value_objectwriter.cc:541
type_resolver
TypeResolver * type_resolver
Definition: conformance_cpp.cc:97
Field_Kind_TYPE_FLOAT
@ Field_Kind_TYPE_FLOAT
Definition: type.pb.h:89
google::protobuf::util::converter::DefaultValueObjectWriter::MaybePopulateChildrenOfAny
void MaybePopulateChildrenOfAny(Node *node)
Definition: default_value_objectwriter.cc:407
google::protobuf::util::converter::DefaultValueObjectWriter::RenderDataPiece
void RenderDataPiece(StringPiece name, const DataPiece &data)
Definition: default_value_objectwriter.cc:586
google::protobuf::util::converter::DefaultValueObjectWriter::RenderUint32
DefaultValueObjectWriter * RenderUint32(StringPiece name, uint32 value) override
Definition: default_value_objectwriter.cc:99
Type
struct Type Type
Definition: php/ext/google/protobuf/protobuf.h:664
google::protobuf::util::StatusOr::ok
bool ok() const
Definition: statusor.h:246
data
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: glcorearb.h:2879
google::protobuf::util::converter::ObjectWriter::RenderUint32
virtual ObjectWriter * RenderUint32(StringPiece name, uint32 value)=0
true
#define true
Definition: cJSON.c:65
google::protobuf::util::converter::DataPiece::ToUint64
util::StatusOr< uint64 > ToUint64() const
Definition: datapiece.cc:156
google::protobuf::util::converter::DefaultValueObjectWriter::Node
Definition: default_value_objectwriter.h:151
Field_Kind_TYPE_ENUM
@ Field_Kind_TYPE_ENUM
Definition: type.pb.h:101
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
google::protobuf::util::converter::kStructType
const char kStructType[]
Definition: constants.h:72
google::protobuf::util::converter::DataPiece
Definition: datapiece.h:59
false
#define false
Definition: cJSON.c:70
Field_Kind_TYPE_BYTES
@ Field_Kind_TYPE_BYTES
Definition: type.pb.h:99
google::protobuf::util::converter::DefaultValueObjectWriter::stack_
std::stack< Node * > stack_
Definition: default_value_objectwriter.h:309
google::protobuf::util::converter::DefaultValueObjectWriter::RegisterFieldScrubCallBack
void RegisterFieldScrubCallBack(FieldScrubCallBackPtr field_scrub_callback)
Definition: default_value_objectwriter.cc:185
google::protobuf::util::converter::DefaultValueObjectWriter::Node::WriteChildren
void WriteChildren(ObjectWriter *ow)
Definition: default_value_objectwriter.cc:268
google::protobuf::util::converter::DefaultValueObjectWriter::RenderDouble
DefaultValueObjectWriter * RenderDouble(StringPiece name, double value) override
Definition: default_value_objectwriter.cc:129
google::protobuf::InsertIfNotPresent
bool InsertIfNotPresent(Collection *const collection, const typename Collection::value_type &vt)
Definition: map_util.h:321
google
Definition: data_proto2_to_proto3_util.h:11
root_
Node root_
Definition: field_mask_util.cc:288
google::protobuf::util::converter::DefaultValueObjectWriter::Node::Node
Node(const std::string &name, const google::protobuf::Type *type, NodeKind kind, const DataPiece &data, bool is_placeholder, const std::vector< std::string > &path, bool suppress_empty_list, bool preserve_proto_field_names, bool use_ints_for_enums, FieldScrubCallBack *field_scrub_callback)
Definition: default_value_objectwriter.cc:201
google::protobuf::util::converter::ObjectWriter::EndObject
virtual ObjectWriter * EndObject()=0
google::protobuf::util::converter::ObjectWriter::RenderInt64
virtual ObjectWriter * RenderInt64(StringPiece name, int64 value)=0
google::protobuf::util::converter::DefaultValueObjectWriter::Node::type
const google::protobuf::Type * type() const
Definition: default_value_objectwriter.h:185
google::protobuf::util::converter::DefaultValueObjectWriter::Node::kind
NodeKind kind() const
Definition: default_value_objectwriter.h:189
google::protobuf::util::converter::DefaultValueObjectWriter::RenderInt64
DefaultValueObjectWriter * RenderInt64(StringPiece name, int64 value) override
Definition: default_value_objectwriter.cc:109


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:49