mirror of
https://github.com/matrix-construct/construct
synced 2024-11-29 10:12:39 +01:00
ircd::json: Verifiably pasken the strongly typed object::size() result.
This commit is contained in:
parent
7e89baf369
commit
575f5829dd
2 changed files with 15 additions and 3 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue