text stringlengths 0 234 |
|---|
if B = null then B := new Node; B.Value := X; return; end if; |
if X < B.Value then |
Add(X, B.Left); |
elsif X > B.Value then |
Add(X, B.Right); |
end if; |
Function Definition: procedure Fib is |
Function Body: procedure PrintInt(N: Integer) is |
C: Integer := N rem 10; |
begin |
if N > 9 then PrintInt(N / 10); end if; |
Put(Character'Val(48 + C)); |
Function Definition: procedure somme is |
Function Body: tmp : integer; |
begin fib(n-2); tmp := f; fib(n-1); f := f + Tmp; end; |
begin |
if n <= 1 then f := N; else somme; end if; |
Function Definition: procedure Clear is |
Function Body: begin |
null; |
end Clear; |
-- ------------------------------ |
-- Generate a random bitstream. |
-- ------------------------------ |
procedure Generate_Id (Rand : out Ada.Streams.Stream_Element_Array) is |
use Ada.Streams; |
use Interfaces; |
Size : constant Stream_Element_Offset := Rand'Length / 4; |
begin |
-- Generate the random sequence. |
for I in 0 .. Size - 1 loop |
declare |
Value : constant Unsigned_32 := Id_Random.Random (Random); |
begin |
Rand (4 * I) := Stream_Element (Value and 16#0FF#); |
Rand (4 * I + 1) := Stream_Element (Shift_Right (Value, 8) and 16#0FF#); |
Rand (4 * I + 2) := Stream_Element (Shift_Right (Value, 16) and 16#0FF#); |
Rand (4 * I + 3) := Stream_Element (Shift_Right (Value, 24) and 16#0FF#); |
Function Definition: procedure Dispatch (Server : in Rest_Servlet; |
Function Body: Method : in Method_Type; |
Request : in out Requests.Request'Class; |
Response : in out Responses.Response'Class) is |
pragma Unreferenced (Server); |
begin |
if not Request.Has_Route then |
Response.Set_Status (Responses.SC_NOT_FOUND); |
Response.Set_Committed; |
return; |
end if; |
declare |
Route : constant Routes.Route_Type_Accessor := Request.Get_Route; |
begin |
if not (Route in Routes.Servlets.Rest.API_Route_Type'Class) then |
Response.Set_Status (Responses.SC_NOT_FOUND); |
Response.Set_Committed; |
return; |
end if; |
declare |
Api : constant access Routes.Servlets.Rest.API_Route_Type'Class |
:= Routes.Servlets.Rest.API_Route_Type'Class (Route.Element.all)'Access; |
Desc : constant Descriptor_Access := Api.Descriptors (Method); |
Output : constant Streams.Print_Stream := Response.Get_Output_Stream; |
Mime : Mime_Access; |
begin |
if Desc = null then |
Response.Set_Status (Responses.SC_NOT_FOUND); |
Response.Set_Committed; |
return; |
end if; |
Mime := Desc.Get_Mime_Type (Request); |
if Mime = null or else Mime.all = Util.Http.Mimes.Json then |
declare |
Stream : Streams.JSON.Print_Stream; |
begin |
Streams.JSON.Initialize (Stream, Output); |
Response.Set_Content_Type ("application/json; charset=utf-8"); |
Api.Descriptors (Method).Dispatch (Request, Response, Stream); |
Function Definition: function Get_Permission (Handler : in Descriptor) |
Function Body: return Security.Permissions.Permission_Index is |
begin |
return Handler.Permission; |
end Get_Permission; |
-- ------------------------------ |
-- Get the mime type selected for the operation. |
-- ------------------------------ |
function Get_Mime_Type (Handler : in Descriptor; |
Req : in Servlet.Rest.Request'Class) return Mime_Access is |
Accept_Header : constant String := Req.Get_Header ("Accept"); |
begin |
if Handler.Mimes /= null then |
return Util.Http.Headers.Get_Accepted (Accept_Header, Handler.Mimes.all); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.