2015-08-26 10:31:56 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* OBIDMS_column_char functions *
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file obidsmcolumn_char.c
|
|
|
|
* @author Celine Mercier
|
|
|
|
* @date August 10th 2015
|
|
|
|
* @brief Functions handling OBIColumns containing data with the OBIType OBI_CHAR.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "obidmscolumn.h"
|
|
|
|
#include "obitypes.h"
|
2015-08-26 15:05:23 +02:00
|
|
|
|
|
|
|
|
2015-08-26 10:31:56 +02:00
|
|
|
/**********************************************************************
|
|
|
|
*
|
|
|
|
* D E F I N I T I O N O F T H E P U B L I C F U N C T I O N S
|
|
|
|
*
|
|
|
|
**********************************************************************/
|
|
|
|
|
2016-02-18 10:38:51 +01:00
|
|
|
|
2015-11-06 17:55:15 +01:00
|
|
|
int obi_column_set_obichar_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx, obichar_t value)
|
2015-08-26 10:31:56 +02:00
|
|
|
{
|
2017-07-05 14:49:20 +02:00
|
|
|
if (obi_column_prepare_to_set_value(column, line_nb, element_idx) < 0)
|
2016-04-13 15:10:24 +02:00
|
|
|
return -1;
|
2015-09-01 17:38:08 +02:00
|
|
|
|
|
|
|
// Set the value
|
2016-02-18 10:38:51 +01:00
|
|
|
*(((obichar_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx) = value;
|
2015-09-01 17:38:08 +02:00
|
|
|
|
2015-08-26 10:31:56 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-18 10:38:51 +01:00
|
|
|
obichar_t obi_column_get_obichar_with_elt_idx(OBIDMS_column_p column, index_t line_nb, index_t element_idx)
|
|
|
|
{
|
2016-04-13 15:10:24 +02:00
|
|
|
if (obi_column_prepare_to_get_value(column, line_nb) < 0)
|
2015-09-14 17:04:29 +02:00
|
|
|
return OBIChar_NA;
|
2015-11-29 11:57:07 +01:00
|
|
|
|
2016-02-18 10:38:51 +01:00
|
|
|
return *(((obichar_t*) (column->data)) + (line_nb * ((column->header)->nb_elements_per_line)) + element_idx);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:15 +01:00
|
|
|
int obi_column_set_obichar_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name, obichar_t value)
|
2015-08-26 15:05:23 +02:00
|
|
|
{
|
2016-04-13 15:10:24 +02:00
|
|
|
index_t element_idx = obi_column_get_element_index_from_name(column, element_name);
|
2015-11-06 17:55:15 +01:00
|
|
|
if (element_idx == OBIIdx_NA)
|
2015-10-14 18:05:34 +02:00
|
|
|
return -1;
|
2015-08-26 15:05:23 +02:00
|
|
|
|
2016-04-13 15:10:24 +02:00
|
|
|
return obi_column_set_obichar_with_elt_idx(column, line_nb, element_idx, value);
|
2016-02-18 10:38:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-11-06 17:55:15 +01:00
|
|
|
obichar_t obi_column_get_obichar_with_elt_name(OBIDMS_column_p column, index_t line_nb, const char* element_name)
|
2015-08-26 15:05:23 +02:00
|
|
|
{
|
2016-04-13 15:10:24 +02:00
|
|
|
index_t element_idx = obi_column_get_element_index_from_name(column, element_name);
|
2015-11-06 17:55:15 +01:00
|
|
|
if (element_idx == OBIIdx_NA)
|
2015-10-14 18:05:34 +02:00
|
|
|
return OBIChar_NA;
|
2016-02-18 10:38:51 +01:00
|
|
|
|
2016-04-13 15:10:24 +02:00
|
|
|
return obi_column_get_obichar_with_elt_idx(column, line_nb, element_idx);
|
2016-02-18 10:38:51 +01:00
|
|
|
}
|