libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
GblScanner Struct Reference

#include <gimbal_scanner.h>

Inheritance diagram for GblScanner:
GblObject GblBox GblITableVariant GblInstance

Data Fields

union { 
 
   GblScannerClass *   pClass 
 
   GblObject   base 
 
};  
 
GblStringView token
 
GblStringView next
 
const GblStringRefpError
 
GBL_SCANNER_FLAGS status
 
- Data Fields inherited from GblObject
union { 
 
   GblObjectClass *   pClass 
 
   GblBox   base 
 
};  
 
- Data Fields inherited from GblBox
union { 
 
   GblBoxClass *   pClass 
 
   GblInstance   base 
 
};  
 
struct { 
 
   GblArrayMap *   pFields 
 
   volatile uint16_t   refCounter 
 
   uint16_t   contextType: 1 
 
   uint16_t   constructedInPlace: 1 
 
   uint16_t   derivedFlags: 14 
 
private_ 
 
- Data Fields inherited from GblInstance
GblClasspClass
 

Related Symbols

(Note that these are not member symbols.)

Input and Delimeters

Methods for setting input and delimeter pattern

GblStringRefGblScanner_input (const GblScanner *pSelf)
 
void GblScanner_setInput (GblScanner *pSelf, const char *pStr, size_t count)
 
void GblScanner_setInputRef (GblScanner *pSelf, const GblStringRef *pRef)
 
GblStringRefGblScanner_delimeters (const GblScanner *pSelf)
 
void GblScanner_setDelimeters (GblScanner *pSelf, const char *pPattern)
 
Errors

Methods for managing errors

void GblScanner_clearError (GblScanner *pSelf)
 
void GblScanner_raiseError (GblScanner *pSelf, GblFlags flags, const char *pFmt,...)
 
Stream

Methods for controlling the input stream

void GblScanner_reset (GblScanner *pSelf)
 
size_t GblScanner_tell (const GblScanner *pSelf)
 
GblBool GblScanner_seek (GblScanner *pSelf, int whence)
 
Cursor

Methods for managing the stream cursor

const GblScannerCursorGblScanner_cursor (const GblScanner *pSelf, size_t depth)
 
size_t GblScanner_cursorDepth (const GblScanner *pSelf)
 
GBL_RESULT GblScanner_pushCursor (GblScanner *pSelf)
 
GBL_RESULT GblScanner_popCursor (GblScanner *pSelf)
 
Scanning

Methods for scanning the next token

GblBool GblScanner_scanToken (GblScanner *pSelf)
 
GblBool GblScanner_scanMatch (GblScanner *pSelf, const char *pPat)
 
GblBool GblScanner_scanPattern (GblScanner *pSelf, const GblPattern *pPat)
 
GblBool GblScanner_scanLines (GblScanner *pSelf, size_t lines)
 
GblBool GblScanner_scanBytes (GblScanner *pSelf, size_t bytes)
 
GblBool GblScanner_scanBool (GblScanner *pSelf, GblBool *pBool)
 
GblBool GblScanner_scanChar (GblScanner *pSelf, char *pChar)
 
GblBool GblScanner_scanUint8 (GblScanner *pSelf, uint8_t *pUint)
 
GblBool GblScanner_scanUint16 (GblScanner *pSelf, uint16_t *pUint)
 
GblBool GblScanner_scanInt16 (GblScanner *pSelf, int16_t *pInt)
 
GblBool GblScanner_scanInt32 (GblScanner *pSelf, int32_t *pInt)
 
GblBool GblScanner_scanUint32 (GblScanner *pSelf, uint32_t *pUint)
 
GblBool GblScanner_scanInt64 (GblScanner *pSelf, int64_t *pInt)
 
GblBool GblScanner_scanUint64 (GblScanner *pSelf, uint64_t *pUint)
 
GblBool GblScanner_scanFloat (GblScanner *pSelf, float *pFloat)
 
GblBool GblScanner_scanDouble (GblScanner *pSelf, double *pDouble)
 
GblBool GblScanner_scanType (GblScanner *pSelf, GblType t,...)
 
GblBool GblScanner_scanTypeVa (GblScanner *pSelf, GblType t, va_list *pVa)
 
#define GblScanner_scan(self, ptr)
 
Peeking

Methods for peeking at the next token

GblBool GblScanner_peekToken (GblScanner *pSelf)
 
GblBool GblScanner_peekMatch (GblScanner *pSelf, const char *pMatch)
 
GblBool GblScanner_peekPattern (GblScanner *pSelf, const GblPattern *pPat)
 
GblBool GblScanner_peekLines (GblScanner *pSelf, size_t count)
 
GblBool GblScanner_peekBytes (GblScanner *pSelf, size_t count)
 
GblBool GblScanner_peekBool (GblScanner *pSelf, GblBool *pBool)
 
GblBool GblScanner_peekChar (GblScanner *pSelf, char *pChar)
 
GblBool GblScanner_peekUint8 (GblScanner *pSelf, uint8_t *pUint)
 
GblBool GblScanner_peekUint16 (GblScanner *pSelf, uint16_t *pUint)
 
GblBool GblScanner_peekInt16 (GblScanner *pSelf, int16_t *pInt)
 
GblBool GblScanner_peekInt32 (GblScanner *pSelf, int32_t *pInt)
 
GblBool GblScanner_peekUint32 (GblScanner *pSelf, uint32_t *pUint)
 
GblBool GblScanner_peekInt64 (GblScanner *pSelf, int64_t *pInt)
 
GblBool GblScanner_peekUint64 (GblScanner *pSelf, uint64_t *pUint)
 
GblBool GblScanner_peekFloat (GblScanner *pSelf, float *pFloat)
 
GblBool GblScanner_peekDouble (GblScanner *pSelf, double *pDouble)
 
GblBool GblScanner_peekType (GblScanner *pSelf, GblType t,...)
 
GblBool GblScanner_peekTypeVa (GblScanner *pSelf, GblType t, va_list *pVa)
 
#define GblScanner_peek(self, ptr)
 
Skipping

Methods for skipping over the input steram

GblBool GblScanner_skipTokens (GblScanner *pSelf, size_t count)
 
GblBool GblScanner_skipMatch (GblScanner *pSelf, const char *pPattern)
 
GblBool GblScanner_skipPattern (GblScanner *pSelf, const GblPattern *pPat)
 
GblBool GblScanner_skipToMatch (GblScanner *pSelf, const char *pPattern)
 
GblBool GblScanner_skipToPattern (GblScanner *pSelf, const GblPattern *pPat)
 
GblBool GblScanner_skipLines (GblScanner *pSelf, size_t count)
 
GblBool GblScanner_skipBytes (GblScanner *pSelf, size_t count)
 
Utilities

Methods providing other utilities

int GblScanner_scanf (GblScanner *pSelf, const char *pFmt,...)
 
int GblScanner_vscanf (GblScanner *pSelf, const char *pFmt, va_list *pList)
 

Detailed Description

Generic text stream scanner object.

GblScanner offers a generic way to scan through a stream of text, parsing its contents into variables of any type supported by the type system.

See also
GblScannerClass

Definition at line 112 of file gimbal_scanner.h.

Friends And Related Symbol Documentation

◆ GblScanner_input()

GblStringRef * GblScanner_input ( const GblScanner pSelf)
related

Returns a string reference to the string current being used as the input stream.

◆ GblScanner_setInput()

void GblScanner_setInput ( GblScanner pSelf,
const char *  pStr,
size_t  count 
)
related

Sets the input stream to the given string, optionally taking its size, and resetting the stream.

◆ GblScanner_setInputRef()

void GblScanner_setInputRef ( GblScanner pSelf,
const GblStringRef pRef 
)
related

Sets the input stream to given string reference, taking ownership of it, and resetting the sream.

◆ GblScanner_delimeters()

GblStringRef * GblScanner_delimeters ( const GblScanner pSelf)
related

Returns a reference to the string used as the delimeter regular expression pattern.

◆ GblScanner_setDelimeters()

void GblScanner_setDelimeters ( GblScanner pSelf,
const char *  pPattern 
)
related

Sets the stream's delimeter regular expression pattern to pPattern.

◆ GblScanner_clearError()

void GblScanner_clearError ( GblScanner pSelf)
related

Clears the pending error message string and any error flags which are set on the given scanner.

◆ GblScanner_raiseError()

void GblScanner_raiseError ( GblScanner pSelf,
GblFlags  flags,
const char *  pFmt,
  ... 
)
related

Raises an error, setting the given flags and message for the given scanner.

◆ GblScanner_reset()

void GblScanner_reset ( GblScanner pSelf)
related

Resets the state of the input stream, moving the cursor back to the beginning.

◆ GblScanner_tell()

size_t GblScanner_tell ( const GblScanner pSelf)
related

Fetches the current position of the cursor into the input stream.

◆ GblScanner_seek()

GblBool GblScanner_seek ( GblScanner pSelf,
int  whence 
)
related

Moves the cursor's current stream position by the given positive or negative offset.

◆ GblScanner_cursor()

const GblScannerCursor * GblScanner_cursor ( const GblScanner pSelf,
size_t  depth 
)
related

Returns the top cursor on the stack, which maintains the current position into the input stream.

◆ GblScanner_cursorDepth()

size_t GblScanner_cursorDepth ( const GblScanner pSelf)
related

Returns the depth of the cursor stack for the given scanner object.

◆ GblScanner_pushCursor()

GBL_RESULT GblScanner_pushCursor ( GblScanner pSelf)
related

Pushes the value of the current cursor onto the stack, saving its state.

◆ GblScanner_popCursor()

GBL_RESULT GblScanner_popCursor ( GblScanner pSelf)
related

Pops the value of the current cursor from the top of the stack, reloading its state.

◆ GblScanner_scanToken()

GblBool GblScanner_scanToken ( GblScanner pSelf)
related

Scans the next token, storing it to GblScanner::token or returning GBL_FALSE upon failure.

◆ GblScanner_scanMatch()

GblBool GblScanner_scanMatch ( GblScanner pSelf,
const char *  pPat 
)
related

Scans the next token to GblScanner::token if it matches the given pattern or returning GBL_FALSE upon failure.

◆ GblScanner_scanPattern()

GblBool GblScanner_scanPattern ( GblScanner pSelf,
const GblPattern pPat 
)
related
Todo:
implement me: GblScanner_scanMatch() overload

◆ GblScanner_scanLines()

GblBool GblScanner_scanLines ( GblScanner pSelf,
size_t  lines 
)
related

Scans the given number of lines to GblScanner::token or returns GBL_FALSE upon failure.

◆ GblScanner_scanBytes()

GblBool GblScanner_scanBytes ( GblScanner pSelf,
size_t  bytes 
)
related

Scans the given number of bytes to GblScanner::token or returns GBL_FALSE upon failure.

◆ GblScanner_scanBool()

GblBool GblScanner_scanBool ( GblScanner pSelf,
GblBool pBool 
)
related

Scans the next token as a boolean to GblScanner::token, returning GBL_TRUE and setting pBool to the scanned value upon success.

◆ GblScanner_scanChar()

GblBool GblScanner_scanChar ( GblScanner pSelf,
char *  pChar 
)
related

Scans the next token as a character to GblScanner::token, returning GBL_TRUE and setting pChar to the scanned value upon success.

◆ GblScanner_scanUint8()

GblBool GblScanner_scanUint8 ( GblScanner pSelf,
uint8_t *  pUint 
)
related

Scans the next token as an 8-bit unsigned integer to GblScanner::token, returning GBL_TRUE and setting pUint to the scanned value upon success.

◆ GblScanner_scanUint16()

GblBool GblScanner_scanUint16 ( GblScanner pSelf,
uint16_t *  pUint 
)
related

Scans the next token as a 16-bit unsigned integer to GblScanner::token, returning GBL_TRUE and setting pUint to the scanned value upon success.

◆ GblScanner_scanInt16()

GblBool GblScanner_scanInt16 ( GblScanner pSelf,
int16_t *  pInt 
)
related

Scans the next token as a 16-bit integer to GblScanner::token, returning GBL_TRUE and setting pInt to the scanned value upon success.

◆ GblScanner_scanInt32()

GblBool GblScanner_scanInt32 ( GblScanner pSelf,
int32_t *  pInt 
)
related

Scans the next token as a 32-bit integer to GblScanner::token, returning GBL_TRUE and setting pInt to the scanned value upon success.

◆ GblScanner_scanUint32()

GblBool GblScanner_scanUint32 ( GblScanner pSelf,
uint32_t *  pUint 
)
related

Scans the next token as a 32-bit unsigned integer to GblScanner::token, returning GBL_TRUE and setting pUint to the scanned value upon success.

◆ GblScanner_scanInt64()

GblBool GblScanner_scanInt64 ( GblScanner pSelf,
int64_t *  pInt 
)
related

Scans the next token as a 64-bit integer to GblScanner::token, returning GBL_TRUE and setting pInt to the scanned value upon success.

◆ GblScanner_scanUint64()

GblBool GblScanner_scanUint64 ( GblScanner pSelf,
uint64_t *  pUint 
)
related

Scans the next token as a 64-bit unsigned integer to GblScanner::token, returning GBL_TRUE and setting pUint to the scanned value upon success.

◆ GblScanner_scanFloat()

GblBool GblScanner_scanFloat ( GblScanner pSelf,
float *  pFloat 
)
related

Scans the next token as a float to GblScanner::token, returning GBL_TRUE and setting pFloat to the scanned value upon success.

◆ GblScanner_scanDouble()

GblBool GblScanner_scanDouble ( GblScanner pSelf,
double *  pDouble 
)
related

Scans the next token as a double to GblScanner::token, returning GBL_TRUE and setting pDouble to the scanned value upon success.

◆ GblScanner_scanType()

GblBool GblScanner_scanType ( GblScanner pSelf,
GblType  t,
  ... 
)
related

Scans the next token and attempts to convert it from a string to the given type, t, moving its value through the variadic argument list.

◆ GblScanner_scanTypeVa()

GblBool GblScanner_scanTypeVa ( GblScanner pSelf,
GblType  t,
va_list *  pVa 
)
related

Same as GblScanner_scanType(), except taking a va_list* rather than (a) variadic argument(s)

◆ GblScanner_scan

#define GblScanner_scan (   self,
  ptr 
)
related

