1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU 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, see <http://www.gnu.org/licenses/>. */
22 #include <data/missing-values.h>
29 VAR_NUMERIC, /* A numeric variable. */
30 VAR_STRING /* A string variable. */
33 bool var_type_is_valid (enum var_type);
34 enum var_type var_type_from_width (int width);
37 struct variable *var_create (const char *name, int width);
38 struct variable *var_clone (const struct variable *);
39 void var_destroy (struct variable *);
42 Long variable names can be used in most contexts, but a few
43 procedures and file formats are limited to short names. */
44 #define SHORT_NAME_LEN 8
45 #define LONG_NAME_LEN 64
47 const char *var_get_name (const struct variable *);
48 void var_set_name (struct variable *, const char *);
49 bool var_is_valid_name (const char *, bool issue_error);
50 bool var_is_plausible_name (const char *name, bool issue_error);
52 int compare_vars_by_name (const void *, const void *, const void *);
53 unsigned hash_var_by_name (const void *, const void *);
55 int compare_var_ptrs_by_name (const void *, const void *, const void *);
56 unsigned hash_var_ptr_by_name (const void *, const void *);
58 /* Variable types and widths. */
59 enum var_type var_get_type (const struct variable *);
60 int var_get_width (const struct variable *);
61 void var_set_width (struct variable *, int width);
63 typedef bool var_predicate_func (const struct variable *);
65 bool var_is_numeric (const struct variable *);
66 bool var_is_alpha (const struct variable *);
67 bool var_is_short_string (const struct variable *);
68 bool var_is_long_string (const struct variable *);
69 size_t var_get_value_cnt (const struct variable *);
71 /* Variables' missing values. */
72 const struct missing_values *var_get_missing_values (const struct variable *);
73 void var_set_missing_values (struct variable *, const struct missing_values *);
74 void var_clear_missing_values (struct variable *);
75 bool var_has_missing_values (const struct variable *);
77 bool var_is_value_missing (const struct variable *, const union value *,
79 bool var_is_num_missing (const struct variable *, double, enum mv_class);
80 bool var_is_str_missing (const struct variable *, const char[], enum mv_class);
83 const struct val_labs *var_get_value_labels (const struct variable *);
84 bool var_has_value_labels (const struct variable *);
85 void var_set_value_labels (struct variable *, const struct val_labs *);
86 bool var_add_value_label (struct variable *,
87 const union value *, const char *);
88 void var_replace_value_label (struct variable *,
89 const union value *, const char *);
90 void var_clear_value_labels (struct variable *);
91 const char *var_lookup_value_label (const struct variable *,
93 const char *var_get_value_name (const struct variable *, const union value *);
95 /* Print and write formats. */
96 const struct fmt_spec *var_get_print_format (const struct variable *);
97 void var_set_print_format (struct variable *, const struct fmt_spec *);
98 const struct fmt_spec *var_get_write_format (const struct variable *);
99 void var_set_write_format (struct variable *, const struct fmt_spec *);
100 void var_set_both_formats (struct variable *, const struct fmt_spec *);
102 /* Variable labels. */
103 const char *var_to_string (const struct variable *);
104 const char *var_get_label (const struct variable *);
105 void var_set_label (struct variable *, const char *);
106 void var_clear_label (struct variable *);
107 bool var_has_label (const struct variable *);
109 /* How data is measured. */
118 bool measure_is_valid (enum measure);
119 enum measure var_get_measure (const struct variable *);
120 void var_set_measure (struct variable *, enum measure);
122 /* GUI display width. */
123 int var_get_display_width (const struct variable *);
124 void var_set_display_width (struct variable *, int display_width);
126 int var_default_display_width (int width);
128 /* Alignment of data for display. */
137 bool alignment_is_valid (enum alignment);
138 enum alignment var_get_alignment (const struct variable *);
139 void var_set_alignment (struct variable *, enum alignment);
141 /* Whether variables' values should be preserved from case to
143 bool var_get_leave (const struct variable *);
144 void var_set_leave (struct variable *, bool leave);
145 bool var_must_leave (const struct variable *);
148 size_t var_get_short_name_cnt (const struct variable *);
149 const char *var_get_short_name (const struct variable *, size_t idx);
150 void var_set_short_name (struct variable *, size_t, const char *);
151 void var_clear_short_names (struct variable *);
153 /* Relationship with dictionary. */
154 size_t var_get_dict_index (const struct variable *);
155 size_t var_get_case_index (const struct variable *);
157 /* Variable auxiliary data. */
158 void *var_get_aux (const struct variable *);
159 void *var_attach_aux (const struct variable *,
160 void *aux, void (*aux_dtor) (struct variable *));
161 void var_clear_aux (struct variable *);
162 void *var_detach_aux (struct variable *);
163 void var_dtor_free (struct variable *);
165 /* Observed categorical values. */
166 struct cat_vals *var_get_obs_vals (const struct variable *);
167 void var_set_obs_vals (const struct variable *, struct cat_vals *);
168 bool var_has_obs_vals (const struct variable *);
170 /* Classes of variables. */
173 DC_ORDINARY, /* Ordinary identifier. */
174 DC_SYSTEM, /* System variable. */
175 DC_SCRATCH /* Scratch variable. */
178 enum dict_class dict_class_from_id (const char *name);
179 const char *dict_class_to_name (enum dict_class dict_class);
181 #endif /* !variable.h */