Skip to content

Commit 2e64834

Browse files
committed
wip: cleanup
1 parent 37fc432 commit 2e64834

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

examples/14_toml_template.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

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

5556
ds.extent = {10};
5657

@@ -100,7 +101,7 @@ void read()
100101
openPMD::Series read(
101102
"../samples/tomlTemplate." + backendEnding(),
102103
openPMD::Access::READ_LINEAR);
103-
read.readIterations(); // @todo change to read.parseBase()
104+
read.parseBase();
104105
openPMD::helper::listSeries(read);
105106
}
106107

include/openPMD/Dataset.hpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,24 @@ class Dataset
4141
public:
4242
enum : std::uint64_t
4343
{
44-
JOINED_DIMENSION = std::numeric_limits<std::uint64_t>::max()
44+
JOINED_DIMENSION = std::numeric_limits<std::uint64_t>::max(),
45+
UNDEFINED_EXTENT = std::numeric_limits<std::uint64_t>::max() - 1
4546
};
4647

47-
Dataset(Datatype, Extent = {1}, std::string options = "{}");
48+
Dataset(Datatype, Extent, std::string options = "{}");
4849

4950
/**
5051
* @brief Constructor that sets the datatype to undefined.
5152
*
52-
* Helpful for resizing datasets, since datatypes need not be given twice.
53+
* Helpful for:
54+
*
55+
* 1. Resizing datasets, since datatypes need not be given twice.
56+
* 2. Initializing datasets as undefined, as used by template mode in the
57+
* JSON/TOML backend. In this case, the default (undefined) specification
58+
* for the Extent may be used.
5359
*
5460
*/
55-
Dataset(Extent);
61+
Dataset(Extent = {UNDEFINED_EXTENT});
5662

5763
Dataset &extend(Extent newExtent);
5864

src/IO/JSON/JSONIOHandlerImpl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ void JSONIOHandlerImpl::createDataset(
644644
}
645645
case IOMode::Template:
646646
if (parameter.extent != Extent{0} &&
647-
parameter.dtype != Datatype::UNDEFINED)
647+
parameter.extent[0] != Dataset::UNDEFINED_EXTENT)
648648
{
649649
dset["extent"] = parameter.extent;
650650
}
@@ -1998,7 +1998,7 @@ JSONIOHandlerImpl::obtainJsonContents(File const &file)
19981998
}
19991999
}
20002000

2001-
if (m_IOModeSpecificationVia == SpecificationVia::DefaultValue &&
2001+
if (m_attributeModeSpecificationVia == SpecificationVia::DefaultValue &&
20022002
openpmd_internal.contains(JSONDefaults::AttributeMode))
20032003
{
20042004
auto modeOption = openPMD::json::asLowerCaseStringDynamic(

0 commit comments

Comments
 (0)