mirror of
https://github.com/matrix-construct/construct
synced 2024-12-27 07:54:05 +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 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);
|
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.
|
/// 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);
|
return array::stringify(buf, b, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
ircd::string_view
|
size_t
|
||||||
ircd::json::stringify(mutable_buffer &buf,
|
ircd::json::serialized(const std::string *const &b,
|
||||||
const string_view *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)
|
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>
|
template<class it>
|
||||||
|
|
Loading…
Reference in a new issue