本文介绍了如何通过C或C ++ API获得HDF5数据集的名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用C ++ API读取HDF5数据集的名称.对于H5::Attribute对象,有一个getName()方法.但是,我看不到用于H5:DataSet对象的类似getName()方法.

I'm trying to read the name of a HDF5 DataSet using the C++ API. For H5::Attribute objects, there is a getName() method. However, I don't see a similar getName() method for H5:DataSet objects.

理想情况下,我想这样做:

Ideally I want to do this:

 void Dump(H5::DataSet& ds)
 {
    cout << "Dataset " << ds.getName() << endl;
    // continue to print dataset values
 }

我知道h5dump可以做到,但是简单地看一下代码,它只能通过使用H5Giterate走树来知道,只有父母知道孩子的名字,但是孩子却不知道知道自己的名字.

I know h5dump can do it, but briefly looking at the code, it only knows it by walking the tree using H5Giterate, that is only the parent knows the name of the children, but the children don't know their own name.

推荐答案

在C中,有 H5Iget_name .我找不到C ++中的等效项,但可以使用 DataSet::getId() 并将其提供给C函数.

In C, there is H5Iget_name. I couldn't find the equivalent in C++ but you can use DataSet::getId() and give that to the C function.

我想这不像在DataSet中具有getName()访问器那样简单的原因是,要读取数据集,您需要知道其名称或在树上行走.我能想到的唯一例外是在取消引用数据集的引用时.

I guess the reason why this is not as simple as having a getName() accessor in DataSet is that to read a dataset, you either need to know its name or walk the tree. The only exception I can think of is when dereferencing a reference to a dataset.

这篇关于如何通过C或C ++ API获得HDF5数据集的名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 09:51