HDFql Reference Manual v2.6.0

5.2.10hdfql_cursor_clone

Syntax

int hdfql_cursor_clone(const HDFQL_CURSOR *cursor_original, HDFQL_CURSOR *cursor_clone)

Description

Clone (i.e. duplicate) a cursor named cursor_original into another one named cursor_clone. In other words, cursor_clone will be an exact (deep) copy of cursor_original, meaning that it will store the same result set, have the same data type, count, number of dimensions, and position values, as well as the same current element as the original cursor.

Parameter(s)

cursor_original – pointer to a cursor to clone. If the pointer is NULL (in C), the cursor in use is the one to be cloned 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 cursor in use is the one to be cloned instead).

cursor_clone – pointer to the cursor that will be a clone (i.e. duplicate) of the original cursor.

Return

int – depending on the success in cloning cursor_original into cursor_clone, it can be HDFQL_SUCCESS, HDFQL_ERROR_NOT_ENOUGH_MEMORY, or HDFQL_ERROR_NOT_REGISTERED.

Example(s)

// create a cursor named "my_cursor" 
HDFQL_CURSOR my_cursor;

// initialize cursor "my_cursor" 
hdfql_cursor_initialize(&my_cursor);

// show (i.e. get) working directory currently in use and populate cursor in use (i.e. HDFql default cursor) with it
hdfql_execute("SHOW USE DIRECTORY");

// clone the cursor in use (i.e. HDFql default cursor) into the cursor "my_cursor" 
hdfql_cursor_clone(NULL, &my_cursor);

// use cursor "my_cursor" 
hdfql_cursor_use(&my_cursor);

// display number of elements in the cursor in use (should be "Number of elements in cursor is 1")
printf("Number of elements in cursor is %d\n", hdfql_cursor_get_count(NULL));