Layered split file for FREQUENCIES works.
[pspp] / src / output / select.h
1 /* PSPP - a program for statistical analysis.
2    Copyright (C) 2009, 2011 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_SELECT_H
18 #define OUTPUT_SELECT_H 1
19
20 #include "output/output-item.h"
21
22 /* Selecting subsets of a tree of output items based on user-specified
23    criteria.  pspp-output uses this; a future OMS or OUTPUT MODIFY command
24    would use it too. */
25
26 /* Classifications for output items.  These only roughly correspond to the
27    output item types; for example, "warnings" are a subset of text items.
28    These classifications really  */
29 #define OUTPUT_CLASSES                                \
30     OUTPUT_CLASS(CHARTS, "charts")                    \
31     OUTPUT_CLASS(HEADINGS, "headings")                \
32     OUTPUT_CLASS(LOGS, "logs")                        \
33     OUTPUT_CLASS(MODELS, "models")                    \
34     OUTPUT_CLASS(TABLES, "tables")                    \
35     OUTPUT_CLASS(TEXTS, "texts")                      \
36     OUTPUT_CLASS(TREES, "trees")                      \
37     OUTPUT_CLASS(WARNINGS, "warnings")                \
38     OUTPUT_CLASS(OUTLINEHEADERS, "outlineheaders")    \
39     OUTPUT_CLASS(PAGETITLE, "pagetitle")              \
40     OUTPUT_CLASS(NOTES, "notes")                      \
41     OUTPUT_CLASS(UNKNOWN, "unknown")                  \
42     OUTPUT_CLASS(OTHER, "other")
43 enum output_item_class
44   {
45 #define OUTPUT_CLASS(ENUM, NAME) OUTPUT_CLASS_##ENUM,
46     OUTPUT_CLASSES
47 #undef OUTPUT_CLASS
48   };
49 enum
50   {
51 #define OUTPUT_CLASS(ENUM, NAME) +1
52     OUTPUT_N_CLASSES = OUTPUT_CLASSES
53 #undef OUTPUT_CLASS
54 };
55 #define OUTPUT_ALL_CLASSES ((1u << OUTPUT_N_CLASSES) - 1)
56
57 const char *output_item_class_to_string (enum output_item_class);
58 enum output_item_class output_item_class_from_string (const char *);
59
60 enum output_item_class output_item_classify (const struct output_item *);
61
62 /* Matching criteria for commands, subtypes, and labels.
63
64    Each of the members is an array of strings.  A string that ends in '*'
65    matches anything that begins with the rest of the string, otherwise a string
66    requires an exact (case-insensitive) match. */
67 struct output_criteria_match
68   {
69     struct string_array commands;
70     struct string_array subtypes;
71     struct string_array labels;
72   };
73
74 struct output_criteria
75   {
76     /* Include objects that are not visible? */
77     bool include_hidden;
78
79     /* If false, include all objects.
80        If true, include only objects that have an error on loading. */
81     bool error;
82
83     /* Bit-mask of OUTPUT_CLASS_* for the classes to include. */
84     unsigned int classes;
85
86     /* Include all of the objects that match 'include' and do not match
87        'exclude', except that objects are included by default if 'include' is
88        empty. */
89     struct output_criteria_match include;
90     struct output_criteria_match exclude;
91
92     /* Include objects under commands with indexes listed in COMMANDS.  Indexes
93        are 1-based.  Everything is included if N_COMMANDS is 0. */
94     size_t *commands;
95     size_t n_commands;
96
97     /* Include XML and binary member names that match (except that everything
98        is included by default if empty). */
99     struct string_array members;
100
101     /* Include the objects with indexes listed in INSTANCES within each of the
102        commands that are included.  Indexes are 1-based.  Index -1 means the
103        last object within a command. */
104     int *instances;
105     size_t n_instances;
106   };
107
108 #define OUTPUT_CRITERIA_INITIALIZER { .classes = OUTPUT_ALL_CLASSES }
109
110 struct output_item *output_select (struct output_item *,
111                                    const struct output_criteria[],
112                                    size_t n_criteria);
113
114 #endif /* output/select.h */