Added bindings for WebServerCookie and adde dit to the build.

This commit is contained in:
Relintai 2022-06-26 17:03:06 +02:00
parent 09ef29804e
commit a92f8dd5c0
5 changed files with 109 additions and 11 deletions

View File

@ -9,6 +9,7 @@ sources = [
"register_types.cpp",
"http/http_server_enums.cpp",
"http/web_server_cookie.cpp",
"html/html_builder_bind.cpp",
]

View File

@ -14,6 +14,7 @@ def get_doc_classes():
#"WorldArea",
"HTTPServerEnums",
"WebServerCookie",
"HTMLBuilder",
"HTMLTag",
]

View File

@ -1,10 +1,49 @@
#include "cookie.h"
#include "web_server_cookie.h"
WebServerCookie::WebServerCookie(const String &p_key, const String &p_value) {
http_only = true;
secure = false;
String WebServerCookie::get_domain() {
return domain;
}
void WebServerCookie::set_domain(const String &val) {
domain = val;
}
String WebServerCookie::get_path() {
return path;
}
void WebServerCookie::set_path(const String &val) {
path = val;
}
String WebServerCookie::get_key() {
return key;
}
void WebServerCookie::set_key(const String &val) {
key = val;
}
String WebServerCookie::get_value() {
return value;
}
void WebServerCookie::set_value(const String &val) {
value = val;
}
bool WebServerCookie::get_http_only() {
return http_only;
}
void WebServerCookie::set_http_only(const bool val) {
http_only = val;
}
bool WebServerCookie::get_secure() {
return secure;
}
void WebServerCookie::set_secure(const bool val) {
secure = val;
}
void WebServerCookie::set_data(const String &p_key, const String &p_value) {
key = p_key;
value = p_value;
}
@ -16,3 +55,31 @@ WebServerCookie::WebServerCookie() {
WebServerCookie::~WebServerCookie() {
}
void WebServerCookie::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_domain"), &WebServerCookie::get_domain);
ClassDB::bind_method(D_METHOD("set_domain", "val"), &WebServerCookie::set_domain);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "domain"), "set_domain", "get_domain");
ClassDB::bind_method(D_METHOD("get_path"), &WebServerCookie::get_path);
ClassDB::bind_method(D_METHOD("set_path", "val"), &WebServerCookie::set_path);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "path"), "set_path", "get_path");
ClassDB::bind_method(D_METHOD("get_key"), &WebServerCookie::get_key);
ClassDB::bind_method(D_METHOD("set_key", "val"), &WebServerCookie::set_key);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "key"), "set_key", "get_key");
ClassDB::bind_method(D_METHOD("get_value"), &WebServerCookie::get_value);
ClassDB::bind_method(D_METHOD("set_value", "val"), &WebServerCookie::set_value);
ADD_PROPERTY(PropertyInfo(Variant::STRING, "value"), "set_value", "get_value");
ClassDB::bind_method(D_METHOD("get_http_only"), &WebServerCookie::get_http_only);
ClassDB::bind_method(D_METHOD("set_http_only", "val"), &WebServerCookie::set_http_only);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "http_only"), "set_http_only", "get_http_only");
ClassDB::bind_method(D_METHOD("get_secure"), &WebServerCookie::get_secure);
ClassDB::bind_method(D_METHOD("set_secure", "val"), &WebServerCookie::set_secure);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "secure"), "set_secure", "get_secure");
ClassDB::bind_method(D_METHOD("set_data", "key", "value"), &WebServerCookie::set_data);
}

View File

@ -1,10 +1,37 @@
#ifndef COOKIE_H
#define COOKIE_H
#ifndef WEB_SERVER_COOKIE_H
#define WEB_SERVER_COOKIE_H
#include "core/string.h"
#include "core/ustring.h"
#include "core/reference.h"
class WebServerCookie : public Reference {
GDCLASS(WebServerCookie, Reference);
class WebServerCookie {
public:
String get_domain();
void set_domain(const String &val);
String get_path();
void set_path(const String &val);
String get_key();
void set_key(const String &val);
String get_value();
void set_value(const String &val);
bool get_http_only();
void set_http_only(const bool val);
bool get_secure();
void set_secure(const bool val);
void set_data(const String &p_key, const String &p_value);
WebServerCookie();
~WebServerCookie();
//todo date
String domain;
String path;
@ -13,9 +40,8 @@ public:
bool http_only;
bool secure;
WebServerCookie();
WebServerCookie(const String &p_key, const String &p_value);
~WebServerCookie();
protected:
static void _bind_methods();
};
#endif

View File

@ -26,10 +26,13 @@ SOFTWARE.
#include "html/html_builder_bind.h"
#include "http/http_server_enums.h"
#include "http/web_server_cookie.h"
void register_web_types() {
ClassDB::register_class<HTTPServerEnums>();
ClassDB::register_class<WebServerCookie>();
ClassDB::register_class<_HTMLBuilder>();
ClassDB::register_class<_HTMLTag>();
}