From b0278d86ade8335e8da79fb4f774f81bc3d09670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Del=20Pino?= <stephane.delpino44@gmail.com> Date: Mon, 9 Nov 2020 12:14:38 +0100 Subject: [PATCH] Replace printLSOptions and printLSAvailable get functions printLSOptions -> getLSOptions printLSAvailable -> getLSAvailable These new function do not print the result anymore but return a string. To display available or set options, one should now uses: ``` cout << getLSOptions() << "\n"; let available:string, available = getLSAvailable(); cout << available << "\n"; ``` --- src/language/modules/LinearSolverModule.cpp | 49 ++++++++++++--------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/src/language/modules/LinearSolverModule.cpp b/src/language/modules/LinearSolverModule.cpp index 9e626ba2b..a5bb2cf90 100644 --- a/src/language/modules/LinearSolverModule.cpp +++ b/src/language/modules/LinearSolverModule.cpp @@ -57,29 +57,36 @@ LinearSolverModule::LinearSolverModule() )); - this->_addBuiltinFunction("printLSOptions", std::make_shared<BuiltinFunctionEmbedder<void()>>( + this->_addBuiltinFunction("getLSOptions", std::make_shared<BuiltinFunctionEmbedder<std::string()>>( + + []() -> std::string { + std::ostringstream os; + os << rang::fgB::yellow << "Linear solver options" << rang::style::reset + << '\n'; + os << LinearSolverOptions::default_options; + return os.str(); + } + + )); + + this->_addBuiltinFunction("getLSAvailable", std::make_shared<BuiltinFunctionEmbedder<std::string()>>( - []() -> void { - std::cout << rang::fgB::yellow << "Linear solver options" - << rang::style::reset << '\n'; - std::cout << LinearSolverOptions::default_options; + []() -> std::string { + std::ostringstream os; + + os << rang::fgB::yellow << "Available linear solver options" + << rang::style::reset << '\n'; + os << rang::fgB::blue << " libraries" << rang::style::reset << '\n'; + + printLSEnumListNames<LSLibrary>(os); + os << rang::fgB::blue << " methods" << rang::style::reset << '\n'; + printLSEnumListNames<LSMethod>(os); + os << rang::fgB::blue << " preconditioners" << rang::style::reset + << '\n'; + printLSEnumListNames<LSPrecond>(os); + + return os.str(); } )); - - this->_addBuiltinFunction("printLSAvailable", - std::make_shared<BuiltinFunctionEmbedder<void()>>( - - []() -> void { - std::cout << rang::fgB::yellow << "Available linear solver options" - << rang::style::reset << '\n'; - std::cout << rang::fgB::blue << " libraries" << rang::style::reset << '\n'; - printLSEnumListNames<LSLibrary>(std::cout); - std::cout << rang::fgB::blue << " methods" << rang::style::reset << '\n'; - printLSEnumListNames<LSMethod>(std::cout); - std::cout << rang::fgB::blue << " preconditioners" << rang::style::reset << '\n'; - printLSEnumListNames<LSPrecond>(std::cout); - } - - )); } -- GitLab