From 0d32e0d3342ef2455014c8e1164977c816763317 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 21 Nov 2023 16:26:34 -0500 Subject: Added rudimentary item creation --- src/utils.cc | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/utils.cc') diff --git a/src/utils.cc b/src/utils.cc index 75f13a3..94118ed 100644 --- a/src/utils.cc +++ b/src/utils.cc @@ -45,6 +45,14 @@ int utils::parseInt(const std::string& s) { } } +double utils::parseDouble(const std::string& s) { + try { + return std::stod(s); + } catch(std::exception& e) { + throw std::runtime_error("A double was expected but " + s + " was given"); + } +} + void utils::saveJson(const nlohmann::json& data, const fs::path& path) { std::ofstream f(path); f << std::setw(4) << data << std::endl; -- cgit v1.2.3