24 lines
412 B
C
24 lines
412 B
C
|
#ifndef SV_INCLUDED
|
||
|
#define SV_INCLUDED
|
||
|
|
||
|
#include <stddef.h>
|
||
|
// macros
|
||
|
#define SV(s) sv_str(s)
|
||
|
#define SV_NULL sv_strn(NULL, 0)
|
||
|
|
||
|
// printf macros
|
||
|
#define SV_FMT "%.*s"
|
||
|
#define SV_ARG(sv) (int) (sv).len, (sv).buf
|
||
|
|
||
|
struct String_View{
|
||
|
size_t len; // String lenght
|
||
|
const char *buf; // String data
|
||
|
};
|
||
|
typedef struct String_View SV;
|
||
|
|
||
|
SV sv_str(const char *s);
|
||
|
SV sv_strn(const char *s, size_t len);
|
||
|
|
||
|
|
||
|
#endif
|