Go to the documentation of this file.
33 #include <unordered_map>
58 #include <google/protobuf/port_def.inc>
70 using ::PROTOBUF_NAMESPACE_ID::internal::WireFormat;
71 using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
93 StatusOr<std::string> MapKeyDefaultValueAsString(
95 switch (
field.kind()) {
125 use_lower_camel_for_enums_(
false),
126 use_ints_for_enums_(
false),
127 preserve_proto_field_names_(
false),
130 render_unknown_fields_(
false),
131 render_unknown_enum_values_(
true),
132 add_trailing_zeros_for_timestamp_and_duration_(
false),
133 suppress_empty_object_(
false) {
142 own_typeinfo_(
false),
144 use_lower_camel_for_enums_(
false),
145 use_ints_for_enums_(
false),
146 preserve_proto_field_names_(
false),
149 render_unknown_fields_(
false),
150 render_unknown_enum_values_(
true),
151 add_trailing_zeros_for_timestamp_and_duration_(
false),
152 suppress_empty_object_(
false) {
173 if (
field !=
nullptr) {
178 if (actual_type != expected_type &&
179 (!IsPackable(*
field) ||
190 bool include_start_and_end,
194 if (type_renderer !=
nullptr) {
195 return (*type_renderer)(
this,
type,
name, ow);
208 if (include_start_and_end) {
211 while (tag != end_tag) {
212 if (tag != last_tag) {
215 if (
field !=
nullptr) {
217 field_name =
field->name();
219 field_name =
field->json_name();
223 if (
field ==
nullptr) {
232 if (
field->cardinality() ==
249 if (include_start_and_end) {
260 if (IsPackable(*
field) &&
274 return tag_to_return;
292 if (
field ==
nullptr) {
297 if (
field->number() == 1) {
299 }
else if (
field->number() == 2) {
300 if (map_key.empty()) {
304 if (key_field ==
nullptr) {
320 return tag_to_return;
344 StrCat(
"Timestamp seconds exceeds limit for field: ",
351 StrCat(
"Timestamp nanos exceeds limit for field: ", field_name));
369 StrCat(
"Duration seconds exceeds limit for field: ", field_name));
375 StrCat(
"Duration nanos exceeds limit for field: ", field_name));
383 StrCat(
"Duration nanos is non-negative, but seconds is "
384 "negative for field: ",
390 }
else if (seconds == 0 && nanos < 0) {
395 "%s%lld%ss", sign.c_str(),
static_cast<long long>(seconds),
412 ow->
RenderDouble(field_name, bit_cast<double>(buffer64));
426 ow->
RenderFloat(field_name, bit_cast<float>(buffer32));
440 ow->
RenderInt64(field_name, bit_cast<int64>(buffer64));
454 ow->
RenderUint64(field_name, bit_cast<uint64>(buffer64));
468 ow->
RenderInt32(field_name, bit_cast<int32>(buffer32));
482 ow->
RenderUint32(field_name, bit_cast<uint32>(buffer32));
559 if (
field ==
nullptr) {
583 if (
field ==
nullptr) {
605 if (
field ==
nullptr) {
611 if (
field->number() == 1) {
616 }
else if (
field->number() == 2) {
639 "Invalid Any, the type_url is missing.");
645 if (!resolved_type.
ok()) {
649 resolved_type.
status().message());
681 uint32 paths_field_tag = 0;
684 if (paths_field_tag == 0) {
686 if (
field !=
nullptr &&
field->number() == 1 &&
687 field->name() ==
"paths") {
688 paths_field_tag = tag;
691 if (paths_field_tag != tag) {
693 "Invalid FieldMask, unexpected field.");
698 if (!combined.empty()) {
699 combined.append(
",");
708 std::unordered_map<std::string, ProtoStreamObjectSource::TypeRenderer>*
716 (*renderers_)[
"google.protobuf.Timestamp"] =
718 (*renderers_)[
"google.protobuf.Duration"] =
720 (*renderers_)[
"google.protobuf.DoubleValue"] =
722 (*renderers_)[
"google.protobuf.FloatValue"] =
724 (*renderers_)[
"google.protobuf.Int64Value"] =
726 (*renderers_)[
"google.protobuf.UInt64Value"] =
728 (*renderers_)[
"google.protobuf.Int32Value"] =
730 (*renderers_)[
"google.protobuf.UInt32Value"] =
732 (*renderers_)[
"google.protobuf.BoolValue"] =
734 (*renderers_)[
"google.protobuf.StringValue"] =
736 (*renderers_)[
"google.protobuf.BytesValue"] =
739 (*renderers_)[
"google.protobuf.Struct"] =
741 (*renderers_)[
"google.protobuf.Value"] =
743 (*renderers_)[
"google.protobuf.ListValue"] =
745 (*renderers_)[
"google.protobuf.FieldMask"] =
777 if (
type ==
nullptr) {
780 StrCat(
"Invalid configuration. Could not find the type: ",
788 if (type_renderer !=
nullptr) {
797 "Nested protocol message not parsed in its entirety.");
815 switch (
field->kind()) {
823 ow->
RenderInt32(field_name, bit_cast<int32>(buffer32));
828 ow->
RenderInt64(field_name, bit_cast<int64>(buffer64));
833 ow->
RenderUint32(field_name, bit_cast<uint32>(buffer32));
838 ow->
RenderUint64(field_name, bit_cast<uint64>(buffer64));
853 ow->
RenderInt32(field_name, bit_cast<int32>(buffer32));
858 ow->
RenderInt64(field_name, bit_cast<int64>(buffer64));
863 ow->
RenderUint32(field_name, bit_cast<uint32>(buffer32));
868 ow->
RenderUint64(field_name, bit_cast<uint64>(buffer64));
873 ow->
RenderFloat(field_name, bit_cast<float>(buffer32));
878 ow->
RenderDouble(field_name, bit_cast<double>(buffer64));
899 FindEnumValueByNumber(*en, buffer32);
900 if (enum_value !=
nullptr) {
939 switch (
field.kind()) {
943 result = buffer64 != 0 ?
"true" :
"false";
949 result =
StrCat(bit_cast<int32>(buffer32));
955 result =
StrCat(bit_cast<int64>(buffer64));
961 result =
StrCat(bit_cast<uint32>(buffer32));
967 result =
StrCat(bit_cast<uint64>(buffer64));
985 result =
StrCat(bit_cast<int32>(buffer32));
991 result =
StrCat(bit_cast<int64>(buffer64));
997 result =
StrCat(bit_cast<uint32>(buffer32));
1003 result =
StrCat(bit_cast<uint64>(buffer64));
1009 result =
SimpleFtoa(bit_cast<float>(buffer32));
1015 result =
SimpleDtoa(bit_cast<double>(buffer64));
1027 if (en !=
nullptr) {
1029 FindEnumValueByNumber(*en, buffer32);
1030 if (enum_value !=
nullptr) {
1031 result = enum_value->name();
1069 int64 signed_seconds = 0;
1070 int32 signed_nanos = 0;
1074 if (
field ==
nullptr) {
1080 if (
field->number() == 1) {
1083 signed_seconds = bit_cast<int64>(seconds);
1084 }
else if (
field->number() == 2) {
1087 signed_nanos = bit_cast<int32>(nanos);
1090 return std::pair<int64, int32>(signed_seconds, signed_nanos);
1098 StrCat(
"Message too deep. Max recursion depth reached for type '",
1099 type_name,
"', field '", field_name,
"'"));
1108 for (
int i = 0;
i <
type.fields_size(); ++
i) {
1110 return &
type.fields(
i);
1119 return field.cardinality() ==
1128 for (
int i = 0;
i < tech_enum.enumvalue_size(); ++
i) {
1130 if (ev.number() ==
number) {
1141 return with_trailing_zeros ?
".000" :
"";
1145 (nanos % 1000 != 0) ?
"%.9f" : (nanos % 1000000 != 0) ?
"%.6f" :
"%.3f";
1149 return formatted.substr(1);
GLuint const GLchar * name
const Descriptor::ReservedRange value
static util::Status RenderUInt32(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
virtual ObjectWriter * StartList(StringPiece name)=0
string SimpleDtoa(double value)
@ Field_Kind_TYPE_SFIXED64
std::string ToCamelCase(const StringPiece input)
static util::Status RenderFieldMask(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
const T & ValueOrDie() const
zend_class_entry * field_type
static util::Status RenderInt32(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
string StrCat(const AlphaNum &a, const AlphaNum &b)
virtual const google::protobuf::Enum * GetEnumByTypeUrl(StringPiece type_url) const =0
GLenum GLuint GLenum GLsizei length
static util::Status RenderInt64(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
bool use_lower_camel_for_enums_
@ Field_Kind_TYPE_FIXED32
util::Status RenderPacked(const google::protobuf::Field *field, ObjectWriter *ow) const
@ Field_Kind_TYPE_SFIXED32
virtual ObjectWriter * RenderUint64(StringPiece name, uint64 value)=0
~ProtoStreamObjectSource() override
static util::Status RenderUInt64(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
const Status & status() const
static util::Status RenderBytes(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
static TypeRenderer * FindTypeRenderer(const std::string &type_url)
static util::Status RenderFloat(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
const int64 kTimestampMaxSeconds
@ Field_Kind_TYPE_MESSAGE
void set_preserve_proto_field_names(bool value)
void call_once(Args &&... args)
#define ASSIGN_OR_RETURN(lhs, rexpr)
static util::Status RenderDuration(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
GLsizei const GLchar *const * string
static std::unordered_map< std::string, TypeRenderer > * renderers_
bool add_trailing_zeros_for_timestamp_and_duration_
util::Status IncrementRecursionDepth(StringPiece type_name, StringPiece field_name) const
const int64 kDurationMaxSeconds
void set_use_ints_for_enums(bool value)
const int64 kDurationMinSeconds
virtual util::StatusOr< const google::protobuf::Type * > ResolveTypeUrl(StringPiece type_url) const =0
util::Status(* TypeRenderer)(const ProtoStreamObjectSource *, const google::protobuf::Type &, StringPiece, ObjectWriter *)
virtual const google::protobuf::Type * GetTypeByTypeUrl(StringPiece type_url) const =0
void OnShutdown(void(*func)())
virtual ObjectWriter * RenderDouble(StringPiece name, double value)=0
bool IsMap(const google::protobuf::Field &field) const
virtual ObjectWriter * RenderBool(StringPiece name, bool value)=0
virtual ObjectWriter * RenderInt32(StringPiece name, int32 value)=0
virtual util::Status WriteMessage(const google::protobuf::Type &descriptor, StringPiece name, const uint32 end_tag, bool include_start_and_end, ObjectWriter *ow) const
const Collection::value_type::second_type * FindOrNull(const Collection &collection, const typename Collection::value_type::first_type &key)
virtual ObjectWriter * StartObject(StringPiece name)=0
static void InitRendererMap()
static util::Status RenderString(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
static bool IsTypePackable(Type field_type)
GLint GLint GLsizei GLint GLenum format
static util::Status RenderTimestamp(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
static util::Status RenderStructValue(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
bool IsMap(const google::protobuf::Field &field, const google::protobuf::Type &type)
virtual ObjectWriter * EndList()=0
@ Field_Kind_TYPE_FIXED64
@ Field_Cardinality_CARDINALITY_REPEATED
virtual util::StatusOr< uint32 > RenderList(const google::protobuf::Field *field, StringPiece name, uint32 list_tag, ObjectWriter *ow) const
bool render_unknown_enum_values_
static util::Status RenderBool(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
util::Status NamedWriteTo(StringPiece name, ObjectWriter *ow) const override
string StringPrintf(const char *format,...)
std::string EnumValueNameToLowerCamelCase(const StringPiece input)
string SimpleFtoa(float value)
const FieldDescriptor * field
static void DeleteRendererMap()
static const int kDefaultMaxRecursionDepth
const std::string ReadFieldValueAsString(const google::protobuf::Field &field) const
Status
Status of any operation that the TOF sdk performs.
bool suppress_empty_object_
virtual ObjectWriter * RenderBytes(StringPiece name, StringPiece value)=0
std::pair< int64, int32 > ReadSecondsAndNanos(const google::protobuf::Type &type) const
virtual ObjectWriter * RenderNull(StringPiece name)=0
virtual ObjectWriter * RenderString(StringPiece name, StringPiece value)=0
const google::protobuf::Type & type_
static util::Status RenderDouble(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
const google::protobuf::Field * FindAndVerifyField(const google::protobuf::Type &type, uint32 tag) const
const int64 kTimestampMinSeconds
#define GOOGLE_LOG_IF(LEVEL, CONDITION)
std::string ConvertFieldMaskPath(const StringPiece path, ConverterCallback converter)
util::StatusOr< uint32 > RenderMap(const google::protobuf::Field *field, StringPiece name, uint32 list_tag, ObjectWriter *ow) const
util::Status RenderNonMessageField(const google::protobuf::Field *field, StringPiece field_name, ObjectWriter *ow) const
virtual util::Status RenderField(const google::protobuf::Field *field, StringPiece field_name, ObjectWriter *ow) const
static util::Status RenderStruct(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
bool preserve_proto_field_names_
bool render_unknown_fields_
virtual ObjectWriter * RenderUint32(StringPiece name, uint32 value)=0
string FormatTime(int64 seconds, int32 nanos)
const int32 kNanosPerSecond
const TypeInfo * typeinfo_
GLsizei const GLfloat * value
static util::Status RenderAny(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
#define RETURN_IF_ERROR(expr)
static util::Status RenderStructListValue(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
void set_use_lower_camel_for_enums(bool value)
ProtoStreamObjectSource(io::CodedInputStream *stream, TypeResolver *type_resolver, const google::protobuf::Type &type)
const char kStructNullValueTypeUrl[]
io::CodedInputStream * stream_
virtual ObjectWriter * RenderFloat(StringPiece name, float value)=0
PROTOBUF_NAMESPACE_ID::internal::once_flag source_renderers_init_
virtual ObjectWriter * EndObject()=0
virtual ObjectWriter * RenderInt64(StringPiece name, int64 value)=0
libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:58