1 /* PSPP - computes sample statistics.
2 Copyright (C) 2007 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 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, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 /* Casereader client interface.
21 A casereader abstracts interfaces through which cases may be
22 read. A casereader may be a front-end for a system file, a
23 portable file, the active file in a data set, or anything else
24 on which a casereader interface has been overlaid. Casereader
25 layering, in which a casereader acts as a filter or translator
26 on top of another casereader, is also supported.
28 There is no central interface for obtaining casereaders: a
29 casereader for reading a system file is obtained from the
30 system file reading module, and so on. Once a casereader has
31 been obtained, by whatever means, the interface to it is
32 uniform. The most important functions for casereader usage
35 - casereader_read: Reads a case from the casereader. The
36 case is consumed and cannot be read again. The caller is
37 responsible for destroying the case.
39 - casereader_clone: Makes a copy of a casereader. May be
40 used to read one or a set of cases from a casereader
43 - casereader_destroy: Destroys a casereader.
45 Casereaders can encounter error conditions, such as I/O
46 errors, as they read cases. Error conditions prevent any more
47 cases from being read from the casereader. Error conditions
48 are reported by casereader_error. Error condition may be
49 propagated to or from a casereader with taint_propagate using
50 the casereader's taint object, which may be obtained with
51 casereader_get_taint. */
53 #ifndef DATA_CASEREADER_H
54 #define DATA_CASEREADER_H 1
56 #include <libpspp/compiler.h>
57 #include <data/case.h>
58 #include <data/missing-values.h>
64 bool casereader_read (struct casereader *, struct ccase *);
65 bool casereader_destroy (struct casereader *);
67 struct casereader *casereader_clone (const struct casereader *);
68 void casereader_split (struct casereader *,
69 struct casereader **, struct casereader **);
70 struct casereader *casereader_rename (struct casereader *);
71 void casereader_swap (struct casereader *, struct casereader *);
73 bool casereader_peek (struct casereader *, casenumber, struct ccase *)
76 bool casereader_error (const struct casereader *);
77 void casereader_force_error (struct casereader *);
78 const struct taint *casereader_get_taint (const struct casereader *);
80 casenumber casereader_get_case_cnt (struct casereader *);
81 casenumber casereader_count_cases (struct casereader *);
82 size_t casereader_get_value_cnt (struct casereader *);
84 void casereader_transfer (struct casereader *, struct casewriter *);
87 casereader_create_filter_func (struct casereader *,
88 bool (*include) (const struct ccase *,
90 bool (*destroy) (void *aux),
92 struct casewriter *exclude);
94 casereader_create_filter_weight (struct casereader *,
95 const struct dictionary *dict,
96 bool *warn_on_invalid,
97 struct casewriter *exclude);
99 casereader_create_filter_missing (struct casereader *,
100 struct variable **vars, size_t var_cnt,
102 struct casewriter *exclude);
105 casereader_create_counter (struct casereader *, casenumber *counter,
106 casenumber initial_value);
109 casereader_create_translator (struct casereader *, size_t output_value_cnt,
110 void (*translate) (const struct ccase *input,
111 struct ccase *output,
113 bool (*destroy) (void *aux),
116 #endif /* data/casereader.h */