-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.hpp
52 lines (43 loc) · 1.4 KB
/
util.hpp
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
#pragma once
#include <string>
#include <vector>
struct findDelineatorResult {
ulong pos;
std::string delineator;
};
/**
* @brief find the first occurrence of one of the delinators in the vector.
*
* @param s the string
* @param delineator the delinators
* @return findDelineatorResult the result
*/
findDelineatorResult findDelineator(std::string const &s, std::vector<std::string> const &delineator);
/**
* @brief split a string based on the given delinators
*
* @param input the string
* @param delineator the list of delinators
* @return std::vector<std::string> the split string.
*/
std::vector<std::string> splitString(std::string const &input, std::vector<std::string> const &delineator);
/**
* @brief similar to splitString but also removes the empty strings
*
* @param input the string
* @param delineator the list of delinators
* @return std::vector<std::string> the split string.
*/
std::vector<std::string> splitStringRemoveEmpty(std::string const &input, std::vector<std::string> const &delineator);
bool strEndsIn(std::string const &str, std::string const &end);
std::string <rim(std::string &s);
std::string &rtrim(std::string &s);
std::string &trim(std::string &s);
/**
* @brief validates if a string is only comprised of a numbers and -.
*
* @param s the string.
* @return true it is a number.
* @return false it is not a number.
*/
bool isNumber(const std::string& s);