Skip to content

Commit

Permalink
Include counts in data conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
mavam committed Sep 19, 2020
1 parent 59f4827 commit d82d1bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libvast/src/data.cpp
Expand Up @@ -376,7 +376,8 @@ caf::error convert(const data& d, caf::config_value& cv) {
auto f = detail::overload(
[&](const auto& x) -> caf::error {
using value_type = std::decay_t<decltype(x)>;
if constexpr (detail::is_any_v<value_type, bool, integer, real, duration>)
if constexpr (detail::is_any_v<value_type, bool, integer, count, real,
duration>)
cv = x;
else
cv = to_string(x);
Expand All @@ -393,6 +394,7 @@ caf::error convert(const data& d, caf::config_value& cv) {
"config_value");
},
[&](const std::string& x) -> caf::error {
// Go deeper into the string an infer more CAF-specific typing.
if (auto uri = caf::make_uri(x))
cv = std::move(*uri);
else
Expand Down
2 changes: 2 additions & 0 deletions libvast/test/data.cpp
Expand Up @@ -334,6 +334,7 @@ TEST(convert - caf::config_value) {
{"x", "foo"},
{"r", record{
{"i", -42},
{"u", 42u},
{"r", record{
{"u", 3.14}
}},
Expand All @@ -351,6 +352,7 @@ TEST(convert - caf::config_value) {
y.emplace("x", "foo");
auto r = config_value::dictionary{};
r.emplace("i", -42);
r.emplace("u", 42u);
auto rr = config_value::dictionary{};
rr.emplace("u", 3.14);
r.emplace("r", std::move(rr));
Expand Down

0 comments on commit d82d1bd

Please sign in to comment.