text
stringlengths 0
234
|
|---|
Current := Current.Next_Route;
|
end loop;
|
-- Add before the
|
when EXT_MATCH =>
|
while Current /= null loop
|
if not (Current.all in Path_Node_Type'Class)
|
and then not (Current.all in Param_Node_Type'Class)
|
and then not (Current.all in EL_Node_Type'Class)
|
then
|
exit;
|
end if;
|
Previous := Current;
|
Current := Current.Next_Route;
|
end loop;
|
when WILDCARD_MATCH =>
|
while Current /= null loop
|
Previous := Current;
|
Current := Current.Next_Route;
|
end loop;
|
when others =>
|
null;
|
end case;
|
if Previous /= null then
|
Node.Next_Route := Previous.Next_Route;
|
Previous.Next_Route := Node;
|
else
|
Node.Next_Route := Parent.Children;
|
Parent.Children := Node;
|
end if;
|
end Insert;
|
-- ------------------------------
|
-- Add a route associated with the given path pattern. The pattern is split into components.
|
-- Some path components can be a fixed string (/home) and others can be variable.
|
-- When a path component is variable, the value can be retrieved from the route context.
|
-- Once the route path is created, the <tt>Process</tt> procedure is called with the route
|
-- reference.
|
-- ------------------------------
|
procedure Add_Route (Router : in out Router_Type;
|
Pattern : in String;
|
ELContext : in EL.Contexts.ELContext'Class;
|
Process : not null access procedure (Route : in out Route_Type_Ref)) is
|
First : Natural := Pattern'First;
|
Pos : Natural;
|
Node : Route_Node_Access := Router.Route.Children;
|
Match : Route_Match_Type := NO_MATCH;
|
New_Path : Path_Node_Access;
|
Parent : Route_Node_Access := Router.Route'Unchecked_Access;
|
Parent2 : Route_Node_Access;
|
Found : Boolean;
|
begin
|
Log.Info ("Adding route {0}", Pattern);
|
loop
|
-- Ignore consecutive '/'.
|
while First <= Pattern'Last and then Pattern (First) = '/' loop
|
First := First + 1;
|
end loop;
|
-- Find the path component's end.
|
Pos := Util.Strings.Index (Pattern, '/', First);
|
if Pos = 0 then
|
Pos := Pattern'Last;
|
else
|
Pos := Pos - 1;
|
end if;
|
if First > Pattern'Last then
|
Found := False;
|
-- Find an exact match for this component.
|
while Node /= null loop
|
if Node.all in Path_Node_Type'Class then
|
Match := Node.Matches (Pattern (First .. Pos), Pos = Pattern'Last);
|
if Match = YES_MATCH then
|
Parent := Node;
|
Node := Node.Children;
|
Found := True;
|
exit;
|
end if;
|
end if;
|
Node := Node.Next_Route;
|
end loop;
|
-- Add a path node matching the component at beginning of the children list.
|
-- (before the Param_Node and EL_Node instances if any).
|
if not Found then
|
New_Path := new Path_Node_Type (Len => 0);
|
Insert (Parent, New_Path.all'Access, YES_MATCH);
|
Parent := Parent.Children;
|
end if;
|
elsif Pattern (First) = '#' then
|
declare
|
E : EL_Node_Access;
|
begin
|
Found := False;
|
-- Find the EL_Node that have the same EL expression.
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.