Skip to content
Snippets Groups Projects

TCKs for HLT1

Merged Roel Aaij requested to merge standalone_property_default_values into master
Compare and Show latest version
1 file
+ 12
1
Compare changes
  • Side-by-side
  • Inline
@@ -18,25 +18,36 @@
int main()
{
// Read the semicolon-separated list of algorithms from stdin
std::istreambuf_iterator<char> begin(std::cin), end;
std::string input(begin, end);
if (!input.empty() && input[input.size() - 1] == '\n') {
input.erase(input.size() - 1);
}
// Split the list into algorithm namespace::type
std::vector<std::string> algorithms;
boost::split(algorithms, input, boost::is_any_of(";"));
using json_float = nlohmann::basic_json<std::map, std::vector, std::string, bool, std::int64_t, std::uint64_t, float>;
// Use non-default JSON parser to parse all floating point numbers
// as floats and integers as 32 bits. This aligns with what is used
// in Allen
using json_float = nlohmann::basic_json<std::map, std::vector, std::string, bool, std::int32_t, std::uint32_t, float>;
json_float default_properties;
// Loop over the algorithms, instantiate each algorithm and get its
// (default valued) properties.
for (auto alg : algorithms) {
auto allen_alg = instantiate_allen_algorithm({alg, "algorithm", ""});
std::map<std::string, std::string> string_props;
for (auto [k, j] : allen_alg.get_properties()) {
// Assign to out JSON parser type to get the wanted parsing
// behaviour and use to_string to allow the Python JSON parser
// to change the values into Python objects.
json_float jf = j;
string_props[k] = to_string(jf);
}
// Save the representation in another JSON.
default_properties[alg] = string_props;
}
std::cout << std::setw(4) << default_properties;
Loading