MMgr v2.3.0
Zero-heap memory manager in C11. One borrowed buffer, carved by asserted offset.
Loading...
Searching...
No Matches
verba_scribo — text and number writing

Data Structures

struct  VerbaLinea
 A line written into out, at bytes so far, and passed to flush as it fills. More...
struct  VerbaTextusCfg
 Arguments for the entries that write text into a buffer. More...
struct  VerbaScriboTextusNs
 Type of the verba_textus dispatch table. More...
struct  VerbaLitteraCfg
 Arguments for the entries that write one character. More...
struct  VerbaScriboLitteraNs
 Type of the verba_littera dispatch table. More...
struct  VerbaNumerusCfg
 Arguments for the entries that write an integer. More...
struct  VerbaScriboNumerusNs
 Type of the verba_numerus dispatch table. More...
struct  VerbaFractioCfg
 Arguments for the entries that write a double. More...
struct  VerbaScriboFractioNs
 Type of the verba_fractio dispatch table. More...
struct  VerbaFinisCfg
 Arguments for the entries that write the buffer itself, with no value to place in it. More...
struct  VerbaScriboFinisNs
 Type of the verba_finis dispatch table. More...

Macros

#define MMGR_G_MAX_SIG
 Expands to 18u, the most significant digits mmgr_verba_g will retain.
#define MMGR_FIXED_MAX_DECIMALS
 Expands to 18u, the max digits after the point mmgr_verba_fixed will write.

Typedefs

typedef int(*) VerbaLineaFlush(void *context, const char *bytes, size_t size)
 Where a line passes the size bytes at bytes it holds once it is full.

Functions

EMBED_HOST_DEVICE VerbaLinea mmgr_line_over (char *out, size_t capacity)
 Makes a line over a buffer, of no capacity where the buffer is NULL.
EMBED_HOST_DEVICE embed_bool mmgr_line_flush (VerbaLinea *line)
 Passes what the line holds to its flush and empties it.
EMBED_HOST_DEVICE size_t mmgr_line_put_n (VerbaLinea *line, const char *text, size_t length)
 Writes length bytes of text.
EMBED_HOST_DEVICE size_t mmgr_line_put (VerbaLinea *line, const char *text)
 Writes a terminated text.
EMBED_HOST_DEVICE size_t mmgr_line_put_max (VerbaLinea *line, const char *text, size_t max)
 Writes a terminated text, at max max bytes of it.
EMBED_HOST_DEVICE void mmgr_line_put_columns (VerbaLinea *line, const char *text, unsigned int columns)
 Writes a terminated text and spaces after it out to columns.
EMBED_HOST_DEVICE void mmgr_line_put_right (VerbaLinea *line, const char *text, unsigned int columns)
 Writes spaces out to columns and then a terminated text, and so the text is right aligned.
EMBED_HOST_DEVICE void mmgr_line_ch (VerbaLinea *line, char character)
 Writes one character.
EMBED_HOST_DEVICE void mmgr_line_decimal (VerbaLinea *line, uint64_t value, unsigned int digits_least)
 Writes value in base ten, padded on the left with zeros to digits_least digits.
EMBED_HOST_DEVICE void mmgr_line_decimal_columns (VerbaLinea *line, uint64_t value, unsigned int columns)
 Writes value in base ten, right aligned in columns with spaces before it.
EMBED_HOST_DEVICE void mmgr_line_decimal_signed (VerbaLinea *line, int64_t value)
 Writes a signed value in base ten, a minus sign before a negative one.
EMBED_HOST_DEVICE void mmgr_line_hex (VerbaLinea *line, uint64_t value, unsigned int digits_least)
 Writes value in lower case base sixteen, padded on the left with zeros to digits_least digits.
EMBED_HOST_DEVICE void mmgr_line_fixed (VerbaLinea *line, double value, unsigned int decimals, unsigned int columns, embed_bool plus)
 Writes a double with decimals digits after the point, right aligned in columns with spaces before it.
EMBED_HOST_DEVICE void mmgr_line_exponent (VerbaLinea *line, double value, unsigned int decimals, unsigned int columns, embed_bool plus)
 Writes a double as one digit, a point, decimals digits, e, a sign and a power of two digits or more, right aligned in columns with spaces before it.
