-/* PSPP - computes sample statistics.
+/* PSPP - a program for statistical analysis.
Copyright (C) 2007 Free Software Foundation, Inc.
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
struct casewriter
{
struct taint *taint;
+ size_t value_cnt;
casenumber case_cnt;
const struct casewriter_class *class;
void *aux;
void
casewriter_write (struct casewriter *writer, struct ccase *c)
{
+ assert (case_get_value_cnt (c) >= writer->value_cnt);
writer->class->write (writer, writer->aux, c);
}
return ok;
}
+/* Returns the number of `union value's in each case written to
+ WRITER. */
+size_t
+casewriter_get_value_cnt (const struct casewriter *writer)
+{
+ return writer->value_cnt;
+}
+
/* Destroys WRITER and in its place returns a casereader that can
be used to read back the data written to WRITER. WRITER must
not be used again after calling this function, even as an
}
/* Creates and returns a new casewriter with the given CLASS and
- auxiliary data AUX. */
+ auxiliary data AUX. The casewriter accepts cases with
+ VALUE_CNT `union value's. */
struct casewriter *
-casewriter_create (const struct casewriter_class *class, void *aux)
+casewriter_create (size_t value_cnt,
+ const struct casewriter_class *class, void *aux)
{
struct casewriter *writer = xmalloc (sizeof *writer);
writer->taint = taint_create ();
+ writer->value_cnt = value_cnt;
writer->case_cnt = 0;
writer->class = class;
writer->aux = aux;
create_casewriter_window (size_t value_cnt, casenumber max_in_core_cases)
{
struct casewindow *window = casewindow_create (value_cnt, max_in_core_cases);
- struct casewriter *writer = casewriter_create (&casewriter_window_class,
+ struct casewriter *writer = casewriter_create (value_cnt,
+ &casewriter_window_class,
window);
taint_propagate (casewindow_get_taint (window),
casewriter_get_taint (writer));