GRASS GIS 8 Programmer's Manual  8.2.2dev(2023)-3d2c704037
value.c File Reference

DBMI Library (base) - value management. More...

#include <stdlib.h>
#include <grass/dbmi.h>
Include dependency graph for value.c:

Go to the source code of this file.

Functions

int db_test_value_isnull (dbValue *value)
 Check of value is null. More...
 
int db_get_value_int (dbValue *value)
 Get integer value. More...
 
double db_get_value_double (dbValue *value)
 Get double precision value. More...
 
double db_get_value_as_double (dbValue *value, int ctype)
 Get value as double. More...
 
const char * db_get_value_string (dbValue *value)
 Get string value. More...
 
int db_get_value_year (dbValue *value)
 Get year value. More...
 
int db_get_value_month (dbValue *value)
 Get month value. More...
 
int db_get_value_day (dbValue *value)
 Get day value. More...
 
int db_get_value_hour (dbValue *value)
 Get hour value. More...
 
int db_get_value_minute (dbValue *value)
 Get minute value. More...
 
double db_get_value_seconds (dbValue *value)
 Get seconds value. More...
 
void db_set_value_null (dbValue *value)
 Set value to null. More...
 
void db_set_value_not_null (dbValue *value)
 Set value to not null. More...
 
void db_set_value_int (dbValue *value, int i)
 Set integer value. More...
 
void db_set_value_double (dbValue *value, double d)
 Set double precision value. More...
 
int db_set_value_string (dbValue *value, const char *s)
 Set string value. More...
 
void db_set_value_year (dbValue *value, int year)
 Set year value. More...
 
void db_set_value_month (dbValue *value, int month)
 Set month value. More...
 
void db_set_value_day (dbValue *value, int day)
 Set day value. More...
 
void db_set_value_hour (dbValue *value, int hour)
 Set hour value. More...
 
void db_set_value_minute (dbValue *value, int minute)
 Set minute value. More...
 
void db_set_value_seconds (dbValue *value, double seconds)
 Set seconds value. More...
 
int db_test_value_datetime_current (dbValue *value)
 Check if datatime is current. More...
 
void db_set_value_datetime_current (dbValue *value)
 Set datetime to current. More...
 
void db_set_value_datetime_not_current (dbValue *value)
 Set value to non-current. More...
 
void db_copy_value (dbValue *dst, dbValue *src)
 Copy value. More...
 
void db_CatValArray_init (dbCatValArray *arr)
 Initialize dbCatValArray. More...
 
void db_CatValArray_free (dbCatValArray *arr)
 Free allocated dbCatValArray. More...
 
int db_CatValArray_alloc (dbCatValArray *arr, int n)
 Allocate dbCatValArray. More...
 
int db_CatValArray_realloc (dbCatValArray *arr, int n)
 Realloc dbCatValArray. More...
 

Detailed Description

DBMI Library (base) - value management.

(C) 1999-2009, 2011 by the GRASS Development Team

This program is free software under the GNU General Public License (>=v2). Read the file COPYING that comes with GRASS for details.

Author
Joel Jones (CERL/UIUC), Radim Blazek
Doxygenized by Martin Landa <landa.martin gmail.com> (2011)

Definition in file value.c.

Function Documentation

◆ db_CatValArray_alloc()

int db_CatValArray_alloc ( dbCatValArray arr,
int  n 
)

Allocate dbCatValArray.

Todo:
return type void?
Parameters
arrpointer to dbCatValArray
nnumber of items
Returns
DB_OK

Definition at line 401 of file value.c.

References dbCatValArray::alloc, DB_OK, G_calloc, and dbCatValArray::value.

◆ db_CatValArray_free()

void db_CatValArray_free ( dbCatValArray arr)

◆ db_CatValArray_init()

void db_CatValArray_init ( dbCatValArray arr)

Initialize dbCatValArray.

Parameters
arrpointer to dbCatValArray to be initialized

Definition at line 361 of file value.c.

References dbCatValArray::alloc, dbCatValArray::n_values, NULL, and dbCatValArray::value.

◆ db_CatValArray_realloc()

int db_CatValArray_realloc ( dbCatValArray arr,
int  n 
)

