1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2005 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/>. */
17 /* User-missing values.
19 struct missing_values is an opaque type that represents a set
20 of user-missing values associated with a variable. Valid sets
21 of missing values depend on variable width:
23 - Numeric variables may have up to 3 discrete numeric
24 user-missing values, or a range of numeric values, or a
25 range plus one discrete value.
27 - Short string variables may have up to 3 discrete string
30 - Long string variables may not have user-missing
33 #ifndef DATA_MISSING_VALUES_H
34 #define DATA_MISSING_VALUES_H 1
37 #include "data/value.h"
40 Opaque--use access functions defined below. */
43 int type; /* Types of missing values, one of MVT_*. */
44 int width; /* 0=numeric, otherwise string width. */
45 union value values[3]; /* Missing values. [1], [2] are the range. */
48 /* Classes of missing values. */
51 MV_NEVER = 0, /* Never considered missing. */
52 MV_USER = 1, /* Missing if value is user-missing. */
53 MV_SYSTEM = 2, /* Missing if value is system-missing. */
54 MV_ANY = MV_USER | MV_SYSTEM /* Missing if it is user or system-missing. */
57 /* Is a value missing? */
58 bool mv_is_value_missing (const struct missing_values *, const union value *,
60 bool mv_is_num_missing (const struct missing_values *, double, enum mv_class);
61 bool mv_is_str_missing (const struct missing_values *, const char[],
64 /* Initializing missing value sets. */
65 void mv_init (struct missing_values *, int width);
66 void mv_copy (struct missing_values *, const struct missing_values *);
67 void mv_clear (struct missing_values *);
69 /* Changing width of a missing value set. */
70 bool mv_is_resizable (const struct missing_values *, int width);
71 void mv_resize (struct missing_values *, int width);
73 /* Basic property inspection. */
74 bool mv_is_empty (const struct missing_values *);
75 int mv_get_width (const struct missing_values *);
77 /* Inspecting discrete values. */
78 int mv_n_values (const struct missing_values *);
79 bool mv_has_value (const struct missing_values *);
80 void mv_get_value (const struct missing_values *, union value *, int idx);
82 /* Inspecting ranges. */
83 bool mv_has_range (const struct missing_values *);
84 void mv_get_range (const struct missing_values *, double *low, double *high);
86 /* Adding and modifying discrete values. */
87 bool mv_add_value (struct missing_values *, const union value *);
88 bool mv_add_str (struct missing_values *, const char[]);
89 bool mv_add_num (struct missing_values *, double);
90 void mv_pop_value (struct missing_values *, union value *);
91 void mv_replace_value (struct missing_values *, const union value *, int idx);
93 /* Adding and modifying ranges. */
94 bool mv_add_range (struct missing_values *, double low, double high);
95 void mv_pop_range (struct missing_values *, double *low, double *high);
97 #endif /* data/missing-values.h */