EMBED_HOST_DEVICE void mmgr_line_general (VerbaLinea *line, double value, unsigned int significant, unsigned int columns, embed_bool plus)
 Writes a double to significant digits in the shorter form that printf's g chooses, right aligned in columns with spaces before it.
EMBED_HOST_DEVICE size_t mmgr_line_finish (VerbaLinea *line)
 Stores the terminator, the one store a line no write reached yet still needs.
EMBED_HOST_DEVICE embed_bool mmgr_line_ok (const VerbaLinea *line)
 Reports whether every write fit.
EMBED_HOST_DEVICE size_t mmgr_verba_put_n (const VerbaTextusCfg *args)
 Writes a counted run of text.
EMBED_HOST_DEVICE size_t mmgr_verba_put (const VerbaTextusCfg *args)
 Writes a terminated string, with a measure of it first.
EMBED_HOST_DEVICE size_t mmgr_verba_put_clip (const VerbaTextusCfg *args)
 Writes as much of a string as fits.
EMBED_HOST_DEVICE size_t mmgr_verba_xml (const VerbaTextusCfg *args)
 Writes text with the four XML entities substituted.
EMBED_HOST_DEVICE size_t mmgr_verba_json (const VerbaTextusCfg *args)
 Writes text as a quoted JSON string.
EMBED_HOST_DEVICE size_t mmgr_verba_ch (const VerbaLitteraCfg *args)
 Writes one character.
EMBED_HOST_DEVICE size_t mmgr_verba_u64_clip (const VerbaNumerusCfg *args)
 Writes a value right aligned, padded with spaces.
EMBED_HOST_DEVICE size_t mmgr_verba_uint (const VerbaNumerusCfg *args)
 Writes a value in the base the caller gives.
EMBED_HOST_DEVICE size_t mmgr_verba_u32w (const VerbaNumerusCfg *args)
 Writes a value in base ten, padded to min digits.
EMBED_HOST_DEVICE size_t mmgr_verba_hex (const VerbaNumerusCfg *args)
 Writes a value in lower case base sixteen.
EMBED_HOST_DEVICE size_t mmgr_verba_u32 (const VerbaNumerusCfg *args)
 Writes a value in base ten, unpadded.
EMBED_HOST_DEVICE size_t mmgr_verba_u64 (const VerbaNumerusCfg *args)
 Writes a value in base ten, unpadded.
EMBED_HOST_DEVICE size_t mmgr_verba_i64 (const VerbaNumerusCfg *args)
 Writes a signed value in base ten.
EMBED_HOST_DEVICE size_t mmgr_verba_g (const VerbaFractioCfg *args)
 Writes a double to a significant digit count.
EMBED_HOST_DEVICE size_t mmgr_verba_fixed (const VerbaFractioCfg *args)
 Writes a double to a decimal count.
EMBED_HOST_DEVICE embed_bool mmgr_verba_sign_bit (const VerbaFractioCfg *args)
 Reports a double's sign bit.
EMBED_HOST_DEVICE embed_bool mmgr_verba_is_inf (const VerbaFractioCfg *args)
 Reports whether a double is an infinity.
EMBED_HOST_DEVICE embed_bool mmgr_verba_is_nan (const VerbaFractioCfg *args)
 Reports whether a double is a NaN.
EMBED_HOST_DEVICE size_t mmgr_verba_finish (const VerbaFinisCfg *args)
 Stores the terminator and reports the length.
EMBED_HOST_DEVICE embed_bool mmgr_verba_ok (const VerbaFinisCfg *args)
 Reports whether there is still room.

Variables

static const VerbaScriboTextusNs verba_textus
 Dispatch table instance named verba_textus, with each member set to its mmgr_verba_ function.
static const VerbaScriboLitteraNs verba_littera
 Dispatch table instance named verba_littera, whose one member holds mmgr_verba_ch.
static const VerbaScriboNumerusNs verba_numerus
 Dispatch table instance named verba_numerus, with each member set to its mmgr_verba_ function.
