Internal Print Implementation.
More...
Internal Print Implementation.
Provides a common implementation for printing formatted output, any function that needs to print formatted output should define the _PRINT_WRITE() and _PRINT_FILL() macros before including this file.
The _PRINT_WRITE(ctx, buffer, count) macro should evaluate to an expression that writes count bytes from the buffer to the output source and takes a pointer to the current print_ctx_t, a pointer to the buffer and the number of bytes to write as arguments.
The _PRINT_FILL(ctx, c, count) macro should evaluate to an expression that writes count bytes of character c to the output source and takes a pointer to the current print_ctx_t, the character to write and the number of times to write it as arguments.
The macros should return the number of bytes written, or EOF on error.
- Todo:
- Implement floating point printing.
- See also
- https://cplusplus.com/reference/cstdio/printf/ for details on the format specifiers.
|
| enum | _print_format_flags_t {
_PRINT_LEFT_ALIGNED = 1 << 1
, _PRINT_FORCE_SIGN = 1 << 2
, _PRINT_SPACE_SIGN = 1 << 3
, _PRINT_ALTERNATE_FORM = 1 << 4
,
_PRINT_UPPER_CASE = 1 << 5
, _PRINT_PAD_ZERO = 1 << 6
} |
| |
| enum | _print_format_length_t {
_PRINT_DEFAULT = 0
, _PRINT_HH
, _PRINT_H
, _PRINT_L
,
_PRINT_LL
, _PRINT_J
, _PRINT_Z
, _PRINT_T
} |
| |
|
| static int | _print_padding_left (_print_ctx_t *ctx, _print_format_ctx_t *format, int len) |
| |
| static int | _print_padding_right (_print_ctx_t *ctx, _print_format_ctx_t *format, int padding) |
| |
| static int | _print_integer_print (_print_ctx_t *ctx, _print_format_ctx_t *format, _print_integer_t *integer) |
| |
| static int | _print_format_signed_integer (_print_ctx_t *ctx, _print_format_ctx_t *format) |
| |
| static int | _print_format_unsigned_integer (_print_ctx_t *ctx, _print_format_ctx_t *format, uint32_t base) |
| |
| static int | _print_format_char (_print_ctx_t *ctx, _print_format_ctx_t *format) |
| |
| static int | _print_format_string (_print_ctx_t *ctx, _print_format_ctx_t *format) |
| |
| static int | _print_format_written (_print_ctx_t *ctx) |
| |
| static int | _print_format_percent (_print_ctx_t *ctx) |
| |
| static int | _print_format (_print_ctx_t *ctx) |
| |
| static int | _print (const char *_RESTRICT format, size_t n, va_list arg, void *data) |
| |
◆ _PRINT_INTEGER_PUSH
| #define _PRINT_INTEGER_PUSH |
( |
|
integer, |
|
|
|
c |
|
) |
| (*--(integer)->dataPtr = (c)) |
◆ _PRINT_INTEGER_PREFIX_PUSH
| #define _PRINT_INTEGER_PREFIX_PUSH |
( |
|
integer, |
|
|
|
c |
|
) |
| (*--(integer)->prefixPtr = (c)) |
◆ _PRINT_INTEGER_LEN
| #define _PRINT_INTEGER_LEN |
( |
|
integer | ) |
((int)((sizeof((integer)->data)) - ((integer)->dataPtr - (integer)->data))) |
◆ _PRINT_INTEGER_PREFIX_LEN
| #define _PRINT_INTEGER_PREFIX_LEN |
( |
|
integer | ) |
((int)((sizeof((integer)->prefix)) - ((integer)->prefixPtr - (integer)->prefix))) |
◆ _print_format_flags_t
| Enumerator |
|---|
| _PRINT_LEFT_ALIGNED | |
| _PRINT_FORCE_SIGN | |
| _PRINT_SPACE_SIGN | |
| _PRINT_ALTERNATE_FORM | |
| _PRINT_UPPER_CASE | |
| _PRINT_PAD_ZERO | |
Definition at line 56 of file print.h.
◆ _print_format_length_t
| Enumerator |
|---|
| _PRINT_DEFAULT | |
| _PRINT_HH | |
| _PRINT_H | |
| _PRINT_L | |
| _PRINT_LL | |
| _PRINT_J | |
| _PRINT_Z | |
| _PRINT_T | |
Definition at line 66 of file print.h.
◆ _print_padding_left()
◆ _print_padding_right()
◆ _print_integer_print()
◆ _print_format_signed_integer()
◆ _print_format_unsigned_integer()
◆ _print_format_char()
◆ _print_format_string()
◆ _print_format_written()
◆ _print_format_percent()
◆ _print_format()
- Todo:
- Implement floating point formatting
Definition at line 439 of file print.h.
◆ _print()