diff src/core/strings.cc @ 101:c537996cf67b

*: multitude of config changes 1. theme is now configurable from the settings menu (but you have to restart for it to apply) 2. config is now stored in an INI file, with no method of conversion from json (this repo is private-ish anyway)
author Paper <mrpapersonic@gmail.com>
date Fri, 03 Nov 2023 14:06:02 -0400
parents f5940a575d83
children b315f3759c56
line wrap: on
line diff
--- a/src/core/strings.cc	Fri Nov 03 09:43:04 2023 -0400
+++ b/src/core/strings.cc	Fri Nov 03 14:06:02 2023 -0400
@@ -3,6 +3,7 @@
  **/
 #include "core/strings.h"
 #include <QByteArray>
+#include <QDebug>
 #include <QString>
 #include <QLocale>
 #include <algorithm>
@@ -133,4 +134,15 @@
 	return QString::fromWCharArray(wstring.c_str(), wstring.length());
 }
 
+int ToInt(const std::string& str, int def) {
+	int tmp = 0;
+	try {
+		tmp = std::stoi(str);
+	} catch (std::invalid_argument const& ex) {
+		qDebug() << "Failed to parse int from std::string: no number found in " << ToQString(str) << " defaulting to " << def;
+		tmp = def;
+	}
+	return tmp;
+}
+
 } // namespace Strings