static const VerbaScriboFractioNs verba_fractio
 Dispatch table instance named verba_fractio, with each member set to its mmgr_verba_ function.
static const VerbaScriboFinisNs verba_finis
 Dispatch table instance named verba_finis, with each member set to its mmgr_verba_ function.

Detailed Description

Macro Definition Documentation

◆ MMGR_G_MAX_SIG

#define MMGR_G_MAX_SIG

Expands to 18u, the most significant digits mmgr_verba_g will retain.

Note
A larger args->sig stops here. An args->sig of 0 counts as 1.

Definition at line 35 of file verba_scribo.h.

◆ MMGR_FIXED_MAX_DECIMALS

#define MMGR_FIXED_MAX_DECIMALS

Expands to 18u, the max digits after the point mmgr_verba_fixed will write.

Note
A larger args->decimals stops here. An args->decimals of 0 writes no point at all.

Definition at line 42 of file verba_scribo.h.

Typedef Documentation

◆ VerbaLineaFlush

typedef int(*) VerbaLineaFlush(void *context, const char *bytes, size_t size)

Where a line passes the size bytes at bytes it holds once it is full.

Parameters
[in]contextThe line's context [BORROWS].
[in]bytesWhat the line holds [BORROWS].
[in]sizeBytes at bytes.
Returns
1 where the bytes went, 0 where they did not go.

Definition at line 45 of file verba_linea.h.

Function Documentation

◆ mmgr_line_over()

EMBED_HOST_DEVICE VerbaLinea mmgr_line_over ( char * out,
size_t capacity )

Makes a line over a buffer, of no capacity where the buffer is NULL.

Parameters
[in]outThe line's buffer, or NULL where its take failed [BORROWS].
[in]capacityBytes in out.
Returns
The line, nothing written and no flush.
Note
A line over a refused take stores nothing and mmgr_line_finish answers 0, and therefore a caller tests the take once and writes the line either way.

References mmgr_line_over().

Referenced by mmgr_line_over().

◆ mmgr_line_flush()

EMBED_HOST_DEVICE embed_bool mmgr_line_flush ( VerbaLinea * line)

Passes what the line holds to its flush and empties it.

Parameters
[in,out]lineThe line [BORROWS].
Returns
EMBED_TRUE where the flush took the bytes or grew the line, EMBED_FALSE where the line has no flush, is full, or its flush refused.
Note
A flush that refuses leaves the line full.

References mmgr_line_flush().

Referenced by mmgr_line_flush().

◆ mmgr_line_put_n()

EMBED_HOST_DEVICE size_t mmgr_line_put_n ( VerbaLinea * line,
const char * text,
size_t length )

Writes length bytes of text.

Parameters
[in,out]lineThe line [BORROWS].
[in]textBytes to write [BORROWS].
[in]lengthBytes of text.
Returns
Bytes of text the line took, passed on included: length where every byte went.
Note
A text past the room left goes on in pieces where the line has a flush. It fills the line where it has none, what fits written.
A line of fewer than two bytes holds none past its terminator, and so any text fills it.
Warning
text must be readable for length bytes.

References mmgr_line_put_n().

Referenced by mmgr_line_put_n().

◆ mmgr_line_put()

EMBED_HOST_DEVICE size_t mmgr_line_put ( VerbaLinea * line,
const char * text )

Writes a terminated text.

Parameters
[in,out]lineThe line [BORROWS].
[in]textTerminated text to write [BORROWS].
Returns
Bytes of text the line took, passed on included.
Note
The read of the text goes a piece the size of the room left at a time, never past its terminator. So a line with a flush takes a text of any length and needs no bound on it. A text longer than its room fills a line with none, what fits written.

References mmgr_line_put().

Referenced by mmgr_line_put().

◆ mmgr_line_put_max()

EMBED_HOST_DEVICE size_t mmgr_line_put_max ( VerbaLinea * line,
const char * text,
size_t max )

Writes a terminated text, at max max bytes of it.

Parameters
[in,out]lineThe line [BORROWS].
[in]textText to write [BORROWS].
[in]maxThe max bytes of text read.
Returns
Bytes of text the line took, passed on included.

