ATSLIB/libats/stringbuf
This package implements string buffers that can grow or shrink.
A typical use of such a buffer is for turning a value into some
form of string representation (stringization).
Synopsis
vtypedef stringbuf = stringbuf_vtype
Synopsis
absvtype stringbuf_vtype = ptr
Synopsis
fun{} stringbuf$recapacitize (): int
Description
The value returned by this function determines whether the capacity of a
string buffer is allowed to be expanded automatically if needed.
Synopsis
overload stringbuf_make_nil with stringbuf_make_nil_int
overload stringbuf_make_nil with stringbuf_make_nil_size
Description
Given a size m, this function returns a string buffer of capacity m and
size 0.
Synopsis
fun{}
stringbuf_free (sbf: stringbuf):<!wrt> void
Description
This function frees a given string buffer.
Synopsis
fun{}
stringbuf_getfree_strnptr
(sbf: stringbuf, n: &size_t? >> size_t(n)):<!wrt> #[n:nat] strnptr(n)
Description
This function returns the string associated with a given string buffer
after freeing the buffer, and ot stores the length of the returned string
in its second (call-by-reference) parameter.
Synopsis
fun{}
stringbuf_get_size (sbf: !stringbuf):<> size_t
Description
Given a string buffer, this function returns its current size, that is, the
number of characters stored in the buffer.
Synopsis
fun{}
stringbuf_get_capacity (sbf: !stringbuf):<> size_t
Description
Given a string buffer, this function returns its current capacity, that is,
the maximal number of characters that can be stored in the buffer.
Synopsis
fun{}
stringbuf_insert_char (!stringbuf, x: charNZ): int
Description
This function inserts a non-null character into a given string buffer.
If the character is inserted, then 1 is returned. Otherwise, 0 is returned
(due to the buffer being full but not allowed to recapacitize).
Synopsis
fun{}
stringbuf_insert_string (!stringbuf, x: string): int
Description
This function inserts a string into a given string buffer.
If the string is inserted, then the length of the string is returned.
Otherwise, 0 is returned.
Synopsis
fun{}
stringbuf_insert_strlen{n:int} (!stringbuf, string(n), size_t(n)): int
Description
This function is a slight variant of stringbuf_insert_string.
Synopsis
fun{}
stringbuf_insert_bool (sbf: !stringbuf, x: bool): int
Description
Given a string buffer and a boolean, this function inserts a string
representation of the boolean into the buffer.
Synopsis
fun{}
stringbuf_insert_int (sbf: !stringbuf, x: int): int
Description
Given a string buffer and an integer, this function inserts a string
representation of the integer into the buffer.
Synopsis
fun{}
stringbuf_insert_uint (sbf: !stringbuf, x: uint): int
Description
This function is a slight variant of stringbuf_insert_int.
Synopsis
fun{}
stringbuf_insert_lint (sbf: !stringbuf, x: lint): int
Description
This function is a slight variant of stringbuf_insert_int.
Synopsis
fun{}
stringbuf_insert_ulint (sbf: !stringbuf, x: ulint): int
Description
This function is a slight variant of stringbuf_insert_int.
Synopsis
fun{}
stringbuf_reset_capacity
(sbf: !stringbuf, m2: sizeGte(1)):<!wrt> bool
Description
Given a string buffer and a size m2, this function resets the capacity of
the buffer to m2. Note that m2 is expected to be greater than or equal to
the current size of the buffer for otherwise this function returns false
to indicate the capacity of the buffer is not reset.
Synopsis
fun{}
stringbuf_truncate
(sbf: !stringbuf, n2: size_t):<!wrt> bool
Description
Given a stringbuf-value sbf and an integer n2, if n2 is less than the
current size of the buffer associated with sbf, then the function resets
the size of the buffer to n2. Otherwise, the function makes no change.
Synopsis
fun{}
stringbuf_truncout
(sbf: !stringbuf, n2: size_t):<!wrt> Strptr0
Description
This function is like stringbuf_trunout except that it returns
a linear string representing the truncated portion of a given stringbuf-value.
Synopsis
fun{}
stringbuf_truncout_all (sbf: !stringbuf):<!wrt> Strptr1
Description
This function is just the special case of stringbuf_truncout
where the second passed argument equals 0.