Realloc dbCatValArray.

Todo:
return code void?
Parameters
arrpointer to dbCatValArray
nnumber of items
Returns
DB_OK

Definition at line 420 of file value.c.

References dbCatValArray::alloc, DB_OK, G_realloc, and dbCatValArray::value.

◆ db_copy_value()

void db_copy_value ( dbValue dst,
dbValue src 
)

Copy value.

Copy value from src to destination

Parameters
dstdestination dbValue
srcsource dbValue

Definition at line 340 of file value.c.

◆ db_get_value_as_double()

double db_get_value_as_double ( dbValue value,
int  ctype 
)

Get value as double.

For given value and C type of value returns double representation.

Parameters
valuepointer to dbValue
ctypeC data type
Returns
value

Definition at line 65 of file value.c.

References DB_C_TYPE_DOUBLE, DB_C_TYPE_INT, DB_C_TYPE_STRING, db_get_value_double(), db_get_value_int(), and db_get_value_string().

◆ db_get_value_day()

int db_get_value_day ( dbValue value)

Get day value.

Parameters
valuepointer to dbValue
Returns
value

Definition at line 128 of file value.c.

References _db_date_time::day, and _db_value::t.

Referenced by db_convert_value_datetime_into_string().

◆ db_get_value_double()

double db_get_value_double ( dbValue value)

Get double precision value.

Parameters
valuepointer to dbValue
Returns
value

Definition at line 50 of file value.c.

References _db_value::d.

Referenced by db_convert_value_to_string(), and db_get_value_as_double().

◆ db_get_value_hour()

int db_get_value_hour ( dbValue value)

Get hour value.

Parameters
valuepointer to dbValue
Returns
value

Definition at line 140 of file value.c.

References _db_date_time::hour, and _db_value::t.

Referenced by db_convert_value_datetime_into_string().

◆ db_get_value_int()

int db_get_value_int ( dbValue value)

Get integer value.

Parameters
valuepointer to dbValue
Returns
value

Definition at line 38 of file value.c.

References _db_value::i.

Referenced by db_convert_value_to_string(), and db_get_value_as_double().

◆ db_get_value_minute()

int db_get_value_minute ( dbValue value)

Get minute value.

Parameters
valuepointer to dbValue
Returns
value

Definition at line 152 of file value.c.

References _db_date_time::minute, and _db_value::t.

Referenced by db_convert_value_datetime_into_string().

◆ db_get_value_month()

int db_get_value_month ( dbValue value)

Get month value.

Parameters
valuepointer to dbValue
Returns
value

Definition at line 116 of file value.c.

References _db_date_time::month, and _db_value::t.

Referenced by db_convert_value_datetime_into_string().

◆ db_get_value_seconds()

double db_get_value_seconds ( dbValue value)

Get seconds value.

Parameters
valuepointer to dbValue
Returns
value

Definition at line 164 of file value.c.

References _db_date_time::seconds, and _db_value::t.

Referenced by db_convert_value_datetime_into_string().

◆ db_get_value_string()

const char* db_get_value_string ( dbValue value)

Get string value.

Parameters
valuepointer to dbValue
Returns
value

Definition at line 92 of file value.c.

References db_get_string(), and _db_value::s.

Referenced by db_convert_value_to_string(), and db_get_value_as_double().

◆ db_get_value_year()

int db_get_value_year ( dbValue value)

Get year value.

Parameters
valuepointer to dbValue
Returns
value

Definition at line 104 of file value.c.

References _db_value::t, and _db_date_time::year.

Referenced by db_convert_value_datetime_into_string().

◆ db_set_value_datetime_current()

void db_set_value_datetime_current ( dbValue value)

Set datetime to current.

Parameters
valuepointer to dbValue

Definition at line 315 of file value.c.

References _db_date_time::current, db_set_value_not_null(), and _db_value::t.

Referenced by db_convert_Cstring_to_value_datetime().

◆ db_set_value_datetime_not_current()

void db_set_value_datetime_not_current ( dbValue value)

Set value to non-current.

Parameters
valuepointer to dbValue

Definition at line 326 of file value.c.

