34 }
catch (
const std::runtime_error &
e) {
43 for (std::string path : tok) {
44 std::string relative_path =
"subpackages/" + path;
56 for (
const auto &child : options) {
68 const std::string &calcname)
const {
74 print.
get(
"options"));
87 for (
const auto &child : user_input) {
88 if (defaults.
exists(child.name())) {
91 throw std::runtime_error(
"Votca has no option:" + child.path() +
"." +
99 for (
const auto &child : options) {
103 options.
getAttribute<std::string>(
"default") ==
"REQUIRED" &&
105 throw std::runtime_error(
"Please specify an input for:" + options.
path() +
106 "." + options.
name());
116 for (
auto &child : options) {
129 Property &options,
const std::vector<std::string> &attributes)
const {
130 for (
const auto &attribute : attributes) {
135 for (
auto &child : options) {
143 std::string defaults_file_path =
152 if (prop.HasChildren()) {
154 }
else if (prop.hasAttribute(
"default") && !prop.hasAttribute(
"injected")) {
155 std::string value = prop.getAttribute<std::string>(
"default");
158 [value](
const std::string &keyword) { return value == keyword; }))
159 prop.value() = value;
177 for (
auto &child : defaults) {
178 if (user_input.
exists(child.name())) {
184 std::map<std::string, Index> tags;
185 for (
const auto &child : defaults) {
186 tags[child.name()]++;
189 for (
const auto &tag : tags) {
190 if (tag.second > 1) {
191 throw std::runtime_error(
192 "Developers: Each distinct tag in list should only appear once.");
194 std::vector<const tools::Property *> inputs =
195 user_input.
Select(tag.first);
199 if (inputs.empty()) {
200 defaults.deleteChildren(
201 [&](
const Property &prop) {
return prop.
name() == tag.first; });
206 for (
Index i = 1; i <
Index(inputs.size()); i++) {
209 std::vector<Property *> newdefault_elements =
210 defaults.
Select(tag.first);
212 for (
Index i = 0; i <
Index(inputs.size()); i++) {
220 for (
const auto &child : user_input) {
228 std::string att = p.
getAttribute<std::string>(
"choices");
229 std::size_t start_bracket = att.find(
'[');
230 if (start_bracket != std::string::npos) {
231 std::size_t end_bracket = att.find(
']');
232 att = att.substr(start_bracket + 1, end_bracket - start_bracket - 1);
243 if (prop.HasChildren()) {
247 if (choices.empty()) {
251 std::ostringstream oss;
252 oss <<
"\nThe input value for \"" << prop.name() <<
"\"";
253 if (choices.size() == 1) {
254 oss <<
" should be a \"" << choices.front() <<
"\"";
256 oss <<
" should be one of the following values: ";
257 for (
const std::string &c : choices) {
258 oss <<
"\"" << c <<
"\""
262 oss <<
" But \"" << prop.value()
263 <<
"\" cannot be converted into one.\n";
264 throw std::runtime_error(oss.str());
271 const Property &prop,
const std::vector<std::string> &choices)
const {
273 const std::string &head = choices.front();
274 std::ostringstream oss;
275 bool is_valid =
true;
276 if (head ==
"bool") {
278 }
else if (head ==
"float") {
280 }
else if (head ==
"float+") {
282 }
else if (head ==
"int") {
284 }
else if (head ==
"int+") {
287 std::string value = prop.
as<std::string>();
288 std::string att = prop.
getAttribute<std::string>(
"choices");
289 std::size_t start_bracket = att.find(
'[');
290 if (start_bracket == std::string::npos) {
292 auto it = std::find(std::cbegin(choices), std::cend(choices), value);
293 is_valid = (it != std::cend(choices));
297 for (
const std::string &word : tok) {
298 auto it = std::find(std::cbegin(choices), std::cend(choices), word);
299 if (it == std::cend(choices)) {
base class for all analysis tools