References mmgr_line_put_max().

Referenced by mmgr_line_put_max().

◆ mmgr_line_put_columns()

EMBED_HOST_DEVICE void mmgr_line_put_columns ( VerbaLinea * line,
const char * text,
unsigned int columns )

Writes a terminated text and spaces after it out to columns.

Parameters
[in,out]lineThe line [BORROWS].
[in]textTerminated text to write [BORROWS].
[in]columnsBytes the text and its spaces fill. A longer text gets no spaces.
Note
The read of the text goes as mmgr_line_put reads it.

References mmgr_line_put_columns().

Referenced by mmgr_line_put_columns().

◆ mmgr_line_put_right()

EMBED_HOST_DEVICE void mmgr_line_put_right ( VerbaLinea * line,
const char * text,
unsigned int columns )

Writes spaces out to columns and then a terminated text, and so the text is right aligned.

Parameters
[in,out]lineThe line [BORROWS].
[in]textTerminated text to write [BORROWS].
[in]columnsBytes the spaces and the text fill. A text of columns bytes or more gets no spaces.
Note
The measure of the text reads at max columns bytes of it. The text then goes as mmgr_line_put reads it.

References mmgr_line_put_right().

Referenced by mmgr_line_put_right().

◆ mmgr_line_ch()

EMBED_HOST_DEVICE void mmgr_line_ch ( VerbaLinea * line,
char character )

Writes one character.

Parameters
[in,out]lineThe line [BORROWS].
[in]characterThe character.

References mmgr_line_ch().

Referenced by mmgr_line_ch().

◆ mmgr_line_decimal()

EMBED_HOST_DEVICE void mmgr_line_decimal ( VerbaLinea * line,
uint64_t value,
unsigned int digits_least )

Writes value in base ten, padded on the left with zeros to digits_least digits.

Parameters
[in,out]lineThe line [BORROWS].
[in]valueThe value.
[in]digits_leastFewest digits written, clamped at 255.

References mmgr_line_decimal().

Referenced by mmgr_line_decimal().

◆ mmgr_line_decimal_columns()

EMBED_HOST_DEVICE void mmgr_line_decimal_columns ( VerbaLinea * line,
uint64_t value,
unsigned int columns )

Writes value in base ten, right aligned in columns with spaces before it.

Parameters
[in,out]lineThe line [BORROWS].
[in]valueThe value.
[in]columnsBytes the value and its spaces fill, clamped at 255.

References mmgr_line_decimal_columns().

Referenced by mmgr_line_decimal_columns().

◆ mmgr_line_decimal_signed()

EMBED_HOST_DEVICE void mmgr_line_decimal_signed ( VerbaLinea * line,
int64_t value )

Writes a signed value in base ten, a minus sign before a negative one.

Parameters
[in,out]lineThe line [BORROWS].
[in]valueThe value. INT64_MIN goes out whole.

References mmgr_line_decimal_signed().

Referenced by mmgr_line_decimal_signed().

◆ mmgr_line_hex()

EMBED_HOST_DEVICE void mmgr_line_hex ( VerbaLinea * line,
uint64_t value,
unsigned int digits_least )

Writes value in lower case base sixteen, padded on the left with zeros to digits_least digits.

Parameters
[in,out]lineThe line [BORROWS].
[in]valueThe value.
[in]digits_leastFewest digits written, clamped at 255.

References mmgr_line_hex().

Referenced by mmgr_line_hex().

◆ mmgr_line_fixed()

EMBED_HOST_DEVICE void mmgr_line_fixed ( VerbaLinea * line,
double value,
unsigned int decimals,
unsigned int columns,
embed_bool plus )

Writes a double with decimals digits after the point, right aligned in columns with spaces before it.

Parameters
[in,out]lineThe line [BORROWS].
[in]valueThe value.
[in]decimalsDigits after the point, clamped at MMGR_FIXED_MAX_DECIMALS. A count of 0 writes no point.
[in]columnsBytes the value, its sign and its spaces fill, clamped at 255.
[in]plusEMBED_TRUE writes a plus sign before a value whose sign bit is clear.
Note
The fraction rounds from the exact value of the double, as mmgr_verba_fixed rounds it. An exact tie goes to the even digit, as the C library rounds it. A negative zero writes its minus sign.
Warning
A magnitude too large for 64 bits of integer part goes out as mmgr_verba_g writes it, at ten significant digits.

