Skip to content

Commit 7913c28

Browse files
committed
basic structure
1 parent e701617 commit 7913c28

18 files changed

+663
-88
lines changed

LICENSE

-21
This file was deleted.

SCsub

+20-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,25 @@
22
# SCsub
33

44

5+
56
Import('env')
7+
mysql_env = env.Clone()
8+
9+
10+
sources = [
11+
"register_types.cpp",
12+
"scr/helpers.cpp",
13+
"scr/sql_conn.cpp",
14+
"scr/mysql.cpp",
15+
16+
]
17+
18+
19+
mysql_env.Prepend(CPPPATH=["/media/cleber/DATA/COMPILATIONS/dependencies/boost/libs/mysql/include/boost"])
20+
21+
env.Append(LIBPATH=["#/media/cleber/DATA/COMPILATIONS/dependencies/boost/stage/lib"])
22+
env.Append(LIBPATH=['#/media/cleber/DATA/COMPILATIONS/godot_modules/mysql/deb/ssl/lib64'])
23+
env.Append(LIBS=["libcrypto", "libssl"])
24+
625

7-
env.add_source_files(env.modules_sources, "*.cpp")
26+
mysql_env.add_source_files(env.modules_sources, sources)

config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def get_doc_path():
1515

1616
def get_doc_classes():
1717
return [
18-
"mysql",
18+
"MySQL",
1919
]
2020

2121

mysql.cpp

-17
This file was deleted.

mysql.h

-38
This file was deleted.

mysql_test/project.godot

+2
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@ config_version=5
1111
[application]
1212

1313
config/name="Mysql 3 Tests"
14+
config/tags=PackedStringArray("test")
15+
run/main_scene="res://teste1/teste1.tscn"
1416
config/features=PackedStringArray("4.1", "Double Precision", "Forward Plus")
1517
config/icon="res://icon.svg"

mysql_test/teste1/teste1.gd

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
extends Node
2+
3+
var mysql = MySQL.new()
4+
5+
func _ready():
6+
var mysql = MySQL.new()
7+
8+
mysql.teste()
9+
10+
get_tree().quit()

mysql_test/teste1/teste1.tscn

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[gd_scene load_steps=2 format=3 uid="uid://c83ftcb0tjjsd"]
2+
3+
[ext_resource type="Script" path="res://teste1/teste1.gd" id="1_bkkp4"]
4+
5+
[node name="teste1" type="Node"]
6+
script = ExtResource("1_bkkp4")

notes.txt

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
int *pnum; // Declara o ponteiro
3+
int num; // Declara o valor
4+
5+
num = 10;
6+
pnum = &num
7+
&num // Endereço
8+
9+
*pnum; //Imprime o
10+
11+
delete pnum; OBRIGATÓRIO
12+
13+
14+
15+
Trabalhando com unique_ptr:
16+
https://learn.microsoft.com/pt-br/cpp/cpp/how-to-create-and-use-unique-ptr-instances?view=msvc-170
17+
18+
19+
new_connection = Instancia nova conexão
20+
21+
22+
set_credeltials = configura a conexão
23+
24+
get/set_param = Mudaparametros
25+
26+
// std::string std_string = gdt_data.utf8().get_data();
27+
28+
29+
mysql uses: boost::mysql::string_view AKA boost::core::basic_string_view<char>
30+
Godot uses: CharType
31+
32+
Godot::String >> boost::core::basic_string_view<char>
33+
boost::core::basic_string_view<char> >> Godot::String
34+
35+
/*
36+
Conexão:
37+
todo o contexto de conexão entra aqui
38+
39+
40+
Principais membros:
41+
mysql::handshake_params
42+
mysql::tcp_ssl_connection conn
43+
44+
Funções:
45+
set/get param
46+
set_credential
47+
connect
48+
disconnect
49+
get_status
50+
get_meta
51+
52+
53+
mysql:
54+
todas as operaç~pes são feitas daqui
55+
querty
56+
prep_stmt querty
57+
58+
59+
60+
result:
61+
Os dados e meta dados das queruties ficarão aqui
62+
63+
[get]
64+
affected_rows
65+
has_value
66+
info
67+
last_insert_id
68+
meta
69+
rows
70+
warning_count
71+
72+
73+
Error MySQL::set_credentials(String conn_name, String hostname, String user, String password, String schema, int port){
74+
ERR_FAIL_COND_V_MSG(connections_holder[conn_name].set_param("hostname", hostname), ERR_INVALID_PARAMETER, vformat("%s is an invalid parameter: hostname "));
75+
ERR_FAIL_COND_V_MSG(connections_holder[conn_name].set_param("username", user), ERR_INVALID_PARAMETER, vformat("%s is an invalid parameter: user "));
76+
ERR_FAIL_COND_V_MSG(connections_holder[conn_name].set_param("password", password), ERR_INVALID_PARAMETER, vformat("%s is an invalid parameter: password"));
77+
ERR_FAIL_COND_V_MSG(connections_holder[conn_name].set_param("database", schema), ERR_INVALID_PARAMETER, vformat("%s is an invalid parameter: schema"));
78+
ERR_FAIL_COND_V_MSG(connections_holder[conn_name].set_param("port", port), ERR_INVALID_PARAMETER, vformat("%s is an invalid parameter: port"));
79+
return OK;
80+
}
81+
*/

