Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | s_expressions-enumeration_io: add a Value primitive with default |
|---|---|
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
a5f4c35865ab12bd345133d185a19201 |
| User & Date: | nat 2019-04-08 21:24:30.545 |
Context
|
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 | |
|
2017-07-10
| ||
| 20:33 | s_expressions-file_rw_tests: update to test Open_Or_Create primitives check-in: f3f5729400 user: nat tags: trunk | |
Changes
Changes to src/natools-s_expressions-enumeration_io.adb.
1 | ------------------------------------------------------------------------------ | | | 1 2 3 4 5 6 7 8 9 | ------------------------------------------------------------------------------ -- Copyright (c) 2015-2019, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- |
| ︙ | ︙ | |||
56 57 58 59 60 61 62 63 64 65 66 |
return To_Atom (Enum'Image (T));
end Image;
function Value (Data : Atom) return Enum is
begin
return Enum'Value (To_Image (Data));
end Value;
end Typed_IO;
end Natools.S_Expressions.Enumeration_IO;
| > > > > > > > > > | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
return To_Atom (Enum'Image (T));
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;
|
Changes to src/natools-s_expressions-enumeration_io.ads.
1 | ------------------------------------------------------------------------------ | | | 1 2 3 4 5 6 7 8 9 | ------------------------------------------------------------------------------ -- Copyright (c) 2015-2019, Natacha Porté -- -- -- -- Permission to use, copy, modify, and distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- |
| ︙ | ︙ | |||
36 37 38 39 40 41 42 43 44 45 46 |
package Typed_IO is
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
end Typed_IO;
end Natools.S_Expressions.Enumeration_IO;
| > > > > | 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
package Typed_IO is
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;
|