Wildmeshing Toolkit
Loading...
Searching...
No Matches
named_error_text.cpp
Go to the documentation of this file.
1
3#include <fmt/format.h>
4#include <cstdint>
5#include <nlohmann/json.hpp>
6#include <optional>
8#include "../AttributeDescription.hpp"
11 const std::string_view& path,
12 const std::optional<uint8_t>& dimension,
13 const std::optional<attribute::AttributeType>& type)
14{
15 std::string typestr;
16 if (type.has_value()) {
17 nlohmann::json j;
18 j = type.value(); // just using the fact we can generate a strnig for this using json
19 // to get a printable string
20 typestr = j;
21 }
22 if (type.has_value() && dimension.has_value()) {
23 return fmt::format("named {} on {}-simplices of type {}", path, dimension.value(), typestr);
24 } else if (dimension.has_value()) {
25 return fmt::format("named {} on {}-simplices", path, dimension.value());
26 } else if (type.has_value()) {
27 return fmt::format("named {} of type {}", path, typestr);
28 } else {
29 return fmt::format("named {}", path);
30 }
31}
33{
34 return make_named_error_string(ad.path, ad.dimension, ad.type);
35}
36} // namespace wmtk::components::multimesh::utils::detail
std::string make_named_error_string(const std::string_view &path, const std::optional< uint8_t > &dimension, const std::optional< attribute::AttributeType > &type)