2 * Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
11 #ifndef TEST_SCOPED_KEY_VALUE_CONFIG_H_
12 #define TEST_SCOPED_KEY_VALUE_CONFIG_H_
19 #include "absl/strings/string_view.h"
20 #include "api/field_trials_registry.h"
21 #include "test/field_trial.h"
26 class ScopedKeyValueConfig
: public FieldTrialsRegistry
{
28 virtual ~ScopedKeyValueConfig();
29 ScopedKeyValueConfig();
30 explicit ScopedKeyValueConfig(absl::string_view s
);
31 ScopedKeyValueConfig(ScopedKeyValueConfig
& parent
, absl::string_view s
);
34 ScopedKeyValueConfig(ScopedKeyValueConfig
* parent
, absl::string_view s
);
35 ScopedKeyValueConfig
* GetRoot(ScopedKeyValueConfig
* n
);
36 std::string
GetValue(absl::string_view key
) const override
;
37 std::string
LookupRecurse(absl::string_view key
) const;
39 ScopedKeyValueConfig
* const parent_
;
41 // The leaf in a list of stacked ScopedKeyValueConfig.
42 // Only set on root (e.g with parent_ == nullptr).
43 const ScopedKeyValueConfig
* leaf_
;
45 // Unlike std::less<std::string>, std::less<> is transparent and allows
46 // heterogeneous lookup directly with absl::string_view.
47 std::map
<std::string
, std::string
, std::less
<>> key_value_map_
;
48 std::unique_ptr
<ScopedFieldTrials
> scoped_field_trials_
;
54 #endif // TEST_SCOPED_KEY_VALUE_CONFIG_H_