Skip to content

Commit

Permalink
Add strpad to string dtype metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboc committed Apr 23, 2024
1 parent a9c5344 commit bfc5819
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ data.metadata
/*
{
"signed": true,
"cset": -1,
"vlen": false,
"littleEndian": true,
"type": 0,
Expand Down
16 changes: 12 additions & 4 deletions src/hdf5_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,7 @@ val get_dtype_metadata(hid_t dtype)
if (dtype_class == H5T_STRING)
{
attr.set("cset", (int)(H5Tget_cset(dtype)));
}
else
{
attr.set("cset", -1);
attr.set("strpad", (int)(H5Tget_strpad(dtype)));
}

if (dtype_class == H5T_COMPOUND)
Expand Down Expand Up @@ -1318,6 +1315,17 @@ EMSCRIPTEN_BINDINGS(hdf5)
.value("H5T_VLEN", H5T_VLEN) // = 9, /**< variable-Length types */
.value("H5T_ARRAY", H5T_ARRAY) // = 10, /**< array types */
;
enum_<H5T_cset_t>("H5T_cset_t")
.value("H5T_CSET_ERROR", H5T_CSET_ERROR) // = -1, /**< error */
.value("H5T_CSET_ASCII", H5T_CSET_ASCII) // = 0, /**< US ASCII */
.value("H5T_CSET_UTF8", H5T_CSET_UTF8) // = 1, /**< UTF-8 Unicode encoding */
;
enum_<H5T_str_t>("H5T_str_t")
.value("H5T_STR_ERROR", H5T_STR_ERROR) // = -1, /**<error */
.value("H5T_STR_NULLTERM", H5T_STR_NULLTERM) // = 0, /**<null-terminated */
.value("H5T_STR_NULLPAD", H5T_STR_NULLPAD) // = 1, /**<pad with nulls */
.value("H5T_STR_SPACEPAD", H5T_STR_SPACEPAD) // = 2, /**<pad with spaces */
;

//constant("H5L_type_t", H5L_type_t);
// FILE ACCESS
Expand Down
3 changes: 2 additions & 1 deletion src/hdf5_util_helpers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,15 @@ export interface Metadata {
array_type?: Metadata,
chunks: number[] | null,
compound_type?: CompoundTypeMetadata,
cset: number,
cset?: number,
enum_type?: EnumTypeMetadata,
littleEndian: boolean,
maxshape: number[] | null,
ref_type?: 'object' | 'region',
shape: number[] | null,
signed: boolean,
size: number,
strpad?: number,
total_size: number,
type: number,
vlen: boolean,
Expand Down
1 change: 0 additions & 1 deletion test/bool_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ async function bool_test() {

assert.deepEqual(f.get('bool').metadata, {
chunks: null,
cset: -1,
enum_type: {
type: 0,
nmembers: 2,
Expand Down
5 changes: 1 addition & 4 deletions test/compound_and_array_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ async function compound_array_test() {
members: [
{
array_type: {
cset: -1,
shape: [2, 2],
littleEndian: true,
signed: false,
Expand All @@ -76,7 +75,6 @@ async function compound_array_test() {
type: 1,
vlen: false,
},
cset: -1,
littleEndian: true,
name: 'floaty',
offset: 0,
Expand All @@ -93,11 +91,11 @@ async function compound_array_test() {
littleEndian: false,
signed: false,
size: 5,
strpad: 1,
total_size: 4,
type: 3,
vlen: false,
},
cset: -1,
littleEndian: false,
name: 'stringy',
offset: 32,
Expand All @@ -110,7 +108,6 @@ async function compound_array_test() {
],
nmembers: 2
},
cset: -1,
littleEndian: true,
maxshape: [2],
shape: [2],
Expand Down

0 comments on commit bfc5819

Please sign in to comment.