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
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 typedef bool var_is_missing_func (const struct variable *,
78 bool var_is_value_missing (const struct variable *, const union value *);
79 bool var_is_num_missing (const struct variable *, double);
80 bool var_is_str_missing (const struct variable *, const char[]);
81 bool var_is_value_user_missing (const struct variable *,
83 bool var_is_num_user_missing (const struct variable *, double);
84 bool var_is_str_user_missing (const struct variable *, const char[]);
85 bool var_is_value_system_missing (const struct variable *,
89 const struct val_labs *var_get_value_labels (const struct variable *);
90 bool var_has_value_labels (const struct variable *);
91 void var_set_value_labels (struct variable *, const struct val_labs *);
92 bool var_add_value_label (struct variable *,
93 const union value *, const char *);
94 void var_replace_value_label (struct variable *,
95 const union value *, const char *);
96 void var_clear_value_labels (struct variable *);
97 const char *var_lookup_value_label (const struct variable *,
99 const char *var_get_value_name (const struct variable *, const union value *);
101 /* Print and write formats. */
102 const struct fmt_spec *var_get_print_format (const struct variable *);
103 void var_set_print_format (struct variable *, const struct fmt_spec *);
104 const struct fmt_spec *var_get_write_format (const struct variable *);
105 void var_set_write_format (struct variable *, const struct fmt_spec *);
106 void var_set_both_formats (struct variable *, const struct fmt_spec *);
108 /* Variable labels. */
109 const char *var_to_string (const struct variable *);
110 const char *var_get_label (const struct variable *);
111 void var_set_label (struct variable *, const char *);
112 void var_clear_label (struct variable *);
113 bool var_has_label (const struct variable *);
115 /* How data is measured. */
124 bool measure_is_valid (enum measure);
125 enum measure var_get_measure (const struct variable *);
126 void var_set_measure (struct variable *, enum measure);
128 /* GUI display width. */
129 int var_get_display_width (const struct variable *);
130 void var_set_display_width (struct variable *, int display_width);
132 /* Alignment of data for display. */
141 bool alignment_is_valid (enum alignment);
142 enum alignment var_get_alignment (const struct variable *);
143 void var_set_alignment (struct variable *, enum alignment);
145 /* Whether variables' values should be preserved from case to
147 bool var_get_leave (const struct variable *);
148 void var_set_leave (struct variable *, bool leave);
149 bool var_must_leave (const struct variable *);
152 const char *var_get_short_name (const struct variable *);
153 void var_set_short_name (struct variable *, const char *);
154 void var_clear_short_name (struct variable *);
156 /* Relationship with dictionary. */
157 size_t var_get_dict_index (const struct variable *);
158 size_t var_get_case_index (const struct variable *);
160 /* Variable auxiliary data. */
161 void *var_get_aux (const struct variable *);
162 void *var_attach_aux (struct variable *,
163 void *aux, void (*aux_dtor) (struct variable *));
164 void var_clear_aux (struct variable *);
165 void *var_detach_aux (struct variable *);
166 void var_dtor_free (struct variable *);
168 /* Observed categorical values. */
169 struct cat_vals *var_get_obs_vals (const struct variable *);
170 void var_set_obs_vals (struct variable *, struct cat_vals *);
171 bool var_has_obs_vals (const struct variable *);
173 /* Classes of variables. */
176 DC_ORDINARY, /* Ordinary identifier. */
177 DC_SYSTEM, /* System variable. */
178 DC_SCRATCH /* Scratch variable. */
181 enum dict_class dict_class_from_id (const char *name);
182 const char *dict_class_to_name (enum dict_class dict_class);
184 #endif /* !variable.h */