Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef _SQLITE_STATEMENT_H |
| 18 | #define _SQLITE_STATEMENT_H |
| 19 | |
Mike Lockwood | 7850ef9 | 2010-05-14 10:10:36 -0400 | [diff] [blame] | 20 | #include <stdint.h> |
| 21 | |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 22 | typedef struct sqlite3 sqlite3; |
| 23 | typedef struct sqlite3_stmt sqlite3_stmt; |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 24 | |
Mike Lockwood | 7850ef9 | 2010-05-14 10:10:36 -0400 | [diff] [blame] | 25 | namespace android { |
| 26 | |
| 27 | class SqliteDatabase; |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 28 | |
| 29 | class SqliteStatement { |
| 30 | private: |
| 31 | sqlite3* mDatabaseHandle; |
| 32 | sqlite3_stmt* mStatement; |
| 33 | bool mDone; |
| 34 | |
| 35 | public: |
| 36 | SqliteStatement(SqliteDatabase* db); |
| 37 | virtual ~SqliteStatement(); |
| 38 | |
| 39 | bool prepare(const char* sql); |
| 40 | bool step(); |
| 41 | void reset(); |
| 42 | void finalize(); |
| 43 | |
| 44 | void bind(int column, int value); |
| 45 | void bind(int column, const char* value); |
| 46 | |
| 47 | int getColumnInt(int column); |
| 48 | int64_t getColumnInt64(int column); |
| 49 | const char* getColumnString(int column); |
| 50 | |
| 51 | inline bool isDone() const { return mDone; } |
| 52 | }; |
| 53 | |
Mike Lockwood | 7850ef9 | 2010-05-14 10:10:36 -0400 | [diff] [blame] | 54 | }; // namespace android |
| 55 | |
Mike Lockwood | 16864ba | 2010-05-11 17:16:59 -0400 | [diff] [blame] | 56 | #endif // _SQLITE_STATEMENT_H |