summaryrefslogtreecommitdiffstats
path: root/c++/src/H5Attribute.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2009-07-27 04:00:17 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2009-07-27 04:00:17 (GMT)
commitc1ad3676c4b56b80663d271ac367a65cc41c39ab (patch)
tree42f19502941ff1d02d45b92a7f8a0a3f6945002e /c++/src/H5Attribute.cpp
parent405ea51bb7728dc696e29694b22e81dc4b6ce2c1 (diff)
downloadhdf5-c1ad3676c4b56b80663d271ac367a65cc41c39ab.zip
hdf5-c1ad3676c4b56b80663d271ac367a65cc41c39ab.tar.gz
hdf5-c1ad3676c4b56b80663d271ac367a65cc41c39ab.tar.bz2
[svn-r17238] Purpose: Fix bug and improve readability
Description: - Revised DataSet::write to pass in correct string buffer - Added member function DataSet::getInMemDataSize() to simplify getting the dataset's data size in memory. - Added private functions for reading fixed- and variable-length string data: p_read_fixed_len and p_read_variable_len. - Added tests to write/read array of strings to datasets. Platforms tested: Linux/32 2.6 (jam) FreeBSD/64 6.3 (liberty) SunOS 5.10 (linew)
Diffstat (limited to 'c++/src/H5Attribute.cpp')
-rw-r--r--c++/src/H5Attribute.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index b1ab73e..6de5e63 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -198,35 +198,37 @@ void Attribute::read(const DataType& mem_type, H5std_string& strg) const
//--------------------------------------------------------------------------
size_t Attribute::getInMemDataSize() const
{
+ char *func = "Attribute::getInMemDataSize";
+
// Get the data type of this attribute
hid_t mem_type_id = H5Aget_type(id);
- if (mem_type_id <= 0)
+ if( mem_type_id < 0 )
{
- throw AttributeIException("Attribute::getInMemDataSize", "H5Aget_type failed");
+ throw AttributeIException(func, "H5Aget_type failed");
}
// Get the data type's size
hid_t native_type = H5Tget_native_type(mem_type_id, H5T_DIR_DEFAULT);
if (native_type < 0)
{
- throw AttributeIException("Attribute::getInMemDataSize", "H5Tget_native_type failed");
+ throw AttributeIException(func, "H5Tget_native_type failed");
}
size_t type_size = H5Tget_size(native_type);
if (type_size == 0)
{
- throw AttributeIException("Attribute::getInMemDataSize", "H5Tget_size failed");
+ throw AttributeIException(func, "H5Tget_size failed");
}
// Get number of elements of the attribute
hid_t space_id = H5Aget_space(id);
if (space_id < 0)
{
- throw AttributeIException("Attribute::getInMemDataSize", "H5Aget_space failed");
+ throw AttributeIException(func, "H5Aget_space failed");
}
hssize_t num_elements = H5Sget_simple_extent_npoints(space_id);
if (num_elements < 0)
{
- throw AttributeIException("Attribute::getInMemDataSize", "H5Sget_simple_extent_npoints failed");
+ throw AttributeIException(func, "H5Sget_simple_extent_npoints failed");
}
// Calculate and return the size of the data