9 #ifndef H5DATASPACE_MISC_HPP 
   10 #define H5DATASPACE_MISC_HPP 
   14 #include <initializer_list> 
   16 #include <H5Spublic.h> 
   18 #include "../H5DataSpace.hpp" 
   19 #include "../H5Exception.hpp" 
   31 template<
typename... Args>
 
   33     : 
DataSpace(
std::vector<size_t>{
static_cast<size_t>(dim1),
 
   34                                     static_cast<size_t>(dims)...}){}
 
   36 template <
class IT, 
typename>
 
   38     std::vector<hsize_t> real_dims(begin, end);
 
   40     if ((
_hid = H5Screate_simple(
int(real_dims.size()), real_dims.data(),
 
   47                             const std::vector<size_t>& maxdims) {
 
   49     if (dims.size() != maxdims.size()) {
 
   53     std::vector<hsize_t> real_dims(dims.begin(), dims.end());
 
   54     std::vector<hsize_t> real_maxdims(maxdims.begin(), maxdims.end());
 
   57     std::replace(real_maxdims.begin(), real_maxdims.end(),
 
   60     if ((
_hid = H5Screate_simple(
int(dims.size()), real_dims.data(),
 
   61                                  real_maxdims.data())) < 0) {
 
   67     H5S_class_t h5_dataspace_type;
 
   70         h5_dataspace_type = H5S_SCALAR;
 
   73         h5_dataspace_type = H5S_NULL;
 
   77                                  "datascape_scalar or datascape_null");
 
   80     if ((
_hid = H5Screate(h5_dataspace_type)) < 0) {
 
   89     if ((res.
_hid = H5Scopy(
_hid)) < 0) {
 
   96     const int ndim = H5Sget_simple_extent_ndims(
_hid);
 
   98         HDF5ErrMapper::ToException<DataSetException>(
 
   99             "Unable to get dataspace number of dimensions");
 
  107     if (dims.size() > 0) {
 
  108         if (H5Sget_simple_extent_dims(
_hid, dims.data(), 
NULL) < 0) {
 
  109             HDF5ErrMapper::ToException<DataSetException>(
 
  110                 "Unable to get dataspace dimensions");
 
  118     if (H5Sget_simple_extent_dims(
_hid, 
NULL, maxdims.data()) < 0) {
 
  119         HDF5ErrMapper::ToException<DataSetException>(
 
  120             "Unable to get dataspace dimensions");
 
  123     std::vector<size_t> res(maxdims.begin(), maxdims.end());
 
  124     std::replace(maxdims.begin(), maxdims.end(),
 
  129 template <
typename ScalarValue>
 
  134         (std::is_arithmetic<ScalarValue>::value ||
 
  135          std::is_enum<ScalarValue>::value ||
 
  136          std::is_same<std::string, ScalarValue>::value),
 
  137         "Only the following types are supported by DataSpace::From: \n" 
  138         "  signed_arithmetic_types = int |  long | float |  double \n" 
  139         "  unsigned_arithmetic_types = unsigned signed_arithmetic_types \n" 
  140         "  string_types = std::string \n" 
  141         "  all_basic_types = string_types | unsigned_arithmetic_types | " 
  142         "signed_arithmetic_types \n " 
  143         "  stl_container_types = std::vector<all_basic_types> " 
  144         "  boost_container_types = " 
  145         "boost::numeric::ublas::matrix<all_basic_types> | " 
  146         "boost::multi_array<all_basic_types> \n" 
  147         "  all_supported_types = all_basic_types | stl_container_types | " 
  148         "boost_container_types");
 
  153 template <
typename Value>
 
  155     return DataSpace(details::get_dim_vector<Value>(container));
 
  159 template <
typename Value, std::
size_t N>
 
  161     std::vector<size_t> dims;
 
  167 template <
typename Value, std::
size_t Dims>
 
  170     std::vector<size_t> dims(Dims);
 
  171     for (std::size_t i = 0; i < Dims; ++i) {
 
  172         dims[i] = container.shape()[i];
 
  177 template <
typename Value>
 
  180     std::vector<size_t> dims(2);
 
  181     dims[0] = mat.size1();
 
  182     dims[1] = mat.size2();
 
  193     if (input_dims == dataset_dims)
 
  197     for (std::vector<size_t>::const_reverse_iterator i = dims.rbegin();
 
  198          i != --dims.rend() && *i == 1; ++i)
 
  201     if (input_dims == dataset_dims)
 
  204     dataset_dims = dims.size();
 
  205     for (std::vector<size_t>::const_iterator i = dims.begin();
 
  206          i != --dims.end() && *i == 1; ++i)
 
  209     if (input_dims == dataset_dims)
 
  213     return input_dims == 0 && dataset_dims == 1 && dims[dims.size() - 1] == 1;
 
  219 #endif // H5DATASPACE_MISC_HPP