struct pivot_splits_var
{
struct pivot_dimension *dimension;
- char *name;
+ const struct variable *var;
int width;
- size_t idx;
- struct fmt_spec format;
struct hmap values;
};
*psvar = (struct pivot_splits_var) {
.width = var_get_width (var),
- .name = xstrdup (var_get_name (var)),
- .idx = var_get_case_index (var),
- .format = *var_get_print_format (var),
.values = HMAP_INITIALIZER (psvar->values),
.dimension = d,
+ .var = var,
};
}
hmap_delete (&psvar->values, &psval->hmap_node);
free (psval);
}
- free (psvar->name);
hmap_destroy (&psvar->values);
}
free (ps->vars);
for (size_t i = 0; i < ps->n; i++)
{
struct pivot_splits_var *psvar = &ps->vars[i];
- const union value *value = case_data_idx (example, psvar->idx);
+ const union value *value = case_data (example, psvar->var);
struct pivot_splits_value *psval = pivot_splits_value_find (psvar, value);
if (!psval)
{
value_clone (&psval->value, value, psvar->width);
psval->leaf = pivot_category_create_leaf (
psvar->dimension->root,
- pivot_value_new_value (value, psvar->width, &psvar->format,
- ps->encoding));
+ pivot_value_new_var_value (psvar->var, value));
n_new++;
}
ds_put_cstr (&s, ", ");
struct pivot_splits_var *psvar = &ps->vars[i];
- const union value *value = case_data_idx (example, psvar->idx);
- ds_put_format (&s, "%s = ", psvar->name);
+ const union value *value = case_data (example, psvar->var);
+ ds_put_format (&s, "%s = ", var_get_name (psvar->var));
- char *s2 = data_out (value, ps->encoding, &psvar->format,
+ char *s2 = data_out (value, ps->encoding,
+ var_get_print_format (psvar->var),
settings_get_fmt_settings ());
ds_put_cstr (&s, s2 + strspn (s2, " "));
free (s2);
}
struct pivot_splits_var *psvar = &ps->vars[0];
- const union value *value = case_data_idx (example, psvar->idx);
+ const union value *value = case_data (example, psvar->var);
ps->dindexes[0] = pivot_category_create_leaf (
psvar->dimension->root,
- pivot_value_new_value (value, psvar->width, &psvar->format,
- ps->encoding));
+ pivot_value_new_var_value (psvar->var, value));
}
}