Skip to content

Commit c2aae33

Browse files
committed
Add MyPath::printGroup() helper
1 parent 28512f6 commit c2aae33

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

include/openPMD/backend/Attributable.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ class Attributable
281281

282282
/** Reconstructs a path that can be passed to a Series constructor */
283283
std::string filePath() const;
284+
std::string printGroup() const;
284285
};
285286

286287
/**

src/backend/Attributable.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <complex>
2929
#include <iostream>
3030
#include <set>
31+
#include <sstream>
3132

3233
namespace openPMD
3334
{
@@ -197,6 +198,21 @@ std::string Attributable::MyPath::filePath() const
197198
return directory + seriesName + seriesExtension;
198199
}
199200

201+
std::string Attributable::MyPath::printGroup() const
202+
{
203+
std::stringstream res;
204+
if (this->group.empty())
205+
{
206+
return res.str();
207+
}
208+
res << *this->group.begin();
209+
for (auto it = ++this->group.begin(); it != this->group.end(); ++it)
210+
{
211+
res << '/' << *it;
212+
}
213+
return res.str();
214+
}
215+
200216
auto Attributable::myPath() const -> MyPath
201217
{
202218
MyPath res;

0 commit comments

Comments
 (0)