Added a selectColumn method for finding a column by name

This commit is contained in:
2020-10-06 10:56:29 +01:00
parent 2e17d6f75f
commit abec0e5800
2 changed files with 18 additions and 0 deletions

View File

@@ -358,4 +358,19 @@ int setColumnValue(struct column_data_t *col, uint64_t row, const char *value, s
return 0;
}
struct column_data_t *selectColumn(struct column_data_t **col_data, size_t n_cols, const char *name)
{
struct column_data_t *col = 0;
size_t idx = 0;
size_t name_len = strlen(name);
while (idx < n_cols) {
col = *(col_data + idx);
if (col->name_len == name_len && strncmp(col->name, name, name_len) == 0) {
return *(col_data + idx);
}
idx++;
}
return 0;
}