-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathstring.h
76 lines (63 loc) · 3.32 KB
/
string.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
67
68
69
70
71
72
73
74
75
76
/*****************************************
NanoShell Operating System
(C) 2020-2021 iProgramInCpp
String manipulation module header file
******************************************/
#ifndef _STRING_H
#define _STRING_H
#include <main.h>
#include <utf8.h>
// Memory functions
int memcmp(const void*ap,const void*bp,size_t size);
void* memcpy(void* dstptr, const void* srcptr, size_t size);// TODO: I don't think we need restrict keyword here
void* memmove(void* restrict dstptr, const void* restrict srcptr, size_t size);
void* memset(void* bufptr, int val, size_t size);
void memtolower(char* as, int w);
void memtoupper(char* as, int w);
void* fast_memset(void* bufptr, int val, size_t size);
// String functions
size_t strgetlento(const char* str, char chr);
int atoi(const char* str);
int atoihex(const char* str);
size_t strlen(const char* str);
size_t strnlen(const char* str, size_t nchars);
void* strcpy(const char* ds, const char* ss);
void strtolower(char* as);
void strtoupper(char* as);
int strcmp(const char* as, const char* bs);
char* strcat(char* dest, const char* after);
char* strpcat(char* dest, const char* after);
char* strchr (const char* stringToSearch, const char characterToSearchFor);
char* strrchr (const char* stringToSearch, const char characterToSearchFor);
char* strdup (const char* pText);//! Make sure to free this.
char* strncpy(char *dst, const char *src, size_t n);
size_t strlcat(char* dst, const char* src, size_t sz);
void fast_memcpy(void* restrict dest, const void* restrict src, int size);//aligns to 32 bytes!!
void fmemcpy32 (void* restrict dest, const void* restrict src, int size);
// Works like strncpy, except that the destination buffer will always contain a NULL terminator afterwards.
char* SafeStringCopy(char *DestinationBuffer, size_t szDestinationBuffer, const char* Source);
void memcpy_128_byte_aligned(void* restrict dest, const void* restrict src, int num_bytes);//Source/Dest - 16-byte aligned, count- 128 byte aligned!
void memcpy_16_byte_aligned(void* restrict dest, const void* restrict src, int num_bytes);//Everything is 16 byte aligned
void memset_ints(void* restrict dest, uint32_t src, int num_ints);
void memcpy_ints(void* restrict dest, const void* restrict src, int num_ints);
void memset_shorts(void* restrict dest, uint32_t src, int num_shorts);
void memmove_ints(void* restrict dest, const void* restrict src, int num_ints);
void align4_memcpy(void* restrict dest, const void* restrict src, int size);
void align8_memcpy(void* restrict dest, const void* restrict src, int size);
void align16_memcpy(void* restrict dest, const void* restrict src, int size);
void fmemcpy128(void* restrict dest, const void* restrict src, int size);
void fmemcpy256(void* restrict dest, const void* restrict src, int size);
//Other string functions:
bool StartsWith(const char* pText, const char* pCheck);
bool EndsWith(const char* pText, const char* pCheck);
//requires 4 byte aligned size.
void ZeroMemory (void* bufptr1, size_t size);
//BetterStrTok: https://github.com/iProgramMC/BetterStrTok
typedef struct {
bool m_bInitted;
char*m_pContinuation;
char*m_pReturnValue;
} TokenState;
char* Tokenize (TokenState* pState, char* pString, char* separator);
bool WildcardMatches(const char* pattern, const char* candidate);
#endif//_STRING_H