当前位置: 首页>>代码示例>>C++>>正文


C++ dataset::read方法代码示例

本文整理汇总了C++中dataset::read方法的典型用法代码示例。如果您正苦于以下问题:C++ dataset::read方法的具体用法?C++ dataset::read怎么用?C++ dataset::read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dataset的用法示例。


在下文中一共展示了dataset::read方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: file_space

typename boost::enable_if<is_multi_array<T>, void>::type
read_dataset(dataset & data_set, T & array)
{
    const int array_rank = T::dimensionality;
    typedef typename T::element value_type;

    // --- use temporary dataspace object to get the shape of the dataset
    dataspace file_space(data_set);
    if (!(file_space.rank() == array_rank))
        H5XX_THROW("dataset \"" + get_name(data_set) + "\" and target array have mismatching dimensions");

    boost::array<hsize_t, array_rank> file_dims = file_space.extents<array_rank>();

    // --- clear array - TODO check if this feature is necessary/wanted
    boost::array<size_t, array_rank> array_zero;
    array_zero.assign(0);
    array.resize(array_zero);

    // --- resize array to match the dataset - TODO check if this feature is necessary/wanted
    boost::array<size_t, array_rank> array_shape;
    std::copy(file_dims.begin(), file_dims.begin() + array_rank, array_shape.begin());
    array.resize(array_shape);

    hid_t mem_space_id = H5S_ALL;
    hid_t file_space_id = H5S_ALL;
    hid_t xfer_plist_id = H5P_DEFAULT;

    data_set.read(ctype<value_type>::hid(), array.origin(), mem_space_id, file_space_id, xfer_plist_id);
}
开发者ID:KaiSzuttor,项目名称:h5xx,代码行数:29,代码来源:boost_multi_array.hpp

示例2:

typename boost::enable_if<is_multi_array<T>, void>::type
read_dataset(dataset & data_set, T & array, dataspace const& memspace, dataspace const& filespace)
{
    // --- disabled this check, it is orthogonal to a useful feature (eg read from 2D dataset into 1D array)
//    const int array_rank = T::dimensionality;
//    if (!(memspace.rank() == array_rank)) {
//        throw error("memory dataspace and array rank do not match");
//    }

    if (static_cast<hsize_t>(filespace.get_select_npoints()) > array.num_elements())
        H5XX_THROW("target array does not provide enough space to store selected dataspace elements");

    hid_t mem_space_id = memspace.hid(); //H5S_ALL;
    hid_t file_space_id = filespace.hid();
    hid_t xfer_plist_id = H5P_DEFAULT;

    typedef typename T::element value_type;
    data_set.read(ctype<value_type>::hid(), array.origin(), mem_space_id, file_space_id, xfer_plist_id);
}
开发者ID:KaiSzuttor,项目名称:h5xx,代码行数:19,代码来源:boost_multi_array.hpp


注:本文中的dataset::read方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。