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

Function lbug_value_get_struct_field_name

src/c_api/value.cpp:526–542  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

524}
525
526lbug_state lbug_value_get_struct_field_name(lbug_value* value, uint64_t index, char** out_result) {
527 auto physical_type_id = static_cast<Value*>(value->_value)->getDataType().getPhysicalType();
528 if (physical_type_id != PhysicalTypeID::STRUCT) {
529 return LbugError;
530 }
531 auto val = static_cast<Value*>(value->_value);
532 const auto& data_type = val->getDataType();
533 if (index >= StructType::getNumFields(data_type)) {
534 return LbugError;
535 }
536 std::string struct_field_name = StructType::getFields(data_type)[index].getName();
537 if (struct_field_name.empty()) {
538 return LbugError;
539 }
540 *out_result = convertToOwnedCString(struct_field_name);
541 return LbugSuccess;
542}
543
544lbug_state lbug_value_get_struct_field_index(lbug_value* value, const char* field_name,
545 uint64_t* out_result) {

Callers 1

TEST_FFunction · 0.85

Calls 5

convertToOwnedCStringFunction · 0.85
getDataTypeMethod · 0.80
getPhysicalTypeMethod · 0.45
getNameMethod · 0.45
emptyMethod · 0.45

Tested by 1

TEST_FFunction · 0.68