/* PSPP - computes sample statistics.
Copyright (C) 1997-9, 2000, 2006 Free Software Foundation, Inc.
- Written by Ben Pfaff <blp@gnu.org>.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
#include <data/storage-stream.h>
+#include <assert.h>
#include <stdlib.h>
#include <data/case-sink.h>
#include <data/case-source.h>
#include <data/case.h>
#include <data/casefile.h>
+#include <data/fastfile.h>
#include "xalloc.h"
struct storage_stream_info *info;
sink->aux = info = xmalloc (sizeof *info);
- info->casefile = casefile_create (sink->value_cnt);
+ info->casefile = fastfile_create (sink->value_cnt);
}
/* Destroys storage stream represented by INFO. */
struct casereader *reader;
bool ok = true;
- for (reader = casefile_get_reader (info->casefile);
+ for (reader = casefile_get_reader (info->casefile, NULL);
ok && casereader_read (reader, &casefile_case);
case_destroy (&casefile_case))
{
storage_source_destroy,
};
+/* Returns the casefile encapsulated by SOURCE. */
struct casefile *
storage_source_get_casefile (struct case_source *source)
{
return info->casefile;
}
+/* Destroys SOURCE and returns the casefile that it
+ encapsulated. */
+struct casefile *
+storage_source_decapsulate (struct case_source *source)
+{
+ struct storage_stream_info *info = source->aux;
+ struct casefile *casefile;
+
+ assert (source->class == &storage_source_class);
+ casefile = info->casefile;
+ info->casefile = NULL;
+ free_case_source (source);
+ return casefile;
+}
+
+/* Creates and returns a new storage stream that encapsulates
+ CASEFILE. */
struct case_source *
-storage_source_create (struct casefile *cf)
+storage_source_create (struct casefile *casefile)
{
struct storage_stream_info *info;
info = xmalloc (sizeof *info);
- info->casefile = cf;
+ info->casefile = casefile;
return create_case_source (&storage_source_class, info);
}