summaryrefslogtreecommitdiffstats
path: root/src/H5Pstrcpl.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2012-09-25 15:47:25 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2012-09-25 15:47:25 (GMT)
commit6a89177036b5808ed0ce06ce0aab3af056b56984 (patch)
tree43367eb16716e1a2f074e2af07121e2723eae8d8 /src/H5Pstrcpl.c
parent50e3990f2a9e3bba421460d8d5cb21bb6f6e98fe (diff)
downloadhdf5-6a89177036b5808ed0ce06ce0aab3af056b56984.zip
hdf5-6a89177036b5808ed0ce06ce0aab3af056b56984.tar.gz
hdf5-6a89177036b5808ed0ce06ce0aab3af056b56984.tar.bz2
[svn-r22807] Description:
Add encode/decode API routines for property lists: H5Pencode/H5Pdecode. Tested on: FreeBSD/32 8.2 (loyalty) w/gcc4.6, w/C++ & FORTRAN, in debug mode FreeBSD/64 8.2 (freedom) w/gcc4.6, w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (koala) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, w/threadsafe, in production mode Linux/PPC 2.6 (ostrich) w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-ia64 2.6 (ember) w/Intel compilers, w/parallel, C++ & FORTRAN, in production mode Mac OS X/32 10.7.3 (amazon) in debug mode Mac OS X/32 10.7.3 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode Mac OS X/32 10.7.3 (amazon) w/parallel, in debug mode
Diffstat (limited to 'src/H5Pstrcpl.c')
-rw-r--r--src/H5Pstrcpl.c85
1 files changed, 83 insertions, 2 deletions
diff --git a/src/H5Pstrcpl.c b/src/H5Pstrcpl.c
index 505e35f..97b7ee3 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, uint8_t **pp, size_t *size);
+static herr_t H5P__strcrt_char_encoding_dec(const uint8_t **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,74 @@ 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, uint8_t **pp, size_t *size)
+{
+ const H5T_cset_t *encoding = (const H5T_cset_t *)value; /* Create local alias for values */
+
+ 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 uint8_t **pp, void *_value)
+{
+ H5T_cset_t *encoding = (H5T_cset_t *)_value; /* Character set encoding */
+
+ 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() */
+