-
Notifications
You must be signed in to change notification settings - Fork 0
/
pstring.h
66 lines (56 loc) · 1.3 KB
/
pstring.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdbool.h>
#include <stdint.h>
#ifndef _PSTRING_H
#define _PSTRING_H
typedef struct pstring {
size_t len;
char* str;
} pstring_t;
/**
* Initializes required string.
*
* @param str Required string.
*/
void pstring_init(pstring_t* str);
/**
* Adds additional data to the end of string.
*
* @param str Required string.
* @param buff Source buffer.
* @param len Count of bytes required to copy.
*
* @return {@code false} if not enougth memory.
*/
bool pstring_append(pstring_t* str, const char* buff, size_t len);
/**
* Replace string data to the new data from buffer.
*
* @param str Required string.
* @param buff Source buffer.
* @param len Count of bytes required to copy.
*
* @return {@code false} if not enougth memory.
*/
bool pstring_replace(pstring_t* str, const char* buff, size_t len);
/**
* Extract substring of required string.
*
* @param str Required string.
* @param begin Begin position for substring.
*
* @return {@code false} if not enougth memory.
*/
bool pstring_substring(pstring_t* str, size_t begin);
/**
* Inserts zero-ending byte to the end of string.
*
* @param str Required string.
*/
void pstring_finalize(pstring_t* str);
/**
* Free memory for string if it required.
*
* @param str Required string.
*/
void pstring_free(pstring_t* str);
#endif