Commit b3254dcbe8651bb63cc91b71934155fd560bf621
1 parent
0fc61cbc
add some constructor helper for version and db_version
Showing
2 changed files
with
23 additions
and
0 deletions
Show diff stats
database/db_version.anubis
| @@ -24,6 +24,16 @@ public type DB_Version: | @@ -24,6 +24,16 @@ public type DB_Version: | ||
| 24 | . | 24 | . |
| 25 | 25 | ||
| 26 | public define DB_Version | 26 | public define DB_Version |
| 27 | + db_version | ||
| 28 | + ( | ||
| 29 | + String version_str, | ||
| 30 | + String hash | ||
| 31 | + )= | ||
| 32 | + db_version(version(version_str), hash) | ||
| 33 | +. | ||
| 34 | + | ||
| 35 | + | ||
| 36 | +public define DB_Version | ||
| 27 | db_v_0 = | 37 | db_v_0 = |
| 28 | db_version(version(0), "") | 38 | db_version(version(0), "") |
| 29 | . | 39 | . |
types/version.anubis
| @@ -16,6 +16,8 @@ public type Version: | @@ -16,6 +16,8 @@ public type Version: | ||
| 16 | ) | 16 | ) |
| 17 | . | 17 | . |
| 18 | 18 | ||
| 19 | +public define Maybe(Version) to_Version(String version_string). | ||
| 20 | + | ||
| 19 | public define Version | 21 | public define Version |
| 20 | version( | 22 | version( |
| 21 | Word8 a, | 23 | Word8 a, |
| @@ -27,6 +29,17 @@ public define Version | @@ -27,6 +29,17 @@ public define Version | ||
| 27 | version( word32(word16(d, c), word16(b, a))) | 29 | version( word32(word16(d, c), word16(b, a))) |
| 28 | . | 30 | . |
| 29 | 31 | ||
| 32 | +public define Version | ||
| 33 | + version | ||
| 34 | + ( | ||
| 35 | + String version_str | ||
| 36 | + )= | ||
| 37 | + if to_Version(version_str) is | ||
| 38 | + { | ||
| 39 | + failure then version(0), | ||
| 40 | + success(_version) then _version | ||
| 41 | + } | ||
| 42 | +. | ||
| 30 | 43 | ||
| 31 | define Maybe(Version) | 44 | define Maybe(Version) |
| 32 | convert_digits_to_Version | 45 | convert_digits_to_Version |