X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fcasewriter-translator.c;h=79694a4609469f6deee93f9eccfab44212ef7ef6;hb=a1d8ce0ad176357cf250ec065e0bf1a4520a19e3;hp=7252eaa50542bafdd627ce44c56eda881a8c6351;hpb=f5c108becd49d78f4898cab11352291f5689d24e;p=pspp-builds.git
diff --git a/src/data/casewriter-translator.c b/src/data/casewriter-translator.c
index 7252eaa5..79694a46 100644
--- a/src/data/casewriter-translator.c
+++ b/src/data/casewriter-translator.c
@@ -1,20 +1,18 @@
-/* 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 . */
#include
@@ -31,17 +29,29 @@ struct casewriter_translator
{
struct casewriter *subwriter;
- void (*translate) (const struct ccase *input, struct ccase *output,
- void *aux);
+ void (*translate) (struct ccase *input, struct ccase *output, void *aux);
bool (*destroy) (void *aux);
void *aux;
};
static struct casewriter_class casewriter_translator_class;
+/* Creates and returns a new casewriter whose cases are passed
+ through TRANSLATE, which must create case OUTPUT, with
+ OUTPUT_VALUE_CNT values, and populate it based on INPUT and
+ auxiliary data AUX. The translated cases are then written to
+ SUBWRITER. TRANSLATE must also destroy INPUT.
+
+ When the translating casewriter is destroyed, DESTROY will be
+ called to allow any state maintained by TRANSLATE to be freed.
+
+ After this function is called, SUBWRITER must not ever again
+ be referenced directly. It will be destroyed automatically
+ when the translating casewriter is destroyed. */
struct casewriter *
casewriter_create_translator (struct casewriter *subwriter,
- void (*translate) (const struct ccase *input,
+ size_t translated_value_cnt,
+ void (*translate) (struct ccase *input,
struct ccase *output,
void *aux),
bool (*destroy) (void *aux),
@@ -53,7 +63,8 @@ casewriter_create_translator (struct casewriter *subwriter,
ct->translate = translate;
ct->destroy = destroy;
ct->aux = aux;
- writer = casewriter_create (&casewriter_translator_class, ct);
+ writer = casewriter_create (translated_value_cnt,
+ &casewriter_translator_class, ct);
taint_propagate (casewriter_get_taint (ct->subwriter),
casewriter_get_taint (writer));
return writer;