-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dynamic_string.h
executable file
·69 lines (58 loc) · 1.71 KB
/
Dynamic_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
/**
* Projekt: IFJ2021
*
* @brief Implementace dynamickeho stringu pro ukladani v scanneru
*
* @author Tony Pham xphamt00@stud.fit.vutbr.cz
* @author Vít Janeček xjanec30@stud.fit.vutbr.cz
*/
#ifndef _DYNAMIC_STRING_H
#define _DYNAMIC_STRING_H
#include <stdbool.h>
/**
* @struct Struktura reprezentujici dynamicky string
*/
typedef struct {
char *str;
unsigned int length;
unsigned int alloc;
} Dynamic_string;
/**
* Funkce inicializuje dynamicky string pro scanner.
*
* @param string Ukazatel na string.
* @return Vraci true pokud se povede inicializace a malloc jinak vraci false.
*/
bool DS_Init(Dynamic_string *string);
/**
* Funkce prida zank do dynamickyho stringu.
*
* @param string Ukazatel na string.
* @param c Znak, ktery je vkladan do stringu.
* @return Vraci true pokud se povede vlozit znak do stringu a malloc jinak vraci false.
*/
bool DS_Add(Dynamic_string *string, char c);
/**
* Funkce prekopiruje jeden string do druheho.
*
* @param string Ukazatel na string.
* @param s_new Ukazatel na string, do kterého bude nakopirovan predchovi parametr string.
* @return Vraci true pokud se povede nakopirovat string do stringu a malloc jinak vraci false.
*/
bool DS_Copy(Dynamic_string *string,Dynamic_string *s_new);
/**
* Funkce porovná 2 stringy.
*
* @param string Ukazatel na string.
* @param c_string Ukazatel na string, se kterym se bude porovnavat 1. string.
* @return Vraci 0 pokud se rovnají, jinak vrací ASCI hodnotu podle toho jestli je dany char vetsi nebo mensi.
*/
int DS_Cmp(Dynamic_string *string, const char *c_string);
/**
* Funkce odstrani dynamicky string.
*
* @param string Ukazatel na string.
*/
void DS_Free(Dynamic_string *string);
#endif
/** @endcode */