summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJerome Soumagne <jsoumagne@hdfgroup.org>2016-06-13 20:22:18 (GMT)
committerJerome Soumagne <jsoumagne@hdfgroup.org>2016-11-29 23:42:33 (GMT)
commita4b81fe620b8ecf7e022544b00332e825ca33db0 (patch)
treebf39eb199e682b28f844895d520f7a7d19e8f8f8 /src
parent43db208d2b9fc32975f8e5863ac8bf73fafe6b2e (diff)
downloadhdf5-a4b81fe620b8ecf7e022544b00332e825ca33db0.zip
hdf5-a4b81fe620b8ecf7e022544b00332e825ca33db0.tar.gz
hdf5-a4b81fe620b8ecf7e022544b00332e825ca33db0.tar.bz2
Add H5R_cast()
Diffstat (limited to 'src')
-rw-r--r--src/H5R.c39
-rw-r--r--src/H5Rprivate.h2
2 files changed, 41 insertions, 0 deletions
diff --git a/src/H5R.c b/src/H5R.c
index bea7fe4..7ee472b 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -2256,3 +2256,42 @@ H5R_decode(const unsigned char *buf)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5R_decode() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5R_cast
+ *
+ * Purpose: Cast reference to parent type.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5R_cast(href_t _ref, H5R_type_t ref_type)
+{
+ struct href *ref = (struct href *)_ref;
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ HDassert(ref);
+
+ switch (ref->ref_type) {
+ case H5R_EXT_REGION:
+ case H5R_EXT_ATTR:
+ if (ref_type < ref->ref_type && ref_type > H5R_ATTR)
+ /* Safe to cast */
+ ref->ref_type = ref_type;
+ break;
+ case H5R_EXT_OBJECT:
+ case H5R_OBJECT:
+ case H5R_REGION:
+ case H5R_ATTR:
+ default:
+ HDassert("unknown reference type" && 0);
+ HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)")
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5R_cast() */
diff --git a/src/H5Rprivate.h b/src/H5Rprivate.h
index cde489a..056f95f 100644
--- a/src/H5Rprivate.h
+++ b/src/H5Rprivate.h
@@ -42,4 +42,6 @@ H5_DLL H5R_type_t H5R_get_type(href_t ref);
H5_DLL herr_t H5R_encode(href_t ref, unsigned char *buf, size_t *nalloc);
H5_DLL href_t H5R_decode(const unsigned char *buf);
+H5_DLL herr_t H5R_cast(href_t _ref, H5R_type_t ref_type);
+
#endif /* _H5Rprivate_H */