mirror of
https://github.com/matrix-construct/construct
synced 2024-10-03 22:28:52 +02:00
ircd::json: Minor cleanup.
This commit is contained in:
parent
731c154b19
commit
eead379f36
3 changed files with 48 additions and 15 deletions
|
@ -128,7 +128,10 @@ const try
|
|||
}
|
||||
catch(const bad_lex_cast &e)
|
||||
{
|
||||
throw type_error("indice %zu must cast to type %s", i, typeid(T).name());
|
||||
throw type_error
|
||||
{
|
||||
"indice %zu must cast to type %s", i, typeid(T).name()
|
||||
};
|
||||
}
|
||||
|
||||
inline ircd::string_view
|
||||
|
@ -136,7 +139,13 @@ ircd::json::array::at(const size_t &i)
|
|||
const
|
||||
{
|
||||
const auto it(find(i));
|
||||
return likely(it != end())? *it : throw not_found("indice %zu", i);
|
||||
if(it == end())
|
||||
throw not_found
|
||||
{
|
||||
"indice %zu", i
|
||||
};
|
||||
|
||||
return *it;
|
||||
}
|
||||
|
||||
inline ircd::json::array::const_iterator
|
||||
|
|
|
@ -204,7 +204,10 @@ const try
|
|||
{
|
||||
const auto it(object.find(key));
|
||||
if(it == std::end(object))
|
||||
throw not_found("'%s'", key);
|
||||
throw not_found
|
||||
{
|
||||
"'%s'", key
|
||||
};
|
||||
|
||||
object = it->second;
|
||||
return false;
|
||||
|
@ -214,9 +217,12 @@ const try
|
|||
}
|
||||
catch(const bad_lex_cast &e)
|
||||
{
|
||||
throw type_error("'%s' must cast to type %s",
|
||||
ircd::string(path),
|
||||
typeid(T).name());
|
||||
throw type_error
|
||||
{
|
||||
"'%s' must cast to type %s",
|
||||
ircd::string(path),
|
||||
typeid(T).name()
|
||||
};
|
||||
}
|
||||
|
||||
template<ircd::json::name_hash_t key,
|
||||
|
@ -227,15 +233,21 @@ try
|
|||
{
|
||||
const auto it(object.find(key));
|
||||
if(it == end(object))
|
||||
throw not_found("[key hash] '%zu'", key);
|
||||
throw not_found
|
||||
{
|
||||
"[key hash] '%zu'", key
|
||||
};
|
||||
|
||||
return lex_cast<T>(it->second);
|
||||
}
|
||||
catch(const bad_lex_cast &e)
|
||||
{
|
||||
throw type_error("[key hash] '%zu' must cast to type %s",
|
||||
key,
|
||||
typeid(T).name());
|
||||
throw type_error
|
||||
{
|
||||
"[key hash] '%zu' must cast to type %s",
|
||||
key,
|
||||
typeid(T).name()
|
||||
};
|
||||
}
|
||||
|
||||
template<class T>
|
||||
|
@ -245,15 +257,21 @@ const try
|
|||
{
|
||||
const auto it(find(key));
|
||||
if(it == end())
|
||||
throw not_found("'%s'", key);
|
||||
throw not_found
|
||||
{
|
||||
"'%s'", key
|
||||
};
|
||||
|
||||
return lex_cast<T>(it->second);
|
||||
}
|
||||
catch(const bad_lex_cast &e)
|
||||
{
|
||||
throw type_error("'%s' must cast to type %s",
|
||||
key,
|
||||
typeid(T).name());
|
||||
throw type_error
|
||||
{
|
||||
"'%s' must cast to type %s",
|
||||
key,
|
||||
typeid(T).name()
|
||||
};
|
||||
}
|
||||
|
||||
inline ircd::string_view
|
||||
|
|
|
@ -103,7 +103,13 @@ ircd::json::vector::at(const size_t &i)
|
|||
const
|
||||
{
|
||||
const auto it(find(i));
|
||||
return likely(it != end())? *it : throw not_found("indice %zu", i);
|
||||
if(it == end())
|
||||
throw not_found
|
||||
{
|
||||
"indice %zu", i
|
||||
};
|
||||
|
||||
return *it;
|
||||
}
|
||||
|
||||
inline ircd::json::vector::const_iterator
|
||||
|
|
Loading…
Reference in a new issue