MCPcopy Create free account
hub / github.com/boutproject/BOUT-dev / parseExpression

Function parseExpression

src/sys/options.cxx:348–364  ·  view source on GitHub ↗

Use FieldFactory to evaluate expression

Source from the content-addressed store, hash-verified

346namespace {
347/// Use FieldFactory to evaluate expression
348double parseExpression(const Options::ValueType& value, const Options* options,
349 const std::string& type, const std::string& full_name) {
350 try {
351 // Parse the string, giving this Option pointer for the context
352 // then generate a value at t,x,y,z = 0,0,0,0
353 auto gen = FieldFactory::get()->parse(bout::utils::get<std::string>(value), options);
354 if (!gen) {
355 throw ParseException("FieldFactory did not return a generator for '{}'",
356 bout::utils::variantToString(value));
357 }
358 return gen->generate({});
359 } catch (ParseException& error) {
360 // Convert any exceptions to something a bit more useful
361 throw BoutException(_("Couldn't get {} from option {:s} = '{:s}': {}"), type,
362 full_name, bout::utils::variantToString(value), error.what());
363 }
364}
365
366/// Helper function to print `key = value` with optional source
367template <class T>

Callers 7

as<int>Method · 0.85
as<BoutReal>Method · 0.85
as<bool>Method · 0.85
parseStringMethod · 0.85
parseIdentifierExprMethod · 0.85
parseParenExprMethod · 0.85
parseContextExprMethod · 0.85

Calls 2

parseMethod · 0.45
generateMethod · 0.45

Tested by

no test coverage detected