Truxton enumeration get string
Jump to navigation
Jump to search
This retrieves a string value from a column in a custom enumeration result.
Contents
Syntax
void truxton_enumeration_get_string( uint64_t enumeration_handle, uint64_t column_index, char * buffer, size_t buffer_size );
Parameters
enumeration_handle
The handle returned by calling truxton_enumeration_create().
column_index
The index, starting at zero, of the column to retrieve.
buffer
The buffer to receive the string from the database column.
buffer_size
The size of the destination buffer in bytes.
Sample
void main()
{
truxton_start();
uint64_t truxton = truxton_create();
uint64_t enumerator = truxton_enumeration_create( truxton );
truxton_enumeration_set_scope(enumerator, Type_Custom_Enumeration);
truxton_enumeration_set_query(enumerator, "SELECT \"Latitude\", \"Longitude\", \"LocationTypeID\", \"When\", \"Label\" FROM \"Location\"");
double latitude = 0;
double longitude = 0;
uint64_t type = 0;
uint64_t when = 0;
char label[256];
while( truxton_enumeration_get_next(enumerator) != 0 )
{
latitude = truxton_enumeration_get_double( enumerator, 0 );
longitude = truxton_enumeration_get_double( enumerator, 1 );
type = truxton_enumeration_get_integer( enumerator, 2 );
when = truxton_enumeration_get_time(enumerator, 3);
truxton_enumeration_get_string(enumerator, 4, label, sizeof(label) );
printf("%lf %lf %" PRIu64 " %" PRIu64 " %s\n", latitude, longitude, type, when, label);
}
truxton_enumeration_destroy( enumerator );
truxton_destroy( truxton );
truxton_stop();
}