shapereader
Read ESRI shapefiles
Public Member Functions
dbf_record_t Struct Reference

Record.

#include <dbf.h>

Public Member Functions

void dbf_record_bytes (const dbf_record_t *record, const dbf_field_t *field, const char **pbytes, size_t *len)
 Get bytes. More...
 
int dbf_record_date (const dbf_record_t *record, const dbf_field_t *field, struct tm *tm)
 Get a date. More...
 
int dbf_record_datetime (const dbf_record_t *record, const dbf_field_t *field, struct tm *tm)
 Get a date and a time. More...
 
int dbf_record_double (const dbf_record_t *record, const dbf_field_t *field, double *value)
 Get a double value. More...
 
int dbf_record_int32 (const dbf_record_t *record, const dbf_field_t *field, int32_t *value)
 Get a 32-bit integer value. More...
 
int dbf_record_int64 (const dbf_record_t *record, const dbf_field_t *field, int64_t *value)
 Get a 64-bit integer value. More...
 
int dbf_record_is_deleted (const dbf_record_t *record)
 Check if a record is deleted. More...
 
int dbf_record_is_null (const dbf_record_t *record, const dbf_field_t *field)
 Check if a field is null. More...
 
int dbf_record_logical (const dbf_record_t *record, const dbf_field_t *field)
 Get a logical value. More...
 
int dbf_record_logical_is_false (const dbf_record_t *record, const dbf_field_t *field)
 Check if a logical value is false. More...
 
int dbf_record_logical_is_true (const dbf_record_t *record, const dbf_field_t *field)
 Check if a logical value is true. More...
 
char * dbf_record_strdup (const dbf_record_t *record, const dbf_field_t *field)
 Duplicate a string. More...
 
void dbf_record_string (const dbf_record_t *record, const dbf_field_t *field, const char **pstr, size_t *len)
 Get a string. More...
 
int dbf_record_strtod (const dbf_record_t *record, const dbf_field_t *field, double *value)
 Convert a string to double representation. More...
 
int dbf_record_strtol (const dbf_record_t *record, const dbf_field_t *field, int base, long *value)
 Convert a string to a long integer. More...
 
int dbf_record_strtold (const dbf_record_t *record, const dbf_field_t *field, long double *value)
 Convert a string to long double representation. More...
 
int dbf_record_strtoll (const dbf_record_t *record, const dbf_field_t *field, int base, long long *value)
 Convert a string to a long long integer. More...
 
int dbf_record_strtoul (const dbf_record_t *record, const dbf_field_t *field, int base, unsigned long *value)
 Convert a string to an unsigned long integer. More...
 
int dbf_record_strtoull (const dbf_record_t *record, const dbf_field_t *field, int base, unsigned long long *value)
 Convert a string to an unsigned long long integer. More...
 

Member Function Documentation

◆ dbf_record_bytes()

void dbf_record_bytes ( const dbf_record_t record,
const dbf_field_t field,
const char **  pbytes,
size_t *  len 
)

Gets the bytes and the number of bytes from a field in a record.

Parameters
recorda record.
fielda field in the record.
[out]pbytesa pointer to the bytes.
[out]lenthe number of bytes.

◆ dbf_record_date()

int dbf_record_date ( const dbf_record_t record,
const dbf_field_t field,
struct tm *  tm 
)

Fills a tm structure with the day, month and year from a date in the format "YYYYMMDD".

The tm_wday member is only valid after 15 October 1582 in the Gregorian calendar.

The tm_isdst member is always set to -1.

Parameters
recorda record.
fielda field in the record.
[out]tma tm structure.
Returns
true on success, otherwise false.

◆ dbf_record_datetime()

int dbf_record_datetime ( const dbf_record_t record,
const dbf_field_t field,
struct tm *  tm 
)

Fills a tm structure with a date and time from a date and time field.

The tm_isdst member is always set to -1.

Parameters
recorda record.
fielda field in the record.
[out]tma tm structure.
Returns
true on success, otherwise false.

◆ dbf_record_double()

int dbf_record_double ( const dbf_record_t record,
const dbf_field_t field,
double *  value 
)

Gets a floating-point number from a double field.

Parameters
recorda record.
fielda field in the record.
[out]valuethe double value.
Returns
true on success, otherwise false.

◆ dbf_record_int32()

int dbf_record_int32 ( const dbf_record_t record,
const dbf_field_t field,
int32_t *  value 
)

Gets an integer from an auto-increment or integer field.

Parameters
recorda record.
fielda field in the record.
[out]valuethe unscaled value.
Returns
true on success, otherwise false.

◆ dbf_record_int64()

int dbf_record_int64 ( const dbf_record_t record,
const dbf_field_t field,
int64_t *  value 
)

Gets an unscaled integer from a currency field. The scale is stored in field->decimal_places.

For example, the decimal fraction 3.45 has the unscaled value 345 and the scale 2.

