Natools

Check-in [c7fcf14363]
Login
Overview
Comment:s_expressions-enumeration_io: improve argument names of the new Value primitive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c7fcf143637021b06086b401ad6dde990ae2bbf3
User & Date: nat on 2019-04-09 18:56:41
Other Links: manifest | tags
Context
2019-04-10
19:49
s_expressions-enumeration_io-tests: test Value of invalid enum atoms check-in: b63c559d17 user: nat tags: trunk
2019-04-09
18:56
s_expressions-enumeration_io: improve argument names of the new Value primitive check-in: c7fcf14363 user: nat tags: trunk
2019-04-08
21:24
s_expressions-enumeration_io: add a Value primitive with default check-in: a5f4c35865 user: nat tags: trunk
Changes

Modified src/natools-s_expressions-enumeration_io.adb from [bb31d4989d] to [5e239acf77].

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
      end Image;

      function Value (Data : Atom) return Enum is
      begin
         return Enum'Value (To_Image (Data));
      end Value;

      function Value (Data : Atom; Default : Enum) return Enum is
         Img : constant String := To_Image (Data);
      begin
         return Enum'Value (Img);
      exception
         when Constraint_Error =>
            return Default;
      end Value;

   end Typed_IO;

end Natools.S_Expressions.Enumeration_IO;







|





|





57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
      end Image;

      function Value (Data : Atom) return Enum is
      begin
         return Enum'Value (To_Image (Data));
      end Value;

      function Value (Data : Atom; Fallback : Enum) return Enum is
         Img : constant String := To_Image (Data);
      begin
         return Enum'Value (Img);
      exception
         when Constraint_Error =>
            return Fallback;
      end Value;

   end Typed_IO;

end Natools.S_Expressions.Enumeration_IO;

Modified src/natools-s_expressions-enumeration_io.ads from [91a3fb55d8] to [51b790e0e4].

37
38
39
40
41
42
43
44
45
46
47
48
49
50

      function Image (T : Enum) return Atom;
         --  Convert an enumeration value into an atom

      function Value (Data : Atom) return Enum;
         --  Convert an atom into an enumeration value

      function Value (Data : Atom; Default : Enum) return Enum;
         --  Convert an atom into an enumeration value,
         --  with a default value on invalid atom images

   end Typed_IO;

end Natools.S_Expressions.Enumeration_IO;







|

|




37
38
39
40
41
42
43
44
45
46
47
48
49
50

      function Image (T : Enum) return Atom;
         --  Convert an enumeration value into an atom

      function Value (Data : Atom) return Enum;
         --  Convert an atom into an enumeration value

      function Value (Data : Atom; Fallback : Enum) return Enum;
         --  Convert an atom into an enumeration value,
         --  with a fallback value on invalid atom images

   end Typed_IO;

end Natools.S_Expressions.Enumeration_IO;