Add support for reading and writing SPV files.
[pspp] / src / output / spv / spv-select.h
diff --git a/src/output/spv/spv-select.h b/src/output/spv/spv-select.h
new file mode 100644 (file)
index 0000000..f0e42c5
--- /dev/null
@@ -0,0 +1,75 @@
+/* PSPP - a program for statistical analysis.
+   Copyright (C) 2018 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef OUTPUT_SPV_SELECT_H
+#define OUTPUT_SPV_SELECT_H 1
+
+#include "libpspp/string-set.h"
+
+struct spv_item;
+struct spv_reader;
+
+struct spv_criteria
+  {
+    bool include_hidden;
+
+#define SPV_ALL_CLASSES ((1u << SPV_N_CLASSES) - 1)
+    unsigned int classes;
+
+    struct spv_command_match *commands;
+    size_t n_commands;
+
+    struct string_set subtypes;
+
+    struct spv_label_match *labels;
+    size_t n_labels;
+
+    int *instances;
+    size_t n_instances;
+
+    bool error;
+  };
+
+#define SPV_CRITERIA_INITIALIZER(CRITERIA)                      \
+  {                                                             \
+    .classes = SPV_ALL_CLASSES,                                 \
+    .subtypes = STRING_SET_INITIALIZER (CRITERIA.subtypes),     \
+  }
+
+struct spv_command_match
+  {
+    char *name;
+    int instance;
+  };
+
+enum spv_label_match_op
+  {
+    SPV_LABEL_MATCH_EQUALS,
+    SPV_LABEL_MATCH_CONTAINS,
+    SPV_LABEL_MATCH_STARTS,
+    SPV_LABEL_MATCH_ENDS,
+  };
+
+struct spv_label_match
+  {
+    enum spv_label_match_op op;
+    char *arg;
+  };
+
+void spv_select (const struct spv_reader *, const struct spv_criteria *,
+                 struct spv_item ***items, size_t *n_items);
+
+#endif /* output/spv/spv-select.h */