summaryrefslogtreecommitdiff
path: root/stdlib/buffer.mli
diff options
context:
space:
mode:
authorPierre Weis <Pierre.Weis@inria.fr>2003-04-28 08:13:20 +0000
committerPierre Weis <Pierre.Weis@inria.fr>2003-04-28 08:13:20 +0000
commite9cda5216baa14984ea52887d1d45a16f3bcecc7 (patch)
treed3ee40faaf2344fea3e7fc6fd005e481b4f41eab /stdlib/buffer.mli
parent55edf60997a566cc967a592beee26e2241b9afcf (diff)
downloadocaml-e9cda5216baa14984ea52887d1d45a16f3bcecc7.tar.gz
Addition of function add_substitute for adding strings to buffer with
variable names substitution via a function mapping. git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@5516 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
Diffstat (limited to 'stdlib/buffer.mli')
-rw-r--r--stdlib/buffer.mli16
1 files changed, 14 insertions, 2 deletions
diff --git a/stdlib/buffer.mli b/stdlib/buffer.mli
index 849f489ffe..02451c51dd 100644
--- a/stdlib/buffer.mli
+++ b/stdlib/buffer.mli
@@ -25,14 +25,14 @@ type t
val create : int -> t
(** [create n] returns a fresh buffer, initially empty.
The [n] parameter is the initial size of the internal string
- that holds the buffer contents. That string is automatically
+ that holds the buffer contents. That string is automatically
reallocated when more than [n] characters are stored in the buffer,
but shrinks back to [n] characters when [reset] is called.
For best performance, [n] should be of the same order of magnitude
as the number of characters that are expected to be stored in
the buffer (for instance, 80 for a buffer that holds one output
line). Nothing bad will happen if the buffer grows beyond that
- limit, however. In doubt, take [n = 16] for instance.
+ limit, however. In doubt, take [n = 16] for instance.
If [n] is not between 1 and {!Sys.max_string_length}, it will
be clipped to that interval. *)
@@ -63,6 +63,18 @@ val add_substring : t -> string -> int -> int -> unit
(** [add_substring b s ofs len] takes [len] characters from offset
[ofs] in string [s] and appends them at the end of the buffer [b]. *)
+val add_substitute : t -> (string -> string) -> string -> unit
+(** [add_substitute b f s] appends the string [s] at the end of the buffer [b]
+ with substitution: variable names in [s] get replaced by their image by [f].
+ A variable name is defined as a non empty sequence of alphanumeric or [_]
+ characters (or alternatively an arbitrary sequence of characters
+ enclosed by a pair of matching parentheses or curly brackets),
+ that immediately follows a (non-escaped) [$] character;
+ an escaped [$] character is a [$] that immediately follows
+ a backslash character; it then stands for a plain [$].
+ Raise [Not_found] if the closing character of a parenthesized variable
+ cannot be found. *)
+
val add_buffer : t -> t -> unit
(** [add_buffer b1 b2] appends the current contents of buffer [b2]
at the end of buffer [b1]. [b2] is not modified. *)