115 lines
2.7 KiB
C
115 lines
2.7 KiB
C
/**
|
|
* @file obitypes.h
|
|
* @author Celine Mercier
|
|
* @date 18 May 2015
|
|
* @brief Header file for the OBITypes.
|
|
*/
|
|
|
|
#ifndef OBITYPES_H_
|
|
#define OBITYPES_H_
|
|
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <stdint.h>
|
|
|
|
|
|
#define OBIInt_NA (INT32_MIN)
|
|
#define OBIIdx_NA (SIZE_MAX)
|
|
#define OBIFloat_NA (float_NA())
|
|
#define OBIChar_NA (0) // TODO not sure about this one as it can be impossible to distinguish from uninitialized values
|
|
|
|
|
|
/**
|
|
* @brief enum for the boolean OBIType.
|
|
*/
|
|
typedef enum OBIBool {
|
|
FALSE = 0,
|
|
TRUE = 1,
|
|
OBIBool_NA = 2
|
|
} obibool_t, *obibool_p; /**< a boolean true/false value */
|
|
|
|
|
|
/**
|
|
* @brief enum OBITypes for the data type of the OBIDMS columns.
|
|
*/
|
|
typedef enum OBIType {
|
|
OBI_VOID = 0, /**< data type not specified */
|
|
OBI_INT, /**< a signed integer value (C type : int32_t) */
|
|
OBI_FLOAT, /**< a floating value (C type : double) */
|
|
OBI_BOOL, /**< a boolean true/false value, see obibool_t enum */
|
|
OBI_CHAR, /**< a character (C type : char) */
|
|
OBI_IDX /**< an index in a data structure (C type : size_t) */
|
|
} OBIType_t, *OBIType_p;
|
|
|
|
|
|
typedef int32_t obiint_t;
|
|
typedef double obifloat_t;
|
|
typedef char obichar_t;
|
|
typedef size_t obiidx_t;
|
|
|
|
|
|
typedef union
|
|
{
|
|
double value;
|
|
unsigned int word[2];
|
|
} ieee_double;
|
|
|
|
|
|
static double float_NA(void) // as defined in R
|
|
{
|
|
volatile ieee_double x;
|
|
x.word[0] = 0x7ff00000;
|
|
x.word[1] = 1954;
|
|
return x.value;
|
|
}
|
|
|
|
|
|
/**
|
|
* @brief returns the memory size in bytes of an OBIType
|
|
*
|
|
* @param type the OBIType code used as query
|
|
*
|
|
* @return the size in bytes of the type
|
|
* @retval 0 on error (unknown type)
|
|
*
|
|
* @since May 2015
|
|
* @author Eric Coissac (eric.coissac@metabarcoding.org)
|
|
*/
|
|
size_t obi_sizeof(OBIType_t type);
|
|
|
|
|
|
/**
|
|
* @brief returns the size requested to store an array of OBIType
|
|
*
|
|
* The returned size is large enough to store an array of size nbelement
|
|
* but rounded at a multiple of the memory page size.
|
|
*
|
|
* @param type the OBIType code used as query
|
|
* @param nbelement the number of elements to be stored
|
|
*
|
|
* @return the size in bytes of the array
|
|
* @retval 0 on error (unknown type)
|
|
*
|
|
* @since May 2015
|
|
* @author Eric Coissac (eric.coissac@metabarcoding.org)
|
|
*/
|
|
size_t obi_array_sizeof(OBIType_t type, size_t nbelements, size_t nb_elements_per_line);
|
|
|
|
|
|
/**
|
|
* @brief returns the name in the form of a character string of an OBIType
|
|
*
|
|
*
|
|
* @param data_type the OBIType code used as query
|
|
*
|
|
* @return the name of the OBIType
|
|
* @retval NULL on error (unknown type or error allocating the memory for the character string)
|
|
*
|
|
* @since August 2015
|
|
* @author Celine Mercier (celine.mercier@metabarcoding.org)
|
|
*/
|
|
char* name_data_type(int data_type);
|
|
|
|
|
|
#endif /* OBITYPES_H_ */
|