X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Futils.mli;h=c63db29b01e25c1adbd3c83d05587db34f40079a;hb=59f809a2c74294922d37657426a5eaf3f7694dcd;hp=0f6175140bac7e92577893c841365aea961cf71a;hpb=3e80e1ab9b032346a0961c3e925f1ef8adca1cc3;p=goals.git diff --git a/src/utils.mli b/src/utils.mli index 0f61751..c63db29 100644 --- a/src/utils.mli +++ b/src/utils.mli @@ -17,9 +17,21 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *) +val nprocs : unit -> int +(** Return the number of processors on the system. *) + val failwithf : ('a, unit, string, 'b) format4 -> 'a (** Like [failwith] but supports printf-like arguments. *) +val (//) : string -> string -> string +(** The {!Filename.concat} function. *) + +val is_directory : string -> bool +(** Return true iff parameter is a directory. *) + +val unique : unit -> int +(** Returns a unique number each time called. *) + val filter_map : ('a -> 'b option) -> 'a list -> 'b list (** [filter_map f l] applies [f] to every element of [l], filters out the [None] elements and returns the list of the arguments of @@ -28,3 +40,27 @@ val filter_map : ('a -> 'b option) -> 'a list -> 'b list val string_find : string -> string -> int (** [string_find str sub] finds the index of [sub] in [str]. If not found, returns -1. *) + +val split : string -> string -> string * string +(** [split sep str] splits [str] at the first occurrence of the + separator [sep], returning the part before and the part after. + If separator is not found, return the whole string and an + empty string. *) + +val nsplit : ?max:int -> string -> string -> string list +(** [nsplit ?max sep str] splits [str] into multiple strings at each + separator [sep]. + + As with the Perl split function, you can give an optional + [?max] parameter to limit the number of strings returned. The + final element of the list will contain the remainder of the + input string. *) + +val isspace : char -> bool +val triml : ?test:(char -> bool) -> string -> string +val trimr : ?test:(char -> bool) -> string -> string +val trim : ?test:(char -> bool) -> string -> string +(** Trim strings at left, right or both. *) + +val absolute_path : string -> string +(** Convert any path into an absolute path. *)