Android-cuttlefish cvd tool
defaults.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2025 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#pragma once
17
18#include <functional>
19#include <map>
20#include <optional>
21#include <string>
22#include <string_view>
23
24#include "absl/container/btree_map.h"
25
27
28namespace cuttlefish {
29
30class Defaults {
31 public:
33 Defaults(std::map<std::string, std::string, std::less<void>> defaults);
34 static Result<Defaults> FromFile(const std::string& path);
35
36 std::optional<std::string_view> Value(std::string_view k) const;
37 std::optional<bool> BoolValue(std::string_view k) const;
38
39 private:
40 absl::btree_map<std::string, std::string> defaults_;
41};
42
43} // namespace cuttlefish
Definition: defaults.h:30
static Result< Defaults > FromFile(const std::string &path)
Definition: defaults.cc:53
Defaults()
Definition: defaults.h:32
std::optional< std::string_view > Value(std::string_view k) const
Definition: defaults.cc:39
absl::btree_map< std::string, std::string > defaults_
Definition: defaults.h:40
std::optional< bool > BoolValue(std::string_view k) const
Definition: defaults.cc:49
Definition: alloc_driver.h:20
tl::expected< T, StackTraceError > Result
Definition: result_type.h:30