struct file_handle *fh =
fh_create_file (NULL, name, fh_default_properties () );
struct sysfile_info *sfi = xmalloc (sizeof (*sfi));
+ dict_set_encoding (dict, "UTF-8");
sfi->writer = sfm_open_writer (fh, dict, opts);
sfi->dict = dict;
sfi->opened = true;
=head3 new ($dict, $name, %input_fmt)
Creates and returns a new variable in the dictionary C<dict>. The
-new variable will have the name C<name>.
+new variable will have the name C<name>. C<name> must be a valid UTF8 string.
The input format is set by the C<input_fmt> parameter
(See L</PSPP::Fmt>).
By default, the write and print formats are the same as the input format.
=head3 set_label ($label)
-Sets the variable label to C<label>.
+Sets the variable label to C<label>, which must be a valid UTF8 string.
=cut
=head3 add_value_label ($key, $label)
Adds the value label C<label> to the variable for the value C<key>.
+C<label> must be a valid UTF8 string.
On error the subroutine returns zero.
=head3 add_value_labels (@array)
=pod
-=head3 set_value_labels ($key, $value)
+=head3 set_value_labels ($key, $label)
C<Set_value_labels> is identical to calling L</clear_value_labels>
followed by L</add_value_labels>.
Appends a case to the system file.
C<Case> is an array of scalars, each of which are the values of
the variables in the dictionary corresponding to the system file.
+If the case contains strings, then the strings must be UTF8 encoded.
The special value C<PSPP::SYSMIS> may be used to indicate that a value
is system missing.
If the array contains less elements than variables in the dictionary,
Returns a scalar containing a string representing C<value> formatted according
to the print format of C<variable>.
-In the most common ussage, C<value> should be a value of C<variable>.
+In the most common usage, C<value> should be a value of C<variable>.
=head3 PSPP::value_is_missing ($value, $variable)
#include <gtk/gtk.h>
#include <ui/gui/psppire-marshal.h>
+#include "psppire-var-ptr.h"
#include "psppire-dict.h"
#include <data/dictionary.h>
#include <data/missing-values.h>
return G_TYPE_STRING;
break;
case DICT_TVM_COL_VAR:
- return G_TYPE_POINTER;
+ return PSPPIRE_VAR_PTR_TYPE;
break;
default:
g_return_val_if_reached ((GType)0);
}
break;
case DICT_TVM_COL_VAR:
- g_value_init (value, G_TYPE_POINTER);
- g_value_set_pointer (value, var);
+ g_value_init (value, PSPPIRE_VAR_PTR_TYPE);
+ g_value_set_boxed (value, var);
break;
default:
g_return_if_reached ();
g_object_class_install_property (object_class,
PROP_N_COLS,
n_cols_spec);
-
}
return n_vars;
}
+/* Returns TRUE iff VV contains the item V.
+ V must be an initialised value containing a
+ PSPPIRE_VAR_PTR_TYPE.
+*/
+gboolean
+psppire_var_view_contains_var (PsppireVarView *vv, const GValue *v)
+{
+ gboolean ok;
+ GtkTreeIter iter;
+ g_return_val_if_fail (G_VALUE_HOLDS (v, PSPPIRE_VAR_PTR_TYPE), FALSE);
+
+ for (ok = psppire_var_view_get_iter_first (vv, &iter);
+ ok;
+ ok = psppire_var_view_get_iter_next (vv, &iter))
+ {
+ const struct variable *var = psppire_var_view_get_variable (vv, 0, &iter);
+ if (var == g_value_get_boxed (v))
+ return TRUE;
+ }
+
+ return FALSE;
+}
GType psppire_var_view_get_type (void);
+gboolean psppire_var_view_contains_var (PsppireVarView *vv, const GValue *v);
+
gint psppire_var_view_append_names (PsppireVarView *vv, gint column, GString *string);
+
gboolean psppire_var_view_get_iter_first (PsppireVarView *vv, GtkTreeIter *iter);
+
gboolean psppire_var_view_get_iter_next (PsppireVarView *vv, GtkTreeIter *iter);
+
const struct variable * psppire_var_view_get_variable (PsppireVarView *vv, gint column, GtkTreeIter *iter);