diff --git a/src/python/corrade/test/test_utility.py b/src/python/corrade/test/test_utility.py index 28f57f6..c703306 100644 --- a/src/python/corrade/test/test_utility.py +++ b/src/python/corrade/test/test_utility.py @@ -70,6 +70,9 @@ class Configuration(unittest.TestCase): a = utility.Configuration(filename) a['value'] = 'hello' + a['int'] = -168454764726 + a['float'] = 3.14 + a['bool'] = True a_refcount = sys.getrefcount(a) b = a.add_group('someGroup') @@ -84,7 +87,7 @@ class Configuration(unittest.TestCase): a.save() with open(filename, 'r') as f: - self.assertEqual(f.read(), "value=hello\n[someGroup]\nsomeKey=42\n") + self.assertEqual(f.read(), "value=hello\nint=-168454764726\nfloat=3.14\nbool=1\n[someGroup]\nsomeKey=42\n") def test_save_different_filename(self): a = utility.Configuration() diff --git a/src/python/corrade/utility.cpp b/src/python/corrade/utility.cpp index 54bea40..564107e 100644 --- a/src/python/corrade/utility.cpp +++ b/src/python/corrade/utility.cpp @@ -57,6 +57,15 @@ void utility(py::module_& m) { }, "Value", py::arg("key")) .def("__setitem__", [](Utility::ConfigurationGroup& self, const std::string& key, const std::string& value) { self.setValue(key, value); + }, "Set a value", py::arg("key"), py::arg("value")) + .def("__setitem__", [](Utility::ConfigurationGroup& self, const std::string& key, double value) { + self.setValue(key, value); + }, "Set a value", py::arg("key"), py::arg("value")) + .def("__setitem__", [](Utility::ConfigurationGroup& self, const std::string& key, std::int64_t value) { + self.setValue(key, value); + }, "Set a value", py::arg("key"), py::arg("value")) + .def("__setitem__", [](Utility::ConfigurationGroup& self, const std::string& key, bool value) { + self.setValue(key, value); }, "Set a value", py::arg("key"), py::arg("value")); py::class_{m, "Configuration", "Parser and writer for configuration files"}