X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fcasereader.c;h=27c6148bc1c538e2e308edafc42ee4c3f203b236;hb=2bdde1cd21cd58349cf4bd852fddf40524854288;hp=3be1042d8224f2e4b97d6beb66e4dcc71adb56ee;hpb=b5a51d1c0bc3eda065002dd505cade85f4d75514;p=pspp-builds.git diff --git a/src/data/casereader.c b/src/data/casereader.c index 3be1042d..27c6148b 100644 --- a/src/data/casereader.c +++ b/src/data/casereader.c @@ -311,6 +311,26 @@ casereader_create_sequential (const struct taint *taint, reader->aux = aux; return reader; } + +/* If READER is a casereader of the given CLASS, returns its + associated auxiliary data; otherwise, returns a null pointer. + + This function is intended for use from casereader + implementations, not by casereader users. Even within + casereader implementations, its usefulness is quite limited, + for at least two reasons. First, every casereader member + function already receives a pointer to the casereader's + auxiliary data. Second, a casereader's class can change + (through a call to casereader_swap) and this is in practice + quite common (e.g. any call to casereader_clone on a + casereader that does not directly support clone will cause the + casereader to be replaced by a shim caseader). */ +void * +casereader_dynamic_cast (struct casereader *reader, + struct casereader_class *class) +{ + return reader->class == class ? reader->aux : NULL; +} /* Random-access casereader implementation.