Parameters
recorda record.
fielda field in the record.
[out]valuethe unscaled value.
Returns
true on success, otherwise false.

◆ dbf_record_is_deleted()

int dbf_record_is_deleted ( const dbf_record_t record)

Returns true if the record is marked as deleted.

Parameters
recorda record.
Returns
true if the record is deleted, otherwise false.

◆ dbf_record_is_null()

int dbf_record_is_null ( const dbf_record_t record,
const dbf_field_t field 
)

Returns true if the field contains an empty string, if a number field contains asterisks, if a date field is "00000000" or if a logical field is neither true nor false.

Parameters
recorda record.
fielda field in the record.
Returns
true if the field is defined, otherwise false.

◆ dbf_record_logical()

int dbf_record_logical ( const dbf_record_t record,
const dbf_field_t field 
)

Returns the value of a logical field.

Possible values are:

  • True: 'T', 't', 'Y' or 'y'
  • False: 'F', 'f', 'N' or 'n'
  • Undefined: '?' or a space character
Parameters
recorda record.
fielda field in the record.
Returns
a logical value or zero if the field is not a logical field.

◆ dbf_record_logical_is_false()

int dbf_record_logical_is_false ( const dbf_record_t record,
const dbf_field_t field 
)

Returns true if a field's value is 'F', 'f', 'N' or 'n'.

A logical value can be true, false or undefined.

Parameters
recorda record.
fielda field in the record.
Returns
true if the logical value is false, otherwise false.

◆ dbf_record_logical_is_true()

int dbf_record_logical_is_true ( const dbf_record_t record,
const dbf_field_t field 
)

Returns true if a field's value is 'T', 't', 'Y' or 'y'.

A logical value can be true, false or undefined.

Parameters
recorda record.
fielda field in the record.
Returns
true if the logical value is true, otherwise false.

◆ dbf_record_strdup()

char * dbf_record_strdup ( const dbf_record_t record,
const dbf_field_t field 
)

Duplicates a string. The string is not decoded to UTF-8.

Parameters
recorda record.
fielda field in the record.
Returns
a string that needs to be freed with free(). The function returns NULL if the required memory could not be allocated.

◆ dbf_record_string()

void dbf_record_string ( const dbf_record_t record,
const dbf_field_t field,
const char **  pstr,
size_t *  len 
)

Gets a string and its length. The string is not null-terminated and not decoded to UTF-8.

Parameters
recorda record.
fielda field in the record.
[out]pstra pointer to the string.
[out]lenthe length.

◆ dbf_record_strtod()

int dbf_record_strtod ( const dbf_record_t record,
const dbf_field_t field,
double *  value 
)

Converts a numeric string to a floating-point number. Fails if the string does not contain a number.

Parameters
recorda record.
fielda field in the record.
[out]valuethe converted value.
Returns
true on success, otherwise false.

◆ dbf_record_strtol()

int dbf_record_strtol ( const dbf_record_t record,
const dbf_field_t field,
int  base,
long *  value 
)

Converts a numeric string to a long integer. Fails if the string does not contain a number with no decimal places.

Parameters
recorda record.
fielda field in the record.
base10 for decimal. See strtol(3) for details.
[out]valuethe converted value.
Returns
true on success, otherwise false.

◆ dbf_record_strtold()

int dbf_record_strtold ( const dbf_record_t record,
const dbf_field_t field,
long double *  value 
)

Converts a numeric string field to a floating-point number. Fails if the string does not contain a number.

Parameters
recorda record.
fielda field in the record.
[out]valuethe converted value.
Returns
true on success, otherwise false.

◆ dbf_record_strtoll()

int dbf_record_strtoll ( const dbf_record_t record,
const dbf_field_t field,
int  base,
long long *  value 
)

Converts a numeric string to a long long integer. Fails if the string does not contain a number with no decimal places.

Parameters
recorda record.
fielda field in the record.
base10 for decimal. See strtol(3) for details.
[out]valuethe converted value.
Returns
true on success, otherwise false.

◆ dbf_record_strtoul()

int dbf_record_strtoul ( const dbf_record_t record,
const dbf_field_t field,
int  base,
unsigned long *  value 
)

Converts a numeric string to an unsigned long integer. Fails if the string does not contain a non-negative number with no decimal places.

Parameters
recorda record.
fielda field in the record.
base10 for decimal. See strtoul(3) for details.
[out]valuethe converted value.
Returns
true on success, otherwise false.

◆ dbf_record_strtoull()

int dbf_record_strtoull ( const dbf_record_t record,
const dbf_field_t field,
int  base,
unsigned long long *  value 
)

Converts a numeric string to an unsigned long long integer. Fails if the string does not contain a non-negative number with no decimal places.

Parameters
recorda record.
fielda field in the record.
base10 for decimal. See strtoull(3) for details.
[out]valuethe converted value.
Returns
true on success, otherwise false.

The documentation for this struct was generated from the following file: