1 /* 2 * Copyright (c) 2023 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 <string> 21 #include "variant_value.h" 22 #include <vector> 23 24 namespace OHOS { 25 namespace AccessControl { 26 namespace SandboxManager { 27 class GenericValues final { 28 public: 29 GenericValues() = default; 30 virtual ~GenericValues() = default; 31 32 void Put(const std::string &key, int32_t value); 33 34 void Put(const std::string &key, int64_t value); 35 36 void Put(const std::string &key, const std::string &value); 37 38 void Put(const std::string &key, const VariantValue &value); 39 40 std::vector<std::string> GetAllKeys() const; 41 42 VariantValue Get(const std::string &key) const; 43 44 int32_t GetInt(const std::string &key) const; 45 46 int64_t GetInt64(const std::string &key) const; 47 48 std::string GetString(const std::string &key) const; 49 50 void Remove(const std::string &key); 51 private: 52 std::map<std::string, VariantValue> map_; 53 }; 54 } // namespace SandboxManager 55 } // namespace AccessControl 56 } // namespace OHOS 57 #endif // GENERIC_VALUES_H 58