-
Notifications
You must be signed in to change notification settings - Fork 0
/
string.h
79 lines (64 loc) · 1.43 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
77
78
/**
* Project: Compiler for IFJ21 language
*
* Brief: Dynamic string to store text
*
* Author: Stepan Bakaj <xbakaj00@stud.fit.vutbr.cz>
*
* Date: 23-10-2021
*/
#ifndef IFJ_BRATWURST2021_STRING_H
#define IFJ_BRATWURST2021_STRING_H
#include <stdbool.h>
typedef struct string {
char* string;
unsigned alloc_lenght;
unsigned lenght;
} *string_ptr_t;
/**
* Inicialization of string.
*
* @param string Pointer to string.
* @return True if inicialization was successful, false otherwise.
*/
string_ptr_t string_init();
/**
* Release alocate string memory.
*
* @param string Pointer to string.
*/
void string_free(string_ptr_t string);
/**
* Append string of char.
*
* @param string Pointer to string.
* @param a Character that we append.
* @return True if append was successful, false otherwise.
*
*/
bool string_append_character(string_ptr_t string, char a);
/**
* Get parametr of struct and returned pointer of char.
*
* @param string Pointer to string.
* @return Pointer to string.
*
*/
char* get_char_arr(string_ptr_t string);
/**
* String from struct parse to int.
*
* @param string Pointer to string.
* @return Parse string to int value.
*
*/
int string_to_int (string_ptr_t string);
/**
* String from struct parse to double.
*
* @param string Pointer to string.
* @return Parse string to double value.
*
*/
double string_to_dec (string_ptr_t string);
#endif //IFJ_BRATWURST2021_STRING_H