X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fdata%2Fcasereader-provider.h;h=b8d53500504fb2c2595e894b9baf944a8651d0b7;hb=refs%2Fbuilds%2F20110315030503%2Fpspp;hp=2726f6831ab4dce66e5477df39c603726d4ab748;hpb=ed88deded6a59254dd55883308c4c20966efc77e;p=pspp
diff --git a/src/data/casereader-provider.h b/src/data/casereader-provider.h
index 2726f6831a..b8d5350050 100644
--- a/src/data/casereader-provider.h
+++ b/src/data/casereader-provider.h
@@ -1,20 +1,18 @@
-/* PSPP - computes sample statistics.
- Copyright (C) 2007 Free Software Foundation, Inc.
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 2007, 2009 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 . */
/* Definitions needed to implement a new type of casereader.
Code that only uses casereaders does not need this header.
@@ -41,24 +39,27 @@
#include
/* Casereader class for sequential data sources. */
-struct casereader_class
+struct casereader_class
{
/* Mandatory.
- Reads the next case from READER into case C, which the
- casereader must create and which the client is responsible
- for destroying. If successful, returns true and advances
- READER to the next case, so that the next call to this
- function will read the next case. The case just read will
- never be read again by a call to this function for READER.
+ Reads the next case from READER. If successful, returns
+ the case and advances READER, so that the next call to
+ this function will read the following case. The case just
+ read will never be read again by a call to this function
+ for READER.
- At end of file or upon an I/O error, returns false. After
- false is returned once, this function will not be called
- again for the given READER.
+ If a case is successfully returned, the client is
+ responsible for calling case_unref upon it when it is no
+ longer needed.
+
+ At end of file or upon an I/O error, returns a null
+ pointer. After null is returned once, this function will
+ not be called again for the given READER.
If an I/O error occurs, this function should call
casereader_force_error on READER. */
- bool (*read) (struct casereader *reader, void *aux, struct ccase *c);
+ struct ccase *(*read) (struct casereader *reader, void *aux);
/* Mandatory.
@@ -90,28 +91,31 @@ struct casereader_class
(But it might be easier to use the random-access
casereader wrapper instead.)
- Reads the case at 0-based offset IDX from the beginning of
- READER into case C, which the casereader must create and
- which the client is responsible for destroying.
+ Reads and returns the case at 0-based offset IDX from the
+ beginning of READER. If a case is successfully returned,
+ the client is responsible for calling case_unref upon it
+ when it is no longer needed.
- At end of file or upon an I/O error, returns false. If
- this function returns false, then it will never be called
- again for an equal or greater value of IDX, and the "read"
- member function will never be called to advance as far as
- IDX cases further into the casereader. That is, returning
- false indicates that the casereader has fewer than IDX
- cases left.
+ At end of file or upon an I/O error, returns a null
+ pointer. If this function returns null, then it will
+ never be called again for an equal or greater value of
+ IDX, and the "read" member function will never be called
+ to advance as far as IDX cases further into the
+ casereader. That is, returning null indicates that the
+ casereader has fewer than IDX cases left.
If an I/O error occurs, this function should call
casereader_force_error on READER. */
- bool (*peek) (struct casereader *reader, void *aux, casenumber idx,
- struct ccase *c);
+ struct ccase *(*peek) (struct casereader *reader, void *aux,
+ casenumber idx);
};
struct casereader *
casereader_create_sequential (const struct taint *,
- size_t value_cnt, casenumber case_cnt,
+ const struct caseproto *, casenumber case_cnt,
const struct casereader_class *, void *);
+
+void *casereader_dynamic_cast (struct casereader *, const struct casereader_class *);
/* Casereader class for random-access data sources. */
struct casereader_random_class
@@ -119,21 +123,22 @@ struct casereader_random_class
/* Mandatory.
Reads the case at 0-based offset IDX from the beginning of
- READER into case C, which the casereader must create and
- which the client is responsible for destroying.
-
- At end of file or upon an I/O error, returns false. If
- this function returns false, then it will never be called
- again for an equal or greater value of IDX, and the "read"
- member function will never be called to advance as far as
- IDX cases further into the casereader. That is, returning
- false indicates that the casereader has fewer than IDX
- cases.
+ READER. If a case is successfully returned, the client is
+ responsible for calling case_unref upon it when it is no
+ longer needed.
+
+ At end of file or upon an I/O error, returns a null
+ pointer. If this function returns null, then it will
+ never be called again for an equal or greater value of
+ IDX, and the "read" member function will never be called
+ to advance as far as IDX cases further into the
+ casereader. That is, returning null indicates that the
+ casereader has fewer than IDX cases.
If an I/O error occurs, this function should call
casereader_force_error on READER. */
- bool (*read) (struct casereader *reader, void *aux, casenumber idx,
- struct ccase *c);
+ struct ccase *(*read) (struct casereader *reader, void *aux,
+ casenumber idx);
/* Mandatory.
@@ -144,7 +149,7 @@ struct casereader_random_class
void (*destroy) (struct casereader *reader, void *aux);
/* Mandatory.
-
+
A call to this function tells the callee that the CNT
cases at the beginning of READER will never be read again.
The casereader implementation should free any resources
@@ -155,7 +160,7 @@ struct casereader_random_class
};
struct casereader *
-casereader_create_random (size_t value_cnt, casenumber case_cnt,
+casereader_create_random (const struct caseproto *, casenumber case_cnt,
const struct casereader_random_class *, void *aux);
#endif /* data/casereader-provider.h */