References mmgr_line_fixed().

Referenced by mmgr_line_fixed().

◆ mmgr_line_exponent()

EMBED_HOST_DEVICE void mmgr_line_exponent ( VerbaLinea * line,
double value,
unsigned int decimals,
unsigned int columns,
embed_bool plus )

Writes a double as one digit, a point, decimals digits, e, a sign and a power of two digits or more, right aligned in columns with spaces before it.

Parameters
[in,out]lineThe line [BORROWS].
[in]valueThe value.
[in]decimalsDigits after the point, clamped at MMGR_G_MAX_SIG less one. A count of 0 writes no point.
[in]columnsBytes the value, its sign and its spaces fill, clamped at 255.
[in]plusEMBED_TRUE writes a plus sign before a value whose sign bit is clear.
Note
The digits round from the exact value of the double. An exact tie goes to the even digit, as the C library rounds it. A zero writes zeros and a power of +00.
An infinity or a NaN goes out as mmgr_verba_fixed writes it.

References mmgr_line_exponent().

Referenced by mmgr_line_exponent().

◆ mmgr_line_general()

EMBED_HOST_DEVICE void mmgr_line_general ( VerbaLinea * line,
double value,
unsigned int significant,
unsigned int columns,
embed_bool plus )

Writes a double to significant digits in the shorter form that printf's g chooses, right aligned in columns with spaces before it.

Parameters
[in,out]lineThe line [BORROWS].
[in]valueThe value.
[in]significantDigits kept, 1 where it is 0, clamped at MMGR_G_MAX_SIG.
[in]columnsBytes the value, its sign and its spaces fill, clamped at 255.
[in]plusEMBED_TRUE writes a plus sign before a value whose sign bit is clear.
Note
The digits round as mmgr_line_exponent rounds them. A power below -4, or of significant or more, writes the exponent form, and any other power writes the plain form. Each form drops the zeros at the end of its digits, and a point with no digit after it.
A zero writes 0. An infinity or a NaN goes out as mmgr_verba_fixed writes it.

References mmgr_line_general().

Referenced by mmgr_line_general().

◆ mmgr_line_finish()

EMBED_HOST_DEVICE size_t mmgr_line_finish ( VerbaLinea * line)

Stores the terminator, the one store a line no write reached yet still needs.

Parameters
[in,out]lineThe line [BORROWS].
Returns
The length the line holds, or 0 where it is full.
Note
A full line holds the terminator in its last byte, and capacity minus one bytes before it.

References mmgr_line_finish().

Referenced by mmgr_line_finish().

◆ mmgr_line_ok()

EMBED_HOST_DEVICE embed_bool mmgr_line_ok ( const VerbaLinea * line)

Reports whether every write fit.

Parameters
[in]lineThe line [BORROWS].
Returns
EMBED_TRUE while the line has room, EMBED_FALSE once a write did not fit.

References mmgr_line_ok().

Referenced by mmgr_line_ok().

◆ mmgr_verba_put_n()

EMBED_HOST_DEVICE size_t mmgr_verba_put_n ( const VerbaTextusCfg * args)

Writes a counted run of text.

Parameters
[in]argsBuffer, capacity, offset, text and its length [BORROWS].
Returns
The offset past the text, or args->cap when it did not fit.
Note
Writes nothing at all when it does not fit, and does not write what it can.
Warning
args->text must be readable for args->text_len bytes. It looks for no terminator.

References mmgr_verba_put_n().

Referenced by mmgr_verba_put_n().

◆ mmgr_verba_put()

EMBED_HOST_DEVICE size_t mmgr_verba_put ( const VerbaTextusCfg * args)

Writes a terminated string, with a measure of it first.

Parameters
[in]argsBuffer, capacity, offset and the text [BORROWS].
Returns
The offset past the text, or args->cap when it did not fit.
Note
Takes args->text_len as the length when it is non-zero, and only otherwise measures.
Warning
args->text must not be NULL here, unlike put_clip, xml and json.

