obitypes.h 2.34 KB
Newer Older
Celine Mercier's avatar
Celine Mercier committed
1 2 3 4 5 6 7 8 9 10 11
/**
 * @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>
12
#include <unistd.h>
Eric Coissac's avatar
Eric Coissac committed
13
#include <stdint.h>
Celine Mercier's avatar
Celine Mercier committed
14

15

Celine Mercier's avatar
Celine Mercier committed
16 17 18 19
#define OBIInt_NA (INT32_MIN)
#define OBIFloat_NA (NAN)
#define OBIIdx_NA (SIZE_MAX)

20

Celine Mercier's avatar
Celine Mercier committed
21 22 23
/**
 * @brief enum for the boolean OBIType.
 */
24
typedef enum OBIBool {
Celine Mercier's avatar
Celine Mercier committed
25 26 27
    FALSE      = 0,
    TRUE       = 1,
    OBIBool_NA = 2
28
} obibool_t, *obibool_p; 		/**< a boolean true/false value */
Celine Mercier's avatar
Celine Mercier committed
29 30 31


/**
32
 * @brief enum OBITypes for the data type of the OBIDMS columns.
Celine Mercier's avatar
Celine Mercier committed
33 34 35
 */
typedef enum OBIType {
	OBI_VOID    = 0,     		/**< data type not specified */
36 37
	OBI_INT,			    	/**< a signed integer value (C type : int32_t) */
	OBI_FLOAT,					/**< a floating value (C type : double) */
38
	OBI_BOOL,					/**< a boolean true/false value, see obibool_t enum */
39 40
	OBI_CHAR,					/**< a character (C type : char) */
	OBI_IDX					    /**< an index in a data structure (C type : size_t) */
Celine Mercier's avatar
Celine Mercier committed
41 42
} OBIType_t, *OBIType_p;

43

Celine Mercier's avatar
Celine Mercier committed
44 45 46 47 48
typedef int32_t obiint_t;
typedef double obifloat_t;
typedef char obichar_t;
typedef size_t obiidx_t;

49

50 51 52 53 54 55 56 57 58 59 60 61 62
/**
 * @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);

63

64 65 66
/**
 * @brief returns the size requested to store an array of OBIType
 *
67
 * The returned size is large enough to store an array of size nbelement
68 69 70
 * but rounded at a multiple of the memory page size.
 *
 * @param type the OBIType code used as query
71
 * @param nbelement the number of elements to be stored
72
 *
73
 * @return the size in bytes of the array
74 75 76 77 78
 * @retval 0 on error (unknown type)
 *
 * @since May 2015
 * @author Eric Coissac (eric.coissac@metabarcoding.org)
 */
79
size_t obi_array_sizeof(OBIType_t type, size_t nbelements, size_t nb_elements_per_line);
Celine Mercier's avatar
Celine Mercier committed
80

81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96

/**
 * @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);


Celine Mercier's avatar
Celine Mercier committed
97
#endif /* OBITYPES_H_ */