MMgr v2.3.0
Zero-heap memory manager in C11. One borrowed buffer, carved by asserted offset.
Loading...
Searching...
No Matches
numeros_scribo — record building

Data Structures

struct  mmgr_field
 One field of a spec. More...
struct  mmgr_fval
 One value, tagged with the type that selects which arm of as holds it. More...
union  mmgr_fval::[union].as
struct  NumerosScriboNs
 Type of the numer dispatch table. More...
struct  NumerosCfg
 Arguments for the four numer calls. More...

Macros

#define MMGR_STR
 Expands to an mmgr_field of type MMGR_FK_STR, with width 0, bytes 0 and literal NULL.
#define MMGR_U32
 Expands to an mmgr_field of type MMGR_FK_U32, with width 0, bytes 0 and literal NULL.
#define MMGR_U64
 Expands to an mmgr_field of type MMGR_FK_U64, with width 0, bytes 0 and literal NULL.
#define MMGR_I64
 Expands to an mmgr_field of type MMGR_FK_I64, with width 0, bytes 0 and literal NULL.
#define MMGR_CH
 Expands to an mmgr_field of type MMGR_FK_CH, with width 0, bytes 0 and literal NULL.
#define MMGR_JSON
 Expands to an mmgr_field of type MMGR_FK_JSON, with width 0, bytes 0 and literal NULL.
#define MMGR_XML
 Expands to an mmgr_field of type MMGR_FK_XML, with width 0, bytes 0 and literal NULL.
#define MMGR_END
 Expands to an mmgr_field of type MMGR_FK_END, with width 0, bytes 0 and literal NULL.
#define MMGR_VSTR(text_)
 Expands to an mmgr_fval of type MMGR_FK_STR, with text_ in as.text and width 0.
#define MMGR_VU32(value_)
 Expands to an mmgr_fval of type MMGR_FK_U32, with value_ in as.u32 and width 0.
#define MMGR_VU64(value_)
 Expands to an mmgr_fval of type MMGR_FK_U64, with value_ in as.u64 and width 0.
#define MMGR_VI64(value_)
 Expands to an mmgr_fval of type MMGR_FK_I64, with value_ in as.i64 and width 0.
#define MMGR_VDEC(value_)
 Expands to an mmgr_fval of type MMGR_FK_DEC, with value_ in as.u32 and width 0.
#define MMGR_VHEX(value_)
 Expands to an mmgr_fval of type MMGR_FK_HEX, with value_ in as.u64 and width 0.
#define MMGR_VOCT(value_)
 Expands to an mmgr_fval of type MMGR_FK_OCT, with value_ in as.u64 and width 0.
#define MMGR_VG(value_)
 Expands to an mmgr_fval of type MMGR_FK_G, with value_ in as.real and width 0.
#define MMGR_VFIX(value_)
 Expands to an mmgr_fval of type MMGR_FK_FIX, with value_ in as.real and width 0.
#define MMGR_VCH(character_)
 Expands to an mmgr_fval of type MMGR_FK_CH, with character_ in as.character and width 0.
#define MMGR_VJSON(text_)
 Expands to an mmgr_fval of type MMGR_FK_JSON, with text_ in as.text and width 0.
#define MMGR_VXML(text_)
 Expands to an mmgr_fval of type MMGR_FK_XML, with text_ in as.text and width 0.
#define MMGR_VDECW(value_, width_)
 Expands to an mmgr_fval of type MMGR_FK_DEC, with value_ in as.u32 and width_ in width.
#define MMGR_VHEXW(value_, width_)
 Expands to an mmgr_fval of type MMGR_FK_HEX, with value_ in as.u64 and width_ in width.
#define MMGR_VOCTW(value_, width_)
 Expands to an mmgr_fval of type MMGR_FK_OCT, with value_ in as.u64 and width_ in width.
#define MMGR_VGW(value_, width_)
 Expands to an mmgr_fval of type MMGR_FK_G, with value_ in as.real and width_ in width.
#define MMGR_VFIXW(value_, width_)
 Expands to an mmgr_fval of type MMGR_FK_FIX, with value_ in as.real and width_ in width.

Enumerations

enum  mmgr_fk {
  MMGR_FK_END ,
  MMGR_FK_LIT ,
  MMGR_FK_STR ,
  MMGR_FK_U32 ,
  MMGR_FK_U64 ,
  MMGR_FK_I64 ,
  MMGR_FK_DEC ,
  MMGR_FK_HEX ,
  MMGR_FK_OCT ,
  MMGR_FK_G ,
  MMGR_FK_FIX ,
  MMGR_FK_CH ,
  MMGR_FK_JSON ,
  MMGR_FK_XML
}
 What one field formats, and which mmgr_fval arm it reads. More...

