Categorical value cache added
[pspp-builds.git] / src / missing-values.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2005 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301, USA. */
19
20 #if !missing_values_h
21 #define missing_values_h 1
22
23 #include <stdbool.h>
24 #include "val.h"
25
26 /* Types of user-missing values.
27    Invisible--use access functions defined below instead. */
28 enum mv_type 
29   {
30     MV_NONE = 0,                /* No user-missing values. */
31     MV_1 = 1,                   /* One user-missing value. */
32     MV_2 = 2,                   /* Two user-missing values. */
33     MV_3 = 3,                   /* Three user-missing values. */
34     MV_RANGE = 4,               /* A range of user-missing values. */
35     MV_RANGE_1 = 5              /* A range plus an individual value. */
36   };
37
38 /* Missing values.
39    Opaque--use access functions defined below. */
40 struct missing_values 
41   {
42     unsigned type;              /* Number and type of missing values. */
43     int width;                  /* 0=numeric, otherwise string width. */
44     union value values[3];      /* Missing values.  [y,z] are the range. */
45   };
46
47 void mv_init (struct missing_values *, int width);
48 void mv_copy (struct missing_values *, const struct missing_values *);
49 bool mv_is_empty (const struct missing_values *);
50 int mv_get_width (const struct missing_values *);
51
52 bool mv_add_value (struct missing_values *, const union value *);
53 bool mv_add_str (struct missing_values *, const char[]);
54 bool mv_add_num (struct missing_values *, double);
55 bool mv_add_num_range (struct missing_values *, double low, double high);
56
57 bool mv_has_value (struct missing_values *);
58 void mv_pop_value (struct missing_values *, union value *);
59 bool mv_has_range (struct missing_values *);
60 void mv_pop_range (struct missing_values *, double *low, double *high);
61
62 bool mv_is_resizable (struct missing_values *, int width);
63 void mv_resize (struct missing_values *, int width);
64
65 typedef bool is_missing_func (const struct missing_values *,
66                               const union value *);
67
68 /* Is a value system or user missing? */
69 bool mv_is_value_missing (const struct missing_values *, const union value *);
70 bool mv_is_num_missing (const struct missing_values *, double);
71 bool mv_is_str_missing (const struct missing_values *, const char[]);
72
73 /* Is a value user missing? */
74 bool mv_is_value_user_missing (const struct missing_values *,
75                                const union value *);
76 bool mv_is_num_user_missing (const struct missing_values *, double);
77 bool mv_is_str_user_missing (const struct missing_values *, const char[]);
78
79 /* Is a value system missing? */
80 bool mv_is_value_system_missing (const struct missing_values *,
81                                  const union value *);
82
83 #endif /* missing-values.h */