output: Make groups contain their subitems, and get rid of spv_item.
[pspp] / src / output / spv / spv-legacy-data.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_LEGACY_DATA_H
18 #define OUTPUT_SPV_LEGACY_DATA_H 1
19
20 /* SPSS Viewer (SPV) legacy binary data decoder.
21
22    Used by spv.h, not useful directly. */
23
24 #include <stdbool.h>
25 #include <stddef.h>
26 #include <stdint.h>
27 #include <stdio.h>
28 #include "libpspp/compiler.h"
29
30 struct spv_data
31   {
32     struct spv_data_source *sources;
33     size_t n_sources;
34   };
35
36 #define SPV_DATA_INITIALIZER { NULL, 0 }
37
38 void spv_data_uninit (struct spv_data *);
39 void spv_data_dump (const struct spv_data *, FILE *);
40
41 struct spv_data_source *spv_data_find_source (const struct spv_data *,
42                                               const char *source_name);
43 struct spv_data_variable *spv_data_find_variable (const struct spv_data *,
44                                                   const char *source_name,
45                                                   const char *variable_name);
46
47 struct spv_data_source
48   {
49     char *source_name;
50     struct spv_data_variable *vars;
51     size_t n_vars, n_values;
52   };
53
54 void spv_data_source_uninit (struct spv_data_source *);
55 void spv_data_source_dump (const struct spv_data_source *, FILE *);
56
57 struct spv_data_variable *spv_data_source_find_variable (
58   const struct spv_data_source *, const char *variable_name);
59
60 struct spv_data_variable
61   {
62     char *var_name;
63     struct spv_data_value *values;
64     size_t n_values;
65   };
66
67 void spv_data_variable_uninit (struct spv_data_variable *);
68 void spv_data_variable_dump (const struct spv_data_variable *, FILE *);
69
70 struct spv_data_value
71   {
72     double index;
73     int width;
74     union
75       {
76         double d;
77         char *s;
78       };
79   };
80
81 void spv_data_value_uninit (struct spv_data_value *);
82 bool spv_data_value_equal (const struct spv_data_value *,
83                            const struct spv_data_value *);
84 struct spv_data_value *spv_data_values_clone (const struct spv_data_value *,
85                                               size_t n);
86
87 char *spv_legacy_data_decode (const uint8_t *in, size_t size,
88                               struct spv_data *out) WARN_UNUSED_RESULT;
89 void spv_data_value_dump (const struct spv_data_value *, FILE *);
90
91 #endif /* output/spv/spv-legacy-data.h */