diff --git a/examples/14_toml_template.cpp b/examples/14_toml_template.cpp index f595e9b10f..076bf7893e 100644 --- a/examples/14_toml_template.cpp +++ b/examples/14_toml_template.cpp @@ -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()) @@ -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}; @@ -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); } diff --git a/include/openPMD/Dataset.hpp b/include/openPMD/Dataset.hpp index a610ce6a67..ad1125d9d3 100644 --- a/include/openPMD/Dataset.hpp +++ b/include/openPMD/Dataset.hpp @@ -41,18 +41,24 @@ class Dataset public: enum : std::uint64_t { - JOINED_DIMENSION = std::numeric_limits::max() + JOINED_DIMENSION = std::numeric_limits::max(), + UNDEFINED_EXTENT = std::numeric_limits::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); diff --git a/src/IO/JSON/JSONIOHandlerImpl.cpp b/src/IO/JSON/JSONIOHandlerImpl.cpp index c10d64934f..0dd2239fd5 100644 --- a/src/IO/JSON/JSONIOHandlerImpl.cpp +++ b/src/IO/JSON/JSONIOHandlerImpl.cpp @@ -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; } @@ -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(