Cleaned up and added bindings for Database.

This commit is contained in:
Relintai 2022-07-06 09:17:49 +02:00
parent d5f5e9fec9
commit b26ad4cab9
2 changed files with 21 additions and 9 deletions

View File

@ -1,8 +1,8 @@
#include "database.h"
#include "query_builder.h"
#include "table_builder.h"
#include "query_result.h"
#include "table_builder.h"
void Database::connect(const String &connection_str) {
}
@ -21,16 +21,24 @@ Ref<TableBuilder> Database::get_table_builder() {
return Ref<TableBuilder>(new TableBuilder());
}
String Database::escape(const String str) {
String Database::escape(const String &str) {
return String();
}
void Database::escape(const String str, String *to) {
void Database::escape_to(const String &str, String *to) {
}
Database::Database() {
}
Database::~Database() {
}
}
void Database::_bind_methods() {
ClassDB::bind_method(D_METHOD("connect", "connection_str"), &Database::connect);
ClassDB::bind_method(D_METHOD("query", "query"), &Database::query);
ClassDB::bind_method(D_METHOD("query_run", "query"), &Database::query_run);
ClassDB::bind_method(D_METHOD("get_query_builder"), &Database::get_query_builder);
ClassDB::bind_method(D_METHOD("get_table_builder"), &Database::get_table_builder);
ClassDB::bind_method(D_METHOD("escape", "str"), &Database::escape);
}

View File

@ -2,7 +2,6 @@
#define DATABASE_H
#include "core/ustring.h"
#include <memory>
#include "core/reference.h"
@ -10,7 +9,9 @@ class QueryBuilder;
class TableBuilder;
class QueryResult;
class Database {
class Database : public Reference {
GDCLASS(Database, Reference);
public:
virtual void connect(const String &connection_str);
virtual Ref<QueryResult> query(const String &query);
@ -19,11 +20,14 @@ public:
virtual Ref<QueryBuilder> get_query_builder();
virtual Ref<TableBuilder> get_table_builder();
virtual String escape(const String str);
virtual void escape(const String str, String *to);
virtual String escape(const String &str);
virtual void escape_to(const String &str, String *to);
Database();
~Database();
protected:
static void _bind_methods();
};
#endif