aboutsummaryrefslogtreecommitdiff
path: root/src/utils.cc
diff options
context:
space:
mode:
authorYour Name <you@example.com>2023-11-21 16:26:34 -0500
committerYour Name <you@example.com>2023-11-21 16:26:34 -0500
commit0d32e0d3342ef2455014c8e1164977c816763317 (patch)
tree0e0a445332accf0eda8f23fe586f614844bee463 /src/utils.cc
parent5678a600b7d1ec4e79724258dfefe45a49258ea3 (diff)
downloaddmtool-0d32e0d3342ef2455014c8e1164977c816763317.tar.gz
dmtool-0d32e0d3342ef2455014c8e1164977c816763317.tar.bz2
dmtool-0d32e0d3342ef2455014c8e1164977c816763317.zip
Added rudimentary item creation
Diffstat (limited to 'src/utils.cc')
-rw-r--r--src/utils.cc8
1 files changed, 8 insertions, 0 deletions
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;