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