Guest User

essai.adb

a guest
May 11th, 2026
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 1.86 KB | None | 0 0
  1. pragma Ada_2022;
  2. with tuppleSpacePackage.RealTupples, Ada.Strings.Unbounded, Ada.Text_IO;
  3. use tuppleSpacePackage.RealTupples,
  4. tuppleSpacePackage, Ada.Strings.Unbounded, Ada.Text_IO;
  5. procedure Essai is
  6.     A, B: Unbounded_String;
  7.     T: String_String_Tupple;
  8.     Z: Integer_Positive_String_Tupple;
  9.     I: Integer;
  10.     P: Positive;
  11.     F: Unbounded_String;
  12.     Space: RealTuppleSpace;
  13.     type TestType is new tuppleSpacePackage.Tupple with record
  14.         A: String (1..10) := (others => ' ');
  15.         B: Integer := -10;
  16.     end record;
  17.     overriding procedure Copy_Into (A: Tupple'Class; B: out TestType);
  18.     procedure Decode (T: TestType; A: out String; B: out Integer) is
  19.     begin
  20.         if A'Length >= 10 then
  21.             A(A'First..A'First+9) := T.A;
  22.         else
  23.             A := T.A(T.A'First..T.A'First+A'Length-1);
  24.         end if;
  25.         B := T.B;
  26.     end Decode;
  27.     function Encode (A: String; B: Integer) return TestType is ("1234567890", B);
  28.     procedure Copy_Into (A: Tupple'Class; B: out TestType) is
  29.     begin
  30.         B := TestType(A);
  31.     end Copy_Into;
  32.     E: Testtype;
  33. begin
  34.     Space.Out_Operation (Encode ("111", "111"));
  35.     Space.Out_Operation (Encode (-3,4, "Text"));
  36.     Space.In_Operation (T);
  37.     Decode (T, A, B);
  38.     Put_line(To_String(A) & " " & To_string(B));
  39.     begin
  40.         Space.INP_Operation (T);
  41.     exception when E: tuppleSpacePackage.No_Immediate_Message =>
  42.         Put_line ("Caught");
  43.     end;
  44.     begin
  45.         Space.RDP_Operation (T);
  46.     exception when E: tuppleSpacePackage.No_Immediate_Message =>
  47.         Put_line ("Caught");
  48.     end;
  49.     Space.In_Operation (Z);
  50.     Space.Out_Operation (Encode ("222", "222"));
  51.     Space.Out_Operation (Encode ("aaa", "aaa"));
  52.     Space.In_Operation (T);
  53.     Decode (T, A, B);
  54.     Put_line(To_String(A) & " " & To_string(B));
  55.     Space.In_Operation (T);
  56.     Decode (T, A, B);
  57.     Put_line(To_String(A) & " " & To_string(B));
  58.     Decode (Z, I, P, F);
  59.     Put_line (I'Image & P'Image & " " & To_String(F));
  60.     Space.Out_Operation (Encode("je ne sai", -48));
  61. end Essai;
Advertisement
Add Comment
Please, Sign In to add comment