@@ -127,7 +127,7 @@ SQLite::~SQLite() {
127
127
128
128
bool SQLite::open_db () {
129
129
if (db) {
130
- UtilityFunctions::printerr (" GDSQLite Error: Can't open database if connection is already open!" );
130
+ ERR_PRINT (" GDSQLite Error: Can't open database if connection is already open!" );
131
131
return false ;
132
132
}
133
133
@@ -157,7 +157,7 @@ bool SQLite::open_db() {
157
157
sqlite3_vfs_register (gdsqlite_vfs (), 0 );
158
158
rc = sqlite3_open_v2 (char_path, &db, SQLITE_OPEN_READONLY, " godot" );
159
159
} else {
160
- UtilityFunctions::printerr (" GDSQLite Error: Opening in-memory databases in read-only mode is currently not supported!" );
160
+ ERR_PRINT (" GDSQLite Error: Opening in-memory databases in read-only mode is currently not supported!" );
161
161
return false ;
162
162
}
163
163
} else {
@@ -168,7 +168,7 @@ bool SQLite::open_db() {
168
168
}
169
169
170
170
if (rc != SQLITE_OK) {
171
- UtilityFunctions::printerr (" GDSQLite Error: Can't open database: " + String::utf8 (sqlite3_errmsg (db)));
171
+ ERR_PRINT (" GDSQLite Error: Can't open database: " + String::utf8 (sqlite3_errmsg (db)));
172
172
return false ;
173
173
} else if (verbosity_level > VerbosityLevel::QUIET) {
174
174
UtilityFunctions::print (" Opened database successfully (" + path + " )" );
@@ -178,7 +178,7 @@ bool SQLite::open_db() {
178
178
if (foreign_keys) {
179
179
rc = sqlite3_exec (db, " PRAGMA foreign_keys=on;" , NULL , NULL , &zErrMsg);
180
180
if (rc != SQLITE_OK) {
181
- UtilityFunctions::printerr (" GDSQLite Error: Can't enable foreign keys: " + String::utf8 (zErrMsg));
181
+ ERR_PRINT (" GDSQLite Error: Can't enable foreign keys: " + String::utf8 (zErrMsg));
182
182
sqlite3_free (zErrMsg);
183
183
return false ;
184
184
}
@@ -191,7 +191,7 @@ bool SQLite::close_db() {
191
191
if (db) {
192
192
// Cannot close database!
193
193
if (sqlite3_close_v2 (db) != SQLITE_OK) {
194
- UtilityFunctions::printerr (" GDSQLite Error: Can't close database!" );
194
+ ERR_PRINT (" GDSQLite Error: Can't close database!" );
195
195
return false ;
196
196
} else {
197
197
db = nullptr ;
@@ -202,7 +202,7 @@ bool SQLite::close_db() {
202
202
}
203
203
}
204
204
205
- UtilityFunctions::printerr (" GDSQLite Error: Can't close database if connection is not open!" );
205
+ ERR_PRINT (" GDSQLite Error: Can't close database if connection is not open!" );
206
206
return false ;
207
207
}
208
208
@@ -231,15 +231,15 @@ bool SQLite::query_with_bindings(const String &p_query, Array param_bindings) {
231
231
zErrMsg = sqlite3_errmsg (db);
232
232
error_message = String::utf8 (zErrMsg);
233
233
if (rc != SQLITE_OK) {
234
- UtilityFunctions::printerr (" --> SQL error: " + error_message);
234
+ ERR_PRINT (" --> SQL error: " + error_message);
235
235
sqlite3_finalize (stmt);
236
236
return false ;
237
237
}
238
238
239
239
/* Check if the param_bindings size exceeds the required parameter count */
240
240
int parameter_count = sqlite3_bind_parameter_count (stmt);
241
241
if (param_bindings.size () < parameter_count) {
242
- UtilityFunctions::printerr (" GDSQLite Error: Insufficient number of parameters to satisfy required number of bindings in statement!" );
242
+ ERR_PRINT (" GDSQLite Error: Insufficient number of parameters to satisfy required number of bindings in statement!" );
243
243
sqlite3_finalize (stmt);
244
244
return false ;
245
245
}
@@ -284,7 +284,7 @@ bool SQLite::query_with_bindings(const String &p_query, Array param_bindings) {
284
284
}
285
285
286
286
default :
287
- UtilityFunctions::printerr (" GDSQLite Error: Binding a parameter of type " + String (std::to_string (binding_value.get_type ()).c_str ()) + " (TYPE_*) is not supported!" );
287
+ ERR_PRINT (" GDSQLite Error: Binding a parameter of type " + String (std::to_string (binding_value.get_type ()).c_str ()) + " (TYPE_*) is not supported!" );
288
288
sqlite3_finalize (stmt);
289
289
return false ;
290
290
}
@@ -348,7 +348,7 @@ bool SQLite::query_with_bindings(const String &p_query, Array param_bindings) {
348
348
zErrMsg = sqlite3_errmsg (db);
349
349
error_message = String::utf8 (zErrMsg);
350
350
if (rc != SQLITE_OK) {
351
- UtilityFunctions::printerr (" --> SQL error: " + error_message);
351
+ ERR_PRINT (" --> SQL error: " + error_message);
352
352
return false ;
353
353
} else if (verbosity_level > VerbosityLevel::NORMAL) {
354
354
UtilityFunctions::print (" --> Query succeeded" );
@@ -361,7 +361,7 @@ bool SQLite::query_with_bindings(const String &p_query, Array param_bindings) {
361
361
}
362
362
363
363
if (!param_bindings.is_empty ()) {
364
- UtilityFunctions::push_warning (" GDSQLite Warning: Provided number of bindings exceeded the required number in statement! (" + String (std::to_string (param_bindings.size ()).c_str ()) + " unused parameter(s))" );
364
+ WARN_PRINT (" GDSQLite Warning: Provided number of bindings exceeded the required number in statement! (" + String (std::to_string (param_bindings.size ()).c_str ()) + " unused parameter(s))" );
365
365
}
366
366
367
367
return true ;
@@ -471,18 +471,18 @@ bool SQLite::validate_table_dict(const Dictionary &p_table_dict) {
471
471
int64_t number_of_columns = columns.size ();
472
472
for (int64_t i = 0 ; i <= number_of_columns - 1 ; i++) {
473
473
if (p_table_dict[columns[i]].get_type () != Variant::DICTIONARY) {
474
- UtilityFunctions::printerr (" GDSQLite Error: All values of the table dictionary should be of type Dictionary" );
474
+ ERR_PRINT (" GDSQLite Error: All values of the table dictionary should be of type Dictionary" );
475
475
return false ;
476
476
}
477
477
478
478
column_dict = p_table_dict[columns[i]];
479
479
if (!column_dict.has (" data_type" )) {
480
- UtilityFunctions::printerr (" GDSQLite Error: The field \" data_type\" is a required part of the table dictionary" );
480
+ ERR_PRINT (" GDSQLite Error: The field \" data_type\" is a required part of the table dictionary" );
481
481
return false ;
482
482
}
483
483
484
484
if (column_dict[" data_type" ].get_type () != Variant::STRING) {
485
- UtilityFunctions::printerr (" GDSQLite Error: The field \" data_type\" should be of type String" );
485
+ ERR_PRINT (" GDSQLite Error: The field \" data_type\" should be of type String" );
486
486
return false ;
487
487
}
488
488
@@ -504,7 +504,7 @@ bool SQLite::validate_table_dict(const Dictionary &p_table_dict) {
504
504
}
505
505
506
506
if (data_type_type != default_type) {
507
- UtilityFunctions::printerr (" GDSQLite Error: The type of the field \" default\" ( " + String (std::to_string (default_type).c_str ()) + " ) should be the same type as the \" datatype\" -field ( " + String (std::to_string (data_type_type).c_str ()) + " )" );
507
+ ERR_PRINT (" GDSQLite Error: The type of the field \" default\" ( " + String (std::to_string (default_type).c_str ()) + " ) should be the same type as the \" datatype\" -field ( " + String (std::to_string (data_type_type).c_str ()) + " )" );
508
508
return false ;
509
509
}
510
510
}
@@ -588,7 +588,7 @@ bool SQLite::insert_rows(const String &p_name, const Array &p_row_array) {
588
588
int64_t number_of_rows = p_row_array.size ();
589
589
for (int64_t i = 0 ; i <= number_of_rows - 1 ; i++) {
590
590
if (p_row_array[i].get_type () != Variant::DICTIONARY) {
591
- UtilityFunctions::printerr (" GDSQLite Error: All elements of the Array should be of type Dictionary" );
591
+ ERR_PRINT (" GDSQLite Error: All elements of the Array should be of type Dictionary" );
592
592
/* Don't forget to close the transaction! */
593
593
/* Maybe we should do a rollback instead? */
594
594
query (" END TRANSACTION;" );
@@ -615,7 +615,7 @@ Array SQLite::select_rows(const String &p_name, const String &p_conditions, cons
615
615
int64_t number_of_columns = p_columns_array.size ();
616
616
for (int64_t i = 0 ; i <= number_of_columns - 1 ; i++) {
617
617
if (p_columns_array[i].get_type () != Variant::STRING) {
618
- UtilityFunctions::printerr (" GDSQLite Error: All elements of the Array should be of type String" );
618
+ ERR_PRINT (" GDSQLite Error: All elements of the Array should be of type String" );
619
619
return query_result;
620
620
}
621
621
query_string += (const String &)p_columns_array[i];
@@ -692,7 +692,7 @@ static void function_callback(sqlite3_context *context, int argc, sqlite3_value
692
692
693
693
/* Check if the callable is valid */
694
694
if (!callable.is_valid ()) {
695
- UtilityFunctions::printerr (" GDSQLite Error: Supplied function reference is invalid! Aborting callback..." );
695
+ ERR_PRINT (" GDSQLite Error: Supplied function reference is invalid! Aborting callback..." );
696
696
return ;
697
697
}
698
698
@@ -793,7 +793,7 @@ bool SQLite::create_function(const String &p_name, const Callable &p_callable, i
793
793
/* Create the actual function */
794
794
rc = sqlite3_create_function (db, zFunctionName, nArg, eTextRep, pApp, xFunc, xStep, xFinal);
795
795
if (rc) {
796
- UtilityFunctions::printerr (" GDSQLite Error: " + String (sqlite3_errmsg (db)));
796
+ ERR_PRINT (" GDSQLite Error: " + String (sqlite3_errmsg (db)));
797
797
return false ;
798
798
} else if (verbosity_level > VerbosityLevel::NORMAL) {
799
799
UtilityFunctions::print (" Succesfully added function \" " + p_name + " \" to function registry" );
@@ -816,7 +816,7 @@ bool SQLite::import_from_json(String import_path) {
816
816
/* Open the json-file and stream its content into a stringstream */
817
817
std::ifstream ifs (char_path);
818
818
if (ifs.fail ()) {
819
- UtilityFunctions::printerr (" GDSQLite Error: " + String (std::strerror (errno)) + " (" + import_path + " )" );
819
+ ERR_PRINT (" GDSQLite Error: " + String (std::strerror (errno)) + " (" + import_path + " )" );
820
820
return false ;
821
821
}
822
822
std::stringstream buffer;
@@ -831,7 +831,7 @@ bool SQLite::import_from_json(String import_path) {
831
831
Error error = json->parse (json_string);
832
832
if (error != Error::OK) {
833
833
/* Throw a parsing error */
834
- UtilityFunctions::printerr (" GDSQLite Error: parsing failed! reason: " + json->get_error_message () + " , at line: " + String::num_int64 (json->get_error_line ()));
834
+ ERR_PRINT (" GDSQLite Error: parsing failed! reason: " + json->get_error_message () + " , at line: " + String::num_int64 (json->get_error_line ()));
835
835
return false ;
836
836
}
837
837
Array database_array = json->get_data ();
@@ -917,7 +917,7 @@ bool SQLite::import_from_json(String import_path) {
917
917
int64_t number_of_rows = object.row_array .size ();
918
918
for (int64_t i = 0 ; i <= number_of_rows - 1 ; i++) {
919
919
if (object.row_array [i].get_type () != Variant::DICTIONARY) {
920
- UtilityFunctions::printerr (" GDSQLite Error: All elements of the Array should be of type Dictionary" );
920
+ ERR_PRINT (" GDSQLite Error: All elements of the Array should be of type Dictionary" );
921
921
return false ;
922
922
}
923
923
if (!insert_row (object.name , object.row_array [i])) {
@@ -1002,7 +1002,7 @@ bool SQLite::export_to_json(String export_path) {
1002
1002
1003
1003
std::ofstream ofs (char_path, std::ios::trunc );
1004
1004
if (ofs.fail ()) {
1005
- UtilityFunctions::printerr (" GDSQLite Error: " + String (std::strerror (errno)) + " (" + export_path + " )" );
1005
+ ERR_PRINT (" GDSQLite Error: " + String (std::strerror (errno)) + " (" + export_path + " )" );
1006
1006
return false ;
1007
1007
}
1008
1008
Ref<JSON> json;
@@ -1027,22 +1027,22 @@ bool SQLite::validate_json(const Array &database_array, std::vector<object_struc
1027
1027
/* Get the name of the object */
1028
1028
if (!temp_dict.has (" name" )) {
1029
1029
/* Did not find the necessary key! */
1030
- UtilityFunctions::printerr (" GDSQlite Error: Did not find required key \" name\" in the supplied json-file" );
1030
+ ERR_PRINT (" GDSQlite Error: Did not find required key \" name\" in the supplied json-file" );
1031
1031
return false ;
1032
1032
}
1033
1033
new_object.name = temp_dict[" name" ];
1034
1034
1035
1035
/* Extract the sql template for generating the object */
1036
1036
if (!temp_dict.has (" sql" )) {
1037
1037
/* Did not find the necessary key! */
1038
- UtilityFunctions::printerr (" GDSQlite Error: Did not find required key \" sql\" in the supplied json-file" );
1038
+ ERR_PRINT (" GDSQlite Error: Did not find required key \" sql\" in the supplied json-file" );
1039
1039
return false ;
1040
1040
}
1041
1041
new_object.sql = temp_dict[" sql" ];
1042
1042
1043
1043
if (!temp_dict.has (" type" )) {
1044
1044
/* Did not find the necessary key! */
1045
- UtilityFunctions::printerr (" GDSQlite Error: Did not find required key \" type\" in the supplied json-file" );
1045
+ ERR_PRINT (" GDSQlite Error: Did not find required key \" type\" in the supplied json-file" );
1046
1046
return false ;
1047
1047
}
1048
1048
if (temp_dict[" type" ] == String (" table" )) {
@@ -1053,10 +1053,10 @@ bool SQLite::validate_json(const Array &database_array, std::vector<object_struc
1053
1053
1054
1054
if (!temp_dict.has (" row_array" )) {
1055
1055
/* Did not find the necessary key! */
1056
- UtilityFunctions::printerr (" GDSQlite Error: Did not find required key \" row_array\" in the supplied json-file" );
1056
+ ERR_PRINT (" GDSQlite Error: Did not find required key \" row_array\" in the supplied json-file" );
1057
1057
return false ;
1058
1058
} else if (Variant (temp_dict[" row_array" ]).get_type () != Variant::ARRAY) {
1059
- UtilityFunctions::printerr (" GDSQlite Error: The value of the key \" row_array\" should consist of an array of rows" );
1059
+ ERR_PRINT (" GDSQlite Error: The value of the key \" row_array\" should consist of an array of rows" );
1060
1060
return false ;
1061
1061
}
1062
1062
new_object.row_array = temp_dict[" row_array" ];
@@ -1068,7 +1068,7 @@ bool SQLite::validate_json(const Array &database_array, std::vector<object_struc
1068
1068
new_object.type = TRIGGER;
1069
1069
} else {
1070
1070
/* Did not find the necessary key! */
1071
- UtilityFunctions::printerr (" GDSQlite Error: The value of key \" type\" is restricted to \" table\" , \" index\" , \" view\" or \" trigger\" " );
1071
+ ERR_PRINT (" GDSQlite Error: The value of key \" type\" is restricted to \" table\" , \" index\" , \" view\" or \" trigger\" " );
1072
1072
return false ;
1073
1073
}
1074
1074
@@ -1213,7 +1213,7 @@ int SQLite::enable_load_extension(const bool &p_onoff) {
1213
1213
rc = sqlite3_enable_load_extension (db, 0 );
1214
1214
}
1215
1215
if (rc != SQLITE_OK) {
1216
- UtilityFunctions::printerr (" GDSQLite Error: Extension loading cannot be enabled/disabled." );
1216
+ ERR_PRINT (" GDSQLite Error: Extension loading cannot be enabled/disabled." );
1217
1217
}
1218
1218
return rc;
1219
1219
}
@@ -1237,7 +1237,7 @@ int SQLite::load_extension(const String &p_path, const String &entrypoint) {
1237
1237
sqlite3_db_config (db, SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION, 0 , NULL );
1238
1238
1239
1239
if (rc != SQLITE_OK) {
1240
- UtilityFunctions::printerr (" GDSQLite Error: Unable to load extension: " + String::utf8 (zErrMsg));
1240
+ ERR_PRINT (" GDSQLite Error: Unable to load extension: " + String::utf8 (zErrMsg));
1241
1241
sqlite3_free (zErrMsg);
1242
1242
return rc;
1243
1243
}
0 commit comments