Remove "Written by Ben Pfaff <blp@gnu.org>" lines everywhere.
[pspp-builds.git] / src / data / missing-values.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2005 Free Software Foundation, Inc.
3
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.
8
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.
13
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
17    02110-1301, USA. */
18
19 #if !missing_values_h
20 #define missing_values_h 1
21
22 #include <stdbool.h>
23 #include "value.h"
24
25 /* Types of user-missing values.
26    Invisible--use access functions defined below instead. */
27 enum mv_type 
28   {
29     MV_NONE = 0,                /* No user-missing values. */
30     MV_1 = 1,                   /* One user-missing value. */
31     MV_2 = 2,                   /* Two user-missing values. */
32     MV_3 = 3,                   /* Three user-missing values. */
33     MV_RANGE = 4,               /* A range of user-missing values. */
34     MV_RANGE_1 = 5              /* A range plus an individual value. */
35   };
36
37 /* Missing values.
38    Opaque--use access functions defined below. */
39 struct missing_values 
40   {
41     unsigned type;              /* Number and type of missing values. */
42     int width;                  /* 0=numeric, otherwise string width. */
43     union value values[3];      /* Missing values.  [y,z] are the range. */
44   };
45
46
47 void mv_init (struct missing_values *, int width);
48 void mv_set_type(struct missing_values *mv, enum mv_type type);
49
50 void mv_copy (struct missing_values *, const struct missing_values *);
51 bool mv_is_empty (const struct missing_values *);
52 int mv_get_width (const struct missing_values *);
53
54 bool mv_add_value (struct missing_values *, const union value *);
55 bool mv_add_str (struct missing_values *, const char[]);
56 bool mv_add_num (struct missing_values *, double);
57 bool mv_add_num_range (struct missing_values *, double low, double high);
58
59 bool mv_has_value (const struct missing_values *);
60 void mv_pop_value (struct missing_values *, union value *);
61 void mv_peek_value (const struct missing_values *mv, union value *v, int idx);
62 void mv_replace_value (struct missing_values *mv, const union value *v, int idx);
63
64 int  mv_n_values (const struct missing_values *mv);
65
66
67 bool mv_has_range (const struct missing_values *);
68 void mv_pop_range (struct missing_values *, double *low, double *high);
69 void mv_peek_range (const struct missing_values *, double *low, double *high);
70
71 bool mv_is_resizable (const struct missing_values *, int width);
72 void mv_resize (struct missing_values *, int width);
73
74 typedef bool mv_is_missing_func (const struct missing_values *,
75                                  const union value *);
76
77 /* Is a value system or user missing? */
78 bool mv_is_value_missing (const struct missing_values *, const union value *);
79 bool mv_is_num_missing (const struct missing_values *, double);
80 bool mv_is_str_missing (const struct missing_values *, const char[]);
81
82 /* Is a value user missing? */
83 bool mv_is_value_user_missing (const struct missing_values *,
84                                const union value *);
85 bool mv_is_num_user_missing (const struct missing_values *, double);
86 bool mv_is_str_user_missing (const struct missing_values *, const char[]);
87
88 /* Is a value system missing? */
89 bool mv_is_value_system_missing (const struct missing_values *,
90                                  const union value *);
91
92 #endif /* missing-values.h */