1
0
mirror of https://github.com/TREX-CoE/trexio.git synced 2025-01-11 05:28:33 +01:00

forgot text templator

This commit is contained in:
q-posev 2021-03-30 11:51:05 +02:00
parent 068beacb07
commit 0d0bed0585

View File

@ -513,16 +513,16 @@ trexio_exit_code trexio_text_free_$group$(trexio_text_t* const file) {
}
#+end_src
** Template for read/write the $group_num$ attribute
** Template for has/read/write the $group_num$ attribute
#+begin_src c :tangle rw_num_text.h
#+begin_src c :tangle hrw_num_text.h
trexio_exit_code trexio_text_has_$group_num$ (trexio_t* const file);
trexio_exit_code trexio_text_read_$group_num$ (trexio_t* const file, uint64_t* const num);
trexio_exit_code trexio_text_write_$group_num$(trexio_t* const file, const uint64_t num);
#+end_src
#+begin_src c :tangle read_num_text.c
trexio_exit_code trexio_text_read_$group_num$(trexio_t* const file, uint64_t* const num) {
if (file == NULL) return TREXIO_INVALID_ARG_1;
if (num == NULL) return TREXIO_INVALID_ARG_2;
@ -538,9 +538,7 @@ trexio_exit_code trexio_text_read_$group_num$(trexio_t* const file, uint64_t* co
#+begin_src c :tangle write_num_text.c
trexio_exit_code trexio_text_write_$group_num$(trexio_t* const file, const uint64_t num) {
if (file == NULL) return TREXIO_INVALID_ARG_1;
if (file->mode == 'r') return TREXIO_READONLY;
$group$_t* $group$ = trexio_text_read_$group$((trexio_text_t*) file);
@ -553,11 +551,29 @@ trexio_exit_code trexio_text_write_$group_num$(trexio_t* const file, const uint6
}
#+end_src
** Template for read/write the $group_dset$ dataset
#+begin_src c :tangle has_num_text.c
trexio_exit_code trexio_text_has_$group_num$(trexio_t* const file) {
if (file == NULL) return TREXIO_INVALID_ARG_1;
$group$_t* $group$ = trexio_text_read_$group$((trexio_text_t*) file);
if ($group$ == NULL) return TREXIO_FAILURE;
if ($group$->$group_num$ > 0L){
return TREXIO_SUCCESS;
} else {
return TREXIO_HAS_NOT;
}
}
#+end_src
** Template for has/read/write the $group_dset$ dataset
The ~dset~ array is assumed allocated with the appropriate size.
#+begin_src c :tangle rw_dset_text.h
#+begin_src c :tangle hrw_dset_text.h
trexio_exit_code trexio_text_has_$group_dset$ (trexio_t* const file);
trexio_exit_code trexio_text_read_$group_dset$ (trexio_t* const file, $group_dset_dtype$* const $group_dset$, const uint32_t rank, const uint64_t* dims);
trexio_exit_code trexio_text_write_$group_dset$(trexio_t* const file, const $group_dset_dtype$* $group_dset$, const uint32_t rank, const uint64_t* dims);
#+end_src
@ -620,6 +636,20 @@ trexio_exit_code trexio_text_write_$group_dset$(trexio_t* const file, const $gro
}
#+end_src
#+begin_src c :tangle has_dset_text.c
trexio_exit_code trexio_text_has_$group_dset$(trexio_t* const file) {
if (file == NULL) return TREXIO_INVALID_ARG_1;
$group$_t* const $group$ = trexio_text_read_$group$((trexio_text_t*) file);
if ($group$ == NULL) return TREXIO_FAILURE;
if ($group$->rank_$group_dset$ > 0){
return TREXIO_SUCCESS;
} else {
return TREXIO_HAS_NOT;
}
}
#+end_src
** RDM struct
*** Read the complete struct