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 RELATIONAL_CURSOR_IMPL_H 17 #define RELATIONAL_CURSOR_IMPL_H 18 19 #include "oh_cursor.h" 20 #include "result_set.h" 21 #include <memory> 22 23 namespace OHOS { 24 namespace RdbNdk { 25 constexpr int RDB_CURSOR_CID = 1234563; // The class id used to uniquely identify the OH_Cursor class. 26 class RelationalCursor : public OH_Cursor { 27 public: 28 explicit RelationalCursor(std::shared_ptr<OHOS::NativeRdb::ResultSet> resultSet); 29 private: 30 static int GetColumnCount(OH_Cursor *cursor, int *count); 31 static int GetColumnType(OH_Cursor *cursor, int32_t columnIndex, OH_ColumnType *columnType); 32 static int GetColumnIndex(OH_Cursor *cursor, const char *name, int *columnIndex); 33 static int GetColumnName(OH_Cursor *cursor, int32_t columnIndex, char *name, int length); 34 static int GetRowCount(OH_Cursor *cursor, int *count); 35 static int GoToNextRow(OH_Cursor *cursor); 36 static int GetSize(OH_Cursor *cursor, int32_t columnIndex, size_t *size); 37 static int GetText(OH_Cursor *cursor, int32_t columnIndex, char *value, int length); 38 static int GetInt64(OH_Cursor *cursor, int32_t columnIndex, int64_t *value); 39 static int GetReal(OH_Cursor *cursor, int32_t columnIndex, double *value); 40 static int GetBlob(OH_Cursor *cursor, int32_t columnIndex, unsigned char *value, int length); 41 static int IsNull(OH_Cursor *cursor, int32_t columnIndex, bool *isNull); 42 static int Destroy(OH_Cursor *cursor); 43 static RelationalCursor *GetSelf(OH_Cursor *cursor); 44 std::shared_ptr<OHOS::NativeRdb::ResultSet> resultSet_; 45 }; 46 } // namespace RdbNdk 47 } // namespace OHOS 48 #endif // RELATIONAL_CURSOR_IMPL_H 49