squareball  0.2.0.53-dd5b
A general-purpose library for C99
sb-parsererror.h File Reference

Parser error object. More...

#include <stdarg.h>
#include <stdlib.h>

Go to the source code of this file.

Data Structures

struct  sb_parser_error_t
 

Functions

sb_error_tsb_parser_error_new (const char *src, size_t src_len, size_t pos, const char *msg)
 
sb_error_tsb_parser_error_new_printf (const char *src, size_t src_len, size_t pos, const char *format,...)
 

Detailed Description

Parser error object.

This is an implementation of sb_error_t object, that is suitable to report errors in parsers, including context of the point of the source where the error happened.

It is used by our configuration parser implementation, that is a good usage example of this error object.

Function Documentation

sb_error_t* sb_parser_error_new ( const char *  src,
size_t  src_len,
size_t  pos,
const char *  msg 
)

Function that creates a new error object with message and parser current position details.

Parameters
srcString with source that was being parsed.
src_lenSource string size.
posCurrent parser position, stating from 0.
msgString with error message.
Returns
An error object.
sb_error_t* sb_parser_error_new_printf ( const char *  src,
size_t  src_len,
size_t  pos,
const char *  format,
  ... 
)

Function that creates a new error object, with printf(3)-like message formatting and parser current position details.

Parameters
srcString with source that was being parsed.
src_lenSource string size.
posCurrent parser position, stating from 0.
formatFormat for human-readable error message.
...One or more printf(3)-like parameters.
Returns
An error object.