-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathframework.h
116 lines (99 loc) · 2.43 KB
/
framework.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#ifndef FRAMEWORK_H
#define FRAMEWORK_H
#include <stddef.h>
#define ARRAY_LENGTH(arr) (sizeof(arr) / sizeof((arr)[0]))
/**
* Function to clear console
*/
void CLS();
/**
* Function to clear console after user hit ENTER
*/
void CLS_ENTER();
/**
* Function to get user Inputs (designed to be used in a loop for multi inputs)
*
* @param int line Line Number (in for loop it would be i+1)
* @return char* the user input
*/
char* userInput(int line);
/**
* Function to get simple oneline user input
*
* @return char* the user input
*/
char* getInput();
/**
* Function to log messages with different log levels
*
* @param const char* level Log level (e.g., "INFO", "WARN", "ERROR")
* @param const char* message Message to log
*/
void logMessage(const char* level, const char* message);
/**
* Function to log messages to a file
*
* @param const char* filename Log file name
* @param const char* level Log level
* @param const char* message Message to log
*/
void logToFile(const char* filename, const char* level, const char* message);
/**
* Function to trim leading and trailing whitespace from a string
*
* @param char* str String to trim
* @return char* Trimmed string
*/
char* trimWhitespace(char* str);
/**
* Function to convert a string to uppercase
*
* @param char* str String to convert
* @return char* Converted string
*/
char* toUpperCase(char* str);
/**
* Function to read a file into a string
*
* @param const char* filename File to read
* @return char* Content of the file
*/
char* readFile(const char* filename);
/**
* Function to write a string to a file
*
* @param const char* filename File to write
* @param const char* content Content to write
*/
void writeFile(const char* filename, const char* content);
/**
* Function to get the current timestamp as a string
*
* @return char* Current timestamp
*/
char* getTimestamp();
/**
* Function to find the maximum of two numbers
*
* @param int a First number
* @param int b Second number
* @return int Maximum number
*/
int maximum(int a, int b);
/**
* Function to find the minimum of two numbers
*
* @param int a First number
* @param int b Second number
* @return int Minimum number
*/
int minimum(int a, int b);
/**
* Function to find the maximum value in an array of integers
*
* @param int* array Array of integers
* @param size_t size Size of the array
* @return int Maximum value
*/
int arrayMax(int* array, size_t size);
#endif