Generic overload macro which automatically calls the respective scan function for the type of ptr.

Definition at line 281 of file gimbal_scanner.h.

◆ GblScanner_peekToken()

GblBool GblScanner_peekToken ( GblScanner pSelf)
related

Peeks at the next token, without advancing the stream, storing it to GblScanner::next or returning GBL_FALSE upon failure.

◆ GblScanner_peekMatch()

GblBool GblScanner_peekMatch ( GblScanner pSelf,
const char *  pMatch 
)
related

Peeks at the next token, storing it to GblScanner::next if it exactly matches the given pattern or returning GBL_FALSE upon failure.

◆ GblScanner_peekPattern()

GblBool GblScanner_peekPattern ( GblScanner pSelf,
const GblPattern pPat 
)
related
Todo:
implement me: GblScanner_peekMatch() overload

◆ GblScanner_peekLines()

GblBool GblScanner_peekLines ( GblScanner pSelf,
size_t  count 
)
related

Peeks at the next count lines, storing them to GblScanner::next or returning GBL_FALSE upon encountering EOF.

◆ GblScanner_peekBytes()

GblBool GblScanner_peekBytes ( GblScanner pSelf,
size_t  count 
)
related

Peeks at the next count bytes, storing them to GblScanner::next or returning GBL_FALSE upon encountering EOF.

