/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2007, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
struct vector **vector; /* Vectors of variables. */
size_t vector_cnt; /* Number of vectors. */
struct attrset attributes; /* Custom attributes. */
+
+ char *encoding; /* Character encoding of string data */
+
const struct dict_callbacks *callbacks; /* Callbacks on dictionary
modification */
void *cb_data ; /* Data passed to callbacks */
+
+ void (*changed) (struct dictionary *, void *); /* Generic change callback */
+ void *changed_data;
};
+
+void
+dict_set_encoding (struct dictionary *d, const char *enc)
+{
+ if (enc)
+ d->encoding = xstrdup (enc);
+}
+
+const char *
+dict_get_encoding (const struct dictionary *d)
+{
+ return d->encoding ;
+}
+
+
+void
+dict_set_change_callback (struct dictionary *d,
+ void (*changed) (struct dictionary *, void*),
+ void *data)
+{
+ d->changed = changed;
+ d->changed_data = data;
+}
+
+
/* Print a representation of dictionary D to stdout, for
debugging purposes. */
void
for (i = 0; i < s->vector_cnt; i++)
d->vector[i] = vector_clone (s->vector[i], s, d);
+ if ( s->encoding)
+ d->encoding = xstrdup (s->encoding);
+
dict_set_attributes (d, dict_get_attributes (s));
return d;
d->var[d->var_cnt++] = v;
hsh_force_insert (d->name_tab, v);
+ if ( d->changed ) d->changed (d, d->changed_data);
if ( d->callbacks && d->callbacks->var_added )
d->callbacks->var_added (d, var_get_dict_index (v), d->cb_data);
vdi.dict_index = dict_index;
var_set_vardict (v, &vdi);
+ if ( d->changed ) d->changed (d, d->changed_data);
if ( d->callbacks && d->callbacks->var_changed )
d->callbacks->var_changed (d, dict_index, d->cb_data);
}
var_clear_vardict (v);
var_destroy (v);
-
+ if ( d->changed ) d->changed (d, d->changed_data);
if (d->callbacks && d->callbacks->var_deleted )
d->callbacks->var_deleted (d, dict_index, case_index, val_cnt, d->cb_data);
}
if (settings_get_algorithm () == ENHANCED)
var_clear_short_names (v);
+ if ( d->changed ) d->changed (d, d->changed_data);
if ( d->callbacks && d->callbacks->var_changed )
d->callbacks->var_changed (d, var_get_dict_index (v), d->cb_data);
}
d->weight = v;
+ if (d->changed) d->changed (d, d->changed_data);
if ( d->callbacks && d->callbacks->weight_changed )
d->callbacks->weight_changed (d,
v ? var_get_dict_index (v) : -1,
d->filter = v;
+ if (d->changed) d->changed (d, d->changed_data);
if ( d->callbacks && d->callbacks->filter_changed )
d->callbacks->filter_changed (d,
v ? var_get_dict_index (v) : -1,
&v, compare_var_ptrs, NULL);
if (orig_count != d->split_cnt)
{
+ if (d->changed) d->changed (d, d->changed_data);
/* We changed the set of split variables so invoke the
callback. */
if (d->callbacks && d->callbacks->split_changed)
d->split = NULL;
}
+ if (d->changed) d->changed (d, d->changed_data);
if ( d->callbacks && d->callbacks->split_changed )
d->callbacks->split_changed (d, d->cb_data);
}
const struct vardict_info *vdi = var_get_vardict (v);
struct dictionary *d = vdi->dict;
+ if ( NULL == d)
+ return;
+
+ if (d->changed ) d->changed (d, d->changed_data);
if ( d->callbacks && d->callbacks->var_changed )
d->callbacks->var_changed (d, var_get_dict_index (v), d->cb_data);
}
dict_pad_values (d, var_get_case_index(v) + 1, delta);
+ if (d->changed) d->changed (d, d->changed_data);
if ( d->callbacks && d->callbacks->var_resized )
d->callbacks->var_resized (d, var_get_dict_index (v), delta, d->cb_data);
}
}
+
+/* Called from variable.c to notify the dictionary that the variable's display width
+ has changed */
+void
+dict_var_display_width_changed (const struct variable *v)
+{
+ if ( var_has_vardict (v))
+ {
+ const struct vardict_info *vdi = var_get_vardict (v);
+ struct dictionary *d;
+
+ d = vdi->dict;
+
+ if (d->changed) d->changed (d, d->changed_data);
+ if ( d->callbacks && d->callbacks->var_display_width_changed )
+ d->callbacks->var_display_width_changed (d, var_get_dict_index (v), d->cb_data);
+ }
+}
+