Skip to content

Commit 73d86ef

Browse files
committed
json: add default-value overloads for kvs getters
1 parent 315d086 commit 73d86ef

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

include/vix/json/Simple.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,26 @@ namespace vix::json
766766
return def;
767767
}
768768

769+
std::string get_string_or(std::string_view key) const
770+
{
771+
return get_string_or(key, std::string{});
772+
}
773+
774+
std::int64_t get_i64_or(std::string_view key) const noexcept
775+
{
776+
return get_i64_or(key, 0);
777+
}
778+
779+
double get_f64_or(std::string_view key) const noexcept
780+
{
781+
return get_f64_or(key, 0.0);
782+
}
783+
784+
bool get_bool_or(std::string_view key) const noexcept
785+
{
786+
return get_bool_or(key, false);
787+
}
788+
769789
// Typed setters
770790

771791
void set_string(std::string_view key, std::string v) { set(key, token(std::move(v))); }

0 commit comments

Comments
 (0)