b2a1e0e7c8a149284ceab825a2d718d0bed21586
[pspp] / src / output / spv / spv-select.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2019 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-array.h"
21
22 struct spv_item;
23 struct spv_reader;
24
25 /* Matching criteria for commands, subtypes, and labels.
26
27    Each of the members is an array of strings.  A string that ends in '*'
28    matches anything that begins with the rest of the string, otherwise a string
29    requires an exact (case-insensitive) match. */
30 struct spv_criteria_match
31   {
32     struct string_array commands;
33     struct string_array subtypes;
34     struct string_array labels;
35   };
36
37 struct spv_criteria
38   {
39     /* Include objects that are not visible? */
40     bool include_hidden;
41
42     /* If false, include all objects.
43        If true, include only objects that have an error on loading. */
44     bool error;
45
46     /* Bit-mask of SPV_CLASS_* for the classes to include. */
47     unsigned int classes;
48
49     /* Include all of the objects that match 'include' and do not match
50        'exclude', except that objects are included by default if 'include' is
51        empty. */
52     struct spv_criteria_match include;
53     struct spv_criteria_match exclude;
54
55     /* Include objects under commands with indexes listed in COMMANDS.  Indexes
56        are 1-based.  Everything is included if N_COMMANDS is 0. */
57     size_t *commands;
58     size_t n_commands;
59
60     /* Include XML and binary member names that match (except that everything
61        is included by default if empty). */
62     struct string_array members;
63
64     /* Include the objects with indexes listed in INSTANCES within each of the
65        commands that are included.  Indexes are 1-based.  Index -1 means the
66        last object within a command. */
67     int *instances;
68     size_t n_instances;
69   };
70
71 #define SPV_CRITERIA_INITIALIZER { .classes = SPV_ALL_CLASSES }
72
73 void spv_select (const struct spv_reader *,
74                  const struct spv_criteria[], size_t n_criteria,
75                  struct spv_item ***items, size_t *n_items);
76
77 #endif /* output/spv/spv-select.h */