This repository has been archived by the owner on Jan 25, 2023. It is now read-only.
forked from cop3330f19/autoplayer-cop-3330-group-2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStringHelper.h
66 lines (56 loc) · 2.76 KB
/
StringHelper.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
#ifndef STRING_HELPER
#define STRING_HELPER
#include <string>
#include <sstream>
#include <vector>
class StringHelper{
public:
/**************************************************************
* parse *
* *
* Passed : 2 arguments: a string, a character that is the *
* delimiter *
* Purpose : Split a given string by its delimiter *
* Returns : String vector *
**************************************************************/
static std::vector<std::string> parse(std::string , char );
/**************************************************************
* toUpper *
* *
* Passed : 1 argument: a string *
* Purpose : Convert string to uppercase *
* Returns : String *
**************************************************************/
static std::string toUpper(const std::string );
/**************************************************************
* stou *
* *
* Passed : 1 argument: a string *
* Purpose : Replace all spaces with an underscore *
* Returns : String *
**************************************************************/
static std::string stou(std::string );
/**************************************************************
* utos *
* *
* Passed : 1 argument: a string *
* Purpose : Replace all undderscores with a space *
* Returns : String *
**************************************************************/
static std::string utos(std::string );
/**************************************************************
* toString *
* *
* Passed : 1 argument: any built-in type *
* Purpose : Convert a value to a string *
* Returns : String *
**************************************************************/
template<typename T>
static std::string toString(const T& value )
{
std::ostringstream oss;
oss << value;
return oss.str();
}
};
#endif