PatchworkOS  3984a1d
A non-POSIX operating system.
Loading...
Searching...
No Matches

Internal Scan Implementation. More...

Collaboration diagram for Scan:

Detailed Description

Internal Scan Implementation.

Provides a common implementation for scanning formatted input, any function that needs to scan formatted input should define the _SCAN_GET() and _SCAN_UNGET() macros before including this file.

The _SCAN_GET(ctx) macro should evaluate to an expression that returns the next character from the input source and takes a pointer to the current scan_ctx_t as an argument.

The_SCAN_UNGET(ctx, c) macro should evaluate to an expression that pushes back the character c to the input source and takes a pointer to the current scan_ctx_t and the character to push back as argument.

Todo:
Implement floating point scanning.
See also
https://cplusplus.com/reference/cstdio/scanf/ for details on the format specifiers.

Data Structures

struct  _scan_ctx_t
 
struct  _scan_format_ctx_t
 
struct  _scanset_t
 

Enumerations

enum  _scan_format_flags_t { _SCAN_SUPPRESS_ASSIGNMENT = 1 << 0 }
 
enum  _scan_format_length_t {
  _SCAN_DEFAULT = 0 , _SCAN_HH , _SCAN_H , _SCAN_L ,
  _SCAN_LL , _SCAN_J , _SCAN_Z , _SCAN_T
}
 
enum  _scan_format_integer_flags_t { _SCAN_INTEGER_UNSIGNED = 0 , _SCAN_INTEGER_SIGNED = 1 << 0 }
 

Functions

static int _scan_next (_scan_ctx_t *ctx)
 
static void _scan_undo (_scan_ctx_t *ctx, int c)
 
static int _scan_whitespace (_scan_ctx_t *ctx)
 
static int _scan_asign_signed_int (_scan_ctx_t *ctx, _scan_format_ctx_t *format, int64_t value)
 
static int _scan_asign_unsigned_int (_scan_ctx_t *ctx, _scan_format_ctx_t *format, uint64_t value)
 
static int _scan_format_integer (_scan_ctx_t *ctx, _scan_format_ctx_t *format, uint32_t base, _scan_format_integer_flags_t flags)
 
static int _scan_format_float (_scan_ctx_t *ctx, _scan_format_ctx_t *format)
 
static int _scan_format_char (_scan_ctx_t *ctx, _scan_format_ctx_t *format)
 
static int _scan_format_string (_scan_ctx_t *ctx, _scan_format_ctx_t *format)
 
static void _scanset_set (_scanset_t *scanset, uint8_t c)
 
static bool _scanset_get (_scanset_t *scanset, uint8_t c)
 
static int _scan_format_scanset (_scan_ctx_t *ctx, _scan_format_ctx_t *format)
 
static int _scan_format_count (_scan_ctx_t *ctx, _scan_format_ctx_t *format)
 
static int _scan_format_percent (_scan_ctx_t *ctx, _scan_format_ctx_t *format)
 
static int _scan_format (_scan_ctx_t *ctx)
 
static int _scan (const char *_RESTRICT format, va_list arg, void *private)
 

Enumeration Type Documentation

◆ _scan_format_flags_t

Enumerator
_SCAN_SUPPRESS_ASSIGNMENT 

Definition at line 108 of file scan.h.

◆ _scan_format_length_t

Enumerator
_SCAN_DEFAULT 
_SCAN_HH 
_SCAN_H 
_SCAN_L 
_SCAN_LL 
_SCAN_J 
_SCAN_Z 
_SCAN_T 

Definition at line 113 of file scan.h.

◆ _scan_format_integer_flags_t

Enumerator
_SCAN_INTEGER_UNSIGNED 
_SCAN_INTEGER_SIGNED 

Definition at line 202 of file scan.h.

Function Documentation

◆ _scan_next()

static int _scan_next ( _scan_ctx_t ctx)
inlinestatic

Definition at line 53 of file scan.h.

Here is the caller graph for this function:

◆ _scan_undo()

static void _scan_undo ( _scan_ctx_t ctx,
int  c 
)
inlinestatic

Definition at line 71 of file scan.h.

Here is the caller graph for this function:

◆ _scan_whitespace()

static int _scan_whitespace ( _scan_ctx_t ctx)
inlinestatic

Definition at line 82 of file scan.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _scan_asign_signed_int()

static int _scan_asign_signed_int ( _scan_ctx_t ctx,
_scan_format_ctx_t format,
int64_t  value 
)
inlinestatic

Definition at line 132 of file scan.h.

Here is the caller graph for this function:

◆ _scan_asign_unsigned_int()

static int _scan_asign_unsigned_int ( _scan_ctx_t ctx,
_scan_format_ctx_t format,
uint64_t  value 
)
inlinestatic

Definition at line 167 of file scan.h.

Here is the caller graph for this function:

◆ _scan_format_integer()

static int _scan_format_integer ( _scan_ctx_t ctx,
_scan_format_ctx_t format,
uint32_t  base,
_scan_format_integer_flags_t  flags 
)
inlinestatic

Definition at line 208 of file scan.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _scan_format_float()

static int _scan_format_float ( _scan_ctx_t ctx,
_scan_format_ctx_t format 
)
inlinestatic
Todo:
Implement floating point scanning

Definition at line 314 of file scan.h.

Here is the caller graph for this function:

◆ _scan_format_char()

static int _scan_format_char ( _scan_ctx_t ctx,
_scan_format_ctx_t format 
)
inlinestatic

Definition at line 322 of file scan.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _scan_format_string()

static int _scan_format_string ( _scan_ctx_t ctx,
_scan_format_ctx_t format 
)
inlinestatic

Definition at line 357 of file scan.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _scanset_set()

static void _scanset_set ( _scanset_t scanset,
uint8_t  c 
)
inlinestatic

Definition at line 406 of file scan.h.

Here is the caller graph for this function:

◆ _scanset_get()

static bool _scanset_get ( _scanset_t scanset,
uint8_t  c 
)
inlinestatic

Definition at line 411 of file scan.h.

Here is the caller graph for this function:

◆ _scan_format_scanset()

static int _scan_format_scanset ( _scan_ctx_t ctx,
_scan_format_ctx_t format 
)
inlinestatic
Todo:
Wide chars

Definition at line 417 of file scan.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _scan_format_count()

static int _scan_format_count ( _scan_ctx_t ctx,
_scan_format_ctx_t format 
)
inlinestatic

Definition at line 514 of file scan.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _scan_format_percent()

static int _scan_format_percent ( _scan_ctx_t ctx,
_scan_format_ctx_t format 
)
inlinestatic

Definition at line 524 of file scan.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _scan_format()

static int _scan_format ( _scan_ctx_t ctx)
inlinestatic

Definition at line 543 of file scan.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _scan()

static int _scan ( const char *_RESTRICT  format,
va_list  arg,
void private 
)
inlinestatic

Definition at line 666 of file scan.h.

Here is the call graph for this function:
Here is the caller graph for this function: