aboutsummaryrefslogtreecommitdiff
path: root/include/base/string.h
blob: 157129f94d0d715517042e947a3d897ee66d5787 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once

typedef byte* string;

/* augmented string functions */
string  str·makecap(const char *s, vlong len, vlong cap);
string  str·makelen(const char *s, vlong len);
string  str·make(const char *s);
string  str·makef(const char *fmt, ...);
void    str·free(string s);
int     str·len(const string s);
int     str·cap(const string s);
void    str·clear(string *s);
void    str·grow(string *s, vlong delta);
void    str·fit(string *s);
int     str·appendlen(string *s, vlong len, const char *b);
int     str·append(string *s, const char *b);
int     str·appendf(string *s, const char *fmt, ...);
int     str·appendbyte(string *s, const char b);
bool    str·equals(const string s, const string t);
int     str·find(string s, const char* substr);
void    str·lower(string s);
void    str·upper(string s);
int     str·read(string s, int size, int n, void *buf);
void    str·replace(string s, const byte* from, const byte* to);
string* str·split(string s, const byte* tok);
string  str·join(vlong len, byte** fields, const byte* sep);

/* raw C string functions */
char    *str·copyn(char *dst, char *src, int n);

/* string parsing */
int     str·atoi(char *s);