Bienvenue sur le site de la LibLapin.
Jetez un coup d'oeil en bas de la page pour choisir votre niveau de documentation en fonction de votre niveau avec la LibLapin.
Pour l'instant, c'est réglé sur 'Manuel complet'. Si c'est votre première fois avec la LibLapin, il vaudrait mieux choisir 'Débutant'.
De même, n'oubliez pas de préciser une version de la bibliothèque.

LibLapin's logo

LibLapin

Parsing





The parsing module header is lapin/container/parsing.h.
int b‌u‌n‌n‌y‌_‌c‌h‌e‌c‌k‌_‌c‌h‌a‌r( const char *str, ssize_t *index, const char *token );

Description

     Check how many char starting from &str[*index] can be found in token, stops when a unfound character is encoutered.

Example:

int i = 2;

b‌u‌n‌n‌y‌_‌c‌h‌e‌c‌k‌_‌c‌h‌a‌r("abcdefg", &i, "dc");

Will return 2.

Parameters

  • const char *str:
         The string to explore.
  • ssize_t *index:
         A pointer to the position to explore in str.
  • const char *token:
         An array of allowed characters.

Return value

How many characters were found.




INDEX

bool b‌u‌n‌n‌y‌_‌c‌h‌e‌c‌k‌_‌t‌e‌x‌t( const char *str, ssize_t *index, const char *token );

Description

     Check if token can be found at &str[*index].

Parameters

  • const char *str:
         The string to explore.
  • ssize_t *index:
         A pointer to the position to explore in str.
  • const char *token:
         The string to match.

Return value

true if token was found, else found.




INDEX

bool b‌u‌n‌n‌y‌_‌c‌h‌e‌c‌k‌_‌t‌e‌x‌t‌_‌c‌a‌s‌e( const char *str, ssize_t *index, const char *token );

Description

     Check if token can be found at &str[*index], ignore case.

Parameters

  • const char *str:
         The string to explore.
  • ssize_t *index:
         A pointer to the position to explore in str.
  • const char *token:
         The string to match.

Return value

true if token was found, else found.




INDEX

bool b‌u‌n‌n‌y‌_‌r‌e‌a‌d‌_‌c‌h‌a‌r( const char *str, ssize_t *index, const char *token );

Description

     Browse str while, starting from &$str[*index], characters can be found in token.

Move *index if something was found.

Parameters

  • const char *str:
         The string to explore.
  • ssize_t *index:
         A pointer to the position to explore in str.
  • const char *token:
         An array of allowed characters.

Return value

true if *index was modified or false if it was not.




INDEX

bool b‌u‌n‌n‌y‌_‌r‌e‌a‌d‌_‌t‌e‌x‌t( const char *str, ssize_t *index, const char *token );

Description

     Browse str if starting from &$str[*index] token can be found. Only read one time. Return if something was read.

Move *index if something was found.

Parameters

  • const char *str:
         The string to explore.
  • ssize_t *index:
         A pointer to the position to explore in str.
  • const char *token:
         The string to match.

Return value

true if *index was modified or false if it was not.




INDEX

void b‌u‌n‌n‌y‌_‌s‌k‌i‌p‌_‌s‌p‌a‌c‌e( const char *str, ssize_t *index );

Description

     Increase *index while str[*index] is any kind of whitespaces. Whitespaces are ' ', '\t', '\n' and '\r'.

Parameters

  • const char *str:
         The string to explore.
  • ssize_t *index:
         A pointer to the position to explore in str.



INDEX


Description

     Increase *index while str[*index] is any kind of inline whitespaces. Those are ' ' and '\t'.

Parameters

  • const char *str:
         The string to explore.
  • ssize_t *index:
         A pointer to the position to explore in str.



INDEX

k
bool b‌u‌n‌n‌y‌_‌r‌e‌a‌d‌_‌f‌i‌e‌l‌d( const char *str, ssize_t *index, );

Description

     Increase *index to reach the space after any found field. A field is a valid C like symbol: a word that start with a letter or an underscore and that go one with letters, underscores or numbers.

