myMPD
Internal API documentation
Loading...
Searching...
No Matches
convert.c File Reference

Type conversion functions. More...

#include "compile_time.h"
#include "src/lib/convert.h"
#include "src/lib/log.h"
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <limits.h>
#include <stdlib.h>
Include dependency graph for convert.c:

Functions

enum str2int_errno str2int (int *out, const char *s)
 
enum str2int_errno str2uint (unsigned *out, const char *s)
 
enum str2int_errno str2int64 (int64_t *out, const char *s)
 
enum str2int_errno str2float (float *out, const char *s)
 

Detailed Description

Type conversion functions.

Function Documentation

◆ str2float()

enum str2int_errno str2float ( float *  out,
const char *  s 
)

Convert string s to float out. The format is the same as strtof, except that the following are inconvertible: NULL, empty string, leading whitespace, any trailing characters

Parameters
outpointer to integer
sstring to convert
Returns
Indicates if the operation succeeded, or why it failed.

◆ str2int()

enum str2int_errno str2int ( int *  out,
const char *  s 
)

Convert string s to int out. The format is the same as strtol, except that the following are inconvertible: NULL, empty string, leading whitespace, any trailing characters

Parameters
outpointer to integer
sstring to convert
Returns
Indicates if the operation succeeded, or why it failed.

◆ str2int64()

enum str2int_errno str2int64 ( int64_t *  out,
const char *  s 
)

Convert string s to int64_t out. The format is the same as strtoll, except that the following are inconvertible: NULL, empty string, leading whitespace, any trailing characters

Parameters
outpointer to integer
sstring to convert
Returns
Indicates if the operation succeeded, or why it failed.

◆ str2uint()

enum str2int_errno str2uint ( unsigned *  out,
const char *  s 
)

Convert string s to unsigned out. The format is the same as strtoul, except that the following are inconvertible: NULL, empty string, leading whitespace, any trailing characters

Parameters
outpointer to integer
sstring to convert
Returns
Indicates if the operation succeeded, or why it failed.