userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
value.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <optional>
7
#include <string>
8
#include <unordered_set>
9
10
#include <
userver/formats/json/value.hpp
>
11
#include <
userver/formats/parse/common_containers.hpp
>
12
#include <
userver/formats/serialize/common_containers.hpp
>
13
#include <
userver/utils/default_dict.hpp
>
14
#include <userver/utils/impl/internal_tag.hpp>
15
#include <userver/utils/impl/transparent_hash.hpp>
16
17
USERVER_NAMESPACE_BEGIN
18
19
namespace
dynamic_config {
20
22
class
DocsMap
final {
23
public
:
24
/* Returns config item or throws an exception if key is missing */
25
formats::json::Value
Get(std::string_view name)
const
;
26
27
bool
Has(std::string_view name)
const
;
28
void
Set(std::string name,
formats::json::Value
);
29
void
Parse(std::string_view json_string,
bool
empty_ok);
30
void
Parse(
formats::json::Value
json,
bool
empty_ok);
31
void
Remove(std::string_view name);
32
size_t
Size()
const
;
33
34
void
MergeOrAssign(
DocsMap
&& source);
35
void
MergeMissing(
const
DocsMap
& source);
36
37
std::unordered_set<std::string> GetNames()
const
;
38
formats::json::Value
AsJson()
const
;
39
bool
AreContentsEqual(
const
DocsMap
& other)
const
;
40
42
// For internal use only.
43
// Set of configs expected to be used is automatically updated when
44
// configs are retrieved with 'Get' method.
45
void
SetConfigsExpectedToBeUsed(utils::impl::TransparentSet<std::string> configs, utils::impl::InternalTag);
46
47
// For internal use only.
48
const
utils::impl::TransparentSet<std::string>& GetConfigsExpectedToBeUsed(utils::impl::InternalTag)
const
;
50
51
private
:
52
utils::impl::TransparentMap<std::string, formats::json::Value> docs_;
53
mutable
utils::impl::TransparentSet<std::string> configs_to_be_used_;
54
};
55
56
template
<
typename
ValueType>
57
using
ValueDict =
utils::DefaultDict<ValueType>
;
58
59
inline
constexpr
auto
kValueDictDefaultName =
utils::kDefaultDictDefaultName
;
60
61
}
// namespace dynamic_config
62
63
USERVER_NAMESPACE_END
userver
dynamic_config
value.hpp
Generated on
for userver by
Doxygen
1.17.0