register_types.cpp

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
1-
/* register_types.cpp */
1+
/* register_types.cpp MySQL */
2+
23

34
#include "register_types.h"
45

56
#include "core/object/class_db.h"
6-
#include "mysql.h"
7+
#include "scr/helpers.h"
8+
#include "scr/sql_conn.h"
9+
#include "scr/mysql.h"
10+
11+
712

813
void initialize_mysql_module(ModuleInitializationLevel p_level) {
9-
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
10-
return;
11-
}
12-
ClassDB::register_class<MySQL>();
14+
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
15+
return;
16+
}
17+
ClassDB::register_class<MySQL>();
18+
ClassDB::register_class<Helpers>();
1319
}
1420

1521
void uninitialize_mysql_module(ModuleInitializationLevel p_level) {
16-
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
17-
return;
18-
}
22+
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
23+
return;
24+
}
1925

2026
}

register_types.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* register_types.h */
22

3-
#include "modules/register_mysql_types.h"
3+
#include "modules/register_module_types.h"
44

55
void initialize_mysql_module(ModuleInitializationLevel p_level);
66
void uninitialize_mysql_module(ModuleInitializationLevel p_level);
7+

scr/helpers.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/* helpers.cpp */
2+
3+
4+
#include "sql_conn.h"
5+
#include <locale>
6+
7+

scr/helpers.h

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* helpers.h */
2+
3+
#ifndef HELPERS_H
4+
#define HELPERS_H
5+
6+
7+
#include "core/object/ref_counted.h"
8+
#include "core/core_bind.h"
9+
10+
#include <boost/mysql.hpp>
11+
#include <boost/asio/io_context.hpp>
12+
#include <boost/asio/ssl/context.hpp>
13+
#include <boost/system/system_error.hpp>
14+
#include <boost/mysql/ssl_mode.hpp>
15+
#include <boost/mysql/connection.hpp>
16+
17+
#include <boost/mysql/string_view.hpp>
18+
#include <boost/mysql/buffer_params.hpp>
19+
#include <boost/mysql/handshake_params.hpp>
20+
21+
#include <iostream>
22+
#include <string>
23+
#include <map>
24+
#include <memory>
25+
26+
27+
//using namespace boost::mysql;
28+
29+
30+
31+
32+
//#pragma once
33+
34+
class Helpers : public RefCounted {
35+
GDCLASS(Helpers, RefCounted);
36+
37+
};
38+
39+
#endif // HELPERS_H
40+
41+
42+

0 commit comments

Comments
 (0)