-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring.h
More file actions
80 lines (64 loc) · 1.61 KB
/
string.h
File metadata and controls
80 lines (64 loc) · 1.61 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#pragma once
#include <stddef.h>
/**
* Represents a simple string structure
* I found this personally a bit easier to use than c strings.
*/
struct string;
typedef struct string *string_t;
string_t createString();
/**
* Returns a pointer to the char at the specified index.
*/
char *charAt(string_t str, size_t index);
/**
* Returns the null terminated data of the string.
*/
char *stringData(string_t str);
/**
* Returns the length of this string, not including trailing
* null characters.
*/
size_t stringLength(string_t str);
/**
* Appens the specified character to the string
*/
int append(string_t str, char c);
/**
* Removes the specified number of characters from the string.
*/
void removeLastChars(string_t str, size_t n);
void destroyString(string_t string);
/**
* Sets contents of the string to the contents of the c string.
* @param cString not taken ownership
*/
void stringSetTo(string_t string, const char *cString);
/**
* Creates a new string with contents from the c string
* @param cString not taken ownership
*/
string_t stringFromCString(const char *cString);
/**
* Creates a new string with contents of the string form of an integer
*/
string_t stringFromInt(int n);
/**
* Appends \p rhs to \p lhs.
* @param rhs not taken ownership
*/
void plusEqual(string_t lhs, string_t rhs);
/**
* Copies the specified string.
*/
string_t stringCopy(string_t s);
/**
* Destroys \p rhs and puts its contents into lhs
* @param lhs
* @param rhs
*/
void moveString(string_t lhs, string_t rhs);
/**
* Writes the specified string to the output file decriptor
*/
void writeString(int fd, string_t str);