-
-
Notifications
You must be signed in to change notification settings - Fork 350
Various improvement in documentation and a decoding function #6383
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
9409460
cababa7
0f28f26
7208005
99cd164
6dbf492
2611dba
7dffba1
6a0d6b7
0fdb23c
9d9ab6b
032da88
4094ca3
a280adf
d6ac0a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -139,8 +139,7 @@ extern "C" { | |
| * \param[in] nfields The number of fields | ||
| * \param[in] nrecords The number of records | ||
| * \param[in] type_size The size in bytes of the structure | ||
| * associated with the table; | ||
| * This value is obtained with \c sizeof(). | ||
| * associated with the table | ||
| * \param[in] field_names An array containing the names of the fields. | ||
| * Names longer than #HLTB_MAX_FIELD_LEN - 1 characters | ||
| * are silently truncated when read back by | ||
|
|
@@ -160,6 +159,13 @@ extern "C" { | |
| * \p dset_name attached to the object specified by the | ||
| * identifier loc_id. | ||
| * | ||
| * \p type_size can be obtained with \c sizeof(), if the data is | ||
| * stored in a predefined C struct. Otherwise, \p type_size should | ||
| * be calculated as the sum of calling H5Tget_size() for each of | ||
| * the given field datatypes in \p field_types, plus any padding | ||
| * bytes included in the structure, based on the given field offsets | ||
| * in \p field_offset. | ||
| * | ||
| */ | ||
| H5HL_DLL herr_t H5TBmake_table(const char *table_title, hid_t loc_id, const char *dset_name, hsize_t nfields, | ||
| hsize_t nrecords, size_t type_size, const char *field_names[], | ||
|
|
@@ -182,8 +188,7 @@ H5HL_DLL herr_t H5TBmake_table(const char *table_title, hid_t loc_id, const char | |
| * \fg_loc_id | ||
| * \param[in] dset_name The name of the dataset to overwrite | ||
| * \param[in] nrecords The number of records to append | ||
| * \param[in] type_size The size of the structure type, | ||
| * as calculated by \c sizeof(). | ||
| * \param[in] type_size The size of the structure type | ||
| * \param[in] field_offset An array containing the offsets of | ||
| * the fields. These offsets can be | ||
| * calculated with the #HOFFSET macro | ||
|
|
@@ -198,6 +203,10 @@ H5HL_DLL herr_t H5TBmake_table(const char *table_title, hid_t loc_id, const char | |
| * identifier \p loc_id. The dataset is extended to hold the | ||
| * new records. | ||
| * | ||
| * \p type_size can be obtained with \c sizeof(), if the data is | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on my reading, for most of these functions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the question is, if the data is not stored in a C struct, how is it stored? If the application is manually moving bytes around in memory then it should know these values.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My understanding from @jhendersonHDF's comment tells me that I should use the same description of type_size in H5TBmake_table() for all type_size entries. I'll go ahead with that unless @fortnern thinks otherwise, as your comment seemed to suggest.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's fine though I added a comment about the method specified for make_table - you only need to look at the field with the highest offset. |
||
| * stored in a predefined C struct. Otherwise, it can be obtained | ||
| * by calling H5TBget_field_info() if not already known. | ||
| * | ||
| */ | ||
| H5HL_DLL herr_t H5TBappend_records(hid_t loc_id, const char *dset_name, hsize_t nrecords, size_t type_size, | ||
| const size_t *field_offset, const size_t *dst_sizes, const void *buf); | ||
|
|
@@ -212,8 +221,7 @@ H5HL_DLL herr_t H5TBappend_records(hid_t loc_id, const char *dset_name, hsize_t | |
| * \param[in] dset_name The name of the dataset to overwrite | ||
| * \param[in] start The zero index record to start writing | ||
| * \param[in] nrecords The number of records to write | ||
| * \param[in] type_size The size of the structure type, as | ||
| * calculated by \c sizeof(). | ||
| * \param[in] type_size The size of the structure type | ||
| * \param[in] field_offset An array containing the offsets of | ||
| * the fields. These offsets can be | ||
| * calculated with the #HOFFSET macro | ||
|
|
@@ -227,6 +235,10 @@ H5HL_DLL herr_t H5TBappend_records(hid_t loc_id, const char *dset_name, hsize_t | |
| * index position start of the table named \p dset_name attached | ||
| * to the object specified by the identifier \p loc_id. | ||
| * | ||
| * \p type_size can be obtained with \c sizeof(), if the data is | ||
| * stored in a predefined C struct. Otherwise, it can be obtained | ||
| * by calling H5TBget_field_info() if not already known. | ||
| * | ||
| */ | ||
| H5HL_DLL herr_t H5TBwrite_records(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, | ||
| size_t type_size, const size_t *field_offset, const size_t *dst_sizes, | ||
|
|
@@ -243,8 +255,7 @@ H5HL_DLL herr_t H5TBwrite_records(hid_t loc_id, const char *dset_name, hsize_t s | |
| * \param[in] field_names The names of the fields to write | ||
| * \param[in] start The zero index record to start writing | ||
| * \param[in] nrecords The number of records to write | ||
| * \param[in] type_size The size of the structure type, as | ||
| * calculated by \c sizeof(). | ||
| * \param[in] type_size The size of the structure type | ||
| * \param[in] field_offset An array containing the offsets of | ||
| * the fields. These offsets can be | ||
| * calculated with the #HOFFSET macro | ||
|
|
@@ -259,6 +270,10 @@ H5HL_DLL herr_t H5TBwrite_records(hid_t loc_id, const char *dset_name, hsize_t s | |
| * dataset named \p dset_name attached to the object specified | ||
| * by the identifier \p loc_id. | ||
| * | ||
| * \p type_size can be obtained with \c sizeof(), if the data is | ||
| * stored in a predefined C struct. Otherwise, it can be obtained | ||
| * by calling H5TBget_field_info() if not already known. | ||
| * | ||
| */ | ||
| H5HL_DLL herr_t H5TBwrite_fields_name(hid_t loc_id, const char *dset_name, const char *field_names, | ||
| hsize_t start, hsize_t nrecords, size_t type_size, | ||
|
|
@@ -278,8 +293,7 @@ H5HL_DLL herr_t H5TBwrite_fields_name(hid_t loc_id, const char *dset_name, const | |
| * \param[in] field_index The indexes of the fields to write | ||
| * \param[in] start The zero based index record to start writing | ||
| * \param[in] nrecords The number of records to write | ||
| * \param[in] type_size The size of the structure type, as | ||
| * calculated by \c sizeof(). | ||
| * \param[in] type_size The size of the structure type | ||
| * \param[in] field_offset An array containing the offsets of | ||
| * the fields. These offsets can be | ||
| * calculated with the #HOFFSET macro | ||
|
|
@@ -294,6 +308,10 @@ H5HL_DLL herr_t H5TBwrite_fields_name(hid_t loc_id, const char *dset_name, const | |
| * dataset named \p dset_name attached to the object | ||
| * specified by the identifier \p loc_id. | ||
| * | ||
| * \p type_size can be obtained with \c sizeof(), if the data is | ||
| * stored in a predefined C struct. Otherwise, it can be obtained | ||
| * by calling H5TBget_field_info() if not already known. | ||
| * | ||
| */ | ||
| H5HL_DLL herr_t H5TBwrite_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, | ||
| const int *field_index, hsize_t start, hsize_t nrecords, | ||
|
|
@@ -315,8 +333,7 @@ H5HL_DLL herr_t H5TBwrite_fields_index(hid_t loc_id, const char *dset_name, hsiz | |
| * | ||
| * \fg_loc_id | ||
| * \param[in] dset_name The name of the dataset to read | ||
| * \param[in] dst_size The size of the structure type, | ||
| * as calculated by \c sizeof() | ||
| * \param[in] dst_size The size of the structure type | ||
| * \param[in] dst_offset An array containing the offsets of | ||
| * the fields. These offsets can be | ||
| * calculated with the #HOFFSET macro | ||
|
|
@@ -331,6 +348,10 @@ H5HL_DLL herr_t H5TBwrite_fields_index(hid_t loc_id, const char *dset_name, hsiz | |
| * \p dset_name attached to the object specified by | ||
| * the identifier \p loc_id. | ||
| * | ||
| * \p dst_size can be obtained with \c sizeof(), if the data is | ||
| * stored in a predefined C struct. Otherwise, it can be obtained | ||
| * by calling H5TBget_field_info() if not already known. | ||
| * | ||
| */ | ||
| H5HL_DLL herr_t H5TBread_table(hid_t loc_id, const char *dset_name, size_t dst_size, const size_t *dst_offset, | ||
| const size_t *dst_sizes, void *dst_buf); | ||
|
|
@@ -349,7 +370,6 @@ H5HL_DLL herr_t H5TBread_table(hid_t loc_id, const char *dset_name, size_t dst_s | |
| * \param[in] nrecords The number of records to read | ||
| * \param[in] type_size The size in bytes of the structure associated | ||
| * with the table | ||
| * (This value is obtained with \c sizeof().) | ||
| * \param[in] field_offset An array containing the offsets of the fields | ||
| * \param[in] dst_sizes An array containing the size in bytes of | ||
| * the fields | ||
|
|
@@ -361,6 +381,10 @@ H5HL_DLL herr_t H5TBread_table(hid_t loc_id, const char *dset_name, size_t dst_s | |
| * by \p field_names from a dataset named \p dset_name | ||
| * attached to the object specified by the identifier \p loc_id. | ||
| * | ||
| * \p type_size can be obtained with \c sizeof(), if the data is | ||
| * stored in a predefined C struct. Otherwise, it can be obtained | ||
| * by calling H5TBget_field_info() if not already known. | ||
| * | ||
| */ | ||
| H5HL_DLL herr_t H5TBread_fields_name(hid_t loc_id, const char *dset_name, const char *field_names, | ||
| hsize_t start, hsize_t nrecords, size_t type_size, | ||
|
|
@@ -384,7 +408,6 @@ H5HL_DLL herr_t H5TBread_fields_name(hid_t loc_id, const char *dset_name, const | |
| * \param[in] nrecords The number of records to read | ||
| * \param[in] type_size The size in bytes of the structure associated | ||
| * with the table | ||
| * (This value is obtained with \c sizeof()) | ||
| * \param[in] field_offset An array containing the offsets of the fields | ||
| * \param[in] dst_sizes An array containing the size in bytes of | ||
| * the fields | ||
|
|
@@ -396,6 +419,10 @@ H5HL_DLL herr_t H5TBread_fields_name(hid_t loc_id, const char *dset_name, const | |
| * by \p field_index from a dataset named \p dset_name attached | ||
| * to the object specified by the identifier \p loc_id. | ||
| * | ||
| * \p type_size can be obtained with \c sizeof(), if the data is | ||
| * stored in a predefined C struct. Otherwise, it can be obtained | ||
| * by calling H5TBget_field_info() if not already known. | ||
| * | ||
| */ | ||
| H5HL_DLL herr_t H5TBread_fields_index(hid_t loc_id, const char *dset_name, hsize_t nfields, | ||
| const int *field_index, hsize_t start, hsize_t nrecords, | ||
|
|
@@ -413,8 +440,7 @@ H5HL_DLL herr_t H5TBread_fields_index(hid_t loc_id, const char *dset_name, hsize | |
| * \param[in] dset_name The name of the dataset to read | ||
| * \param[in] start The start record to read from | ||
| * \param[in] nrecords The number of records to read | ||
| * \param[in] type_size The size of the structure type, | ||
| * as calculated by \c sizeof() | ||
| * \param[in] type_size The size of the structure type | ||
| * \param[in] dst_offset An array containing the offsets of the | ||
| * fields. These offsets can be calculated | ||
| * with the #HOFFSET macro | ||
|
|
@@ -428,6 +454,10 @@ H5HL_DLL herr_t H5TBread_fields_index(hid_t loc_id, const char *dset_name, hsize | |
| * named \p dset_name attached to the object specified by the | ||
| * identifier \p loc_id. | ||
| * | ||
| * \p type_size can be obtained with \c sizeof(), if the data is | ||
| * stored in a predefined C struct. Otherwise, it can be obtained | ||
| * by calling H5TBget_field_info() if not already known. | ||
| * | ||
| */ | ||
| H5HL_DLL herr_t H5TBread_records(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, | ||
| size_t type_size, const size_t *dst_offset, const size_t *dst_sizes, | ||
|
|
@@ -549,6 +579,10 @@ H5HL_DLL herr_t H5TBdelete_record(hid_t loc_id, const char *dset_name, hsize_t s | |
| * \details H5TBinsert_record() inserts records into the middle of the table | ||
| * ("pushing down" all the records after it) | ||
| * | ||
| * \p dst_size can be obtained with \c sizeof() if the predefined C | ||
| * structure is available, otherwise, use H5Tget_size() on the | ||
| * compound datatype. | ||
| * | ||
| */ | ||
| H5HL_DLL herr_t H5TBinsert_record(hid_t loc_id, const char *dset_name, hsize_t start, hsize_t nrecords, | ||
| size_t dst_size, const size_t *dst_offset, const size_t *dst_sizes, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You really just need the last offset plus the size of the last type (and any padding bytes desired after the last member). This is assuming the fields are sorted by offset, otherwise use the highest offest and the size of the type for the field with the highest offset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, though I was mostly going for simplicity and as you already mentioned if the structure is just an untyped block of bytes the size should generally already be known. I do think the API design and documentation leaves a bit to be desired and telling someone how to calculate the size of their in-memory structure here may just be adding more potential for confusion than necessary.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about: "Otherwise, \p type_size should be calculated based on the highest offset in \p field_offset, the size of its corresponding datatype in \p field_types, and any padding bytes desired after that field."