1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2006, 2010, 2012, 2014 Free Software Foundation, Inc.
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.
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.
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/>. */
18 #define ANY_READER_H 1
22 #include "data/case.h"
23 #include "libpspp/float-format.h"
24 #include "libpspp/integer-format.h"
32 const struct any_reader_class *klass;
35 struct any_reader_class
39 int (*detect) (FILE *);
41 struct any_reader *(*open) (struct file_handle *);
42 bool (*close) (struct any_reader *);
43 struct casereader *(*decode) (struct any_reader *, const char *encoding,
45 struct any_read_info *);
46 size_t (*get_strings) (const struct any_reader *, struct pool *pool,
47 char ***labels, bool **ids, char ***values);
50 extern const struct any_reader_class sys_file_reader_class;
51 extern const struct any_reader_class por_file_reader_class;
52 extern const struct any_reader_class pcp_file_reader_class;
56 ANY_SYS, /* SPSS System File. */
57 ANY_PCP, /* SPSS/PC+ System File. */
58 ANY_POR, /* SPSS Portable File. */
63 ANY_COMP_NONE, /* No compression. */
64 ANY_COMP_SIMPLE, /* Bytecode compression of integer values. */
65 ANY_COMP_ZLIB /* ZLIB "deflate" compression. */
68 /* Data file info that doesn't fit in struct dictionary.
70 The strings in this structure are encoded in UTF-8. (They are normally in
71 the ASCII subset of UTF-8.) */
74 const struct any_reader_class *klass;
77 enum integer_format integer_format;
78 enum float_format float_format;
79 enum any_compression compression;
80 casenumber case_cnt; /* -1 if unknown. */
81 char *product; /* Product name. */
82 char *product_ext; /* Extra product info. */
84 /* Writer's version number in X.Y.Z format.
85 The version number is not always present; if not, then
86 all of these are set to 0. */
87 int version_major; /* X. */
88 int version_minor; /* Y. */
89 int version_revision; /* Z. */
92 void any_read_info_destroy (struct any_read_info *);
97 int any_reader_detect (const char *file_name,
98 const struct any_reader_class **);
100 struct any_reader *any_reader_open (struct file_handle *);
101 bool any_reader_close (struct any_reader *);
102 struct casereader *any_reader_decode (struct any_reader *,
103 const char *encoding,
104 struct dictionary **,
105 struct any_read_info *);
106 size_t any_reader_get_strings (const struct any_reader *, struct pool *pool,
107 char ***labels, bool **ids, char ***values);
109 struct casereader *any_reader_open_and_decode (struct file_handle *,
110 const char *encoding,
111 struct dictionary **,
112 struct any_read_info *);
114 #endif /* any-reader.h */