Skip to content

Commit 595adcd

Browse files
committed
Enforce new formatting rules in all source files
1 parent b8648be commit 595adcd

File tree

7 files changed

+1219
-1429
lines changed

7 files changed

+1219
-1429
lines changed

src/gdsqlite.cpp

Lines changed: 963 additions & 1122 deletions
Large diffs are not rendered by default.

src/gdsqlite.h

Lines changed: 83 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -7,123 +7,118 @@
77
#include <godot_cpp/core/class_db.hpp>
88

99
#include <godot_cpp/classes/global_constants.hpp>
10-
#include <godot_cpp/classes/project_settings.hpp>
11-
#include <godot_cpp/classes/marshalls.hpp>
1210
#include <godot_cpp/classes/json.hpp>
11+
#include <godot_cpp/classes/marshalls.hpp>
12+
#include <godot_cpp/classes/project_settings.hpp>
1313

14-
#include <fstream>
15-
#include <vector>
16-
#include <sstream>
17-
#include <cstring>
18-
#include <memory>
1914
#include <sqlite/sqlite3.h>
2015
#include <vfs/gdsqlite_vfs.h>
16+
#include <cstring>
17+
#include <fstream>
18+
#include <memory>
19+
#include <sstream>
20+
#include <vector>
21+
22+
namespace godot {
23+
enum OBJECT_TYPE {
24+
TABLE,
25+
TRIGGER
26+
};
27+
struct object_struct {
28+
String name, sql;
29+
OBJECT_TYPE type;
30+
Array base64_columns, row_array;
31+
};
2132

22-
namespace godot
23-
{
24-
enum OBJECT_TYPE
25-
{
26-
TABLE,
27-
TRIGGER
28-
};
29-
struct object_struct
30-
{
31-
String name, sql;
32-
OBJECT_TYPE type;
33-
Array base64_columns, row_array;
34-
};
33+
class SQLite : public RefCounted {
34+
GDCLASS(SQLite, RefCounted)
3535

36-
class SQLite : public RefCounted
37-
{
38-
GDCLASS(SQLite, RefCounted)
36+
private:
37+
bool validate_json(const Array &import_json, std::vector<object_struct> &tables_to_import);
38+
bool validate_table_dict(const Dictionary &p_table_dict);
39+
int backup_database(sqlite3 *source_db, sqlite3 *destination_db);
3940

40-
private:
41-
bool validate_json(const Array &import_json, std::vector<object_struct> &tables_to_import);
42-
bool validate_table_dict(const Dictionary &p_table_dict);
43-
int backup_database(sqlite3 *source_db, sqlite3 *destination_db);
41+
sqlite3 *db;
42+
std::vector<std::unique_ptr<Callable>> function_registry;
4443

45-
sqlite3 *db;
46-
std::vector<std::unique_ptr<Callable>> function_registry;
44+
int64_t verbosity_level = 1;
45+
bool foreign_keys = false;
46+
bool read_only = false;
47+
String path = "default";
48+
String error_message = "";
49+
String default_extension = "db";
50+
TypedArray<Dictionary> query_result = TypedArray<Dictionary>();
4751

48-
int64_t verbosity_level = 1;
49-
bool foreign_keys = false;
50-
bool read_only = false;
51-
String path = "default";
52-
String error_message = "";
53-
String default_extension = "db";
54-
TypedArray<Dictionary> query_result = TypedArray<Dictionary>();
52+
protected:
53+
static void _bind_methods();
5554

56-
protected:
57-
static void _bind_methods();
55+
public:
56+
// Constants.
57+
enum VerbosityLevel {
58+
QUIET = 0,
59+
NORMAL = 1,
60+
VERBOSE = 2,
61+
VERY_VERBOSE = 3
62+
};
5863

59-
public:
60-
// Constants.
61-
enum VerbosityLevel
62-
{
63-
QUIET = 0,
64-
NORMAL = 1,
65-
VERBOSE = 2,
66-
VERY_VERBOSE = 3
67-
};
64+
SQLite();
65+
~SQLite();
6866

69-
SQLite();
70-
~SQLite();
67+
// Functions.
68+
bool open_db();
69+
bool close_db();
70+
bool query(const String &p_query);
71+
bool query_with_bindings(const String &p_query, Array param_bindings);
7172

72-
// Functions.
73-
bool open_db();
74-
bool close_db();
75-
bool query(const String &p_query);
76-
bool query_with_bindings(const String &p_query, Array param_bindings);
73+
bool create_table(const String &p_name, const Dictionary &p_table_dict);
74+
bool drop_table(const String &p_name);
7775

78-
bool create_table(const String &p_name, const Dictionary &p_table_dict);
79-
bool drop_table(const String &p_name);
76+
bool backup_to(String destination_path);
77+
bool restore_from(String source_path);
8078

81-
bool backup_to(String destination_path);
82-
bool restore_from(String source_path);
79+
bool insert_row(const String &p_name, const Dictionary &p_row_dict);
80+
bool insert_rows(const String &p_name, const Array &p_row_array);
8381

84-
bool insert_row(const String &p_name, const Dictionary &p_row_dict);
85-
bool insert_rows(const String &p_name, const Array &p_row_array);
82+
Array select_rows(const String &p_name, const String &p_conditions, const Array &p_columns_array);
83+
bool update_rows(const String &p_name, const String &p_conditions, const Dictionary &p_updated_row_dict);
84+
bool delete_rows(const String &p_name, const String &p_conditions);
8685

87-
Array select_rows(const String &p_name, const String &p_conditions, const Array &p_columns_array);
88-
bool update_rows(const String &p_name, const String &p_conditions, const Dictionary &p_updated_row_dict);
89-
bool delete_rows(const String &p_name, const String &p_conditions);
86+
bool create_function(const String &p_name, const Callable &p_callable, int p_argc);
9087

91-
bool create_function(const String &p_name, const Callable &p_callable, int p_argc);
88+
bool import_from_json(String import_path);
89+
bool export_to_json(String export_path);
9290

93-
bool import_from_json(String import_path);
94-
bool export_to_json(String export_path);
91+
int get_autocommit() const;
9592

96-
int get_autocommit() const;
93+
// Properties.
94+
void set_last_insert_rowid(const int64_t &p_last_insert_rowid);
95+
int64_t get_last_insert_rowid() const;
9796

98-
// Properties.
99-
void set_last_insert_rowid(const int64_t &p_last_insert_rowid);
100-
int64_t get_last_insert_rowid() const;
97+
void set_verbosity_level(const int64_t &p_verbosity_level);
98+
int64_t get_verbosity_level() const;
10199

102-
void set_verbosity_level(const int64_t &p_verbosity_level);
103-
int64_t get_verbosity_level() const;
100+
void set_foreign_keys(const bool &p_foreign_keys);
101+
bool get_foreign_keys() const;
104102

105-
void set_foreign_keys(const bool &p_foreign_keys);
106-
bool get_foreign_keys() const;
103+
void set_read_only(const bool &p_read_only);
104+
bool get_read_only() const;
107105

108-
void set_read_only(const bool &p_read_only);
109-
bool get_read_only() const;
106+
void set_path(const String &p_path);
107+
String get_path() const;
110108

111-
void set_path(const String &p_path);
112-
String get_path() const;
109+
void set_error_message(const String &p_error_message);
110+
String get_error_message() const;
113111

114-
void set_error_message(const String &p_error_message);
115-
String get_error_message() const;
112+
void set_default_extension(const String &p_default_extension);
113+
String get_default_extension() const;
116114

117-
void set_default_extension(const String &p_default_extension);
118-
String get_default_extension() const;
115+
void set_query_result(const TypedArray<Dictionary> &p_query_result);
116+
TypedArray<Dictionary> get_query_result() const;
119117

120-
void set_query_result(const TypedArray<Dictionary> &p_query_result);
121-
TypedArray<Dictionary> get_query_result() const;
122-
123-
TypedArray<Dictionary> get_query_result_by_reference() const;
124-
};
118+
TypedArray<Dictionary> get_query_result_by_reference() const;
119+
};
125120

126-
}
121+
} //namespace godot
127122

128123
VARIANT_ENUM_CAST(SQLite::VerbosityLevel);
129124

src/register_types.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@
1111
using namespace godot;
1212

1313
void initialize_sqlite_module(ModuleInitializationLevel p_level) {
14-
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
14+
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
1515
return;
1616
}
1717

1818
ClassDB::register_class<SQLite>();
1919
}
2020

2121
void uninitialize_sqlite_module(ModuleInitializationLevel p_level) {
22-
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
22+
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
2323
return;
2424
}
2525
}
@@ -29,12 +29,12 @@ extern "C" {
2929
// Initialization.
3030

3131
GDExtensionBool GDE_EXPORT sqlite_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
32-
godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
32+
godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);
3333

34-
init_obj.register_initializer(initialize_sqlite_module);
35-
init_obj.register_terminator(uninitialize_sqlite_module);
36-
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
34+
init_obj.register_initializer(initialize_sqlite_module);
35+
init_obj.register_terminator(uninitialize_sqlite_module);
36+
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
3737

38-
return init_obj.init();
38+
return init_obj.init();
3939
}
4040
}

0 commit comments

Comments
 (0)