Files
vba10/Database/Database.h

55 lines
1.4 KiB
C
Raw Permalink Normal View History

2015-06-18 17:33:07 +00:00
#pragma once
#include <windows.h>
#include <concrt.h>
#include "Statement.h"
2015-07-18 14:58:27 +00:00
namespace VBA10
2015-06-18 17:33:07 +00:00
{
2015-07-18 14:58:27 +00:00
namespace SQLiteWinRT
{
using Windows::Foundation::Uri;
using Windows::Foundation::IAsyncOperation;
using Windows::Foundation::IAsyncAction;
using Platform::String;
using namespace Windows::Storage;
2015-06-18 17:33:07 +00:00
2015-07-18 14:58:27 +00:00
public enum class SqliteOpenMode
{
Default = 0, // interpreted as OpenOrCreateReadWrite
OpenRead = SQLITE_OPEN_READONLY,
OpenReadWrite = SQLITE_OPEN_READWRITE,
OpenOrCreateReadWrite = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE
};
2015-06-18 17:33:07 +00:00
2015-07-18 14:58:27 +00:00
public ref class Database sealed
{
public:
static IAsyncOperation<Database^>^ FromApplicationUriAsync(Uri^ path);
2015-06-18 17:33:07 +00:00
2015-07-18 14:58:27 +00:00
static SqliteReturnCode GetSqliteErrorCode(int hr) { return SqliteReturnCode(HRESULT_CODE(hr)); }
2015-06-18 17:33:07 +00:00
2015-07-18 14:58:27 +00:00
Database(StorageFile^ file);
Database(StorageFolder^ folder, String^ name);
2015-06-18 17:33:07 +00:00
2015-07-18 14:58:27 +00:00
virtual ~Database();
2015-06-18 17:33:07 +00:00
2015-07-18 14:58:27 +00:00
property String^ Path { String^ get() { return m_path; } }
2015-06-18 17:33:07 +00:00
2015-07-18 14:58:27 +00:00
IAsyncAction^ OpenAsync();
IAsyncAction^ OpenAsync(SqliteOpenMode openMode);
IAsyncOperation<Statement^>^ PrepareStatementAsync(String^ cmd);
IAsyncAction^ ExecuteStatementAsync(String^ cmd);
2015-06-18 17:33:07 +00:00
2015-07-18 14:58:27 +00:00
int64 GetLastInsertedRowId();
2015-06-18 17:33:07 +00:00
2015-07-18 14:58:27 +00:00
internal:
property sqlite3* RawDatabasePtr { sqlite3* get() const { return m_database; } }
2015-06-18 17:33:07 +00:00
2015-07-18 14:58:27 +00:00
private:
sqlite3* m_database;
LONG volatile m_opened;
String^ m_path;
String^ m_filename;
};
}
2015-06-18 17:33:07 +00:00
}