Skip to content

Commit

Permalink
wip: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Dec 11, 2024
1 parent 37fc432 commit 2e64834
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
5 changes: 3 additions & 2 deletions examples/14_toml_template.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

std::string backendEnding()
{
return "json";
auto extensions = openPMD::getFileExtensions();
if (auto it = std::find(extensions.begin(), extensions.end(), "toml");
it != extensions.end())
Expand Down Expand Up @@ -50,7 +51,7 @@ void write()
* Don't specify datatype and extent for this one to indicate that this
* information is not yet known.
*/
E["z"].resetDataset({openPMD::Datatype::UNDEFINED});
E["z"].resetDataset({});

ds.extent = {10};

Expand Down Expand Up @@ -100,7 +101,7 @@ void read()
openPMD::Series read(
"../samples/tomlTemplate." + backendEnding(),
openPMD::Access::READ_LINEAR);
read.readIterations(); // @todo change to read.parseBase()
read.parseBase();
openPMD::helper::listSeries(read);
}

Expand Down
14 changes: 10 additions & 4 deletions include/openPMD/Dataset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,24 @@ class Dataset
public:
enum : std::uint64_t
{
JOINED_DIMENSION = std::numeric_limits<std::uint64_t>::max()
JOINED_DIMENSION = std::numeric_limits<std::uint64_t>::max(),
UNDEFINED_EXTENT = std::numeric_limits<std::uint64_t>::max() - 1
};

Dataset(Datatype, Extent = {1}, std::string options = "{}");
Dataset(Datatype, Extent, std::string options = "{}");

/**
* @brief Constructor that sets the datatype to undefined.
*
* Helpful for resizing datasets, since datatypes need not be given twice.
* Helpful for:
*
* 1. Resizing datasets, since datatypes need not be given twice.
* 2. Initializing datasets as undefined, as used by template mode in the
* JSON/TOML backend. In this case, the default (undefined) specification
* for the Extent may be used.
*
*/
Dataset(Extent);
Dataset(Extent = {UNDEFINED_EXTENT});

Dataset &extend(Extent newExtent);

Expand Down
4 changes: 2 additions & 2 deletions src/IO/JSON/JSONIOHandlerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ void JSONIOHandlerImpl::createDataset(
}
case IOMode::Template:
if (parameter.extent != Extent{0} &&
parameter.dtype != Datatype::UNDEFINED)
parameter.extent[0] != Dataset::UNDEFINED_EXTENT)
{
dset["extent"] = parameter.extent;
}
Expand Down Expand Up @@ -1998,7 +1998,7 @@ JSONIOHandlerImpl::obtainJsonContents(File const &file)
}
}

if (m_IOModeSpecificationVia == SpecificationVia::DefaultValue &&
if (m_attributeModeSpecificationVia == SpecificationVia::DefaultValue &&
openpmd_internal.contains(JSONDefaults::AttributeMode))
{
auto modeOption = openPMD::json::asLowerCaseStringDynamic(
Expand Down

0 comments on commit 2e64834

Please sign in to comment.