-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.h
More file actions
63 lines (52 loc) · 1.25 KB
/
string.h
File metadata and controls
63 lines (52 loc) · 1.25 KB
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
/* IFJ20 - String Library
* Authors:
* Michal Slesar, xslesa01
*/
#ifndef STRING_H
#define STRING_H
#include <stdbool.h>
#include <stddef.h>
/**
* @brief Structure representing a string
*/
typedef struct {
char* ptr; /** Raw pointer to string content */
size_t length; /** Length of the string */
size_t size; /** Number of allocated bytes */
} String;
/** Bytes to be allocated in advance */
#define STRING_BLOCK_SIZE 32
/**
* Initialize empty string
* @param string Target string pointer
*/
bool string_init(String *string);
/**
* Free resources of string
* @param string Target string pointer
*/
bool string_free(String *string);
/**
* Clear content of string but keep allocated resources
* @param string Target string pointer
*/
bool string_clear(String *string);
/**
* Append to string
* @param string Target string pointer
* @param source String to be appended
*/
bool string_append_string(String *string, const char *source);
/**
* Append to string
* @param string Target string pointer
* @param c Char to be appended
*/
bool string_append_char(String *string, char c);
/**
* Compare two strings
* @param string1 First string
* @param string2 Second string
*/
bool string_compare(String *string1, const char *string2);
#endif