mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::json: Add missing serialized() participants.
This commit is contained in:
parent
688f31afd3
commit
4090b80d60
2 changed files with 24 additions and 5 deletions
|
@ -28,6 +28,9 @@ namespace ircd::json
|
|||
|
||||
string_view stringify(mutable_buffer &buf, const string_view *const &begin, const string_view *const &end);
|
||||
string_view stringify(mutable_buffer &buf, const std::string *const &begin, const std::string *const &end);
|
||||
|
||||
size_t serialized(const string_view *const &begin, const string_view *const &end);
|
||||
size_t serialized(const std::string *const &begin, const std::string *const &end);
|
||||
}
|
||||
|
||||
/// Lightweight interface to a JSON array string.
|
||||
|
|
24
ircd/json.cc
24
ircd/json.cc
|
@ -685,12 +685,28 @@ ircd::json::stringify(mutable_buffer &buf,
|
|||
return array::stringify(buf, b, e);
|
||||
}
|
||||
|
||||
ircd::string_view
|
||||
ircd::json::stringify(mutable_buffer &buf,
|
||||
const string_view *const &b,
|
||||
size_t
|
||||
ircd::json::serialized(const std::string *const &b,
|
||||
const std::string *const &e)
|
||||
{
|
||||
const size_t ret(1 + !std::distance(b, e));
|
||||
return std::accumulate(b, e, ret, []
|
||||
(auto ret, const auto &value)
|
||||
{
|
||||
return ret += serialized(string_view{value}) + 1;
|
||||
});
|
||||
}
|
||||
|
||||
size_t
|
||||
ircd::json::serialized(const string_view *const &b,
|
||||
const string_view *const &e)
|
||||
{
|
||||
return array::stringify(buf, b, e);
|
||||
const size_t ret(1 + !std::distance(b, e));
|
||||
return std::accumulate(b, e, ret, []
|
||||
(auto ret, const auto &value)
|
||||
{
|
||||
return ret += serialized(value) + 1;
|
||||
});
|
||||
}
|
||||
|
||||
template<class it>
|
||||
|
|
Loading…
Reference in a new issue