2015-05-22 17:54:34 +02:00
|
|
|
/****************************************************************************
|
2015-06-10 15:19:02 +02:00
|
|
|
* OBIDMS_column header file *
|
2015-05-22 17:54:34 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file obidmscolumn.h
|
|
|
|
* @author Celine Mercier
|
|
|
|
* @date 12 May 2015
|
2015-06-10 15:19:02 +02:00
|
|
|
* @brief Header file for the shared elements of all the OBIDMS column structures.
|
2015-05-22 17:54:34 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef OBIDMSCOLUMN_H_
|
|
|
|
#define OBIDMSCOLUMN_H_
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdbool.h>
|
2015-05-26 10:38:56 +02:00
|
|
|
#include <time.h>
|
2015-05-22 17:54:34 +02:00
|
|
|
|
2015-05-26 10:38:56 +02:00
|
|
|
#include <obidms.h>
|
|
|
|
#include <obitypes.h>
|
|
|
|
#include <obierrno.h>
|
|
|
|
#include <obilittlebigman.h>
|
2015-05-22 17:54:34 +02:00
|
|
|
|
|
|
|
|
2015-05-26 10:38:56 +02:00
|
|
|
#define OBIDMS_MAX_COLNAME (128) /**< The maximum length of an OBIDMS column name
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef int32_t obiversion_t; /**< Used to store the column version number
|
|
|
|
*/
|
2015-05-22 17:54:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief OBIColumnHeader structure.
|
|
|
|
*/
|
|
|
|
|
2015-06-10 15:19:02 +02:00
|
|
|
typedef struct OBIDMS_column_header {
|
2015-05-26 10:38:56 +02:00
|
|
|
bool little_endian; /**< endianess of the column:
|
2015-06-10 15:19:02 +02:00
|
|
|
- `true` on little endian platforms
|
|
|
|
- `false` on big endian platforms
|
2015-05-26 10:38:56 +02:00
|
|
|
|
|
|
|
@see obi_is_little_end()
|
|
|
|
*/
|
|
|
|
int header_size; /**< size of the header in bytes */
|
|
|
|
size_t line_count; /**< number of lines of data */
|
|
|
|
size_t line_used; /**< number of lines of data used*/
|
2015-05-22 17:54:34 +02:00
|
|
|
OBIType_t data_type; /**< type of the data */
|
2015-05-26 10:38:56 +02:00
|
|
|
time_t creation_date; /**< date of creation of the file */
|
|
|
|
obiversion_t version; /**< version of the OBIColumn */
|
2015-05-26 21:36:55 +02:00
|
|
|
char name[OBIDMS_MAX_COLNAME+1]; /**< The column name as a NULL
|
2015-05-26 10:38:56 +02:00
|
|
|
* terminated string.
|
|
|
|
*/
|
|
|
|
char comments[1]; /**< comments stored as a classical
|
|
|
|
zero end C string. T
|
2015-06-10 15:19:02 +02:00
|
|
|
The size of the comment is only limited
|
2015-05-26 10:38:56 +02:00
|
|
|
by the header size
|
|
|
|
*/
|
2015-06-10 15:19:02 +02:00
|
|
|
} OBIDMS_column_header_t, *OBIDMS_column_header_p;
|
2015-05-22 17:54:34 +02:00
|
|
|
|
2015-05-26 10:38:56 +02:00
|
|
|
/**
|
|
|
|
* @brief Structure describing a Column of the OBITools DMS
|
|
|
|
*
|
|
|
|
* A data structure of this type is returned by the functions
|
2015-06-10 15:19:02 +02:00
|
|
|
* creating, opening or cloning an OBIDMS_column.
|
2015-05-26 10:38:56 +02:00
|
|
|
*/
|
2015-06-10 15:19:02 +02:00
|
|
|
typedef struct OBIDMS_column {
|
2015-05-26 10:38:56 +02:00
|
|
|
OBIDMS_p dms ; /**< A pointer to a DMS instance
|
|
|
|
*/
|
2015-06-10 15:19:02 +02:00
|
|
|
OBIDMS_column_header_p header; /**< A pointer to the header of the column
|
2015-05-26 10:38:56 +02:00
|
|
|
*/
|
|
|
|
void* data; /**< A `void` pointer to the beginning of the
|
|
|
|
* data.
|
|
|
|
*
|
2015-06-10 15:19:02 +02:00
|
|
|
* @warning never use this member directly
|
|
|
|
* outside of the code of the
|
|
|
|
* low level functions
|
|
|
|
* of the OBITools DMS
|
2015-05-26 10:38:56 +02:00
|
|
|
*/
|
|
|
|
bool writable;/**< Indicates if the column is writable or not.
|
|
|
|
* - `true` the column is writable
|
|
|
|
* - `false` the column is read-only
|
|
|
|
*
|
|
|
|
* A column is writable only by its creator
|
2015-06-10 15:19:02 +02:00
|
|
|
* until it closes it.
|
2015-05-26 10:38:56 +02:00
|
|
|
*/
|
2015-06-10 15:19:02 +02:00
|
|
|
} OBIDMS_column_t, *OBIDMS_column_p;
|
|
|
|
|
2015-05-26 10:38:56 +02:00
|
|
|
|
|
|
|
/**
|
2015-06-10 15:19:02 +02:00
|
|
|
* @brief Returns the header size in bytes of a column on this platform.
|
2015-05-26 10:38:56 +02:00
|
|
|
*
|
|
|
|
* Header size is defined as a multiple of the memory page size.
|
|
|
|
* Up to now the header size is defined as one time the page size
|
|
|
|
*
|
|
|
|
* @return a `size_t` value corresponding to the header size in bytes
|
|
|
|
*
|
|
|
|
* @since May 2015
|
|
|
|
* @author Eric Coissac (eric.coissac@metabarcoding.org)
|
|
|
|
*/
|
|
|
|
size_t obi_get_platform_header_size();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-10 15:19:02 +02:00
|
|
|
* @brief Creates a column.
|
2015-05-26 10:38:56 +02:00
|
|
|
*
|
|
|
|
* @param dms a pointer as returned by obi_create_dms() or obi_open_dms()
|
|
|
|
* @param name the name of the new column
|
|
|
|
* @param type the OBIType code used to create the column
|
2015-06-10 15:19:02 +02:00
|
|
|
* @param nbelements the number of elements to be stored
|
2015-05-26 10:38:56 +02:00
|
|
|
*
|
|
|
|
* @since May 2015
|
|
|
|
* @author Eric Coissac (eric.coissac@metabarcoding.org)
|
|
|
|
*/
|
2015-06-10 15:19:02 +02:00
|
|
|
OBIDMS_column_p obi_create_column(OBIDMS_p dms,
|
2015-05-26 10:38:56 +02:00
|
|
|
char* name,
|
|
|
|
OBIType_t type,
|
2015-06-10 15:19:02 +02:00
|
|
|
size_t nbelements);
|
2015-05-26 10:38:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
2015-06-10 15:19:02 +02:00
|
|
|
* @brief Returns the latest column version in the `dms` database
|
2015-05-26 10:38:56 +02:00
|
|
|
*
|
|
|
|
* @param dms a pointer as returned by obi_create_dms() or obi_open_dms()
|
|
|
|
* @param name the name of the column
|
|
|
|
*
|
|
|
|
* @return the bigger version number used for this column
|
|
|
|
* @return -1 if the column does not exist
|
|
|
|
*/
|
|
|
|
obiversion_t obi_latest_version(OBIDMS_p dms,char *name);
|
2015-05-22 17:54:34 +02:00
|
|
|
|
|
|
|
|
|
|
|
#endif /* OBIDMSCOLUMN_H_ */
|