mirror of
https://github.com/TREX-CoE/trexio.git
synced 2024-11-03 20:54:07 +01:00
add missing support for reading single string attributes
This commit is contained in:
parent
209f4506c8
commit
721352cb89
@ -34,13 +34,19 @@
|
|||||||
*/
|
*/
|
||||||
%apply int *OUTPUT { int32_t* const num};
|
%apply int *OUTPUT { int32_t* const num};
|
||||||
%apply int *OUTPUT { int64_t* const num};
|
%apply int *OUTPUT { int64_t* const num};
|
||||||
|
|
||||||
/* Does not work for arrays (SIGSEGV) */
|
/* Does not work for arrays (SIGSEGV) */
|
||||||
|
|
||||||
/* This enables access to trexio_[...]_read_dset_str_low set of functions
|
/* This enables access to trexio_[...]_read_dset_str_low set of functions
|
||||||
in order to return one long string with TREXIO_DELIM delimeter as 2-nd argument of output tuple
|
in order to return one long string with TREXIO_DELIM delimeter as 2-nd argument of output tuple
|
||||||
*/
|
*/
|
||||||
%include <cstring.i>
|
%include <cstring.i>
|
||||||
|
/* This enables read of long strings with TREXIO_DELIM delimeters that can be further converted into an array of string */
|
||||||
%cstring_bounded_output(char* dset_out, 4096);
|
%cstring_bounded_output(char* dset_out, 4096);
|
||||||
|
/* This enables read of single string attributes with pre-defined max_str_len
|
||||||
|
for Python we pre-define max_str_len = PYTREXIO_MAX_STR_LENGTH everywhere for simplicity
|
||||||
|
*/
|
||||||
|
%cstring_output_maxsize(char* const str_out, const uint32_t max_str_len);
|
||||||
|
|
||||||
/* [WIP] TREXIO back ends and exit codes can be redefined in the SWIG target language
|
/* [WIP] TREXIO back ends and exit codes can be redefined in the SWIG target language
|
||||||
using %ignore and further #define statements (instead of disabling the type cast in the trexio.h file)
|
using %ignore and further #define statements (instead of disabling the type cast in the trexio.h file)
|
||||||
|
@ -2289,27 +2289,27 @@ def read_$group_dset$(trexio_file):
|
|||||||
|
|
||||||
#+begin_src c :tangle hrw_attr_str_front.h :exports none
|
#+begin_src c :tangle hrw_attr_str_front.h :exports none
|
||||||
trexio_exit_code trexio_has_$group_str$(trexio_t* const file);
|
trexio_exit_code trexio_has_$group_str$(trexio_t* const file);
|
||||||
trexio_exit_code trexio_read_$group_str$(trexio_t* const file, char* const str, const uint32_t max_str_len);
|
trexio_exit_code trexio_read_$group_str$(trexio_t* const file, char* const str_out, const uint32_t max_str_len);
|
||||||
trexio_exit_code trexio_write_$group_str$(trexio_t* const file, const char* str, const uint32_t max_str_len);
|
trexio_exit_code trexio_write_$group_str$(trexio_t* const file, const char* str, const uint32_t max_str_len);
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+begin_src c :tangle read_attr_str_front.c
|
#+begin_src c :tangle read_attr_str_front.c
|
||||||
trexio_exit_code
|
trexio_exit_code
|
||||||
trexio_read_$group_str$ (trexio_t* const file, char* const str, const uint32_t max_str_len)
|
trexio_read_$group_str$ (trexio_t* const file, char* const str_out, const uint32_t max_str_len)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (file == NULL) return TREXIO_INVALID_ARG_1;
|
if (file == NULL) return TREXIO_INVALID_ARG_1;
|
||||||
if (str == NULL) return TREXIO_INVALID_ARG_2;
|
if (str_out == NULL) return TREXIO_INVALID_ARG_2;
|
||||||
if (max_str_len <= 0) return TREXIO_INVALID_ARG_3;
|
if (max_str_len <= 0) return TREXIO_INVALID_ARG_3;
|
||||||
|
|
||||||
switch (file->back_end) {
|
switch (file->back_end) {
|
||||||
|
|
||||||
case TREXIO_TEXT:
|
case TREXIO_TEXT:
|
||||||
return trexio_text_read_$group_str$(file, str, max_str_len);
|
return trexio_text_read_$group_str$(file, str_out, max_str_len);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TREXIO_HDF5:
|
case TREXIO_HDF5:
|
||||||
return trexio_hdf5_read_$group_str$(file, str, max_str_len);
|
return trexio_hdf5_read_$group_str$(file, str_out, max_str_len);
|
||||||
break;
|
break;
|
||||||
/*
|
/*
|
||||||
case TREXIO_JSON:
|
case TREXIO_JSON:
|
||||||
|
Loading…
Reference in New Issue
Block a user