Libft
Custom implementation of core libc functions with additional utility helpers.
Loading...
Searching...
No Matches
buff_format.h File Reference
#include "libft.h"
Include dependency graph for buff_format.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  s_rules
 Structure holding format specifier rules for printf-like formatting. More...
 

Typedefs

typedef struct s_rules t_rules
 

Functions

void rules_parse (t_rules *rules, const char **const fstring)
 Parses format specifiers from a format string.
 
bool rules_apply (t_buff *buff, t_rules *rules)
 Applies formatting rules to a buffer.
 
bool append (t_buff *buff, t_rules *rules, va_list *args)
 Appends formatted argument to buffer based on rules.
 
bool append_char (t_buff *buff, char c)
 Appends a character to the buffer.
 
bool append_int (t_buff *buff, int nb)
 Appends an integer to the buffer as a string.
 
bool append_uint (t_buff *buff, unsigned int nb)
 Appends an unsigned integer to the buffer as a string.
 
bool append_hex (t_buff *buff, unsigned long nb, bool uppercase)
 Appends a number in hexadecimal format to the buffer.
 
bool append_ptr (t_buff *buff, unsigned long nb)
 Appends a pointer address to the buffer.
 

Typedef Documentation

◆ t_rules

typedef struct s_rules t_rules

Function Documentation

◆ append()

bool append ( t_buff buff,
t_rules rules,
va_list *  args 
)

Appends formatted argument to buffer based on rules.

Parameters
buffPointer to the buffer.
rulesPointer to the formatting rules.
argsPointer to the variable argument list.
Returns
true on success, false on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_char()

bool append_char ( t_buff buff,
char  c 
)

Appends a character to the buffer.

Parameters
buffPointer to the buffer.
cCharacter to append.
Returns
true on success, false on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_hex()

bool append_hex ( t_buff buff,
unsigned long  nb,
bool  uppercase 
)

Appends a number in hexadecimal format to the buffer.

Parameters
buffPointer to the buffer.
nbNumber to convert.
uppercaseUse uppercase letters if true.
Returns
true on success, false on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_int()

bool append_int ( t_buff buff,
int  nb 
)

Appends an integer to the buffer as a string.

Parameters
buffPointer to the buffer.
nbInteger to append.
Returns
true on success, false on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_ptr()

bool append_ptr ( t_buff buff,
unsigned long  nb 
)

Appends a pointer address to the buffer.

Parameters
buffPointer to the buffer.
nbPointer value as unsigned long.
Returns
true on success, false on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ append_uint()

bool append_uint ( t_buff buff,
unsigned int  nb 
)

Appends an unsigned integer to the buffer as a string.

Parameters
buffPointer to the buffer.
nbUnsigned integer to append.
Returns
true on success, false on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rules_apply()

bool rules_apply ( t_buff buff,
t_rules rules 
)

Applies formatting rules to a buffer.

Parameters
buffPointer to the buffer.
rulesPointer to the rules structure.
Returns
true on success, false on failure.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rules_parse()

void rules_parse ( t_rules rules,
const char **const  fstring 
)

Parses format specifiers from a format string.

Parameters
rulesPointer to the rules structure to populate.
fstringPointer to format string pointer (advanced by parsing).
Here is the call graph for this function:
Here is the caller graph for this function: