aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.ucl
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-06-23 16:28:11 +0100
committerLexi Winter <lexi@le-fay.org>2025-06-23 16:28:11 +0100
commitd5963532328ce5f1c9f266bf7e760b7d18a60c15 (patch)
tree28e8d4b98f2f3adbd2f02bcc656ad74e626677c9 /nihil.ucl
parent0fa623093366351ad47583f47add6e51f56a56d8 (diff)
downloadnihil-d5963532328ce5f1c9f266bf7e760b7d18a60c15.tar.gz
nihil-d5963532328ce5f1c9f266bf7e760b7d18a60c15.tar.bz2
various updates
Diffstat (limited to 'nihil.ucl')
-rw-r--r--nihil.ucl/error.ccm5
-rw-r--r--nihil.ucl/map.ccm3
-rw-r--r--nihil.ucl/nihil.ucl.ccm1
-rw-r--r--nihil.ucl/parser.ccm8
-rw-r--r--nihil.ucl/type.ccm6
5 files changed, 10 insertions, 13 deletions
diff --git a/nihil.ucl/error.ccm b/nihil.ucl/error.ccm
index 4eda774..c6a0f2d 100644
--- a/nihil.ucl/error.ccm
+++ b/nihil.ucl/error.ccm
@@ -17,10 +17,7 @@ namespace nihil::ucl {
* Exception thrown when an issue occurs with UCL.
*/
export struct error : generic_error {
- template<typename... Args>
- error(std::format_string<Args...> fmt, Args &&...args)
- : generic_error(fmt, std::forward<Args>(args)...)
- {}
+ error(std::string what) : generic_error(std::move(what)) {}
};
} // namespace nihil::ucl
diff --git a/nihil.ucl/map.ccm b/nihil.ucl/map.ccm
index c140885..434659b 100644
--- a/nihil.ucl/map.ccm
+++ b/nihil.ucl/map.ccm
@@ -7,6 +7,7 @@ module;
#include <cassert>
#include <cstdint>
#include <cstdlib>
+#include <format>
#include <memory>
#include <optional>
#include <string>
@@ -22,7 +23,7 @@ namespace nihil::ucl {
// Exception thrown when map::operator[] does not find the key.
export struct key_not_found : error {
key_not_found(std::string_view key)
- : error("key '{}' not found in map", key)
+ : error(std::format("key '{}' not found in map", key))
, _key(key)
{}
diff --git a/nihil.ucl/nihil.ucl.ccm b/nihil.ucl/nihil.ucl.ccm
index 66e2c2b..9c2ea88 100644
--- a/nihil.ucl/nihil.ucl.ccm
+++ b/nihil.ucl/nihil.ucl.ccm
@@ -7,6 +7,7 @@ module;
export module nihil.ucl;
export import :emit;
+export import :error;
export import :object;
export import :object_cast;
export import :parser;
diff --git a/nihil.ucl/parser.ccm b/nihil.ucl/parser.ccm
index 8e715d0..9b87773 100644
--- a/nihil.ucl/parser.ccm
+++ b/nihil.ucl/parser.ccm
@@ -25,10 +25,7 @@ namespace nihil::ucl {
* Exception thrown when an issue occurs parsing UCL.
*/
export struct parse_error : error {
- template<typename... Args>
- parse_error(std::format_string<Args...> fmt, Args &&...args)
- : error(fmt, std::forward<Args>(args)...)
- {}
+ parse_error(std::string what) : error(std::move(what)) {}
};
// UCL parser flags.
@@ -124,8 +121,7 @@ export struct parser {
auto ret = ::ucl_parser_add_chunk(self._parser, dptr,
std::ranges::size(data));
if (ret == false)
- throw parse_error("{}",
- ::ucl_parser_get_error(self._parser));
+ throw parse_error(::ucl_parser_get_error(self._parser));
}
auto add(this parser &self, std::ranges::range auto &&data)
diff --git a/nihil.ucl/type.ccm b/nihil.ucl/type.ccm
index 5050e7a..bf6c6bc 100644
--- a/nihil.ucl/type.ccm
+++ b/nihil.ucl/type.ccm
@@ -5,6 +5,7 @@
module;
#include <concepts>
+#include <format>
#include <string>
#include <ucl.h>
@@ -69,8 +70,9 @@ concept datatype = requires(T o) {
// Exception thrown when a type assertion fails.
export struct type_mismatch : error {
type_mismatch(object_type expected_type, object_type actual_type)
- : error("UCL type mismatch: expected type '{}' != actual type '{}'",
- str(expected_type), str(actual_type))
+ : error(std::format("UCL type mismatch: expected type '{}' "
+ "!= actual type '{}'",
+ str(expected_type), str(actual_type)))
, _expected_type(expected_type)
, _actual_type(actual_type)
{}