1 /*
2  * Copyright (c) 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 DATASHARE_OPERATION_STATEMENT_H
17 #define DATASHARE_OPERATION_STATEMENT_H
18 
19 #include "datashare_predicates.h"
20 #include "datashare_values_bucket.h"
21 
22 namespace OHOS {
23 namespace DataShare {
24 enum class Operation : int32_t {
25     INSERT = 0,
26     UPDATE,
27     DELETE,
28 };
29 
30 struct UpdateOperation {
31     DataShareValuesBucket valuesBucket;
32     DataSharePredicates predicates;
33 };
34 using UpdateOperations = std::map<std::string, std::vector<UpdateOperation>>;
35 
36 struct BatchUpdateResult {
37     std::string uri;
38     std::vector<int> codes;
39 };
40 
41 struct OperationStatement {
42     Operation operationType;
43     std::string uri;
44     DataSharePredicates predicates;
45     DataShareValuesBucket valuesBucket;
46 };
47 
48 enum ExecErrorCode : int32_t {
49     EXEC_SUCCESS = 0,
50     EXEC_FAILED,
51     EXEC_PARTIAL_SUCCESS,
52 };
53 
54 struct ExecResult {
55     Operation operationType;
56     int code;
57     std::string message;
58 };
59 
60 struct ExecResultSet {
61     ExecErrorCode errorCode;
62     std::vector<ExecResult> results;
63 };
64 }
65 }
66 #endif // DATASHARE_OPERATION_STATEMENT_H
67