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, int value); 34 35 void Put(const std::string& key, const std::string& value); 36 37 void Put(const std::string& key, const VariantValue& value); 38 39 std::vector<std::string> GetAllKeys() const; 40 41 VariantValue Get(const std::string& key) const; 42 43 int GetInt(const std::string& key) const; 44 45 std::string GetString(const std::string& key) const; 46 47 private: 48 std::map<std::string, VariantValue> map_; 49 }; 50 } // namespace AccessToken 51 } // namespace Security 52 } // namespace OHOS 53 #endif // GENERIC_VALUES_H 54