References mmgr_verba_put().

Referenced by mmgr_verba_put().

◆ mmgr_verba_put_clip()

EMBED_HOST_DEVICE size_t mmgr_verba_put_clip ( const VerbaTextusCfg * args)

Writes as much of a string as fits.

Parameters
[in]argsBuffer, capacity, offset and the text [BORROWS].
Returns
The offset past the write, which is args->at when nothing was.
Note
Returns args->at and not args->cap when it writes nothing. A later call can still write.
Bounds the measure by the room left, and so the length measured is already the length that fits.
Warning
A NULL args->text writes nothing and does not fault, unlike put.

References mmgr_verba_put_clip().

Referenced by mmgr_verba_put_clip().

◆ mmgr_verba_xml()

EMBED_HOST_DEVICE size_t mmgr_verba_xml ( const VerbaTextusCfg * args)

Writes text with the four XML entities substituted.

Parameters
[in]argsBuffer, capacity, offset and the text [BORROWS].
Returns
The offset past the write, which is args->at for a NULL args->text.
Note
Replaces the ampersand, the two angle brackets and the double quote. The apostrophe is goes out as it is, and so this suits element text and double quoted attributes.
Warning
Walks to the terminator. Its own terminator bounds args->text, and not args->cap.

References mmgr_verba_xml().

Referenced by mmgr_verba_xml().

◆ mmgr_verba_json()

EMBED_HOST_DEVICE size_t mmgr_verba_json ( const VerbaTextusCfg * args)

Writes text as a quoted JSON string.

Parameters
[in]argsBuffer, capacity, offset and the text [BORROWS].
Returns
The offset past the close quote, or args->cap once something did not fit.
Note
Writes the open and close quotes itself, and so the result is a complete JSON string. A NULL args->text writes an empty pair of quotes where xml writes nothing at all.
Warning
Walks to the terminator. Its own terminator bounds args->text, and not args->cap.

References mmgr_verba_json().

Referenced by mmgr_verba_json().

◆ mmgr_verba_ch()

EMBED_HOST_DEVICE size_t mmgr_verba_ch ( const VerbaLitteraCfg * args)

Writes one character.

Parameters
[in]argsBuffer, capacity, offset and the character [BORROWS].
Returns
args->at plus one, or args->cap when there is no room.
Note
The base step the escape and digit entries write through, one character at a time.
Warning
args->out must be writable for args->cap bytes. A byte is always reserved for the terminator finish stores.

References mmgr_verba_ch().

Referenced by mmgr_verba_ch().

◆ mmgr_verba_u64_clip()

EMBED_HOST_DEVICE size_t mmgr_verba_u64_clip ( const VerbaNumerusCfg * args)

Writes a value right aligned, padded with spaces.

Parameters
[in]argsBuffer, capacity, offset, the value and the column count [BORROWS].
Returns
The offset past the write, which is args->at when there was no room.
Note
Takes args->columns as a floor. A value that needs more digits than that widens the field.
Pads on the left with spaces, where uint pads with leading zeros.
Warning
args->out must be writable for args->cap bytes, and one byte stays reserved for the terminator.

References mmgr_verba_u64_clip().

Referenced by mmgr_verba_u64_clip().

◆ mmgr_verba_uint()

EMBED_HOST_DEVICE size_t mmgr_verba_uint ( const VerbaNumerusCfg * args)

Writes a value in the base the caller gives.

Parameters
[in]argsBuffer, capacity, offset, the value, the base and the least digit count [BORROWS].
Returns
The offset past the digits, or args->cap when they do not fit.
Note
The digit count raised to args->min before the room test is what pads with leading zeros.
Warning
Any args->base other than 8 or 16 comes out in base ten, whatever value it holds.

References mmgr_verba_uint().

Referenced by mmgr_verba_uint().

◆ mmgr_verba_u32w()

EMBED_HOST_DEVICE size_t mmgr_verba_u32w ( const VerbaNumerusCfg * args)

Writes a value in base ten, padded to min digits.

