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 16 #ifndef OHOS_DISTRIBUTED_DATA_NATIVE_GDB_GRAPH_STATEMENT_H 17 #define OHOS_DISTRIBUTED_DATA_NATIVE_GDB_GRAPH_STATEMENT_H 18 19 #ifndef JSON_NOEXCEPTION 20 #define JSON_NOEXCEPTION 21 #endif 22 #include "connection.h" 23 #include "grd_adapter.h" 24 #include "nlohmann/json.hpp" 25 #include "statement.h" 26 27 namespace OHOS::DistributedDataAip { 28 class GraphStatement final : public Statement { 29 public: 30 GraphStatement(GRD_DB *db, const std::string &gql, std::shared_ptr<Connection> conn, int32_t &errCode); 31 ~GraphStatement(); 32 33 int32_t Prepare() override; 34 int32_t Step() override; 35 int32_t Finalize() override; 36 37 uint32_t GetColumnCount() const override; 38 std::pair<int32_t, std::string> GetColumnName(int32_t index) const override; 39 std::pair<int32_t, ColumnType> GetColumnType(int32_t index) const override; 40 std::pair<int32_t, GraphValue> GetColumnValue(int32_t index) const override; 41 42 bool IsReady() const override; 43 44 private: 45 std::shared_ptr<Connection> conn_; 46 std::string gql_; 47 GRD_Stmt *stmtHandle_ = nullptr; 48 GRD_DB *dbHandle_ = nullptr; 49 static GraphValue ParseJsonStr(const std::string &jsonStr, int32_t &errCode) ; 50 }; 51 } // namespace OHOS::DistributedDataAip 52 #endif //OHOS_DISTRIBUTED_DATA_NATIVE_GDB_GRAPH_STATEMENT_H 53