| 119 | } |
| 120 | |
| 121 | void StructArray::getFieldByName(libmexclass::proxy::method::Context& context) { |
| 122 | namespace mda = ::matlab::data; |
| 123 | using libmexclass::proxy::ProxyManager; |
| 124 | |
| 125 | mda::StructArray args = context.inputs[0]; |
| 126 | |
| 127 | const mda::StringArray name_mda = args[0]["Name"]; |
| 128 | const auto name_utf16 = std::u16string(name_mda[0]); |
| 129 | MATLAB_ASSIGN_OR_ERROR_WITH_CONTEXT(const auto name, |
| 130 | arrow::util::UTF16StringToUTF8(name_utf16), context, |
| 131 | error::UNICODE_CONVERSION_ERROR_ID); |
| 132 | |
| 133 | auto struct_array = std::static_pointer_cast<arrow::StructArray>(array); |
| 134 | auto field_array = struct_array->GetFieldByName(name); |
| 135 | if (!field_array) { |
| 136 | // Return an error if we could not query the field by name. |
| 137 | const auto msg = "Could not find field named " + name + "."; |
| 138 | context.error = |
| 139 | libmexclass::error::Error{error::ARROW_TABULAR_SCHEMA_AMBIGUOUS_FIELD_NAME, msg}; |
| 140 | return; |
| 141 | } |
| 142 | |
| 143 | // Wrap the array within a proxy object if possible. |
| 144 | MATLAB_ASSIGN_OR_ERROR_WITH_CONTEXT(context.outputs[0], |
| 145 | arrow::matlab::proxy::wrap_and_manage(field_array), |
| 146 | context, error::UNKNOWN_PROXY_FOR_ARRAY_TYPE); |
| 147 | } |
| 148 | |
| 149 | void StructArray::getFieldNames(libmexclass::proxy::method::Context& context) { |
| 150 | namespace mda = ::matlab::data; |
nothing calls this directly
no test coverage detected