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);
65 typedef bool var_predicate_func (const struct variable *);
67 bool var_is_numeric (const struct variable *);
68 bool var_is_alpha (const struct variable *);
69 bool var_is_short_string (const struct variable *);
70 bool var_is_long_string (const struct variable *);
71 size_t var_get_value_cnt (const struct variable *);
73 /* Variables' missing values. */
74 const struct missing_values *var_get_missing_values (const struct variable *);
75 void var_set_missing_values (struct variable *, const struct missing_values *);
76 void var_clear_missing_values (struct variable *);
77 bool var_has_missing_values (const struct variable *);
79 bool var_is_value_missing (const struct variable *, const union value *,
81 bool var_is_num_missing (const struct variable *, double, enum mv_class);
82 bool var_is_str_missing (const struct variable *, const char[], enum mv_class);
85 const struct val_labs *var_get_value_labels (const struct variable *);
86 bool var_has_value_labels (const struct variable *);
87 void var_set_value_labels (struct variable *, const struct val_labs *);
88 bool var_add_value_label (struct variable *,
89 const union value *, const char *);
90 void var_replace_value_label (struct variable *,
91 const union value *, const char *);
92 void var_clear_value_labels (struct variable *);
93 const char *var_lookup_value_label (const struct variable *,
95 const char *var_get_value_name (const struct variable *, const union value *);
97 /* Print and write formats. */
98 const struct fmt_spec *var_get_print_format (const struct variable *);
99 void var_set_print_format (struct variable *, const struct fmt_spec *);
100 const struct fmt_spec *var_get_write_format (const struct variable *);
101 void var_set_write_format (struct variable *, const struct fmt_spec *);
102 void var_set_both_formats (struct variable *, const struct fmt_spec *);
104 /* Variable labels. */
105 const char *var_to_string (const struct variable *);
106 const char *var_get_label (const struct variable *);
107 void var_set_label (struct variable *, const char *);
108 void var_clear_label (struct variable *);
109 bool var_has_label (const struct variable *);
111 /* How data is measured. */
120 bool measure_is_valid (enum measure);
121 enum measure var_get_measure (const struct variable *);
122 void var_set_measure (struct variable *, enum measure);
124 /* GUI display width. */
125 int var_get_display_width (const struct variable *);
126 void var_set_display_width (struct variable *, int display_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 const char *var_get_short_name (const struct variable *);
149 void var_set_short_name (struct variable *, const char *);
150 void var_clear_short_name (struct variable *);
152 /* Relationship with dictionary. */
153 size_t var_get_dict_index (const struct variable *);
154 size_t var_get_case_index (const struct variable *);
156 /* Variable auxiliary data. */
157 void *var_get_aux (const struct variable *);
158 void *var_attach_aux (struct variable *,
159 void *aux, void (*aux_dtor) (struct variable *));
160 void var_clear_aux (struct variable *);
161 void *var_detach_aux (struct variable *);
162 void var_dtor_free (struct variable *);
164 /* Observed categorical values. */
165 struct cat_vals *var_get_obs_vals (const struct variable *);
166 void var_set_obs_vals (struct variable *, struct cat_vals *);
167 bool var_has_obs_vals (const struct variable *);
169 /* Classes of variables. */
172 DC_ORDINARY, /* Ordinary identifier. */
173 DC_SYSTEM, /* System variable. */
174 DC_SCRATCH /* Scratch variable. */
177 enum dict_class dict_class_from_id (const char *name);
178 const char *dict_class_to_name (enum dict_class dict_class);
180 #endif /* !variable.h */