MCPcopy Create free account
hub / github.com/apache/fory / read_null_only_flag

Function read_null_only_flag

cpp/fory/serialization/serializer.h:122–153  ·  view source on GitHub ↗

Read ref flag for NullOnly mode. Returns true if value present, false if null or error. Fast path: primitives, strings, time types use this.

Source from the content-addressed store, hash-verified

120/// Returns true if value present, false if null or error.
121/// Fast path: primitives, strings, time types use this.
122FORY_ALWAYS_INLINE bool read_null_only_flag(ReadContext &ctx,
123 RefMode ref_mode) {
124 if (ref_mode == RefMode::None) {
125 return true;
126 }
127 int8_t flag = ctx.read_int8(ctx.error());
128 if (FORY_PREDICT_FALSE(ctx.has_error())) {
129 return false;
130 }
131 if (flag == NULL_FLAG) {
132 return false;
133 }
134 // NotNullValue or RefValue both mean "continue reading" for non-trackable
135 // types
136 if (flag == NOT_NULL_VALUE_FLAG || flag == REF_VALUE_FLAG) {
137 return true;
138 }
139 if (flag == REF_FLAG) {
140 uint32_t ref_id = ctx.read_var_uint32(ctx.error());
141 if (FORY_PREDICT_FALSE(ctx.has_error())) {
142 return false;
143 }
144 ctx.set_error(Error::invalid_ref(
145 "Unexpected reference flag for non-referencable value, ref id: " +
146 std::to_string(ref_id)));
147 return false;
148 }
149
150 ctx.set_error(Error::invalid_data("Unknown reference flag: " +
151 std::to_string(static_cast<int>(flag))));
152 return false;
153}
154
155// ============================================================================
156// Type Info Helpers

Callers 15

readMethod · 0.85
readMethod · 0.85
readMethod · 0.85
readMethod · 0.85
readMethod · 0.85
readMethod · 0.85
readMethod · 0.85
readMethod · 0.85
readMethod · 0.85
readMethod · 0.85
readMethod · 0.85
readMethod · 0.85

Calls 5

errorMethod · 0.65
read_int8Method · 0.45
has_errorMethod · 0.45
read_var_uint32Method · 0.45
set_errorMethod · 0.45

Tested by 1

readMethod · 0.68