Version 7.0
Copyright © 2021 Lowell D. Thomas
APG
… an ABNF Parser Generator
Data Structures | Functions
lines.h File Reference

Header file for the lines object. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  line
 Defines the characteristics of a single line. More...
 

Functions

void * vpLinesCtor (exception *spEx, const char *cpInput, aint uiLength)
 The lines object constructor. More...
 
void vLinesDtor (void *vpCtx)
 The lines object destructor. More...
 
linespLinesFirst (void *vpCtx)
 Initialize an iterator over the lines. More...
 
linespLinesNext (void *vpCtx)
 Returns the next line of text from the iterator. More...
 
aint uiLinesCount (void *vpCtx)
 Returns the number of lines of text. More...
 
aint uiLinesLength (void *vpCtx)
 Returns the number of text characters. More...
 
abool bLinesFindLine (void *vpCtx, aint uiOffset, aint *uipLine, aint *uipRelOffset)
 Find the line that the given character is in. More...
 

Detailed Description

Header file for the lines object.

Definition in file lines.h.

Function Documentation

◆ bLinesFindLine()

abool bLinesFindLine ( void *  vpCtx,
aint  uiOffset,
aint uipLine,
aint uipRelOffset 
)

Find the line that the given character is in.

Parameters
vpCtxPointer to a lines context, previously returned from vpLinesCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code.
uiOffsetThe zero-based offset of the character to find.
uipLinePointer to an integer, set to the line number that the character is in on return.
uipRelOffsetPointer to an integer, on return, set to the offset of the character relative to the beginning of the line it is in.
Returns
True if the line is found, false if the line could not be found (i.e. uiOffset is beyond the last character of data).

Definition at line 146 of file lines.c.

◆ spLinesFirst()

line* spLinesFirst ( void *  vpCtx)

Initialize an iterator over the lines.

Sets up the iterator and returns the first line.

Parameters
vpCtxPointer to a lines context, previously returned from vpLinesCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code.
Returns
Pointer to the first line of text.

Definition at line 170 of file lines.c.

◆ spLinesNext()

line* spLinesNext ( void *  vpCtx)

Returns the next line of text from the iterator.

Parameters
vpCtxPointer to a lines context, previously returned from vpLinesCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code.
Returns
pointer to the next line of text on success, NULL if no further lines are available or on failure

Definition at line 185 of file lines.c.

◆ uiLinesCount()

aint uiLinesCount ( void *  vpCtx)

Returns the number of lines of text.

Parameters
vpCtxPointer to a lines context, previously returned from vpLinesCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code.
Returns
The number of lines of text.

Definition at line 202 of file lines.c.

◆ uiLinesLength()

aint uiLinesLength ( void *  vpCtx)

Returns the number of text characters.

The number of all characters, including the line ending characters.

Parameters
vpCtxPointer to a lines context, previously returned from vpLinesCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code.
Returns
The number of characters of text.

Definition at line 218 of file lines.c.

◆ vLinesDtor()

void vLinesDtor ( void *  vpCtx)

The lines object destructor.

Releases all allocated memory and clears the context to prevent accidental reuse.

Parameters
vpCtxA pointer to a valid lines context previously return from vpLinesCtor(). Silently ignored if NULL. However, if non-NULL it must be a valid lines context pointer. The application will silently exit with BAD_CONTEXT exit code if vpCtx is invalid.

Definition at line 123 of file lines.c.

◆ vpLinesCtor()

void* vpLinesCtor ( exception spEx,
const char *  cpInput,
aint  uiLength 
)

The lines object constructor.

Reads the character input and separates it into individual lines, generating a list of line structures, one for each line of text.

Parameters
spExPointer to a valid exception structure initialized with XCTOR(). If not valid the application will silently exit with a BAD_CONTEXT exit code.
cpInput- pointer to the array of characters
uiLength- the number of characters in the array
Returns
Pointer to the object context. Exception thrown on memory allocation failure.

Definition at line 85 of file lines.c.

APG Version 7.0 is licensed under the 2-Clause BSD License,
an Open Source Initiative Approved License.