◆ GblScanner_peekBool()

GblBool GblScanner_peekBool ( GblScanner pSelf,
GblBool pBool 
)
related

Peeks at the next token, without advancing, setting pBool and returning GBL_TRUE if it's boolean-convertible, or returning GBL_FALSE otherwise.

◆ GblScanner_peekChar()

GblBool GblScanner_peekChar ( GblScanner pSelf,
char *  pChar 
)
related

Peeks at the next token, without advancing, setting pChar and returning GBL_TRUE if it's character-convertible, or returning GBL_FALSE otherwise.

◆ GblScanner_peekUint8()

GblBool GblScanner_peekUint8 ( GblScanner pSelf,
uint8_t *  pUint 
)
related

Peeks at the next token, without advancing, setting pUint and returning GBL_TRUE if it's uint8-convertible, or returning GBL_FALSE otherwise.

◆ GblScanner_peekUint16()

GblBool GblScanner_peekUint16 ( GblScanner pSelf,
uint16_t *  pUint 
)
related

Peeks at the next token, without advancing, setting pUint and returning GBL_TRUE if it's uint16-convertible, or returning GBL_FALSE otherwise.

◆ GblScanner_peekInt16()

GblBool GblScanner_peekInt16 ( GblScanner pSelf,
int16_t *  pInt 
)
related

