userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
helpers.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/storages/secdist/helpers.hpp
4
/// @brief Secdist JSON parsing helper functions
5
6
#
include
<
string
>
7
8
#
include
<
userver
/
compiler
/
demangle
.
hpp
>
9
#
include
<
userver
/
formats
/
json
/
value
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
storages::
secdist
{
14
15
[[
noreturn
]]
void
ThrowInvalidSecdistType(
const
formats::
json
::
Value
& val, std::string_view type);
16
17
std::string GetString(
const
formats::
json
::
Value
& parent_val, std::string_view name);
18
19
int
GetInt(
const
formats::
json
::
Value
& parent_val, std::string_view name,
int
dflt);
20
21
template
<
typename
T>
22
T GetValue(
const
formats::
json
::
Value
& parent_val, std::string_view key,
const
T& dflt) {
23
const
auto
& val = parent_val
[
key
]
;
24
try
{
25
return
val.
template
As<T>(dflt);
26
}
catch
(
const
formats::
json
::
TypeMismatchException
&) {
27
ThrowInvalidSecdistType(val,
compiler
::GetTypeName<T>());
28
}
29
}
30
31
void
CheckIsObject(
const
formats::
json
::
Value
& val, std::string_view name);
32
33
void
CheckIsArray(
const
formats::
json
::
Value
& val, std::string_view name);
34
35
}
// namespace storages::secdist
36
37
USERVER_NAMESPACE_END
userver
storages
secdist
helpers.hpp
Generated on
for userver by
Doxygen
1.17.0