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

A message logging object. More...

#include "../library/lib.h"
Include dependency graph for msglog.c:

Go to the source code of this file.

Data Structures

struct  msgs
 The message log context. More...
 

Functions

void * vpMsgsCtor (exception *spEx)
 The Message Log constructor. More...
 
void vMsgsDtor (void *vpCtx)
 The object destructor. More...
 
abool bMsgsValidate (void *vpCtx)
 Validate a msglog context pointer. More...
 
void vMsgsClear (void *vpCtx)
 Clears the object of all messages. More...
 
void vMsgsLog (void *vpCtx, const char *cpMsg)
 Logs a message. More...
 
const char * cpMsgsFirst (void *vpCtx)
 Get a pointer to the first logged message, if any. More...
 
const char * cpMsgsNext (void *vpCtx)
 Get a pointer to the next logged message, if any. More...
 
aint uiMsgsCount (void *vpCtx)
 Get the number of logged messages. More...
 

Detailed Description

A message logging object.

This object is a simple, but consistent method for logging multiple messages, whether error messages or warning messages or otherwise, with an iterator for retrieving them.

See vUtilPrintMsgs() for a utility that will display all messages in a message log object.

Definition in file msglog.c.

Function Documentation

◆ bMsgsValidate()

abool bMsgsValidate ( void *  vpCtx)

Validate a msglog context pointer.

Parameters
vpCtxA pointer to a possibly valid msglog context previously return from vpMsgsCtor().
Returns
True if valid. False otherwise.

Definition at line 110 of file msglog.c.

◆ cpMsgsFirst()

const char* cpMsgsFirst ( void *  vpCtx)

Get a pointer to the first logged message, if any.

Initializes an iterator over the logged messages.

Parameters
vpCtx- Pointer to a valid object context, previously returned from vpMsgsCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code.
Returns
A pointer to the first logged message or NULL if none.

Definition at line 164 of file msglog.c.

◆ cpMsgsNext()

const char* cpMsgsNext ( void *  vpCtx)

Get a pointer to the next logged message, if any.

Iterates over the logged messages.

Parameters
vpCtx- Pointer to a valid object context, previously returned from vpMsgsCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code.
Returns
A pointer to the next logged message. NULL if none.

Definition at line 185 of file msglog.c.

◆ uiMsgsCount()

aint uiMsgsCount ( void *  vpCtx)

Get the number of logged messages.

Parameters
vpCtx- Pointer to a valid object context, previously returned from vpMsgsCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code.
Returns
The number of logged messages.

Definition at line 213 of file msglog.c.

◆ vMsgsClear()

void vMsgsClear ( void *  vpCtx)

Clears the object of all messages.

Restores it to the same state as a newly created object.

Parameters
vpCtx- Pointer to a valid object context, previously returned from vpMsgsCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code.

Definition at line 124 of file msglog.c.

◆ vMsgsDtor()

void vMsgsDtor ( void *  vpCtx)

The object destructor.

Frees all memory associated with the object. Clears the memory to prevent accidental use of stale pointers.

Parameters
vpCtxA valid context pointer returned from a previous call to vpMsgsCtor(). NULL is silently ignored. However, if non-NULL it must be a valid point or the application will silently exit with BAD_CONTEXT exit code.

Definition at line 92 of file msglog.c.

◆ vMsgsLog()

void vMsgsLog ( void *  vpCtx,
const char *  cpMsg 
)

Logs a message.

Parameters
vpCtx- Pointer to a valid object context, previously returned from vpMsgsCtor(). If not valid the application will silently exit with a BAD_CONTEXT exit code.
cpMsgPointer to a null-terminated message string.

Definition at line 141 of file msglog.c.

◆ vpMsgsCtor()

void* vpMsgsCtor ( exception spEx)

The Message Log constructor.

Allocates memory and initializes the buffers, vectors and iterators.

Parameters
spExPointer to a valid exception structure initialized with XCTOR(). If not valid the application will silently exit with a BAD_CONTEXT exit code.
Returns
Pointer to the object context. Exception thrown on memory allocation failure.

Definition at line 68 of file msglog.c.

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