Peeks at the next token, without advancing, setting pInt and returning GBL_TRUE if it's int16-convertible, or returning GBL_FALSE otherwise.

◆ GblScanner_peekInt32()

GblBool GblScanner_peekInt32 ( GblScanner pSelf,
int32_t *  pInt 
)
related

Peeks at the next token, without advancing, setting pInt and returning GBL_TRUE if it's int32-convertible, or returning GBL_FALSE otherwise.

◆ GblScanner_peekUint32()

GblBool GblScanner_peekUint32 ( GblScanner pSelf,
uint32_t *  pUint 
)
related

Peeks at the next token, without advancing, setting pUint and returning GBL_TRUE if it's uint32-convertible, or returning GBL_FALSE otherwise.

◆ GblScanner_peekInt64()

GblBool GblScanner_peekInt64 ( GblScanner pSelf,
int64_t *  pInt 
)
related

Peeks at the next token, without advancing, setting pInt and returning GBL_TRUE if it's int64-convertible, or returning GBL_FALSE otherwise.

◆ GblScanner_peekUint64()

GblBool GblScanner_peekUint64 ( GblScanner pSelf,
uint64_t *  pUint 
)
related

Peeks at the next token, without advancing, setting pUint and returning GBL_TRUE if it's uint64-convertible, or returning GBL_FALSE otherwise.

