1a70b7faf87b62d13bfc131b8bfa8d18da4e2e7d
[pspp-builds.git] / src / data / casewriter-provider.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2006 Free Software Foundation, Inc.
3
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.
8
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.
13
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
17    02110-1301, USA. */
18
19 #ifndef DATA_CASEWRITER_PROVIDER_H
20 #define DATA_CASEWRITER_PROVIDER_H 1
21
22 #include <data/casewriter.h>
23
24 struct casewriter_class
25   {
26     /* Mandatory.
27
28        Writes case C to WRITER.  Destroys C before returning.
29
30        If an I/O error occurs, this function should call
31        casewriter_force_error on WRITER.  Some I/O error
32        detection may be deferred to the "destroy" member function
33        (e.g. writes to disk need not be flushed by "write") . */
34     void (*write) (struct casewriter *writer, void *aux, struct ccase *c);
35
36     /* Mandatory.
37
38        Finalizes output and destroys WRITER.
39
40        If an I/O error is detected while finalizing output
41        (e.g. while flushing output to disk), this function should
42        call casewriter_force_error on WRITER. */
43     void (*destroy) (struct casewriter *writer, void *aux);
44
45     /* Optional: supply if practical and desired by clients.
46
47        Finalizes output to WRITER, destroys WRITER, and in its
48        place returns a casereader that can be used to read back
49        the data written to WRITER.  WRITER will not be used again
50        after calling this function, even as an argument to
51        casewriter_destroy.
52
53        If an I/O error is detected while finalizing output
54        (e.g. while flushing output to disk), this function should
55        call casewriter_force_error on WRITER.  The caller will
56        ensure that the error is propagated to the returned
57        casereader. */
58     struct casereader *(*convert_to_reader) (struct casewriter *, void *aux);
59   };
60
61 struct casewriter *casewriter_create (const struct casewriter_class *, void *);
62
63 #endif /* data/casewriter-provider.h */