Functions

EMBED_HOST_DEVICE size_t mmgr_numer_build (const NumerosCfg *args)
 Writes args->spec and args->vals into args->out, from args->at on.
EMBED_HOST_DEVICE size_t mmgr_numer_append (const NumerosCfg *args)
 Writes args->spec and args->vals into args->out after the string already there.
EMBED_HOST_DEVICE size_t mmgr_numer_emit (const NumerosCfg *args)
 Writes args->vals into args->out, from args->at on and with no field list.
EMBED_HOST_DEVICE size_t mmgr_numer_emit_append (const NumerosCfg *args)
 Writes args->vals into args->out after the string already there, reading no field list.

Variables

static const NumerosScriboNs numer
 Dispatch table instance named numer.

Detailed Description

Macro Definition Documentation

◆ MMGR_STR

#define MMGR_STR

Expands to an mmgr_field of type MMGR_FK_STR, with width 0, bytes 0 and literal NULL.

Definition at line 63 of file numeros_scribo.h.

◆ MMGR_U32

#define MMGR_U32

Expands to an mmgr_field of type MMGR_FK_U32, with width 0, bytes 0 and literal NULL.

Definition at line 66 of file numeros_scribo.h.

◆ MMGR_U64

#define MMGR_U64

Expands to an mmgr_field of type MMGR_FK_U64, with width 0, bytes 0 and literal NULL.

Definition at line 69 of file numeros_scribo.h.

◆ MMGR_I64

#define MMGR_I64

Expands to an mmgr_field of type MMGR_FK_I64, with width 0, bytes 0 and literal NULL.

Definition at line 72 of file numeros_scribo.h.

◆ MMGR_CH

#define MMGR_CH

Expands to an mmgr_field of type MMGR_FK_CH, with width 0, bytes 0 and literal NULL.

Definition at line 75 of file numeros_scribo.h.

◆ MMGR_JSON

#define MMGR_JSON

Expands to an mmgr_field of type MMGR_FK_JSON, with width 0, bytes 0 and literal NULL.

Definition at line 78 of file numeros_scribo.h.

◆ MMGR_XML

#define MMGR_XML

Expands to an mmgr_field of type MMGR_FK_XML, with width 0, bytes 0 and literal NULL.

Definition at line 81 of file numeros_scribo.h.

◆ MMGR_END

#define MMGR_END

Expands to an mmgr_field of type MMGR_FK_END, with width 0, bytes 0 and literal NULL.

Note
numer_build stops at this field, and so every spec array needs one as its last entry.

Definition at line 88 of file numeros_scribo.h.

◆ MMGR_VSTR

#define MMGR_VSTR ( text_)

Expands to an mmgr_fval of type MMGR_FK_STR, with text_ in as.text and width 0.

Parameters
[in]text_String placed in as.text [BORROWS].

Definition at line 117 of file numeros_scribo.h.

◆ MMGR_VU32

#define MMGR_VU32 ( value_)

Expands to an mmgr_fval of type MMGR_FK_U32, with value_ in as.u32 and width 0.

Parameters
[in]value_Value placed in as.u32.

Definition at line 124 of file numeros_scribo.h.

◆ MMGR_VU64

#define MMGR_VU64 ( value_)

Expands to an mmgr_fval of type MMGR_FK_U64, with value_ in as.u64 and width 0.

Parameters
[in]value_Value placed in as.u64.

Definition at line 131 of file numeros_scribo.h.

◆ MMGR_VI64

#define MMGR_VI64 ( value_)

Expands to an mmgr_fval of type MMGR_FK_I64, with value_ in as.i64 and width 0.

Parameters
[in]value_Value placed in as.i64.

Definition at line 138 of file numeros_scribo.h.

◆ MMGR_VDEC

#define MMGR_VDEC ( value_)

Expands to an mmgr_fval of type MMGR_FK_DEC, with value_ in as.u32 and width 0.

Parameters
[in]value_Value placed in as.u32.

Definition at line 145 of file numeros_scribo.h.

◆ MMGR_VHEX

#define MMGR_VHEX ( value_)

Expands to an mmgr_fval of type MMGR_FK_HEX, with value_ in as.u64 and width 0.

Parameters
[in]value_Value placed in as.u64.

Definition at line 152 of file numeros_scribo.h.

◆ MMGR_VOCT

