mirror of
https://github.com/Relintai/rcpp_framework.git
synced 2025-05-06 17:51:36 +02:00
Added get_parent_webnode, get_full_uri, and get_full_uri_parent helpers to WebNode.
This commit is contained in:
parent
53238c1265
commit
65892ddd5a
@ -22,6 +22,35 @@ void WebNode::set_uri_segment(const String &val) {
|
|||||||
_uri_segment = val;
|
_uri_segment = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String WebNode::get_full_uri(const bool slash_at_the_end) {
|
||||||
|
if (slash_at_the_end) {
|
||||||
|
return get_full_uri_parent(true) + _uri_segment + '/';
|
||||||
|
} else {
|
||||||
|
return get_full_uri_parent(true) + _uri_segment;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String WebNode::get_full_uri_parent(const bool slash_at_the_end) {
|
||||||
|
String uri = "/";
|
||||||
|
|
||||||
|
WebNode *n = get_parent_webnode();
|
||||||
|
|
||||||
|
while (n) {
|
||||||
|
if (n->_uri_segment == "" || n->_uri_segment == '/') {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
uri = "/" + n->_uri_segment + uri;
|
||||||
|
|
||||||
|
n = n->get_parent_webnode();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!slash_at_the_end) {
|
||||||
|
uri.pop_back();
|
||||||
|
}
|
||||||
|
|
||||||
|
return uri;
|
||||||
|
}
|
||||||
|
|
||||||
Settings *WebNode::get_settings() {
|
Settings *WebNode::get_settings() {
|
||||||
if (_settings) {
|
if (_settings) {
|
||||||
return _settings;
|
return _settings;
|
||||||
@ -147,6 +176,10 @@ WebNode *WebNode::get_root() {
|
|||||||
return s->get_web_root();
|
return s->get_web_root();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WebNode *WebNode::get_parent_webnode() {
|
||||||
|
return Object::cast_to<WebNode>(get_parent());
|
||||||
|
}
|
||||||
|
|
||||||
WebNode::WebNode() :
|
WebNode::WebNode() :
|
||||||
Node() {
|
Node() {
|
||||||
// should look this up in parents when parented (and node parenting is implemented)
|
// should look this up in parents when parented (and node parenting is implemented)
|
||||||
|
@ -22,6 +22,9 @@ public:
|
|||||||
String get_uri_segment();
|
String get_uri_segment();
|
||||||
void set_uri_segment(const String &val);
|
void set_uri_segment(const String &val);
|
||||||
|
|
||||||
|
virtual String get_full_uri(const bool slash_at_the_end = true);
|
||||||
|
virtual String get_full_uri_parent(const bool slash_at_the_end = true);
|
||||||
|
|
||||||
Settings *get_settings();
|
Settings *get_settings();
|
||||||
void set_settings(Settings *settings);
|
void set_settings(Settings *settings);
|
||||||
|
|
||||||
@ -50,6 +53,7 @@ public:
|
|||||||
|
|
||||||
WebServer *get_server();
|
WebServer *get_server();
|
||||||
WebNode *get_root();
|
WebNode *get_root();
|
||||||
|
WebNode *get_parent_webnode();
|
||||||
|
|
||||||
WebNode();
|
WebNode();
|
||||||
~WebNode();
|
~WebNode();
|
||||||
|
Loading…
Reference in New Issue
Block a user