gd_native_type(3)

πŸ’– gd_native_type β€” the getdata manual, bestie edition πŸ’–

okay so this is gd_native_type(3), a page from the GETDATA manual, and I'm gonna walk you through it like we're texting at 2am. it's literally just "what type of data is this field, natively?" and honestly? iconic. let's go. πŸ¦‹


✨ NAME ✨

gd_native_type β€” returns the native data type of a field in a Dirfile. no cap, that's the whole job. πŸ’…


🌸 SYNOPSIS 🌸

#include <getdata.h>

gd_type_t gd_native_type(DIRFILE *dirfile, const char *field_code);

πŸ‘‘ DESCRIPTION πŸ‘‘

The gd_native_type() function queries a dirfile(5) database β€” the one you point at with dirfile β€” and figures out the native type of the data specified by field_code. and yes bestie, field_code may contain a representation suffix. we love a suffix. πŸŽ€

The dirfile argument must point to a valid DIRFILE object, one that was previously created by a call to gd_open(3). don't be out here passing random garbage, it's giving invalid-dirfile energy. πŸ™ˆ

So here's the tea β€” the native data type of a field depends on its entry type, calculated like this:

  • BIT, INDEX β€” GD_UINT64
  • CONST, CARRAY β€” the data type of the field
  • DIVIDE, MULTIPLY β€” if either input field is complex valued: GD_COMPLEX128, otherwise: GD_FLOAT64
  • INDIR β€” the data type of the input CARRAY
  • LINCOM, POLYNOM β€” if any of the scalar parameters is complex valued, or if the native data type of any of the input fields is complex valued: GD_COMPLEX128, otherwise: GD_FLOAT64
  • LINTERP β€” if the look-up table is complex valued: GD_COMPLEX128, otherwise: GD_FLOAT64
  • MPLEX, WINDOW β€” the native data type of the data field
  • PHASE β€” the native data type of the input field
  • RAW β€” the data type of the raw data on disk
  • RECIP β€” if the dividend or the native data type of the input field is complex valued: GD_COMPLEX128, otherwise: GD_FLOAT64
  • SARRAY, SINDIR, STRING β€” GD_STRING
  • SBIT β€” GD_INT64

And one more thing, super important: if the field_code you handed over contains a representation suffix, and the native data type of the field is complex valued, then the native type it returns will be the corresponding real valued type. slay. ✨


πŸ’€ RETURN VALUE πŸ’€

If it works out, gd_native_type() returns the native data type of the field code you specified. and that's gonna equal one of these symbols, periodt:

GD_UINT8, GD_INT8, GD_UINT16, GD_INT16, GD_UINT32, GD_INT32,
GD_FLOAT32, GD_FLOAT64, GD_COMPLEX64, GD_COMPLEX128, GD_STRING.

The meanings of these symbols are explained in the gd_getdata(3) manual page. go read it, iykyk. πŸ“–

On error, this function returns GD_UNKNOWN and stores a negative-valued error code in the DIRFILE object, which you can retrieve with a subsequent call to gd_error(3). not the vibe we wanted but okay.

Possible error codes, bestie, brace yourself:

  • GD_E_ALLOC β€” The library was unable to allocate memory. 😭
  • GD_E_BAD_CODE β€” The field specified by field_code, or one of the fields it uses as input, was not found in the database.
  • GD_E_BAD_DIRFILE β€” The supplied dirfile was invalid.
  • GD_E_DIMENSION β€” A scalar field was found where a vector field was expected.
  • GD_E_IO β€” An error occurred while trying to read a LINTERP table from disk.
  • GD_E_LUT β€” A LINTERP table was malformed.
  • GD_E_RECURSE_LEVEL β€” Too many levels of recursion were encountered while trying to resolve field_code. This usually indicates a circular dependency in field specification in the dirfile. (we've all been in a circular dependency, it's fine, it's a phase.) πŸŒ€

A descriptive error string for the error may be obtained by calling gd_error_string(3). 🫢


πŸ¦‹ HISTORY πŸ¦‹

  • The get_native_type() function appeared in GetData-0.6.0. The return type for STRING fields was GD_NULL.
  • In GetData-0.7.0, this function was renamed to gd_native_type().
  • Before GetData-0.10.0, the return type for STRING fields was GD_NULL.

a whole glow-up arc, honestly. πŸ’–


🌈 SEE ALSO 🌈

gd_error(3), gd_error_string(3) gd_getdata(3), gd_open(3), dirfile(5)


Version 0.10.0 Β· 25 January 2017

and that's the whole page bestie, mwah πŸ’…βœ¨ ily, go read your dirfiles, and remember: GD_UNKNOWN is a mood but not a lifestyle. πŸŽ€πŸ¦‹