DMS: implemented full information file with JSON formatted comments

This commit is contained in:
Celine Mercier
2018-10-07 18:53:25 +02:00
parent 79f4185757
commit 2736a92699
2 changed files with 477 additions and 85 deletions

View File

@ -75,6 +75,25 @@ typedef struct Opened_indexers_list {
} Opened_indexers_list_t, *Opened_indexers_list_p;
/**
* @brief A structure stored in an information file and containing comments and additional informations on the DMS
* including the command line history.
*
* A pointer on the comments is kept in the OBIDMS structure when a DMS is opened.
*/
typedef struct OBIDMS_infos {
bool little_endian; /** Whether the DMS is in little endian.
*/
size_t file_size; /** The size of the file in bytes.
*/
size_t used_size; /**< Used size in bytes.
*/
char comments[]; /**< Comments, additional informations on the DMS including
* the command line history.
*/
} OBIDMS_infos_t, *OBIDMS_infos_p;
/**
* @brief A structure describing an OBIDMS instance
*
@ -114,12 +133,12 @@ typedef struct OBIDMS {
int tax_dir_fd; /**< The file descriptor of the directory entry
* usable to refer and scan the taxonomy directory.
*/
bool little_endian; /**< Endianness of the database.
*/
Opened_columns_list_p opened_columns; /**< List of opened columns.
*/
Opened_indexers_list_p opened_indexers; /**< List of opened indexers.
*/
OBIDMS_infos_p infos; /**< A pointer on the mapped DMS information file.
*/
} OBIDMS_t, *OBIDMS_p;
@ -239,6 +258,44 @@ OBIDMS_p obi_dms(const char* dms_path);
int obi_close_dms(OBIDMS_p dms, bool force);
/**
* @brief Internal function writing new comments in a DMS informations file.
*
* The new comments replace the pre-existing ones.
* The informations file is enlarged if necessary.
*
* @param dms A pointer on the DMS.
* @param comments The new comments that should be written.
*
* @retval 0 if the operation was successfully completed.
* @retval -1 if an error occurred.
*
* @since September 2018
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int obi_dms_write_comments(OBIDMS_p dms, const char* comments);
/**
* @brief Adds comments to a DMS informations file.
*
* This reads the comments in the JSON format and adds the key value pair.
* If the key already exists, the value format is turned into an array and the new value is appended
* if it is not already in the array.
*
* @param column A pointer on an OBIDMS column.
* @param key The key.
* @param value The value associated with the key.
*
* @retval 0 if the operation was successfully completed.
* @retval -1 if an error occurred.
*
* @since September 2018
* @author Celine Mercier (celine.mercier@metabarcoding.org)
*/
int obi_dms_add_comment(OBIDMS_p dms, const char* key, const char* value);
/**
* @brief Returns a column identified by its name and its version number from the list of opened columns.
*