GRASS GIS 7 Programmer's Manual  7.5.svn(2017)-r71790
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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, and dbCatValArray::value.

Referenced by db_select_CatValArray(), and Vedit_bulk_labeling().

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.

Referenced by IL_vector_input_data_2d(), NetA_get_node_costs(), Vect_net_build_graph(), and Vect_net_ttb_build_graph().

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, and dbCatValArray::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.

References _db_date_time::current, _db_value::d, _db_date_time::day, db_copy_string(), _db_date_time::hour, _db_value::i, _db_value::isNull, _db_date_time::minute, _db_date_time::month, _db_string::nalloc, _db_value::s, _db_date_time::seconds, _db_value::t, and _db_date_time::year.

Referenced by db_copy_column(), and db_select_value().

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().

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().

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(), db_get_value_as_double(), db_select_CatValArray(), db_select_int(), P_Aux_to_Vector(), and Vect_write_ascii().

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().

int db_get_value_int ( dbValue value)
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().

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().

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().

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(), db_get_value_as_double(), db_select_CatValArray(), db_select_int(), Gp_load_sites_thematic(), Gv_load_vect_thematic(), and Vect_write_ascii().

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().

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().

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().

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().

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.

References _db_value::d, and db_set_value_not_null().

Referenced by db_convert_Cstring_to_value().

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().

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.

Referenced by db_convert_Cstring_to_value().

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().

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().

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(), db_set_value_double(), db_set_value_int(), and db_set_value_string().

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.

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().

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.

References db_set_string(), db_set_value_not_null(), and _db_value::s.

Referenced by db_convert_Cstring_to_value().

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().

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().

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(), and Vect_write_ascii().