◆ GblScanner_peekFloat()

GblBool GblScanner_peekFloat ( GblScanner pSelf,
float *  pFloat 
)
related

Peeks at the next token, without advancing, setting pFloat and returning GBL_TRUE if it's float-convertible, or returning GBL_FALSE otherwise.

◆ GblScanner_peekDouble()

GblBool GblScanner_peekDouble ( GblScanner pSelf,
double *  pDouble 
)
related

Peeks at the next token, without advancing, setting pDouble and returning GBL_TRUE if it's double-convertible, or returning GBL_FALSE otherwise.

◆ GblScanner_peekType()

GblBool GblScanner_peekType ( GblScanner pSelf,
GblType  t,
  ... 
)
related

Peeks at the next token, without advancing, attempting to convert it to the given variant type, moving its value to the variadic argument, returning GBL_TRUE upon success.

◆ GblScanner_peekTypeVa()

GblBool GblScanner_peekTypeVa ( GblScanner pSelf,
GblType  t,
va_list *  pVa 
)
related

Same as GblScanner_peekType(), except taking a va_list* rather than (a) variadic argument(s)

◆ GblScanner_peek

#define GblScanner_peek (   self,
  ptr 
)
related

Generic overload macro which automatically calls the respective peek function for the type of ptr.

Definition at line 327 of file gimbal_scanner.h.

◆ GblScanner_skipTokens()

GblBool GblScanner_skipTokens ( GblScanner pSelf,
size_t  count 
)
related

Attempts to skip the next count tokens from the stream, returning GBL_TRUE upon success or GBL_FALSE upon EOF.

◆ GblScanner_skipMatch()

GblBool GblScanner_skipMatch ( GblScanner pSelf,
const char *  pPattern 
)
related

Attempts to skip to just past the given regex pPattern, returning GBL_TRUE upon success or GBL_FALSE if not found or upon EOF.

◆ GblScanner_skipPattern()

GblBool GblScanner_skipPattern ( GblScanner pSelf,
const GblPattern pPat 
)
related
Todo:
implement me: GblScanner_skipMatch() overload

◆ GblScanner_skipToMatch()

GblBool GblScanner_skipToMatch ( GblScanner pSelf,
const char *  pPattern 
)
related

Attemps to skip to the matching regex pPattern, returning GBL_TRUE upon success or GBL_FALSE if not found or upon EOF.

◆ GblScanner_skipToPattern()

GblBool GblScanner_skipToPattern ( GblScanner pSelf,
const GblPattern pPat 
)
related
Todo:
implement me: GblScanner_skipToMatch() overload

◆ GblScanner_skipLines()

GblBool GblScanner_skipLines ( GblScanner pSelf,
size_t  count 
)
related

Attempts to skip count lines, returning GBL_TRUE upon success or GBL_FALSE upon EOF.

◆ GblScanner_skipBytes()

GblBool GblScanner_skipBytes ( GblScanner pSelf,
size_t  count 
)
related

Attempts to skip count bytes, returning GBL_TRUE upon success or GBL_FALSE upon EOF.

◆ GblScanner_scanf()

int GblScanner_scanf ( GblScanner pSelf,
const char *  pFmt,
  ... 
)
related

Invokes the C stdlib routine, sscanf(), at the current position of the input stream.

◆ GblScanner_vscanf()

int GblScanner_vscanf ( GblScanner pSelf,
const char *  pFmt,
va_list *  pList 
)
related

Invokes the C stdlib routine, vscanf(), at the current position of the input stream.

Field Documentation

◆ pClass

GblScannerClass* GblScanner::pClass

Pointer to class/vtable structure.

Definition at line 112 of file gimbal_scanner.h.

◆ base

GblObject GblScanner::base

Inherited base instance structure.

Definition at line 112 of file gimbal_scanner.h.

◆ token

GblStringView GblScanner::token

Current token in the stream.

Definition at line 113 of file gimbal_scanner.h.

◆ next

GblStringView GblScanner::next

Peeked-at next token in the stream.

Definition at line 114 of file gimbal_scanner.h.

◆ pError

const GblStringRef* GblScanner::pError

Pending error message.

Definition at line 115 of file gimbal_scanner.h.

◆ status

GBL_SCANNER_FLAGS GblScanner::status

Status after the last operation.

Definition at line 116 of file gimbal_scanner.h.


The documentation for this struct was generated from the following file: