1d9f0492fSopenharmony_ci/*
2d9f0492fSopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3d9f0492fSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4d9f0492fSopenharmony_ci * you may not use this file except in compliance with the License.
5d9f0492fSopenharmony_ci * You may obtain a copy of the License at
6d9f0492fSopenharmony_ci *
7d9f0492fSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8d9f0492fSopenharmony_ci *
9d9f0492fSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10d9f0492fSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11d9f0492fSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12d9f0492fSopenharmony_ci * See the License for the specific language governing permissions and
13d9f0492fSopenharmony_ci * limitations under the License.
14d9f0492fSopenharmony_ci */
15d9f0492fSopenharmony_ci
16d9f0492fSopenharmony_ci#ifndef SYSTEM_PARAMETERS_H
17d9f0492fSopenharmony_ci#define SYSTEM_PARAMETERS_H
18d9f0492fSopenharmony_ci
19d9f0492fSopenharmony_ci#include <limits>
20d9f0492fSopenharmony_ci#include <string>
21d9f0492fSopenharmony_ci
22d9f0492fSopenharmony_cinamespace OHOS {
23d9f0492fSopenharmony_cinamespace system {
24d9f0492fSopenharmony_ci/*
25d9f0492fSopenharmony_ci * Returns the current value of the system parameter `key`.
26d9f0492fSopenharmony_ci * If the parameter is empty or doesn't exist, `def` will be returned.
27d9f0492fSopenharmony_ci */
28d9f0492fSopenharmony_cistd::string GetParameter(const std::string& key, const std::string& def);
29d9f0492fSopenharmony_ci
30d9f0492fSopenharmony_ci/*
31d9f0492fSopenharmony_ci * Returns true if the system parameter `key` has the value "1", "y", "yes", "on", or "true",
32d9f0492fSopenharmony_ci * false for "0", "n", "no", "off", or "false", or `def` otherwise.
33d9f0492fSopenharmony_ci */
34d9f0492fSopenharmony_cibool GetBoolParameter(const std::string& key, bool def);
35d9f0492fSopenharmony_ci
36d9f0492fSopenharmony_ci/*
37d9f0492fSopenharmony_ci * Returns the signed integer corresponding to the system parameter `key`.
38d9f0492fSopenharmony_ci * If the parameter is empty, doesn't exist, doesn't have an integer value, or is outside
39d9f0492fSopenharmony_ci * the optional bounds, returns `def`.
40d9f0492fSopenharmony_ci */
41d9f0492fSopenharmony_citemplate<typename T>
42d9f0492fSopenharmony_ciT GetIntParameter(const std::string& key, T def, T min = std::numeric_limits<T>::min(),
43d9f0492fSopenharmony_ci    T max = std::numeric_limits<T>::max());
44d9f0492fSopenharmony_ci
45d9f0492fSopenharmony_ci/*
46d9f0492fSopenharmony_ci * Returns the unsigned integer corresponding to the system parameter `key`.
47d9f0492fSopenharmony_ci * If the parameter is empty, doesn't exist, doesn't have an integer value, or is outside
48d9f0492fSopenharmony_ci * the optional bound, returns `def`.
49d9f0492fSopenharmony_ci */
50d9f0492fSopenharmony_citemplate<typename T>
51d9f0492fSopenharmony_ciT GetUintParameter(const std::string& key, T def, T max = std::numeric_limits<T>::max());
52d9f0492fSopenharmony_ci
53d9f0492fSopenharmony_ci/*
54d9f0492fSopenharmony_ci * Sets the system parameter `key` to `value`.
55d9f0492fSopenharmony_ci * Note that system parameter setting is inherently asynchronous so a return value of `true`
56d9f0492fSopenharmony_ci * isn't particularly meaningful, and immediately reading back the value won't necessarily
57d9f0492fSopenharmony_ci * tell you whether or not your call succeeded. A `false` return value definitely means failure.
58d9f0492fSopenharmony_ci */
59d9f0492fSopenharmony_cibool SetParameter(const std::string& key, const std::string& value);
60d9f0492fSopenharmony_ci
61d9f0492fSopenharmony_ci/*
62d9f0492fSopenharmony_ci * Obtains the device type of your product represented by a string.
63d9f0492fSopenharmony_ci */
64d9f0492fSopenharmony_cistd::string GetDeviceType(void);
65d9f0492fSopenharmony_ci} // namespace system
66d9f0492fSopenharmony_ci} // namespace OHOS
67d9f0492fSopenharmony_ci
68d9f0492fSopenharmony_ci#endif // SYSTEM_PARAMETERS_H