MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / structToString

Function structToString

src/common/type_utils.cpp:231–267  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

229
230template<bool SKIP_NULL_ENTRY>
231static std::string structToString(const struct_entry_t& val, ValueVector* vector) {
232 const auto& fields = StructType::getFields(vector->dataType);
233 if (fields.size() == 0) {
234 return "{}";
235 }
236 std::string result = "{";
237 auto i = 0u;
238 for (; i < fields.size() - 1; ++i) {
239 auto fieldVector = StructVector::getFieldVector(vector, i);
240 if constexpr (SKIP_NULL_ENTRY) {
241 if (fieldVector->isNull(val.pos)) {
242 continue;
243 }
244 }
245 if (i != 0) {
246 result += ", ";
247 }
248 result += StructType::getField(vector->dataType, i).getName();
249 result += ": ";
250 result += entryToStringWithPos(val.pos, fieldVector.get());
251 }
252 auto fieldVector = StructVector::getFieldVector(vector, i);
253 if constexpr (SKIP_NULL_ENTRY) {
254 if (fieldVector->isNull(val.pos)) {
255 result += "}";
256 return result;
257 }
258 }
259 if (i != 0) {
260 result += ", ";
261 }
262 result += StructType::getField(vector->dataType, i).getName();
263 result += ": ";
264 result += entryToStringWithPos(val.pos, fieldVector.get());
265 result += "}";
266 return result;
267}
268
269std::string TypeUtils::nodeToString(const struct_entry_t& val, ValueVector* vector) {
270 // Internal ID vector is the first field vector.

Callers 1

toStringMethod · 0.85

Calls 5

entryToStringWithPosFunction · 0.85
sizeMethod · 0.45
isNullMethod · 0.45
getNameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected