BioDynaMo  v1.05.119-a4ff3934
cpptoml.h
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 CERN & University of Surrey for the benefit of the
4 // BioDynaMo collaboration. All Rights Reserved.
5 //
6 // Licensed under the Apache License, Version 2.0 (the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // See the LICENSE file distributed with this work for details.
10 // See the NOTICE file distributed with this work for additional information
11 // regarding copyright ownership.
12 //
13 // -----------------------------------------------------------------------------
14 
15 #ifndef CORE_UTIL_CPPTOML_H_
16 #define CORE_UTIL_CPPTOML_H_
17 
18 #define BDM_ASSIGN_CONFIG_VALUE(variable, config_key) \
19  { \
20  if (config->contains_qualified(config_key)) { \
21  auto value = config->get_qualified_as<decltype(variable)>(config_key); \
22  if (value) { \
23  variable = *value; \
24  } \
25  } \
26  }
27 
28 #define BDM_ASSIGN_CONFIG_DOUBLE3_VALUE(variable, config_key) \
29  { \
30  if (config->contains_qualified(config_key)) { \
31  auto value = config->get_array_of<real_t>(config_key); \
32  if (value) { \
33  auto vector = *value; \
34  if (vector.size() == variable.size()) { \
35  for (uint64_t i = 0; i < vector.size(); i++) { \
36  variable[i] = vector[i]; \
37  } \
38  } else { \
39  Log::Fatal("cpptoml parameter parsing", \
40  "An error occurred during parameter parsing of (", \
41  config_key, ". Array dimensions do not match"); \
42  } \
43  } \
44  } \
45  }
46 
47 #endif // CORE_UTIL_CPPTOML_H_