1 /*
2 * Copyright (c) 2021-2022 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 #include "predicates_convert.h"
17 #include "rdb_utils.h"
18
19 namespace OHOS {
20 namespace Contacts {
PredicatesConvert(void)21 PredicatesConvert::PredicatesConvert(void)
22 {
23 }
24
~PredicatesConvert()25 PredicatesConvert::~PredicatesConvert()
26 {
27 }
28
ConvertPredicates(std::string tableName,DataShare::DataSharePredicates & dataPredicates)29 OHOS::NativeRdb::RdbPredicates PredicatesConvert::ConvertPredicates(
30 std::string tableName, DataShare::DataSharePredicates &dataPredicates)
31 {
32 OHOS::NativeRdb::RdbPredicates predicates = RdbDataShareAdapter::RdbUtils::ToPredicates(dataPredicates, tableName);
33 return predicates;
34 }
35
CopyPredicates(std::string tableName,OHOS::NativeRdb::RdbPredicates & oldRdbPredicates)36 OHOS::NativeRdb::RdbPredicates PredicatesConvert::CopyPredicates(
37 std::string tableName, OHOS::NativeRdb::RdbPredicates &oldRdbPredicates)
38 {
39 OHOS::NativeRdb::RdbPredicates predicates(tableName);
40 OHOS::NativeRdb::PredicatesUtils::SetWhereClauseAndArgs(
41 &predicates, oldRdbPredicates.GetWhereClause(), oldRdbPredicates.GetWhereArgs());
42 OHOS::NativeRdb::PredicatesUtils::SetAttributes(&predicates, oldRdbPredicates.IsDistinct(),
43 oldRdbPredicates.GetIndex(), oldRdbPredicates.GetGroup(), oldRdbPredicates.GetOrder(),
44 oldRdbPredicates.GetLimit(), oldRdbPredicates.GetOffset());
45 return predicates;
46 }
47 } // namespace Contacts
48 } // namespace OHOS