22 hid_t open_attribute(archive
const & ar, hid_t file_id, std::string path) {
23 if ((path = ar.complete_path(path)).find_last_of(
'@') == std::string::npos)
25 return H5Aopen_by_name(file_id, path.substr(0, path.find_last_of(
'@')).c_str(), path.substr(path.find_last_of(
'@') + 1).c_str(), H5P_DEFAULT, H5P_DEFAULT);
28 herr_t list_children_visitor(hid_t,
char const * n,
const H5L_info_t *,
void * d) {
29 reinterpret_cast<std::vector<std::string> *
>(d)->push_back(n);
33 herr_t list_attributes_visitor(hid_t,
char const * n,
const H5A_info_t *,
void * d) {
34 reinterpret_cast<std::vector<std::string> *
>(d)->push_back(n);
39 #define ALPS_HDF5_IMPLEMENT_FREE_FUNCTIONS(T) \ 41 alps::hdf5::scalar_type< T >::type * get_pointer< T >::apply( T & value) { \ 45 alps::hdf5::scalar_type< T >::type const * get_pointer< T const >::apply( T const & value) { \ 49 bool is_vectorizable< T >::apply(T const &) { \ 52 bool is_vectorizable< T const >::apply(T &) { \ 59 , std::string const & path \ 61 , std::vector<std::size_t> size \ 62 , std::vector<std::size_t> chunk \ 63 , std::vector<std::size_t> offset \ 66 ar.write(path, value); \ 68 ar.write(path, get_pointer(value), size, chunk, offset); \ 73 , std::string const & path \ 75 , std::vector<std::size_t> chunk \ 76 , std::vector<std::size_t> offset \ 79 ar.read(path, value); \ 81 ar.read(path, get_pointer(value), chunk, offset); \ 85 #undef ALPS_HDF5_IMPLEMENT_FREE_FUNCTIONS 88 template<
typename T>
struct is_datatype_impl_compare {
89 static bool apply(type_type
const & native_id) {
91 H5Tequal(type_type(H5Tcopy(native_id)), type_type(get_native_type(
typename alps::detail::type_wrapper<T>::type())))
95 template<>
struct is_datatype_impl_compare<std::string> {
96 static bool apply(type_type
const & native_id) {
97 return H5Tget_class(native_id) == H5T_STRING;
106 path = complete_path(path);
107 if (context_ == NULL)
109 if (path.find_last_of(
'@') != std::string::npos && is_attribute(path)) {
110 detail::attribute_type attr_id(detail::open_attribute(*
this, context_->file_id_, path));
111 type_id = H5Aget_type(attr_id);
112 }
else if (path.find_last_of(
'@') == std::string::npos && is_data(path)) {
113 detail::data_type data_id(H5Dopen2(context_->file_id_, path.c_str(), H5P_DEFAULT));
114 type_id = H5Dget_type(data_id);
117 detail::type_type native_id(H5Tget_native_type(type_id, H5T_DIR_ASCEND));
118 detail::check_type(type_id);
121 return detail::is_datatype_impl_compare< T >::apply(native_id);
124 #define ALPS_HDF5_IS_DATATYPE_IMPL_IMPL(T) template bool archive::is_datatype_impl<T>(std::string, T) const;
auto is_datatype_impl(std::string path, T) const -> typename std::enable_if< is_native_type< T >::value, bool >::type
#define ALPS_HDF5_LOCK_MUTEX
ALPS_FOREACH_NATIVE_HDF5_TYPE(ALPS_HDF5_READ_SCALAR)
#define ONLY_NATIVE(T, R)
#define ALPS_HDF5_IS_DATATYPE_IMPL_IMPL(T)
#define ALPS_HDF5_FAKE_THREADSAFETY
#define ALPS_HDF5_IMPLEMENT_FREE_FUNCTIONS(T)