diff options
author | Alessandro Felder <alessandrofelder@users.noreply.github.com> | 2021-09-08 20:53:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-08 20:53:15 (GMT) |
commit | 8e06298ecfde5eb647b39cfe0dab70005f092199 (patch) | |
tree | 60812779599015ee44990d56a643767e9c93da73 /hl | |
parent | 919f9daec6f397dfdf3fd41d2ecf002d197db293 (diff) | |
download | hdf5-8e06298ecfde5eb647b39cfe0dab70005f092199.zip hdf5-8e06298ecfde5eb647b39cfe0dab70005f092199.tar.gz hdf5-8e06298ecfde5eb647b39cfe0dab70005f092199.tar.bz2 |
Add high-level set/get for `unsigned long long` attributes. (#973)
* add ULL attr set/get signatures to LT public API
* add LT implementation of ULL set/get attribute
* fix copy-paste typo in test comment
* add ULL test data
* define ullong attr name global variable
* add LT tests for ULL attr set/get
* Committing clang-format changes
* correct type passed to lt get attr test for ULL
* update RELEASE.txt with added ULL set/get functionality
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'hl')
-rw-r--r-- | hl/src/H5LT.c | 53 | ||||
-rw-r--r-- | hl/src/H5LTpublic.h | 6 | ||||
-rw-r--r-- | hl/test/test_lite.c | 109 |
3 files changed, 136 insertions, 32 deletions
diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 1ef0f9d..a314f3f 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -1776,6 +1776,32 @@ H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_nam } /*------------------------------------------------------------------------- + * Function: H5LTset_attribute_ullong + * + * Purpose: Create and write an attribute. + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Alessandro Felder + * + * Date: August 27, 2021 + * + * Comments: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTset_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned long long *data, size_t size) +{ + + if (H5LT_set_attribute_numerical(loc_id, obj_name, attr_name, size, H5T_NATIVE_ULLONG, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- * Function: H5LTset_attribute_float * * Purpose: Create and write an attribute. @@ -3317,6 +3343,33 @@ H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_nam } /*------------------------------------------------------------------------- + * Function: H5LTget_attribute_ullong + * + * Purpose: Reads an attribute named attr_name + * + * Return: Success: 0, Failure: -1 + * + * Programmer: Alessandro Felder + * + * Date: August 27, 2021 + * + * Comments: + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5LTget_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long long *data) +{ + /* Get the attribute */ + if (H5LT_get_attribute_mem(loc_id, obj_name, attr_name, H5T_NATIVE_ULLONG, data) < 0) + return -1; + + return 0; +} + +/*------------------------------------------------------------------------- * Function: H5LTget_attribute_float * * Purpose: Reads an attribute named attr_name diff --git a/hl/src/H5LTpublic.h b/hl/src/H5LTpublic.h index 2af9b07..f19d353 100644 --- a/hl/src/H5LTpublic.h +++ b/hl/src/H5LTpublic.h @@ -139,6 +139,9 @@ H5_HLDLL herr_t H5LTset_attribute_long_long(hid_t loc_id, const char *obj_name, H5_HLDLL herr_t H5LTset_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, const unsigned long *buffer, size_t size); +H5_HLDLL herr_t H5LTset_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, + const unsigned long long *buffer, size_t size); + H5_HLDLL herr_t H5LTset_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, const float *buffer, size_t size); @@ -182,6 +185,9 @@ H5_HLDLL herr_t H5LTget_attribute_long_long(hid_t loc_id, const char *obj_name, H5_HLDLL herr_t H5LTget_attribute_ulong(hid_t loc_id, const char *obj_name, const char *attr_name, unsigned long *data); +H5_HLDLL herr_t H5LTget_attribute_ullong(hid_t loc_id, const char *obj_name, const char *attr_name, + unsigned long long *data); + H5_HLDLL herr_t H5LTget_attribute_float(hid_t loc_id, const char *obj_name, const char *attr_name, float *data); diff --git a/hl/test/test_lite.c b/hl/test/test_lite.c index cae91ff..53f834a 100644 --- a/hl/test/test_lite.c +++ b/hl/test/test_lite.c @@ -43,8 +43,9 @@ #define ATTR7_NAME "attr ushort" #define ATTR8_NAME "attr uint" #define ATTR9_NAME "attr ulong" -#define ATTR10_NAME "attr float" -#define ATTR11_NAME "attr double" +#define ATTR10_NAME "attr ullong" +#define ATTR11_NAME "attr float" +#define ATTR12_NAME "attr double" static herr_t make_attributes(hid_t loc_id, const char *obj_name); @@ -472,28 +473,30 @@ make_attributes(hid_t loc_id, const char *obj_name) size_t type_size; int i; - char attr_str_in[] = {"My attribute"}; - char attr_str_out[20]; - char attr_char_in[5] = {1, 2, 3, 4, 5}; - char attr_char_out[5]; - short attr_short_in[5] = {1, 2, 3, 4, 5}; - short attr_short_out[5]; - int attr_int_in[5] = {1, 2, 3, 4, 5}; - int attr_int_out[5]; - long attr_long_in[5] = {1, 2, 3, 4, 5}; - long attr_long_out[5]; - float attr_float_in[5] = {1, 2, 3, 4, 5}; - float attr_float_out[5]; - double attr_double_in[5] = {1, 2, 3, 4, 5}; - double attr_double_out[5]; - unsigned char attr_uchar_in[5] = {1, 2, 3, 4, 5}; - unsigned char attr_uchar_out[5]; - unsigned short attr_ushort_in[5] = {1, 2, 3, 4, 5}; - unsigned short attr_ushort_out[5]; - unsigned int attr_uint_in[5] = {1, 2, 3, 4, 5}; - unsigned int attr_uint_out[5]; - unsigned long attr_ulong_in[5] = {1, 2, 3, 4, 5}; - unsigned long attr_ulong_out[5]; + char attr_str_in[] = {"My attribute"}; + char attr_str_out[20]; + char attr_char_in[5] = {1, 2, 3, 4, 5}; + char attr_char_out[5]; + short attr_short_in[5] = {1, 2, 3, 4, 5}; + short attr_short_out[5]; + int attr_int_in[5] = {1, 2, 3, 4, 5}; + int attr_int_out[5]; + long attr_long_in[5] = {1, 2, 3, 4, 5}; + long attr_long_out[5]; + float attr_float_in[5] = {1, 2, 3, 4, 5}; + float attr_float_out[5]; + double attr_double_in[5] = {1, 2, 3, 4, 5}; + double attr_double_out[5]; + unsigned char attr_uchar_in[5] = {1, 2, 3, 4, 5}; + unsigned char attr_uchar_out[5]; + unsigned short attr_ushort_in[5] = {1, 2, 3, 4, 5}; + unsigned short attr_ushort_out[5]; + unsigned int attr_uint_in[5] = {1, 2, 3, 4, 5}; + unsigned int attr_uint_out[5]; + unsigned long attr_ulong_in[5] = {1, 2, 3, 4, 5}; + unsigned long attr_ulong_out[5]; + unsigned long long attr_ullong_in[5] = {1, 2, 3, 4, 5}; + unsigned long long attr_ullong_out[5]; /*------------------------------------------------------------------------- * H5LTset_attribute_string test @@ -509,7 +512,7 @@ make_attributes(hid_t loc_id, const char *obj_name) PASSED(); /*------------------------------------------------------------------------- - * H5LTset_attribute_string test + * H5LTget_attribute_string test *------------------------------------------------------------------------- */ @@ -859,7 +862,7 @@ make_attributes(hid_t loc_id, const char *obj_name) PASSED(); /*------------------------------------------------------------------------- - * H5LTget_attribute_long test + * H5LTget_attribute_ulong test *------------------------------------------------------------------------- */ @@ -888,6 +891,48 @@ make_attributes(hid_t loc_id, const char *obj_name) PASSED(); /*------------------------------------------------------------------------- + * H5LTset_attribute_ullong test + *------------------------------------------------------------------------- + */ + + HL_TESTING2("H5LTset_attribute_ullong"); + + /* Set the attribute */ + if (H5LTset_attribute_ullong(loc_id, obj_name, ATTR10_NAME, attr_ullong_in, (size_t)5) < 0) + return -1; + + PASSED(); + + /*------------------------------------------------------------------------- + * H5LTget_attribute_ullong test + *------------------------------------------------------------------------- + */ + + HL_TESTING2("H5LTget_attribute_ullong"); + + /* Get the attribute */ + if (H5LTget_attribute_ullong(loc_id, obj_name, ATTR10_NAME, attr_ullong_out) < 0) + return -1; + + for (i = 0; i < 5; i++) { + if (attr_ullong_in[i] != attr_ullong_out[i]) { + return -1; + } + } + + /* Get the attribute */ + if (H5LTget_attribute(loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_ULLONG, attr_ullong_out) < 0) + return -1; + + for (i = 0; i < 5; i++) { + if (attr_ullong_in[i] != attr_ullong_out[i]) { + return -1; + } + } + + PASSED(); + + /*------------------------------------------------------------------------- * H5LTset_attribute_float test *------------------------------------------------------------------------- */ @@ -895,7 +940,7 @@ make_attributes(hid_t loc_id, const char *obj_name) HL_TESTING2("H5LTset_attribute_float"); /* Set the attribute */ - if (H5LTset_attribute_float(loc_id, obj_name, ATTR10_NAME, attr_float_in, (size_t)5) < 0) + if (H5LTset_attribute_float(loc_id, obj_name, ATTR11_NAME, attr_float_in, (size_t)5) < 0) return -1; PASSED(); @@ -908,7 +953,7 @@ make_attributes(hid_t loc_id, const char *obj_name) HL_TESTING2("H5LTget_attribute_float"); /* Get the attribute */ - if (H5LTget_attribute_float(loc_id, obj_name, ATTR10_NAME, attr_float_out) < 0) + if (H5LTget_attribute_float(loc_id, obj_name, ATTR11_NAME, attr_float_out) < 0) return -1; for (i = 0; i < 5; i++) { @@ -918,7 +963,7 @@ make_attributes(hid_t loc_id, const char *obj_name) } /* Get the attribute */ - if (H5LTget_attribute(loc_id, obj_name, ATTR10_NAME, H5T_NATIVE_FLOAT, attr_float_out) < 0) + if (H5LTget_attribute(loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_FLOAT, attr_float_out) < 0) return -1; for (i = 0; i < 5; i++) { @@ -937,7 +982,7 @@ make_attributes(hid_t loc_id, const char *obj_name) HL_TESTING2("H5LTset_attribute_double"); /* Set the attribute */ - if (H5LTset_attribute_double(loc_id, obj_name, ATTR11_NAME, attr_double_in, (size_t)5) < 0) + if (H5LTset_attribute_double(loc_id, obj_name, ATTR12_NAME, attr_double_in, (size_t)5) < 0) return -1; PASSED(); @@ -950,7 +995,7 @@ make_attributes(hid_t loc_id, const char *obj_name) HL_TESTING2("H5LTget_attribute_double"); /* Get the attribute */ - if (H5LTget_attribute_double(loc_id, obj_name, ATTR11_NAME, attr_double_out) < 0) + if (H5LTget_attribute_double(loc_id, obj_name, ATTR12_NAME, attr_double_out) < 0) return -1; for (i = 0; i < 5; i++) { @@ -960,7 +1005,7 @@ make_attributes(hid_t loc_id, const char *obj_name) } /* Get the attribute */ - if (H5LTget_attribute(loc_id, obj_name, ATTR11_NAME, H5T_NATIVE_DOUBLE, attr_double_out) < 0) + if (H5LTget_attribute(loc_id, obj_name, ATTR12_NAME, H5T_NATIVE_DOUBLE, attr_double_out) < 0) return -1; for (i = 0; i < 5; i++) { |