Comments in column headers are now working.

This commit is contained in:
Celine Mercier
2015-11-10 10:56:45 +01:00
parent f6ec8ba963
commit c4b7e579cf
7 changed files with 33 additions and 19 deletions

View File

@ -25,7 +25,7 @@
#include "obitypes.h"
#define ARRAY_MAX_NAME (2048) /**< The maximum length of an array name.
#define ARRAY_MAX_NAME (1024) /**< The maximum length of an array name.
*/
#define ARRAY_GROWTH_FACTOR (2) /**< The growth factor when an array is enlarged.
*/

View File

@ -495,7 +495,8 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
index_t nb_lines,
index_t nb_elements_per_line,
const char* elements_names,
const char* array_name)
const char* array_name,
const char* comments)
{
OBIDMS_column_p new_column;
OBIDMS_column_directory_p column_directory;
@ -682,12 +683,14 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
header->creation_date = time(NULL);
header->version = version_number;
header->cloned_from = -1;
header->comments[0] = 0x0; // TODO
obi_column_set_elements_names(new_column, elements_names);
strncpy(header->name, column_name, OBIDMS_COLUMN_MAX_NAME);
if (comments != NULL)
strncpy(header->comments, comments, COMMENTS_MAX_LENGTH);
// If the data type is OBI_IDX, the associated obi_array is opened or created
if (data_type == 5)
{
@ -880,7 +883,8 @@ OBIDMS_column_p obi_clone_column(OBIDMS_p dms,
nb_lines,
nb_elements_per_line,
(column_to_clone->header)->elements_names,
(column_to_clone->header)->array_name);
(column_to_clone->header)->array_name,
(column_to_clone->header)->comments);
if (new_column == NULL)
{
@ -893,7 +897,6 @@ OBIDMS_column_p obi_clone_column(OBIDMS_p dms,
}
(new_column->header)->cloned_from = version_number;
//memcpy((new_column->header)->comments, (column_to_clone->header)->comments, obi_get_platform_header_size() - //??(column_to_clone->header)->comments); // TODO
if (clone_data)
{
@ -1284,7 +1287,7 @@ int obi_unmap_header(OBIDMS_column_header_p header)
}
// TODO to be rewritten in an optimized and safe way
// TODO to be rewritten in an optimized and safe way if possible
index_t obi_column_get_element_index_from_name(OBIDMS_column_p column, const char* element_name)
{
char* elements_names;

View File

@ -36,9 +36,10 @@
*/
#define MAXIMUM_LINE_COUNT (1000000) /**< The maximum line count for the data of a column. //TODO
*/
#define FORMATTED_TIME_LENGTH (1024) /**< The length allocated for the character string containing a formatted date
#define FORMATTED_TIME_LENGTH (1024) /**< The length allocated for the character string containing a formatted date.
*/
#define COMMENTS_MAX_LENGTH (2048) /**< The maximum length for comments.
*/
typedef int32_t obiversion_t; /**< Used to store the column version number
*/
@ -75,8 +76,7 @@ typedef struct OBIDMS_column_header {
*/
char array_name[ARRAY_MAX_NAME+1]; /**< If there is one, the obi_array name as a NULL terminated string.
*/
char comments[1]; /**< Comments stored as a classical zero end C string.
* The size of the comment is only limited by the header size.
char comments[COMMENTS_MAX_LENGTH+1]; /**< Comments stored as a classical zero end C string.
*/
} OBIDMS_column_header_t, *OBIDMS_column_header_p;
@ -182,7 +182,8 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
index_t nb_lines,
index_t nb_elements_per_line,
const char* elements_names,
const char* array_name);
const char* array_name,
const char* comments);
/**

View File

@ -21,7 +21,7 @@
#include "obidms.h"
#define OBIDMS_COLUMN_MAX_NAME (2048) /**< The maximum length of an OBIDMS column name.
#define OBIDMS_COLUMN_MAX_NAME (1024) /**< The maximum length of an OBIDMS column name.
*/