1 /* PSPP - computes sample statistics.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 #include <data/missing-values.h>
31 VAR_NUMERIC, /* A numeric variable. */
32 VAR_STRING /* A string variable. */
35 bool var_type_is_valid (enum var_type);
36 enum var_type var_type_from_width (int width);
39 struct variable *var_create (const char *name, int width);
40 struct variable *var_clone (const struct variable *);
41 void var_destroy (struct variable *);
44 Long variable names can be used in most contexts, but a few
45 procedures and file formats are limited to short names. */
46 #define SHORT_NAME_LEN 8
47 #define LONG_NAME_LEN 64
49 const char *var_get_name (const struct variable *);
50 void var_set_name (struct variable *, const char *);
51 bool var_is_valid_name (const char *, bool issue_error);
52 bool var_is_plausible_name (const char *name, bool issue_error);
54 int compare_vars_by_name (const void *, const void *, const void *);
55 unsigned hash_var_by_name (const void *, const void *);
57 int compare_var_ptrs_by_name (const void *, const void *, const void *);
58 unsigned hash_var_ptr_by_name (const void *, const void *);
60 /* Variable types and widths. */
61 enum var_type var_get_type (const struct variable *);
62 int var_get_width (const struct variable *);
63 void var_set_width (struct variable *, int width);
64 bool var_is_numeric (const struct variable *);
65 bool var_is_alpha (const struct variable *);
66 bool var_is_short_string (const struct variable *);
67 bool var_is_long_string (const struct variable *);
68 size_t var_get_value_cnt (const struct variable *);
70 /* Variables' missing values. */
71 const struct missing_values *var_get_missing_values (const struct variable *);
72 void var_set_missing_values (struct variable *, const struct missing_values *);
73 void var_clear_missing_values (struct variable *);
74 bool var_has_missing_values (const struct variable *);
76 bool var_is_value_missing (const struct variable *, const union value *,
78 bool var_is_num_missing (const struct variable *, double, enum mv_class);
79 bool var_is_str_missing (const struct variable *, const char[], enum mv_class);
82 const struct val_labs *var_get_value_labels (const struct variable *);
83 bool var_has_value_labels (const struct variable *);
84 void var_set_value_labels (struct variable *, const struct val_labs *);
85 bool var_add_value_label (struct variable *,
86 const union value *, const char *);
87 void var_replace_value_label (struct variable *,
88 const union value *, const char *);
89 void var_clear_value_labels (struct variable *);
90 const char *var_lookup_value_label (const struct variable *,
92 const char *var_get_value_name (const struct variable *, const union value *);
94 /* Print and write formats. */
95 const struct fmt_spec *var_get_print_format (const struct variable *);
96 void var_set_print_format (struct variable *, const struct fmt_spec *);
97 const struct fmt_spec *var_get_write_format (const struct variable *);
98 void var_set_write_format (struct variable *, const struct fmt_spec *);
99 void var_set_both_formats (struct variable *, const struct fmt_spec *);
101 /* Variable labels. */
102 const char *var_to_string (const struct variable *);
103 const char *var_get_label (const struct variable *);
104 void var_set_label (struct variable *, const char *);
105 void var_clear_label (struct variable *);
106 bool var_has_label (const struct variable *);
108 /* How data is measured. */
117 bool measure_is_valid (enum measure);
118 enum measure var_get_measure (const struct variable *);
119 void var_set_measure (struct variable *, enum measure);
121 /* GUI display width. */
122 int var_get_display_width (const struct variable *);
123 void var_set_display_width (struct variable *, int display_width);
125 /* Alignment of data for display. */
134 bool alignment_is_valid (enum alignment);
135 enum alignment var_get_alignment (const struct variable *);
136 void var_set_alignment (struct variable *, enum alignment);
138 /* Whether variables' values should be preserved from case to
140 bool var_get_leave (const struct variable *);
141 void var_set_leave (struct variable *, bool leave);
142 bool var_must_leave (const struct variable *);
145 const char *var_get_short_name (const struct variable *);
146 void var_set_short_name (struct variable *, const char *);
147 void var_clear_short_name (struct variable *);
149 /* Relationship with dictionary. */
150 size_t var_get_dict_index (const struct variable *);
151 size_t var_get_case_index (const struct variable *);
153 /* Variable auxiliary data. */
154 void *var_get_aux (const struct variable *);
155 void *var_attach_aux (struct variable *,
156 void *aux, void (*aux_dtor) (struct variable *));
157 void var_clear_aux (struct variable *);
158 void *var_detach_aux (struct variable *);
159 void var_dtor_free (struct variable *);
161 /* Observed categorical values. */
162 struct cat_vals *var_get_obs_vals (const struct variable *);
163 void var_set_obs_vals (struct variable *, struct cat_vals *);
164 bool var_has_obs_vals (const struct variable *);
166 /* Classes of variables. */
169 DC_ORDINARY, /* Ordinary identifier. */
170 DC_SYSTEM, /* System variable. */
171 DC_SCRATCH /* Scratch variable. */
174 enum dict_class dict_class_from_id (const char *name);
175 const char *dict_class_to_name (enum dict_class dict_class);
177 #endif /* !variable.h */