1 /*
2  * Copyright (c) 2022-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 OHOS_FILEMGMT_BACKUP_B_JSON_ENTITY_H
17 #define OHOS_FILEMGMT_BACKUP_B_JSON_ENTITY_H
18 
19 #include <any>
20 #include <string>
21 #include <string_view>
22 
23 #include "json/json.h"
24 
25 namespace OHOS::FileManagement::Backup {
26 class BJsonEntity {
27 public:
28     /**
29      * @brief 获取JSon数据源
30      *
31      * @param jsonFromRealWorld 直接来自真实用户场景的配置文件(即,非override配置)
32      * @param option 任意类型对象
33      * @return std::string 取决于具体情况的配置文件
34      */
35     std::string GetJSonSource(std::string_view jsonFromRealWorld, std::any option = std::any())
36     {
37         return std::string(jsonFromRealWorld);
38     }
39 
40 public:
41     /**
42      * @brief 构造方法,具备T(Json::Value&, std::any)能力的构造函数
43      *
44      * @param obj Json对象引用
45      * @param option 任意类型对象
46      */
47     explicit BJsonEntity(Json::Value &obj, std::any option = std::any()) : obj_(obj), option_(option) {}
48     BJsonEntity() = delete;
49     virtual ~BJsonEntity() = default;
50 
51 protected:
52     Json::Value &obj_;
53     std::any option_;
54 };
55 } // namespace OHOS::FileManagement::Backup
56 
57 #endif // OHOS_FILEMGMT_BACKUP_B_JSON_ENTITY_H