0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-03 06:08:52 +02:00

ircd::json: Verifiably pasken the strongly typed object::size() result.

This commit is contained in:
Jason Volk 2018-02-17 14:46:10 -08:00
parent 7e89baf369
commit 575f5829dd
2 changed files with 15 additions and 3 deletions

View file

@ -17,6 +17,7 @@ namespace ircd::json
bool empty(const array &);
bool operator!(const array &);
size_t size(const array &);
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);
@ -143,7 +144,12 @@ const
return it;
}
__attribute__((warning("Taking string_view::size() not the count() of array elements")))
inline size_t
ircd::json::size(const array &array)
{
return array.size();
}
inline size_t
ircd::json::array::size()
const

View file

@ -17,6 +17,7 @@ namespace ircd::json
bool empty(const object &);
bool operator!(const object &);
size_t size(const object &);
template<name_hash_t key, class T = string_view> T at(const object &);
template<name_hash_t key, class T = string_view> T get(const object &, const T &def = {});
}
@ -323,12 +324,17 @@ catch(const bad_lex_cast &e)
return def;
}
__attribute__((warning("Taking string_view::size() not the count() of members in the object")))
inline size_t
ircd::json::size(const object &object)
{
return object.size();
}
inline size_t
ircd::json::object::size()
const
{
return string_view::size();
return count();
}
inline size_t