#define MMGR_VOCT ( value_)

Expands to an mmgr_fval of type MMGR_FK_OCT, with value_ in as.u64 and width 0.

Parameters
[in]value_Value placed in as.u64.

Definition at line 159 of file numeros_scribo.h.

◆ MMGR_VG

#define MMGR_VG ( value_)

Expands to an mmgr_fval of type MMGR_FK_G, with value_ in as.real and width 0.

Parameters
[in]value_Value placed in as.real.

Definition at line 166 of file numeros_scribo.h.

◆ MMGR_VFIX

#define MMGR_VFIX ( value_)

Expands to an mmgr_fval of type MMGR_FK_FIX, with value_ in as.real and width 0.

Parameters
[in]value_Value placed in as.real.

Definition at line 173 of file numeros_scribo.h.

◆ MMGR_VCH

#define MMGR_VCH ( character_)

Expands to an mmgr_fval of type MMGR_FK_CH, with character_ in as.character and width 0.

Parameters
[in]character_Character placed in as.character.

Definition at line 180 of file numeros_scribo.h.

◆ MMGR_VJSON

#define MMGR_VJSON ( text_)

Expands to an mmgr_fval of type MMGR_FK_JSON, with text_ in as.text and width 0.

Parameters
[in]text_String placed in as.text [BORROWS].

Definition at line 187 of file numeros_scribo.h.

◆ MMGR_VXML

#define MMGR_VXML ( text_)

Expands to an mmgr_fval of type MMGR_FK_XML, with text_ in as.text and width 0.

Parameters
[in]text_String placed in as.text [BORROWS].

Definition at line 194 of file numeros_scribo.h.

◆ MMGR_VDECW

#define MMGR_VDECW ( value_,
width_ )

Expands to an mmgr_fval of type MMGR_FK_DEC, with value_ in as.u32 and width_ in width.

Parameters
[in]value_Value placed in as.u32.
[in]width_Width placed in the width member.
Note
numer_emit uses that width. numer_build takes the width from the field instead.

Definition at line 203 of file numeros_scribo.h.

◆ MMGR_VHEXW

#define MMGR_VHEXW ( value_,
width_ )

Expands to an mmgr_fval of type MMGR_FK_HEX, with value_ in as.u64 and width_ in width.

Parameters
[in]value_Value placed in as.u64.
[in]width_Width placed in the width member.
Note
numer_emit uses that width. numer_build takes the width from the field instead.

Definition at line 212 of file numeros_scribo.h.

◆ MMGR_VOCTW

#define MMGR_VOCTW ( value_,
width_ )

Expands to an mmgr_fval of type MMGR_FK_OCT, with value_ in as.u64 and width_ in width.

Parameters
[in]value_Value placed in as.u64.
[in]width_Width placed in the width member.
Note
numer_emit uses that width. numer_build takes the width from the field instead.

Definition at line 221 of file numeros_scribo.h.

◆ MMGR_VGW

#define MMGR_VGW ( value_,
width_ )

Expands to an mmgr_fval of type MMGR_FK_G, with value_ in as.real and width_ in width.

Parameters
[in]value_Value placed in as.real.
[in]width_Width placed in the width member.
Note
numer_emit_one passes that width to mmgr_verba_g as VerbaFractioCfg::sig, the significant digits it retains.
numer_emit uses it. numer_build takes the width from the field instead.

Definition at line 232 of file numeros_scribo.h.

◆ MMGR_VFIXW

#define MMGR_VFIXW ( value_,
width_ )

Expands to an mmgr_fval of type MMGR_FK_FIX, with value_ in as.real and width_ in width.

Parameters
[in]value_Value placed in as.real.
[in]width_Width placed in the width member.
Note
numer_emit_one passes that width to mmgr_verba_fixed as VerbaFractioCfg::decimals, the digits it writes after the point.
numer_emit uses it. numer_build takes the width from the field instead.

Definition at line 243 of file numeros_scribo.h.

Enumeration Type Documentation

◆ mmgr_fk

enum mmgr_fk

What one field formats, and which mmgr_fval arm it reads.

Note
numeros_scribo.c indexes s_type by this value, and so MMGR_FK_XML is the largest one it accepts.
One byte on every compiler, through EMBED_ENUM_BYTE.
Enumerator
MMGR_FK_END 

Ends a spec. numer_build stops at this field.

MMGR_FK_LIT 

Literal text, taken from mmgr_field::lit and mmgr_field::len.

MMGR_FK_STR 

String from as.s, through mmgr_verba_put.

MMGR_FK_U32 

