5.2.17hdfql_subcursor_get_position
Syntax
long long hdfql_subcursor_get_position(const HDFQL_CURSOR *cursor)
Description
Get the current position of the subcursor in use within the result subset. The current position refers to the result of a DATA QUERY LANGUAGE (DQL) or DATA INTROSPECTION LANGUAGE (DIL) operation redirected into a cursor. The first element of the result subset is at position zero, while the last element is located at the position returned by hdfql_subcursor_get_count - 1. If the cursor that the subcursor belongs to has never been populated or has been initialized or cleared, or in case the result subset is empty, the returned current position is minus one. If the subcursor was moved before the first element or after the last element, the returned current position is minus one or the number of elements in the result subset, respectively.
Parameter(s)
cursor – pointer to a cursor to get the current position of the subcursor in use within the result subset. If the pointer is NULL (in C), the current position of the subcursor of the cursor in use is returned instead. The equivalent of a NULL pointer in C++, Java, Python, C#, Fortran, R, and MATLAB HDFql wrappers is NULL, null, None, null, NULL(), NULL, and NaN, respectively. While in C cursor is mandatory, in C++, Java, Python, C#, Fortran, R, and MATLAB it is optional (when not specified, the current position of the subcursor of the cursor in use is returned instead).
Return
long long – current position of the subcursor within the result subset.
Example(s)
// create an HDF5 dataset named "my_dataset" of data type variable-length int of two dimensions (size 2x2)
hdfql_execute("CREATE DATASET my_dataset AS VARINT(2, 2)");
// insert (i.e. write) values into dataset "my_dataset"
hdfql_execute("INSERT INTO my_dataset VALUES(((7, 8, 5), (9)), ((6, 1, 2, 3), (4, 0)))");
// select (i.e. read) data from dataset "my_dataset" and populate cursor in use with it
hdfql_execute("SELECT FROM my_dataset");
// move the cursor in use to the first position within the result set
hdfql_cursor_first(NULL);
// display position of the subcursor in use within the result subset (should be "Position of subcursor is -1")
printf("Position of subcursor is %lld\n", hdfql_subcursor_get_position(NULL));
// move the subcursor in use to the next position within the result subset (two times)
hdfql_subcursor_next(NULL);
hdfql_subcursor_next(NULL);
// display (again) position of the subcursor in use within the result subset (should be "Position of subcursor is 1")
printf("Position of subcursor is %lld\n", hdfql_subcursor_get_position(NULL));