6afad6a9d399036d39eb9998b9454821f2e50384
[pspp-builds.git] / src / data / casefilter.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2006 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 !casefilter_h
20 #define casefilter_h 1
21
22 #include <stdbool.h>
23 #include <data/missing-values.h>
24
25 struct ccase;
26 struct casefilter;
27 struct variable ;
28
29 /* Create a new casefilter that drops cases in which any of the
30    N_VARS variables in VARS are missing in the given CLASS.
31    VARS is an array of variables which if *any* of them are missing.
32    N_VARS is the size of VARS.
33  */
34 struct casefilter * casefilter_create (enum mv_class class,
35                                        const struct variable **, int);
36
37 /* Add the variables in VARS to the list of variables for which the
38    filter considers. N_VARS is the size of VARS */
39 void casefilter_add_variables (struct casefilter *, 
40                                const struct variable *const*, int);
41
42 /* Destroy the filter FILTER */
43 void casefilter_destroy (struct casefilter *); 
44
45 /* Returns true iff the entire case should be skipped */
46 bool casefilter_skip_case (const struct casefilter *, const struct ccase *);
47
48 /* Returns true iff the variable V in case C is missing.
49    Note that this function's behaviour is independent of the set of 
50    variables  contained by the filter.
51  */
52 bool casefilter_variable_missing (const struct casefilter *f, 
53                                    const struct ccase *c, 
54                                    const struct variable *v);
55
56 #endif