Unsigned 32-bit from as.u32, base 10, through mmgr_verba_u32.

MMGR_FK_U64 

Unsigned 64-bit from as.u64, base 10, through mmgr_verba_u64.

MMGR_FK_I64 

Signed 64-bit from as.i64, base 10, through mmgr_verba_i64.

MMGR_FK_DEC 

Unsigned 32-bit from as.u32, base 10, through mmgr_verba_u32w.

MMGR_FK_HEX 

Unsigned 64-bit from as.u64, base 16, through mmgr_verba_hex.

MMGR_FK_OCT 

Unsigned 64-bit from as.u64, base 8, through mmgr_verba_uint.

MMGR_FK_G 

Double from as.d, through mmgr_verba_g, with six significant digits by default.

MMGR_FK_FIX 

Double from as.d, through mmgr_verba_fixed.

MMGR_FK_CH 

Single character from as.c, through mmgr_verba_ch.

MMGR_FK_JSON 

String from as.s, through mmgr_verba_json.

MMGR_FK_XML 

String from as.s, through mmgr_verba_xml.

Definition at line 47 of file numeros_scribo.h.

Function Documentation

◆ mmgr_numer_build()

EMBED_HOST_DEVICE size_t mmgr_numer_build ( const NumerosCfg * args)

Writes args->spec and args->vals into args->out, from args->at on.

Parameters
[in]argsBuffer, capacity, the field list and the values [BORROWS].
Returns
Length of the whole string in args->out, with its terminator not in the count, or 0 when nothing went in.
Note
An MMGR_FK_LIT field writes its own text. Every other field consumes the next value in args->vals.
Returns 0 and puts the terminator back at args->at when a value is absent, when a type differs, or when values remain. That leaves the text written before this call whole.
Warning
args->spec must reach an MMGR_FK_END field, and args->vals must hold args->nvals values.

References mmgr_numer_build().

Referenced by mmgr_numer_build().

◆ mmgr_numer_append()

EMBED_HOST_DEVICE size_t mmgr_numer_append ( const NumerosCfg * args)

Writes args->spec and args->vals into args->out after the string already there.

Parameters
[in]argsBuffer, capacity, the field list and the values [BORROWS].
Returns
Length of the whole string in args->out, or 0 when nothing went in.
Note
Carries on at args->at when the caller threaded one, and measures the existing string with cellul.len only when args->at is 0. Either way the build gets the whole of args->cap and that offset.
Puts the terminator back at the offset it began from and returns 0 when the build writes nothing.
Warning
args->spec must reach an MMGR_FK_END field. The args->out buffer must hold a terminated string when args->at is 0, since that is the only time the call measures the length.

References mmgr_numer_append().

Referenced by mmgr_numer_append().

◆ mmgr_numer_emit()

EMBED_HOST_DEVICE size_t mmgr_numer_emit ( const NumerosCfg * args)

Writes args->vals into args->out, from args->at on and with no field list.

Parameters
[in]argsBuffer, capacity and the values [BORROWS].
Returns
Length of the whole string in args->out, with its terminator not in the count, or 0 when nothing went in.
Note
Each value carries its own width, and no type check runs, since there are no fields to match against.
Warning
args->vals must hold args->nvals values.
A value of type MMGR_FK_END or MMGR_FK_LIT formats nothing, which abandons the write and returns 0.

References mmgr_numer_emit().

Referenced by mmgr_numer_emit().

◆ mmgr_numer_emit_append()

EMBED_HOST_DEVICE size_t mmgr_numer_emit_append ( const NumerosCfg * args)

Writes args->vals into args->out after the string already there, reading no field list.

Parameters
[in]argsBuffer, capacity and the values [BORROWS].
Returns
Length of the whole string in args->out, or 0 when nothing went in.
Note
Carries on at args->at when the caller threaded one, and measures the existing string with cellul.len only when args->at is 0. Either way the emit gets the whole of args->cap and that offset.
Puts the terminator back at the offset it began from and returns 0 when the emit writes nothing.
Warning
args->vals must hold args->nvals values. The args->out buffer must hold a terminated string when args->at is 0, since that is the only time the call measures the length.

References mmgr_numer_emit_append().

Referenced by mmgr_numer_emit_append().

Variable Documentation

◆ numer

const NumerosScriboNs numer
static

Dispatch table instance named numer.

Note
Each member calls the mmgr_numer_ function of the same name, one to one.
mmgr_numer_append reaches build through this table, and mmgr_numer_emit_append reaches emit.

Definition at line 341 of file numeros_scribo.h.