1 /*
2 * Copyright (c) 2024 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 #ifndef DATASHARESERVICE_DATA_SHARE_DB_CONFIG_H
16 #define DATASHARESERVICE_DATA_SHARE_DB_CONFIG_H
17 
18 #include <cstdint>
19 #include <string>
20 #include <tuple>
21 #include <utility>
22 
23 #include "db_delegate.h"
24 #include "extension_ability_info.h"
25 #include "metadata/store_meta_data.h"
26 #include "uri_utils.h"
27 
28 namespace OHOS::DataShare {
29 class DataShareDbConfig {
30 public:
31     struct DbConfig {
32         std::string uri;
33         std::string extUri;
34         std::string bundleName;
35         std::string storeName;
36         std::string backup;
37         int32_t userId;
38         int32_t appIndex;
39         bool hasExtension;
40     };
41     std::tuple<int, DistributedData::StoreMetaData, std::shared_ptr<DBDelegate>> GetDbConfig(DbConfig &dbConfig);
42     std::pair<int, DistributedData::StoreMetaData> GetMetaData(const DbConfig &dbConfig);
43 private:
44     static std::pair<bool, DistributedData::StoreMetaData> QueryMetaData(const std::string &bundleName,
45         const std::string &storeName, int32_t userId, int32_t appIndex);
46 };
47 } // namespace OHOS::DataShare
48 #endif
49