References _db_date_time::current, db_set_value_not_null(), and _db_value::t.

Referenced by db_set_value_day(), db_set_value_hour(), db_set_value_minute(), db_set_value_month(), db_set_value_seconds(), and db_set_value_year().

◆ db_set_value_day()

void db_set_value_day ( dbValue value,
int  day 
)

Set day value.

Parameters
valuepointer to dbValue
dayday value

Definition at line 255 of file value.c.

References _db_date_time::day, db_set_value_datetime_not_current(), and _db_value::t.

Referenced by db_convert_Cstring_to_value_datetime().

◆ db_set_value_double()

void db_set_value_double ( dbValue value,
double  d 
)

Set double precision value.

Parameters
valuepointer to dbValue
ddouble value

Definition at line 207 of file value.c.

◆ db_set_value_hour()

void db_set_value_hour ( dbValue value,
int  hour 
)

Set hour value.

Parameters
valuepointer to dbValue
hourhour value

Definition at line 267 of file value.c.

References db_set_value_datetime_not_current(), _db_date_time::hour, and _db_value::t.

Referenced by db_convert_Cstring_to_value_datetime().

◆ db_set_value_int()

void db_set_value_int ( dbValue value,
int  i 
)

Set integer value.

Parameters
valuepointer to dbValue
iinteger value

Definition at line 195 of file value.c.

References db_set_value_not_null(), and _db_value::i.

◆ db_set_value_minute()

void db_set_value_minute ( dbValue value,
int  minute 
)

Set minute value.

Parameters
valuepointer to dbValue
minuteminute value

Definition at line 279 of file value.c.

References db_set_value_datetime_not_current(), _db_date_time::minute, and _db_value::t.

Referenced by db_convert_Cstring_to_value_datetime().

◆ db_set_value_month()

void db_set_value_month ( dbValue value,
int  month 
)

Set month value.

Parameters
valuepointer to dbValue
monthmonth value

Definition at line 243 of file value.c.

References db_set_value_datetime_not_current(), _db_date_time::month, and _db_value::t.

Referenced by db_convert_Cstring_to_value_datetime().

◆ db_set_value_not_null()

void db_set_value_not_null ( dbValue value)

Set value to not null.

Parameters
valuepointer to dbValue

Definition at line 184 of file value.c.

References _db_value::isNull.

Referenced by db_set_value_datetime_current(), db_set_value_datetime_not_current(), and db_set_value_int().

◆ db_set_value_null()

void db_set_value_null ( dbValue value)

Set value to null.

Parameters
valuepointer to dbValue

Definition at line 174 of file value.c.

References _db_value::isNull.

◆ db_set_value_seconds()

void db_set_value_seconds ( dbValue value,
double  seconds 
)

Set seconds value.

Parameters
valuepointer to dbValue
secondsseconds value

Definition at line 291 of file value.c.

References db_set_value_datetime_not_current(), _db_date_time::seconds, and _db_value::t.

Referenced by db_convert_Cstring_to_value_datetime().

◆ db_set_value_string()

int db_set_value_string ( dbValue value,
const char *  s 
)

Set string value.

Parameters
valuepointer to dbValue
sstring value

Definition at line 219 of file value.c.

◆ db_set_value_year()

void db_set_value_year ( dbValue value,
int  year 
)

Set year value.

Parameters
valuepointer to dbValue
yearyear value

Definition at line 231 of file value.c.

References db_set_value_datetime_not_current(), _db_value::t, and _db_date_time::year.

Referenced by db_convert_Cstring_to_value_datetime().

◆ db_test_value_datetime_current()

int db_test_value_datetime_current ( dbValue value)

Check if datatime is current.

Parameters
valuepointer to dbValue
Returns
non-zero for true
zero for false

Definition at line 305 of file value.c.

References _db_date_time::current, and _db_value::t.

Referenced by db_convert_value_datetime_into_string().

◆ db_test_value_isnull()

int db_test_value_isnull ( dbValue value)

Check of value is null.

Parameters
valuepointer to dbValue
Returns
non-zero is null
zero is not null

Definition at line 26 of file value.c.

References _db_value::isNull.

Referenced by db_convert_value_to_string().