1 /*
2  * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef GENERIC_VALUES_H
17 #define GENERIC_VALUES_H
18 
19 #include <map>
20 #include <vector>
21 #include <string>
22 
23 #include "variant_value.h"
24 
25 namespace OHOS {
26 namespace Security {
27 namespace AccessToken {
28 class GenericValues final {
29 public:
30     GenericValues() = default;
31     virtual ~GenericValues() = default;
32 
33     void Put(const std::string& key, int32_t value);
34 
35     void Put(const std::string& key, int64_t value);
36 
37     void Put(const std::string& key, const std::string& value);
38 
39     void Put(const std::string& key, const VariantValue& value);
40 
41     std::vector<std::string> GetAllKeys() const;
42 
43     VariantValue Get(const std::string& key) const;
44 
45     int32_t GetInt(const std::string& key) const;
46 
47     int64_t GetInt64(const std::string& key) const;
48 
49     std::string GetString(const std::string& key) const;
50 
51     void Remove(const std::string& key);
52 private:
53     std::map<std::string, VariantValue> map_;
54 };
55 } // namespace AccessToken
56 } // namespace Security
57 } // namespace OHOS
58 #endif // GENERIC_VALUES_H
59