pi | template get option

This commit is contained in:
ackimixs
2024-05-20 12:50:11 +02:00
parent de8aae69ac
commit b786384f24
3 changed files with 12 additions and 1 deletions

View File

@@ -13,6 +13,15 @@ public:
[[nodiscard]] bool hasOption(const std::string& option) const;
template <typename T>
[[nodiscard]] T getOption(const std::string& option, T defaultValue) const {
if (!hasOption(option)) {
return defaultValue;
}
return static_cast<T>(std::stod(_options.at(option)));
}
[[nodiscard]] std::optional<std::string> getOption(const std::string& option) const;
[[nodiscard]] std::string getOption(const std::string& option, const std::string& defaultValue) const;

View File

@@ -4,6 +4,8 @@
#include <string>
namespace Modelec
{
#define PI 3.14159265358979323846
bool startWith(const std::string& str, const std::string& start);
bool endsWith(const std::string& str, const std::string& end);