Parameters
[in]argsBuffer, capacity, offset, the value and the least digit count [BORROWS].
Returns
The offset past the digits, or args->cap when they do not fit.
Note
Fixes the base at ten and forwards args->min, as separates it from u32.
Warning
args->base takes no part here, whatever the caller put in it.

References mmgr_verba_u32w().

Referenced by mmgr_verba_u32w().

◆ mmgr_verba_hex()

EMBED_HOST_DEVICE size_t mmgr_verba_hex ( const VerbaNumerusCfg * args)

Writes a value in lower case base sixteen.

Parameters
[in]argsBuffer, capacity, offset, the value and the least digit count [BORROWS].
Returns
The offset past the digits, or args->cap when they do not fit.
Note
Fixes the base at sixteen, and so the digits come out lower case. Forwards args->min so the result can carry leading zeros to a fixed width.
Warning
args->base takes no part here, whatever the caller put in it.

References mmgr_verba_hex().

Referenced by mmgr_verba_hex().

◆ mmgr_verba_u32()

EMBED_HOST_DEVICE size_t mmgr_verba_u32 ( const VerbaNumerusCfg * args)

Writes a value in base ten, unpadded.

Parameters
[in]argsBuffer, capacity, offset and the value [BORROWS].
Returns
The offset past the digits, or args->cap when they do not fit.
Note
Fixes both the base at ten and the least digit count at one.
Warning
Neither args->base nor args->min takes any part here. Reach for u32w to pad.

References mmgr_verba_u32().

Referenced by mmgr_verba_u32().

◆ mmgr_verba_u64()

EMBED_HOST_DEVICE size_t mmgr_verba_u64 ( const VerbaNumerusCfg * args)

Writes a value in base ten, unpadded.

Parameters
[in]argsBuffer, capacity, offset and the value [BORROWS].
Returns
The offset past the digits, or args->cap when they do not fit.
Note
The same walk as u32, since args->val is 64 bits either way. Both names exist to let a caller read the width it means at the call.
Warning
Neither args->base nor args->min takes any part here. Reach for u32w to pad.

References mmgr_verba_u64().

Referenced by mmgr_verba_u64().

◆ mmgr_verba_i64()

EMBED_HOST_DEVICE size_t mmgr_verba_i64 ( const VerbaNumerusCfg * args)

Writes a signed value in base ten.

Parameters
[in]argsBuffer, capacity, offset and the signed value in sval [BORROWS].
Returns
The offset past the digits, or args->cap when they do not fit.
Note
Writes the sign through ch, then passes the magnitude to uint at base ten.
The magnitude is -(sval + 1) plus one, which stays in range for the max negative value.
Warning
Reads args->sval and not args->val. A caller that fills the unsigned member writes a zero.

References mmgr_verba_i64().

Referenced by mmgr_verba_i64().

◆ mmgr_verba_g()

EMBED_HOST_DEVICE size_t mmgr_verba_g ( const VerbaFractioCfg * args)

Writes a double to a significant digit count.

Parameters
[in]argsBuffer, capacity, offset, the value and the significant digit count [BORROWS].
Returns
The offset past the write, or args->cap once something did not fit.
Note
An args->sig of 0 counts as 1, and anything above MMGR_G_MAX_SIG stops there.
Picks the shorter of a plain and an exponential form, and drops trailing zeros before it chooses.
Warning
An infinity writes inf and a NaN writes nan, lower case and unquoted, and so neither is valid JSON on its own.

References mmgr_verba_g().

Referenced by mmgr_verba_g().

◆ mmgr_verba_fixed()

EMBED_HOST_DEVICE size_t mmgr_verba_fixed ( const VerbaFractioCfg * args)

Writes a double to a decimal count.

Parameters
[in]argsBuffer, capacity, offset, the value and the decimal count [BORROWS].
Returns
The offset past the write, or args->cap once something did not fit.
Note
args->decimals stops at MMGR_FIXED_MAX_DECIMALS, and a value of 0 writes no point at all.
A half rounds up, and a fraction that carries raises the integer part. The sign goes out ahead of the magnitude. A negative half rounds away from zero.
Warning
A magnitude too large for 64 bits of integer part falls back to g at ten significant digits. So the result is not always in the fixed form the caller asked for.

