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 on 2019-04-08 21:24:30 |
Other Links: | manifest | tags |
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
Modified src/natools-s_expressions-enumeration_io.adb from [c829293ba9] to [bb31d4989d].
1 | 1 2 3 4 5 6 7 8 9 | - + | ------------------------------------------------------------------------------ |
︙ | |||
56 57 58 59 60 61 62 63 64 65 66 | 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; |
Modified src/natools-s_expressions-enumeration_io.ads from [5a8174aa31] to [91a3fb55d8].
1 | 1 2 3 4 5 6 7 8 9 | - + | ------------------------------------------------------------------------------ |
︙ | |||
36 37 38 39 40 41 42 43 44 45 46 | 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; |