Go to the documentation of this file.
33 #include <unordered_map>
51 T ConvertTo(StringPiece
value,
52 StatusOr<T> (DataPiece::*converter_fn)()
const,
T default_value) {
54 StatusOr<T> result = (DataPiece(
value,
true).*converter_fn)();
67 suppress_empty_list_(
false),
68 preserve_proto_field_names_(
false),
69 use_ints_for_enums_(
false),
70 field_scrub_callback_(nullptr),
193 const std::vector<std::string>&
path,
bool suppress_empty_list,
194 bool preserve_proto_field_names,
bool use_ints_for_enums,
197 suppress_empty_list, preserve_proto_field_names,
198 use_ints_for_enums, field_scrub_callback);
204 const std::vector<std::string>&
path,
bool suppress_empty_list,
205 bool preserve_proto_field_names,
bool use_ints_for_enums,
212 is_placeholder_(is_placeholder),
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) {}
224 for (
int i = 0;
i < children_.size(); ++
i) {
261 if (is_placeholder_)
return;
269 for (
int i = 0;
i < children_.size(); ++
i) {
279 for (
int i = 0;
i < found_type.fields_size(); ++
i) {
281 if (sub_field.number() != 2) {
291 if (!sub_type.
ok()) {
314 std::vector<Node*> new_children;
315 std::unordered_map<std::string, int> orig_children_map;
318 for (
int i = 0;
i < children_.size(); ++
i) {
322 for (
int i = 0;
i <
type_->fields_size(); ++
i) {
327 std::vector<std::string>
path;
328 if (!path_.empty()) {
329 path.insert(
path.begin(), path_.begin(), path_.end());
337 std::unordered_map<std::string, int>::iterator
found =
338 orig_children_map.find(
field.name());
341 if (
found != orig_children_map.end()) {
342 new_children.push_back(children_[
found->second]);
343 children_[
found->second] =
nullptr;
355 if (!found_result.
ok()) {
367 field_type = GetMapValueType(*found_type, typeinfo);
374 field.cardinality() ==
386 std::unique_ptr<Node>
child(
394 new_children.push_back(
child.release());
397 for (
int i = 0;
i < children_.size(); ++
i) {
398 if (children_[
i] ==
nullptr) {
401 new_children.insert(new_children.begin(), children_[
i]);
402 children_[
i] =
nullptr;
404 children_.swap(new_children);
410 if (node !=
nullptr && node->
is_any() && node->
type() !=
nullptr &&
418 bool use_ints_for_enums) {
419 if (!
field.default_value().empty())
431 ? (use_ints_for_enums
439 bool use_ints_for_enums) {
440 switch (
field.kind()) {
493 std::vector<std::string>
path;
507 std::unique_ptr<Node> node(
520 child->set_is_placeholder(
false);
544 std::vector<std::string>
path;
563 child->set_is_placeholder(
false);
572 root_.reset(
nullptr);
592 if (data_string.
ok()) {
599 if (!found_type.
ok()) {
617 std::unique_ptr<Node> node(
625 child->set_is_placeholder(
false);
bool suppress_empty_list_
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)
void set_type(const google::protobuf::Type *type)
GLuint const GLchar * name
const char kTimestampType[]
virtual ObjectWriter * StartList(StringPiece name)=0
@ Field_Kind_TYPE_SFIXED64
DefaultValueObjectWriter * StartObject(StringPiece name) override
virtual DefaultValueObjectWriter * RenderNull(StringPiece name)
const T & ValueOrDie() const
zend_class_entry * field_type
virtual const google::protobuf::Enum * GetEnumByTypeUrl(StringPiece type_url) const =0
void set_is_any(bool is_any)
static DataPiece CreateDefaultDataPieceForField(const google::protobuf::Field &field, const TypeInfo *typeinfo)
@ Field_Kind_TYPE_FIXED32
@ Field_Kind_TYPE_SFIXED32
const char kStructValueType[]
virtual ObjectWriter * RenderUint64(StringPiece name, uint64 value)=0
util::StatusOr< int64 > ToInt64() const
const TypeInfo * typeinfo_
@ Field_Kind_TYPE_MESSAGE
FieldScrubCallBackPtr field_scrub_callback_
virtual void PopulateChildren(const TypeInfo *typeinfo)
void AddChild(Node *child)
GLsizei const GLchar *const * string
DefaultValueObjectWriter * RenderString(StringPiece name, StringPiece value) override
int number_of_children() const
std::vector< std::unique_ptr< std::string > > string_values_
zend_class_entry * enum_type
DefaultValueObjectWriter * EndList() override
#define T(upbtypeconst, upbtype, ctype, default_value)
virtual util::StatusOr< const google::protobuf::Type * > ResolveTypeUrl(StringPiece type_url) const =0
static void RenderDataPieceTo(const DataPiece &data, StringPiece name, ObjectWriter *ow)
virtual ~DefaultValueObjectWriter()
virtual ObjectWriter * RenderDouble(StringPiece name, double value)=0
util::StatusOr< double > ToDouble() const
util::StatusOr< int32 > ToInt32() const
static DataPiece NullData()
DefaultValueObjectWriter * RenderFloat(StringPiece name, float value) override
util::StatusOr< float > ToFloat() const
static DataPiece FindEnumDefault(const google::protobuf::Field &field, const TypeInfo *typeinfo, bool use_ints_for_enums)
virtual ObjectWriter * RenderBool(StringPiece name, bool value)=0
virtual ObjectWriter * RenderInt32(StringPiece name, int32 value)=0
virtual ObjectWriter * StartObject(StringPiece name)=0
GLsizei const GLchar ** path
const std::vector< std::string > & path() const
DefaultValueObjectWriter * RenderBytes(StringPiece name, StringPiece value) override
DefaultValueObjectWriter * EndObject() override
util::StatusOr< uint32 > ToUint32() const
bool IsMap(const google::protobuf::Field &field, const google::protobuf::Type &type)
#define GOOGLE_LOG(LEVEL)
virtual ObjectWriter * EndList()=0
std::unique_ptr< FieldScrubCallBack > FieldScrubCallBackPtr
@ Field_Kind_TYPE_FIXED64
@ Field_Cardinality_CARDINALITY_REPEATED
DefaultValueObjectWriter * RenderInt32(StringPiece name, int32 value) override
static const LogLevel WARNING
bool preserve_proto_field_names_
DefaultValueObjectWriter * RenderUint64(StringPiece name, uint64 value) override
const google::protobuf::Type & type_
const FieldDescriptor * field
Node * FindChild(StringPiece name)
std::unique_ptr< Node > root_
DefaultValueObjectWriter * RenderBool(StringPiece name, bool value) override
Status
Status of any operation that the TOF sdk performs.
virtual ObjectWriter * RenderBytes(StringPiece name, StringPiece value)=0
virtual ObjectWriter * RenderNull(StringPiece name)=0
const google::protobuf::Type * GetMapValueType(const google::protobuf::Type &entry_type, const TypeInfo *typeinfo)
virtual ObjectWriter * RenderString(StringPiece name, StringPiece value)=0
util::StatusOr< bool > ToBool() const
const char kDurationType[]
DefaultValueObjectWriter(TypeResolver *type_resolver, const google::protobuf::Type &type, ObjectWriter *ow)
virtual void WriteTo(ObjectWriter *ow)
DefaultValueObjectWriter * StartList(StringPiece name) override
void MaybePopulateChildrenOfAny(Node *node)
void RenderDataPiece(StringPiece name, const DataPiece &data)
DefaultValueObjectWriter * RenderUint32(StringPiece name, uint32 value) override
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
virtual ObjectWriter * RenderUint32(StringPiece name, uint32 value)=0
util::StatusOr< uint64 > ToUint64() const
GLsizei const GLfloat * value
std::stack< Node * > stack_
void RegisterFieldScrubCallBack(FieldScrubCallBackPtr field_scrub_callback)
void WriteChildren(ObjectWriter *ow)
DefaultValueObjectWriter * RenderDouble(StringPiece name, double value) override
bool InsertIfNotPresent(Collection *const collection, const typename Collection::value_type &vt)
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)
virtual ObjectWriter * EndObject()=0
virtual ObjectWriter * RenderInt64(StringPiece name, int64 value)=0
const google::protobuf::Type * type() const
DefaultValueObjectWriter * RenderInt64(StringPiece name, int64 value) override
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:49