myMPD
Internal API documentation
Loading...
Searching...
No Matches
sds_extras.h File Reference

Extra functions for sds strings. More...

#include "dist/sds/sds.h"
#include <stdbool.h>
#include <stdio.h>
Include dependency graph for sds_extras.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FREE_SDS(SDS_PTR)

Functions

void sds_merge_lines (sds s)
sds * sds_split_comma_trim (const char *p, int *count)
sds sds_catchar (sds s, const char c)
sds sds_replacelen (sds s, const char *p, size_t len)
sds sds_replace (sds s, const char *p)
sds sds_catbool (sds s, bool v)
sds sds_pad_int (int64_t value, sds buffer)
void sds_free_void (void *p)

Detailed Description

Extra functions for sds strings.

Macro Definition Documentation

◆ FREE_SDS

#define FREE_SDS ( SDS_PTR)
Value:
do { \
sdsfree(SDS_PTR); \
SDS_PTR = NULL; \
} while (0)

Frees an sds string and sets it to NULL

Function Documentation

◆ sds_catbool()

sds sds_catbool ( sds s,
bool v )

Converts a bool value to a sds string

Parameters
sstring to append the value
vbool value to convert
Returns
modified sds string

◆ sds_catchar()

sds sds_catchar ( sds s,
const char c )

Appends a char to sds string s, this is faster than using sdscatfmt

Parameters
ssds string
cchar to append
Returns
modified sds string

◆ sds_free_void()

void sds_free_void ( void * p)

Frees an sds string pointed by void pointer

Parameters
pVoid pointer to sds string

◆ sds_merge_lines()

void sds_merge_lines ( sds s)

Removes newline characters from a string in-place.

Parameters
sString to merge the lines

◆ sds_pad_int()

sds sds_pad_int ( int64_t value,
sds buffer )

Prints a zero padded value

Parameters
valuempd song struct
bufferalready allocated sds string to append
Returns
pointer to buffer

◆ sds_replace()

sds sds_replace ( sds s,
const char * p )

Replaces a sds string with a new value, allocates the string if it is NULL

Parameters
ssds string to replace
preplacement string
Returns
modified sds string

◆ sds_replacelen()

sds sds_replacelen ( sds s,
const char * p,
size_t len )

Replaces a sds string with a new value, allocates the string if it is NULL

Parameters
ssds string to replace
preplacement string
lenreplacement string length
Returns
modified sds string

◆ sds_split_comma_trim()

sds * sds_split_comma_trim ( const char * p,
int * count )

Splits a comma separated string and trims whitespaces from single values

Parameters
pstring to split
countpointer to int representing the count of values
Returns
array of sds strings