----------------------------------------------------------------------------
| 911 | |
| 912 | //---------------------------------------------------------------------------- |
| 913 | std::string vtkERFReader::GetAttributeValueAsStr( |
| 914 | const hid_t& erfIdx, const std::string& attributeName) const |
| 915 | { |
| 916 | vtkHDF::ScopedH5AHandle attributeHandler = H5Aopen(erfIdx, attributeName.c_str(), H5P_DEFAULT); |
| 917 | vtkHDF::ScopedH5THandle rawType = H5Aget_type(attributeHandler); |
| 918 | vtkHDF::ScopedH5THandle dataType = H5Tget_native_type(rawType, H5T_DIR_ASCEND); |
| 919 | |
| 920 | if (H5Tget_class(dataType) != H5T_STRING) |
| 921 | { |
| 922 | return ""; |
| 923 | } |
| 924 | |
| 925 | hsize_t stringLength = H5Aget_storage_size(attributeHandler); |
| 926 | std::string value; |
| 927 | value.resize(stringLength + 1); |
| 928 | if (H5Aread(attributeHandler, dataType, value.data()) >= 0) |
| 929 | { |
| 930 | value.erase(std::remove_if(value.begin(), value.end(), |
| 931 | [](char c) |
| 932 | { |
| 933 | // convert it to avoid potential issue with negative char |
| 934 | unsigned char uc = static_cast<unsigned char>(c); |
| 935 | return std::isspace(uc) || !std::isalpha(uc); |
| 936 | }), |
| 937 | value.end()); |
| 938 | } |
| 939 | |
| 940 | return value; |
| 941 | } |
| 942 | |
| 943 | //---------------------------------------------------------------------------- |
| 944 | int vtkERFReader::GetAttributeValueAsInt( |
no test coverage detected