Add support for reading and writing SPV files.
[pspp] / src / output / spv / spv-select.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2018 Free Software Foundation, Inc.
3
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.
8
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.
13
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/>. */
16
17 #ifndef OUTPUT_SPV_SELECT_H
18 #define OUTPUT_SPV_SELECT_H 1
19
20 #include "libpspp/string-set.h"
21
22 struct spv_item;
23 struct spv_reader;
24
25 struct spv_criteria
26   {
27     bool include_hidden;
28
29 #define SPV_ALL_CLASSES ((1u << SPV_N_CLASSES) - 1)
30     unsigned int classes;
31
32     struct spv_command_match *commands;
33     size_t n_commands;
34
35     struct string_set subtypes;
36
37     struct spv_label_match *labels;
38     size_t n_labels;
39
40     int *instances;
41     size_t n_instances;
42
43     bool error;
44   };
45
46 #define SPV_CRITERIA_INITIALIZER(CRITERIA)                      \
47   {                                                             \
48     .classes = SPV_ALL_CLASSES,                                 \
49     .subtypes = STRING_SET_INITIALIZER (CRITERIA.subtypes),     \
50   }
51
52 struct spv_command_match
53   {
54     char *name;
55     int instance;
56   };
57
58 enum spv_label_match_op
59   {
60     SPV_LABEL_MATCH_EQUALS,
61     SPV_LABEL_MATCH_CONTAINS,
62     SPV_LABEL_MATCH_STARTS,
63     SPV_LABEL_MATCH_ENDS,
64   };
65
66 struct spv_label_match
67   {
68     enum spv_label_match_op op;
69     char *arg;
70   };
71
72 void spv_select (const struct spv_reader *, const struct spv_criteria *,
73                  struct spv_item ***items, size_t *n_items);
74
75 #endif /* output/spv/spv-select.h */