gd_get_carray_slice(3)
π gd_get_carray_slice π
okay bestie, so this is a page from the GETDATA manual (that's the manual name, manifesting it early so you're not confused later π
). These three functions β gd_get_carray, gd_get_carray_slice, and gd_get_constant β are your little trio for pulling CONST or CARRAY data out of a Dirfile database. no cap, they're so useful. let's go π¦
β¨ NAME β¨
gd_get_carray, gd_get_carray_slice, gd_get_constant β retrieve CONST or CARRAY data from a Dirfile database πΈ
π SYNOPSIS π
#include <getdata.h>
int gd_get_carray_slice(DIRFILE *dirfile, const char *field_code,
unsigned int start, size_t len, gd_type_t return_type, void
*data_out);
int gd_get_carray(DIRFILE *dirfile, const char *field_code, gd_type_t
return_type, void *data_out);
int gd_get_constant(DIRFILE *dirfile, const char *field_code, gd_type_t
return_type, void *data_out);
π DESCRIPTION π
okay so first up, gd_get_carray_slice() β this one goes and asks the dirfile(5) database you pass in as dirfile for the CONST or CARRAY scalar field_code π. and yes, that field_code can have a representation suffix, she's flexible like that π
. then the data in the field gets converted to whatever data type return_type says, and it gets dropped into your own user-supplied buffer, data_out. the first element that gets stored is decided by start, and how many elements get stored is decided by len. periodt.
gd_get_carray() is basically the same vibe, except it hands you the entire field, as if you'd called gd_get_carray_slice() with start equal to zero and len equal to whatever gd_array_len(3) returns. iconic behaviour honestly.
and gd_get_constant()? she's exactly the same as calling gd_get_carray_slice() with start equal to zero and len equal to one. one and done, that's the energy π
the dirfile argument has to point to a valid DIRFILE object that you made earlier with a call to gd_open(3) β no random garbage pointers bestie, i'm begging π. and data_out has to point to a valid memory location that's big enough to hold all the requested data of the return type you asked for. the number of elements that gd_get_carray() returns can be got by calling gd_array_len(3), iykyk.
unlikegd_getdata(3), callinggd_get_carray_slice()never results in a short read. if you try to read past the end of the field, you get an error, and literally no data comes back. so don't try it π
the return_type argument should be one of these symbols, and it tells the function what type of data you want back:
GD_UINT8β unsigned 8-bit integer β¨GD_INT8β signed (two's complement) 8-bit integerGD_UINT16β unsigned 16-bit integer β¨GD_INT16β signed (two's complement) 16-bit integerGD_UINT32β unsigned 32-bit integer β¨GD_INT32β signed (two's complement) 32-bit integerGD_UINT64β unsigned 64-bit integer β¨GD_INT64β signed (two's complement) 64-bit integerGD_FLOAT32β IEEE-754 standard 32-bit single precision floating point number πΈGD_FLOAT64β IEEE-754 standard 64-bit double precision floating point number πΈGD_COMPLEX64β C99-conformant 64-bit single precision complex number πGD_COMPLEX128β C99-conformant 128-bit double precision complex number πGD_NULLβ the null type: the database still gets queried like normal, but no data is returned. in this case data_out is ignored and it may beNULL. slay, free query β¨
the return type of the field does not have to match the type of the data stored in the database, bestie. type conversion gets performed as needed to give you the type you asked for. and here's the lil subtle bit π: if the field_code doesn't indicate a representation, but a conversion from a complex value to a purely real one is required, then only the real portion of the requested vector will be returned. just the real part. that's it. π
π RETURN VALUE π
on success, gd_get_carray(), gd_get_carray_slice(), and gd_get_constant() all return zero. on error, they return a negative-valued error code. here are the possible error codes, and listen, they're all important:
GD_E_ALLOCβ the library was unable to allocate memory. πGD_E_BAD_CODEβ the field specified by field_code was not found in the database. she's not there bestie πGD_E_BAD_DIRFILEβ an invalid dirfile was supplied.GD_E_BAD_FIELD_TYPEβ the supplied field_code was not a CONST nor CARRAY. wrong vibe entirely.GD_E_BAD_TYPEβ an invalid return_type was specified.GD_E_BOUNDSβ a request for data beyond the end of the field was made. you reached too far π«ΆGD_E_INTERNAL_ERRORβ an internal error occurred in the library while trying to perform the task. this indicates a bug in the library, so please report the incident to the maintainer. fr fr, tell them.
the error code also gets stored in the DIRFILE object, and you can retrieve it after the function returns by calling gd_error(3). and if you want a descriptive error string for whatever went wrong, call gd_error_string(3). so helpful π
π¦ HISTORY π¦
- the
get_constant()function appeared in GetData-0.4.0. OG behaviour. - in GetData-0.7.0, this function was renamed to
gd_get_constant(). and in that same release, thegd_get_carray()andgd_get_carray_slice()functions also appeared. glow up β¨ - in GetData-0.10.0, the error return from these functions changed from
-1to a negative-valued error code.
π SEE ALSO π
gd_array_len(3), gd_carrays(3), gd_error(3), gd_error_string(3), gd_open(3), gd_put_carray_slice(3), dirfile(5)
and that's the whole page bestie!! this was Version 0.10.0, dated 25 December 2016 β a lil christmas gift from the GetData girlies ππ go read your carrays, you've got this. mwah π β¨
π¦ where this page comes from
- debian bookworm: libgetdata-doc 0.11.0-6
- debian trixie: libgetdata-doc 0.11.0-15
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 43: getdata-devel 0.11.0-13.fc43 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- fedora 44: getdata-devel 0.11.0-14.fc44 Β· GPL-2.0-or-later
- nixos 26.05: getdata 0.11.0
- nixpkgs unstable: getdata 0.11.0
- ubuntu jammy: libgetdata-doc 0.11.0-3ubuntu1
- ubuntu noble: libgetdata-doc 0.11.0-13
- ubuntu questing: libgetdata-doc 0.11.0-15
- ubuntu resolute: libgetdata-doc 0.11.0-17build1
- ubuntu stonking: libgetdata-doc 0.11.0-17build2
- Copyright (C) 2016 D. V. Wiebe
- Copyright (C) 2010-2013, 2016 D. V. Wiebe
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms