init: new label_last attribute for session routes

Fixes #2647
This commit is contained in:
Norman Feske 2018-01-19 19:22:06 +01:00
parent eff67d3131
commit 4619e2e84c
2 changed files with 11 additions and 3 deletions

View File

@ -16,6 +16,7 @@
<xs:attribute name="label" type="xs:string" />
<xs:attribute name="label_prefix" type="xs:string" />
<xs:attribute name="label_suffix" type="xs:string" />
<xs:attribute name="label_last" type="xs:string" />
<xs:attribute name="unscoped_label" type="xs:string" />
</xs:complexType>

View File

@ -69,12 +69,17 @@ namespace Init {
if (!service_matches)
return false;
typedef String<Session_label::capacity()> Label;
char const *unscoped_attr = "unscoped_label";
char const *label_last_attr = "label_last";
bool const route_depends_on_child_provided_label =
service_node.has_attribute("label") ||
service_node.has_attribute("label_prefix") ||
service_node.has_attribute("label_suffix");
service_node.has_attribute("label_suffix") ||
service_node.has_attribute(label_last_attr);
char const *unscoped_attr = "unscoped_label";
if (service_node.has_attribute(unscoped_attr)) {
/*
@ -84,10 +89,12 @@ namespace Init {
if (route_depends_on_child_provided_label)
warning("service node contains both scoped and unscoped label attributes");
typedef String<Session_label::capacity()> Label;
return label == service_node.attribute_value(unscoped_attr, Label());
}
if (service_node.has_attribute(label_last_attr))
return service_node.attribute_value(label_last_attr, Label()) == label.last_element();
if (!route_depends_on_child_provided_label)
return true;