0
0
Fork 0
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:
Jason Volk 2017-09-27 20:47:56 -07:00
parent 688f31afd3
commit 4090b80d60
2 changed files with 24 additions and 5 deletions

View file

@ -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.

View file

@ -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>