1 /*
2  * Copyright (C) 2021 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 CELLULAR_DATA_RDB_HELPER_H
17 #define CELLULAR_DATA_RDB_HELPER_H
18 
19 #include <memory>
20 #include <utility>
21 
22 #include "datashare_helper.h"
23 #include "datashare_predicates.h"
24 #include "datashare_result_set.h"
25 #include "datashare_values_bucket.h"
26 #include "vcard_constant.h"
27 
28 namespace OHOS {
29 namespace Telephony {
30 class VCardRdbHelper {
31 public:
32     VCardRdbHelper();
33     static int32_t InsertRawContact(const DataShare::DataShareValuesBucket &rawContactValues);
34     static int32_t InsertContactData(const std::vector<DataShare::DataShareValuesBucket> &contactsDataValues);
35     std::shared_ptr<DataShare::DataShareResultSet> QueryContact(
36         std::vector<std::string> &columns, const DataShare::DataSharePredicates &predicates);
37     static std::shared_ptr<DataShare::DataShareResultSet> QueryAccount(
38         std::vector<std::string> &columns, const DataShare::DataSharePredicates &predicates);
39     static std::shared_ptr<DataShare::DataShareResultSet> QueryRawContact(
40         std::vector<std::string> &columns, const DataShare::DataSharePredicates &predicates);
41     static std::shared_ptr<DataShare::DataShareResultSet> QueryContactData(
42         std::vector<std::string> &columns, const DataShare::DataSharePredicates &predicates);
43     static void SetDataHelper(std::shared_ptr<DataShare::DataShareHelper> dataShareHelper);
44     static void Release();
45     static VCardRdbHelper &GetInstance();
46     static int32_t QueryRawContactMaxId(int32_t queryNum);
47     static int32_t BatchInsertRawContact(const std::vector<DataShare::DataShareValuesBucket> &rawContactValues);
48     static int32_t BatchInsertContactData(const std::vector<DataShare::DataShareValuesBucket> &contactsDataValues);
49 
50 private:
51     static std::shared_ptr<DataShare::DataShareHelper> dataShareHelper_;
52 };
53 } // namespace Telephony
54 } // namespace OHOS
55 #endif // CELLULAR_DATA_RDB_HELPER_H
56