References mmgr_verba_fixed().

Referenced by mmgr_verba_fixed().

◆ mmgr_verba_sign_bit()

EMBED_HOST_DEVICE embed_bool mmgr_verba_sign_bit ( const VerbaFractioCfg * args)

Reports a double's sign bit.

Parameters
[in]argsThe value to test, as args->real [BORROWS].
Returns
EMBED_TRUE when the sign bit holds, with nothing written.
Note
Reads the bit and does not compare against zero. A negative zero returns EMBED_TRUE.
Reads no member but args->real. args->out may stay unset.

References mmgr_verba_sign_bit().

Referenced by mmgr_verba_sign_bit().

◆ mmgr_verba_is_inf()

EMBED_HOST_DEVICE embed_bool mmgr_verba_is_inf ( const VerbaFractioCfg * args)

Reports whether a double is an infinity.

Parameters
[in]argsThe value to test, as args->real [BORROWS].
Returns
EMBED_TRUE for either infinity, with nothing written.
Note
Wants the exponent field all ones and the mantissa zero, where is_nan wants it non-zero.
The sign takes no part. A negative infinity returns EMBED_TRUE too.

References mmgr_verba_is_inf().

Referenced by mmgr_verba_is_inf().

◆ mmgr_verba_is_nan()

EMBED_HOST_DEVICE embed_bool mmgr_verba_is_nan ( const VerbaFractioCfg * args)

Reports whether a double is a NaN.

Parameters
[in]argsThe value to test, as args->real [BORROWS].
Returns
EMBED_TRUE for any NaN, with nothing written.
Note
Wants the exponent field all ones and the mantissa non-zero, where is_inf wants it zero.
Quiet and signaling NaNs answer alike, since the test covers only a non-zero mantissa.

References mmgr_verba_is_nan().

Referenced by mmgr_verba_is_nan().

◆ mmgr_verba_finish()

EMBED_HOST_DEVICE size_t mmgr_verba_finish ( const VerbaFinisCfg * args)

Stores the terminator and reports the length.

Parameters
[in]argsBuffer, capacity and the offset reached [BORROWS].
Returns
args->at, or 0 when args->at already reached args->cap.
Note
A return of 0 covers both an empty result and one that ran out of room. ok tells them apart.
Warning
The only entry that writes a terminator. A buffer is not a string until this runs.

References mmgr_verba_finish().

Referenced by mmgr_verba_finish().

◆ mmgr_verba_ok()

EMBED_HOST_DEVICE embed_bool mmgr_verba_ok ( const VerbaFinisCfg * args)

Reports whether there is still room.

Parameters
[in]argsCapacity and the offset reached [BORROWS].
Returns
EMBED_TRUE while there is still room, EMBED_FALSE once an entry returned args->cap.
Note
Reads neither args->out nor any value member, and so it touches no memory and args->out may be NULL.

References mmgr_verba_ok().

Referenced by mmgr_verba_ok().

Variable Documentation

◆ verba_textus

const VerbaScriboTextusNs verba_textus
static

Dispatch table instance named verba_textus, with each member set to its mmgr_verba_ function.

Definition at line 417 of file verba_scribo.h.

◆ verba_littera

const VerbaScriboLitteraNs verba_littera
static

Dispatch table instance named verba_littera, whose one member holds mmgr_verba_ch.

Definition at line 428 of file verba_scribo.h.

◆ verba_numerus

const VerbaScriboNumerusNs verba_numerus
static

Dispatch table instance named verba_numerus, with each member set to its mmgr_verba_ function.

Definition at line 435 of file verba_scribo.h.

◆ verba_fractio

const VerbaScriboFractioNs verba_fractio
static

Dispatch table instance named verba_fractio, with each member set to its mmgr_verba_ function.

Definition at line 448 of file verba_scribo.h.

◆ verba_finis

const VerbaScriboFinisNs verba_finis
static

Dispatch table instance named verba_finis, with each member set to its mmgr_verba_ function.

Definition at line 459 of file verba_scribo.h.