1 /* PSPP - a program for statistical analysis.
2 Copyright (C) 2006, 2010, 2012, 2014, 2015 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
37 /* The name of this kind of data file, e.g. "SPSS System File". */
40 /* Detects whether FILE contains this type of file. Returns 1 if so, 0 if
41 not, and a negative errno value if there is an error reading FILE. */
42 int (*detect
) (FILE *file
);
44 struct any_reader
*(*open
) (struct file_handle
*);
45 bool (*close
) (struct any_reader
*);
46 struct casereader
*(*decode
) (struct any_reader
*, const char *encoding
,
48 struct any_read_info
*);
49 size_t (*get_strings
) (const struct any_reader
*, struct pool
*pool
,
50 char ***labels
, bool **ids
, char ***values
);
53 extern const struct any_reader_class sys_file_reader_class
;
54 extern const struct any_reader_class por_file_reader_class
;
55 extern const struct any_reader_class pcp_file_reader_class
;
59 ANY_SYS
, /* SPSS System File. */
60 ANY_PCP
, /* SPSS/PC+ System File. */
61 ANY_POR
, /* SPSS Portable File. */
66 ANY_COMP_NONE
, /* No compression. */
67 ANY_COMP_SIMPLE
, /* Bytecode compression of integer values. */
68 ANY_COMP_ZLIB
/* ZLIB "deflate" compression. */
71 /* Data file info that doesn't fit in struct dictionary.
73 The strings in this structure are encoded in UTF-8. (They are normally in
74 the ASCII subset of UTF-8.) */
77 const struct any_reader_class
*klass
;
80 enum integer_format integer_format
;
81 enum float_format float_format
;
82 enum any_compression compression
;
83 casenumber n_cases
; /* -1 if unknown. */
84 char *product
; /* Product name. */
85 char *product_ext
; /* Extra product info. */
87 /* Writer's version number in X.Y.Z format.
88 The version number is not always present; if not, then
89 all of these are set to 0. */
90 int version_major
; /* X. */
91 int version_minor
; /* Y. */
92 int version_revision
; /* Z. */
95 void any_read_info_destroy (struct any_read_info
*);
100 int any_reader_detect (const struct file_handle
*file_name
,
101 const struct any_reader_class
**);
103 struct any_reader
*any_reader_open (struct file_handle
*);
104 bool any_reader_close (struct any_reader
*);
105 struct casereader
*any_reader_decode (struct any_reader
*,
106 const char *encoding
,
107 struct dictionary
**,
108 struct any_read_info
*);
109 size_t any_reader_get_strings (const struct any_reader
*, struct pool
*pool
,
110 char ***labels
, bool **ids
, char ***values
);
112 struct casereader
*any_reader_open_and_decode (struct file_handle
*,
113 const char *encoding
,
114 struct dictionary
**,
115 struct any_read_info
*);
117 #endif /* any-reader.h */