diff options
Diffstat (limited to 'src/H5Pstrcpl.c')
-rw-r--r-- | src/H5Pstrcpl.c | 87 |
1 files changed, 85 insertions, 2 deletions
diff --git a/src/H5Pstrcpl.c b/src/H5Pstrcpl.c index 505e35f..bedacb0 100644 --- a/src/H5Pstrcpl.c +++ b/src/H5Pstrcpl.c @@ -46,6 +46,8 @@ /* Definitions for character set encoding property */ #define H5P_STRCRT_CHAR_ENCODING_SIZE sizeof(H5T_cset_t) #define H5P_STRCRT_CHAR_ENCODING_DEF H5F_DEFAULT_CSET +#define H5P_STRCRT_CHAR_ENCODING_ENC H5P__strcrt_char_encoding_enc +#define H5P_STRCRT_CHAR_ENCODING_DEC H5P__strcrt_char_encoding_dec /******************/ @@ -65,6 +67,10 @@ /* Property class callbacks */ static herr_t H5P__strcrt_reg_prop(H5P_genclass_t *pclass); +/* encode & decode callbacks */ +static herr_t H5P__strcrt_char_encoding_enc(const void *value, void **_pp, size_t *size); +static herr_t H5P__strcrt_char_encoding_dec(const void **_pp, void *value); + /*********************/ /* Package Variables */ @@ -96,6 +102,9 @@ const H5P_libclass_t H5P_CLS_STRCRT[1] = {{ /* Local Variables */ /*******************/ +/* Property value defaults */ +static const H5T_cset_t H5P_def_char_encoding_g = H5P_STRCRT_CHAR_ENCODING_DEF; /* Default character set encoding */ + /*------------------------------------------------------------------------- @@ -112,13 +121,14 @@ const H5P_libclass_t H5P_CLS_STRCRT[1] = {{ static herr_t H5P__strcrt_reg_prop(H5P_genclass_t *pclass) { - H5T_cset_t char_encoding = H5P_STRCRT_CHAR_ENCODING_DEF; /* Default character set encoding */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Register character encoding */ - if(H5P_register_real(pclass, H5P_STRCRT_CHAR_ENCODING_NAME, H5P_STRCRT_CHAR_ENCODING_SIZE, &char_encoding, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if(H5P_register_real(pclass, H5P_STRCRT_CHAR_ENCODING_NAME, H5P_STRCRT_CHAR_ENCODING_SIZE, &H5P_def_char_encoding_g, + NULL, NULL, NULL, H5P_STRCRT_CHAR_ENCODING_ENC, H5P_STRCRT_CHAR_ENCODING_DEC, + NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: @@ -196,3 +206,76 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_char_encoding() */ + +/*------------------------------------------------------------------------- + * Function: H5P__strcrt_char_encoding_enc + * + * Purpose: Callback routine which is called whenever the character + * set encoding property in the string create property list + * is encoded. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Friday, August 31, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__strcrt_char_encoding_enc(const void *value, void **_pp, size_t *size) +{ + const H5T_cset_t *encoding = (const H5T_cset_t *)value; /* Create local alias for values */ + uint8_t **pp = (uint8_t **)_pp; + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(encoding); + HDassert(size); + + if(NULL != *pp) + /* Encode character set encoding */ + *(*pp)++ = (uint8_t)*encoding; + + /* Size of character set encoding */ + (*size)++; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__strcrt_char_encoding_enc() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__strcrt_char_encoding_dec + * + * Purpose: Callback routine which is called whenever the character + * set encoding property in the string create property list + * is decoded. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * Friday, August 31, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__strcrt_char_encoding_dec(const void **_pp, void *_value) +{ + H5T_cset_t *encoding = (H5T_cset_t *)_value; /* Character set encoding */ + const uint8_t **pp = (const uint8_t **)_pp; + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(pp); + HDassert(*pp); + HDassert(encoding); + + /* Decode character set encoding */ + *encoding = (H5T_cset_t)*(*pp)++; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__strcrt_char_encoding_dec() */ + |