hdf5: groups: handle paths to access sub-content objects
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Christian Zimmermann 2024-01-30 19:18:33 +01:00
parent 39c0a3146f
commit 84f18e1d5e
2 changed files with 16 additions and 1 deletions

View file

@ -75,7 +75,16 @@ namespace CNORXZ
const ContentPtr& Group::get(const String& name) const const ContentPtr& Group::get(const String& name) const
{ {
auto i = this->getIndexTo(name); const String delim = "/";
const SizeT delimpos = name.find(delim);
const String thisname = name.substr(0, delimpos);
if(delimpos != String::npos and delimpos+1 < name.size()){
const String next = name.substr(delimpos+1);
auto g = getGroup(thisname);
g->open();
return g->get(next);
}
auto i = this->getIndexTo(thisname);
return *i; return *i;
} }

View file

@ -139,6 +139,12 @@ namespace
VCHECK(tab->path()); VCHECK(tab->path());
EXPECT_EQ(tab->fields()->size(), 3u); EXPECT_EQ(tab->fields()->size(), 3u);
EXPECT_EQ(tab->records()->size(), 5u); EXPECT_EQ(tab->records()->size(), 5u);
EXPECT_THROW(h5f.getTable("moregroups/evenmore/need/tab1/a"), std::runtime_error);
auto tab2 = h5f.getTable("moregroups/evenmore/need/tab1/");
EXPECT_EQ(tab2->fields()->size(), 3u);
EXPECT_EQ(tab2->records()->size(), 5u);
h5f.iter( [](const auto& c) { VCHECK(c->path()); } )(); h5f.iter( [](const auto& c) { VCHECK(c->path()); } )();
h5f.iterRecursive( [](const auto& c) { VCHECK(c->path()); } )(); h5f.iterRecursive( [](const auto& c) { VCHECK(c->path()); } )();
h5f.iterRecursive( [](const auto& c) { c->open(); VCHECK(toString(c->getRecursiveAttributes())); } )(); h5f.iterRecursive( [](const auto& c) { c->open(); VCHECK(toString(c->getRecursiveAttributes())); } )();