Parameters

  • const char *str:
         The string to explore.
  • ssize_t *index:
         A pointer to the position to explore in str.

Return value

true if *index was modified or false if it was not.




INDEX

bool b‌u‌n‌n‌y‌_‌r‌e‌a‌d‌_‌d‌o‌u‌b‌l‌e( const char *str, ssize_t *index, double *val, );

Description

     Increase *index if there is a double at &str[*index], and get this value inside *val.

Parameters

  • const char *str:
         The string to explore.
  • ssize_t *index:
         A pointer to the position to explore in str.
  • double *val:
         Where to store the read value.

Return value

true if *index was modified or false if it was not.




INDEX

bool b‌u‌n‌n‌y‌_‌r‌e‌a‌d‌_‌d‌o‌u‌b‌l‌e( const char *str, ssize_t *index, int *val, );

Description

     Increase *index if there is an integer at &str[*index], and get this value inside *val.

Parameters

  • const char *str:
         The string to explore.
  • ssize_t *index:
         A pointer to the position to explore in str.
  • int *val:
         Where to store the read value.

Return value

true if *index was modified or false if it was not.




INDEX

bool b‌u‌n‌n‌y‌_‌r‌e‌a‌d‌_‌c‌s‌t‌r‌i‌n‌g( const char *str, ssize_t *index, char *val, size_t out_len );

Description

     Increase *index if there is a C-String at &str[*index], and get this value inside val, which is a buffer of size out_len.

A C-String start with '"' and end with '"'. Inside a C-String, backslash tokens can be used to escape characters ('\n', '\r', etc.).
This function support utf-8 characters.
This function support hexadecimal with the following syntax: '\0xHEXA'
This function support binary with the following syntax: '\0bBINARY'
This function support octal with the following syntax: '\0OCTAL'

Parameters

  • const char *str:
         The string to explore.
  • ssize_t *index:
         A pointer to the position to explore in str.
  • int *val:
         Where to store the read value.
  • size_t out_len:
         The size of the sent buffer val.

Return value

true if *index was modified or false if it was not.




INDEX

bool b‌u‌n‌n‌y‌_‌r‌e‌a‌d‌_‌r‌a‌w‌s‌t‌r‌i‌n‌g( const char *str, ssize_t *index, char *val, size_t out_len, char *end_token );

Description

     Read from &str[*index] until one of the characters inside end_tok is reached. Store what was read inside val, which is a buffer of size out_len.

Parameters

  • const char *str:
         The string to explore.
  • ssize_t *index:
         A pointer to the position to explore in str.
  • int *val:
         Where to store the read value.
  • size_t out_len:
         The size of the reception buffer val.
  • char *end_token:
         An array of characters that provoke the end of the reading if reach.

Return value

true if *index was modified or false if it was not.




INDEX

bool b‌u‌n‌n‌y‌_‌r‌e‌a‌d‌_‌r‌a‌w‌s‌t‌r‌i‌n‌g( const char *str, char **out, size_t size );

Description

     Write the sent string into a C-String format.

Parameters

  • const char *str:
         The string to transform.
  • char **out:
         Where the generated string will be saved.
    If *out is NULL, then a new string will be allocated and saved inside *out and size will be ignored.
    If *out is not NULL, then this space will be used to store the generated string, until size is reached.

    The allocated string is inside the bunny memory space (if activated) so it must be freed with b‌u‌n‌n‌y‌_‌f‌r‌e‌e.
  • size_t size:
         The size of *out if *out is not NULL.

Return value

true if the string was generated. false on error.


Error values and logs

On error, $Vb‌u‌n‌n‌y‌_‌e‌r‌r‌n‌o is set to:


  • ENOMEM:

    Out of memory.



INDEX


Description

     Return the line on which str[index] is. The first line is line 1, not 0.

Parameters

  • const char *str:
         The string to inspect.
  • int index:
         The index at which you want to know the line number.

Return value

The line number.




INDEX