-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.h
93 lines (77 loc) · 2.93 KB
/
utils.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
#ifndef AEDA_UGHEATS_UTILS_H
#define AEDA_UGHEATS_UTILS_H
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
/** Checks if a string is made up exclusively by numbers.
* @param str is the string you want to test.
* @return true if the string is only made up by numbers.
*/
bool isNumeric(const string &str);
/** Removes whitespace from both ends of a string.
* @param str is the string you want to trim.
* @return the string passed as parameter without the whitespace at the beginning and ending.
*/
string trim(string &str);
/** Transforms a string into a vector.
* @param str is the string you want to transform.
* @param delim is the separator of the elements of the string.
* @return the vector with the elements of the string separated by delim.
*/
vector<string> strToVect(const string &str, char delim = ' ');
/** Makes a pair of coords from a string
* @param str is the string you want to transform into coords.
* @return the pair of coods.
*/
pair<float,float> makeCoords(const string str);
//Menu utilities
/** Prints a line of a specified size with a specified character.
* @param size is the size of the line.
* @param ch is the character, by default is '-'.
*/
void line(int size, char ch = '-');
/** Outputs an error message and clears cin flags.
* @param message is what you want to display.
*/
void cinERR(const string &message);
/** Tries to get a valid int option from cin to use in a switch-case.
* @param dest is the variable where you want to save the option selected.
* @param message is the message to be display before selecting an option, by default is "Option: ".
*/
void getOption(int &dest, const string &message = "Option: ");
/** Gets a valid nif input from cin
* @param nif return variable where grabbed nif is stored
* @return specifies if nif capture was successful or not
*/
bool inputNIF(int &nif, const string &message);
/** Checks if the nif is valid.
* @param nif is what you want to check.
* @return true if the nif is valid.
*/
bool validNIF(string const &nif);
/** Checks if the postcode is valid.
* @param postcode is what you want to check.
* @return true if the postcode is valid.
*/
bool validPostcode(string const &postcode);
//Just useful
/** The program waits until the user presses Enter to continue.
*/
void enterWait(const string &message = "ENTER to go back");
/** Removes the whitespaces in a string.
* @param str is the string you want to remove the whitespaces.
* @return the string without any whitespaces.
*/
string removeSpaces(string str);
/** Checks if the licence plate is valid.
* @param plate is what you want to check.
* @return true if the licence plate is valid.
*/
bool validLicensePlate(string const &plate);
#endif //AEDA_UGHEATS_UTILS_H