summaryrefslogtreecommitdiffstats
path: root/c++/src/H5Attribute.cpp
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2009-07-27 05:41:46 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2009-07-27 05:41:46 (GMT)
commit0fb5c9b678f60af761556c5ca3337109d352145c (patch)
tree85cb3e102682d6fe0bce5f8763174993df487a04 /c++/src/H5Attribute.cpp
parent8c1762f8a68ff8d30717104f01d1382829518730 (diff)
downloadhdf5-0fb5c9b678f60af761556c5ca3337109d352145c.zip
hdf5-0fb5c9b678f60af761556c5ca3337109d352145c.tar.gz
hdf5-0fb5c9b678f60af761556c5ca3337109d352145c.tar.bz2
[svn-r17239] 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-len 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 0f7a3c2..e1de976 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