Comments in column headers are now working.
This commit is contained in:
@ -24,7 +24,8 @@ cdef class OBIDMS:
|
|||||||
index_t nb_lines=*,
|
index_t nb_lines=*,
|
||||||
index_t nb_elements_per_line=*,
|
index_t nb_elements_per_line=*,
|
||||||
list elements_names=*,
|
list elements_names=*,
|
||||||
str array_name=*)
|
str array_name=*,
|
||||||
|
str comments=*)
|
||||||
|
|
||||||
|
|
||||||
cdef class OBIDMS_column:
|
cdef class OBIDMS_column:
|
||||||
@ -34,7 +35,7 @@ cdef class OBIDMS_column:
|
|||||||
cdef str data_type # TODO keep as OBIType_t? both?
|
cdef str data_type # TODO keep as OBIType_t? both?
|
||||||
cdef str dms_name
|
cdef str dms_name
|
||||||
cdef str column_name
|
cdef str column_name
|
||||||
cdef index_t nb_elements_per_line
|
cdef index_t nb_elements_per_line
|
||||||
cdef list elements_names
|
cdef list elements_names
|
||||||
|
|
||||||
# cpdef object get_item(self, index_t line_nb, str element_name) TODO can't declare because not the same in all subclasses
|
# cpdef object get_item(self, index_t line_nb, str element_name) TODO can't declare because not the same in all subclasses
|
||||||
@ -43,5 +44,6 @@ cdef class OBIDMS_column:
|
|||||||
cpdef str get_data_type(self)
|
cpdef str get_data_type(self)
|
||||||
cpdef index_t get_nb_lines_used(self)
|
cpdef index_t get_nb_lines_used(self)
|
||||||
cpdef str get_creation_date(self)
|
cpdef str get_creation_date(self)
|
||||||
|
cpdef str get_comments(self)
|
||||||
cpdef close(self)
|
cpdef close(self)
|
||||||
|
|
||||||
|
@ -120,7 +120,8 @@ cdef class OBIDMS :
|
|||||||
index_t nb_lines=0,
|
index_t nb_lines=0,
|
||||||
index_t nb_elements_per_line=0,
|
index_t nb_elements_per_line=0,
|
||||||
list elements_names=None,
|
list elements_names=None,
|
||||||
str array_name="default_obiarray"):
|
str array_name="default_obiarray",
|
||||||
|
str comments=""):
|
||||||
|
|
||||||
# Declarations
|
# Declarations
|
||||||
cdef OBIDMS_column column
|
cdef OBIDMS_column column
|
||||||
@ -221,7 +222,8 @@ cdef class OBIDMS :
|
|||||||
create, clone, clone_data,
|
create, clone, clone_data,
|
||||||
version_number, data_type,
|
version_number, data_type,
|
||||||
nb_lines, nb_elements_per_line,
|
nb_lines, nb_elements_per_line,
|
||||||
elements_names, array_name)
|
elements_names, array_name,
|
||||||
|
comments)
|
||||||
|
|
||||||
return column
|
return column
|
||||||
|
|
||||||
@ -240,13 +242,15 @@ cdef class OBIDMS_column :
|
|||||||
index_t nb_lines,
|
index_t nb_lines,
|
||||||
index_t nb_elements_per_line,
|
index_t nb_elements_per_line,
|
||||||
list elements_names,
|
list elements_names,
|
||||||
str array_name):
|
str array_name,
|
||||||
|
str comments):
|
||||||
|
|
||||||
# Declarations
|
# Declarations
|
||||||
cdef bytes column_name_b
|
cdef bytes column_name_b
|
||||||
cdef bytes dms_name_b
|
cdef bytes dms_name_b
|
||||||
cdef bytes array_name_b
|
cdef bytes array_name_b
|
||||||
cdef bytes elements_names_b
|
cdef bytes elements_names_b
|
||||||
|
cdef bytes comments_b
|
||||||
|
|
||||||
# Fill structure
|
# Fill structure
|
||||||
self.dms = dms
|
self.dms = dms
|
||||||
@ -259,6 +263,7 @@ cdef class OBIDMS_column :
|
|||||||
column_name_b = str2bytes(column_name)
|
column_name_b = str2bytes(column_name)
|
||||||
dms_name_b = str2bytes(self.dms.dms_name)
|
dms_name_b = str2bytes(self.dms.dms_name)
|
||||||
array_name_b = str2bytes(array_name)
|
array_name_b = str2bytes(array_name)
|
||||||
|
comments_b = str2bytes(comments)
|
||||||
|
|
||||||
# Create, clone or open column
|
# Create, clone or open column
|
||||||
if create :
|
if create :
|
||||||
@ -268,7 +273,7 @@ cdef class OBIDMS_column :
|
|||||||
elements_names_b = str2bytes(";".join(elements_names))
|
elements_names_b = str2bytes(";".join(elements_names))
|
||||||
self.pointer = obi_create_column(self.dms.pointer, column_name_b, type,
|
self.pointer = obi_create_column(self.dms.pointer, column_name_b, type,
|
||||||
nb_lines, nb_elements_per_line,
|
nb_lines, nb_elements_per_line,
|
||||||
elements_names_b, array_name_b)
|
elements_names_b, array_name_b, comments_b)
|
||||||
else :
|
else :
|
||||||
if clone :
|
if clone :
|
||||||
self.pointer = obi_clone_column(self.dms.pointer, column_name_b, version_number, clone_data)
|
self.pointer = obi_clone_column(self.dms.pointer, column_name_b, version_number, clone_data)
|
||||||
@ -327,6 +332,8 @@ cdef class OBIDMS_column :
|
|||||||
cpdef str get_creation_date(self):
|
cpdef str get_creation_date(self):
|
||||||
return bytes2str(obi_column_format_date(self.pointer.header.creation_date))
|
return bytes2str(obi_column_format_date(self.pointer.header.creation_date))
|
||||||
|
|
||||||
|
cpdef str get_comments(self):
|
||||||
|
return bytes2str(self.pointer.header.comments)
|
||||||
|
|
||||||
cpdef close(self):
|
cpdef close(self):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
@ -43,7 +43,8 @@ cdef extern from "obidmscolumn.h" nogil:
|
|||||||
index_t nb_lines,
|
index_t nb_lines,
|
||||||
index_t nb_elements_per_line,
|
index_t nb_elements_per_line,
|
||||||
const_char_p elements_names,
|
const_char_p elements_names,
|
||||||
const_char_p array_name)
|
const_char_p array_name,
|
||||||
|
const_char_p comments)
|
||||||
|
|
||||||
OBIDMS_column_p obi_open_column(OBIDMS_p dms,
|
OBIDMS_column_p obi_open_column(OBIDMS_p dms,
|
||||||
const_char_p column_name,
|
const_char_p column_name,
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
#include "obitypes.h"
|
#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.
|
#define ARRAY_GROWTH_FACTOR (2) /**< The growth factor when an array is enlarged.
|
||||||
*/
|
*/
|
||||||
|
@ -495,7 +495,8 @@ OBIDMS_column_p obi_create_column(OBIDMS_p dms,
|
|||||||
index_t nb_lines,
|
index_t nb_lines,
|
||||||
index_t nb_elements_per_line,
|
index_t nb_elements_per_line,
|
||||||
const char* elements_names,
|
const char* elements_names,
|
||||||
const char* array_name)
|
const char* array_name,
|
||||||
|
const char* comments)
|
||||||
{
|
{
|
||||||
OBIDMS_column_p new_column;
|
OBIDMS_column_p new_column;
|
||||||
OBIDMS_column_directory_p column_directory;
|
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->creation_date = time(NULL);
|
||||||
header->version = version_number;
|
header->version = version_number;
|
||||||
header->cloned_from = -1;
|
header->cloned_from = -1;
|
||||||
header->comments[0] = 0x0; // TODO
|
|
||||||
|
|
||||||
obi_column_set_elements_names(new_column, elements_names);
|
obi_column_set_elements_names(new_column, elements_names);
|
||||||
|
|
||||||
strncpy(header->name, column_name, OBIDMS_COLUMN_MAX_NAME);
|
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 the data type is OBI_IDX, the associated obi_array is opened or created
|
||||||
if (data_type == 5)
|
if (data_type == 5)
|
||||||
{
|
{
|
||||||
@ -880,7 +883,8 @@ OBIDMS_column_p obi_clone_column(OBIDMS_p dms,
|
|||||||
nb_lines,
|
nb_lines,
|
||||||
nb_elements_per_line,
|
nb_elements_per_line,
|
||||||
(column_to_clone->header)->elements_names,
|
(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)
|
if (new_column == NULL)
|
||||||
{
|
{
|
||||||
@ -893,7 +897,6 @@ OBIDMS_column_p obi_clone_column(OBIDMS_p dms,
|
|||||||
}
|
}
|
||||||
|
|
||||||
(new_column->header)->cloned_from = version_number;
|
(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)
|
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)
|
index_t obi_column_get_element_index_from_name(OBIDMS_column_p column, const char* element_name)
|
||||||
{
|
{
|
||||||
char* elements_names;
|
char* elements_names;
|
||||||
|
@ -36,9 +36,10 @@
|
|||||||
*/
|
*/
|
||||||
#define MAXIMUM_LINE_COUNT (1000000) /**< The maximum line count for the data of a column. //TODO
|
#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
|
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 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.
|
char comments[COMMENTS_MAX_LENGTH+1]; /**< Comments stored as a classical zero end C string.
|
||||||
* The size of the comment is only limited by the header size.
|
|
||||||
*/
|
*/
|
||||||
} OBIDMS_column_header_t, *OBIDMS_column_header_p;
|
} 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_lines,
|
||||||
index_t nb_elements_per_line,
|
index_t nb_elements_per_line,
|
||||||
const char* elements_names,
|
const char* elements_names,
|
||||||
const char* array_name);
|
const char* array_name,
|
||||||
|
const char* comments);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "obidms.h"
|
#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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user