Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions autogen/.gitignore

This file was deleted.

5 changes: 4 additions & 1 deletion autogen/prototype.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
" Optional (defaults to GNDStk).",
"",
"JSONDir",
" Directory where the listed .json input files are located",
" Directory where the .json input files are located",
"",
"JSONFiles",
" The .json input files",
"",
"TO AUTOGENERATE THE PROTOTYPE IN THE REAL GNDStk HIERARCHY",
" Set Path to ../.. if you run json2class.exe from within",
Expand Down
2 changes: 1 addition & 1 deletion autogen/v1.9.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"GNDSDir": "test",
"Path": "../..",
"Version": "v1.9",

"JSONDir": "v1.9",
Expand Down
1 change: 1 addition & 0 deletions src/GNDStk.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <iostream>
Expand Down
20 changes: 20 additions & 0 deletions src/GNDStk/Component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,26 @@ class Component : public BlockData<hasBlockData,DATATYPE>
}
}

// has
// Usable in C++ "compile-time if" (a.k.a. "if constexpr") statements
template<
class EXTRACTOR, class THIS = DERIVED,
class = decltype(std::declval<EXTRACTOR>()(THIS{}))
>
static constexpr bool has(const Lookup<false,EXTRACTOR> &)
{
return true;
}

template<
class EXTRACTOR, bool F,
class = std::enable_if_t<F == false>
>
static constexpr bool has(const Lookup<F,EXTRACTOR> &)
{
return false;
}

// Component << string
// Meaning: read the string's content (currently XML, JSON, or HDF5) into
// an object of the Component's DERIVED class. Uses Node's << string, which
Expand Down
5 changes: 4 additions & 1 deletion src/GNDStk/HDF5.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
class HDF5 {
public:

static inline bool flat = true;
// todo: It's possible that we'll want these to be non-static, so that they
// can differ between HDF5 objects. That might, however, constitute excessive
// generality. Think about this.
static inline bool reduced = true;
static inline bool typed = true;

// data
Expand Down
14 changes: 13 additions & 1 deletion src/GNDStk/HDF5/src/detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,21 @@ inline std::string guessType(std::istringstream &iss, const std::string &type)
iss.clear();
iss.seekg(0);

// Below, the extra test involving iss.peek() proved to be necessary in
// a couple of situations. Without it, a "date" string like, for example,
// 2011-10-15, actually reads into three ints: 2011, -10, and -15, so that
// the type guesser thinks "array of ints". One might have thought that
// the >> operator would want whitespace between successive ints, but it
// doesn't. :-/ A similar thing happened with, for example, a "version"
// string like "8.0.1", which without the extra test looked to the type
// guesser as two doubles. To fix this, we now directly check that after
// any value is successfully read, we see either whitespace or EOF. (The
// EOF check is done first; it's no doubt faster, and we anticipate that
// many times we're checking short strings with just one value in them,
// so that the EOF is likely to be there.)
T value; std::size_t count = 0;
for ( ; !iss.eof() ; ++count)
if (!(iss >> value))
if (!(iss >> value && (iss.peek() == EOF || isspace(iss.peek()))))
return "";
return count ? count > 1 ? type+"s" : type : "";
}
Expand Down
Loading