|
| 1 | +(* |
| 2 | + Copyright (c) Cloud Software Group, Inc. |
| 3 | +
|
| 4 | + This program is free software; you can redistribute it and/or modify |
| 5 | + it under the terms of the GNU Lesser General Public License as published |
| 6 | + by the Free Software Foundation; version 2.1 only. with the special |
| 7 | + exception on linking described in file LICENSE. |
| 8 | +
|
| 9 | + This program is distributed in the hope that it will be useful, |
| 10 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + GNU Lesser General Public License for more details. |
| 13 | + *) |
| 14 | + |
| 15 | +(** a version, derived from a string representation - see below *) |
| 16 | +type t |
| 17 | + |
| 18 | +(** A version string violates the supported syntax *) |
| 19 | +exception Format of string |
| 20 | + |
| 21 | +val of_string : string -> t |
| 22 | +(** Parse a version; may raise [Format]. A version is a sequence of |
| 23 | + unsigned integers separated by a dot; for axample "1.2.3" is a legal |
| 24 | + version. Must have at least one component. Examples: |
| 25 | + - 3 |
| 26 | + - 3.10 |
| 27 | + - 3.10.4 |
| 28 | + - 3.10.4.0.0 |
| 29 | + - 3.10.4.0.1 |
| 30 | + - 0 |
| 31 | + - 0.2 |
| 32 | + *) |
| 33 | + |
| 34 | +val to_string : t -> string |
| 35 | +(** represent a version as a string *) |
| 36 | + |
| 37 | +val compare : t -> t -> int |
| 38 | +(** Total order over versions; yields one of -1, 0, 1 as by convention. |
| 39 | + - 1.2.3 = 1.2.3.0 |
| 40 | + - 1.10.2 > 1.9.1 |
| 41 | + - 0.1.0.0 = 0.1 |
| 42 | + *) |
| 43 | + |
| 44 | +(* version equality relations *) |
| 45 | +val eq : t -> t -> bool |
| 46 | + |
| 47 | +val ge : t -> t -> bool |
| 48 | + |
| 49 | +val gt : t -> t -> bool |
| 50 | + |
| 51 | +val le : t -> t -> bool |
| 52 | + |
| 53 | +val lt : t -> t -> bool |
| 54 | + |
| 55 | +val ne : t -> t -> bool |
| 56 | + |
| 57 | +(* Validate the format of a version string *) |
| 58 | +val is_valid : string -> bool |
| 59 | + |
| 60 | +(* Operations over version strings for convenience. Each function may |
| 61 | + raise [Format] *) |
| 62 | +module String : sig |
| 63 | + val compare : string -> string -> int |
| 64 | + |
| 65 | + val ne : string -> string -> bool |
| 66 | + |
| 67 | + val eq : string -> string -> bool |
| 68 | + |
| 69 | + val le : string -> string -> bool |
| 70 | + |
| 71 | + val ge : string -> string -> bool |
| 72 | + |
| 73 | + val gt : string -> string -> bool |
| 74 | + |
| 75 | + val lt : string -> string -> bool |
| 76 | +end |
0 commit comments