-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.cpp
50 lines (36 loc) · 1.16 KB
/
utils.cpp
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
//
// Author: Jakub Fajkus
// Project: ISA IRC bot
// Last revision: 17.11.2017
//
#include <iostream>
#include <ctime>
#include <vector>
using namespace std;
string get_today_date() {
time_t time_number;
struct tm *time_struct;
char date_buf[11] = "";
time(&time_number);
time_struct = localtime(&time_number);
strftime(date_buf, 11, "%d.%m.%Y", time_struct);
return string(date_buf);
}
vector<string> explode_string(const string delimiter, string source) {
unsigned long start_position = 0;
unsigned long end_position = source.find(delimiter);
vector<string> output;
if (end_position == string::npos) {
output.emplace_back(source);
} else {
do {
string test = source.substr(start_position, end_position - start_position);
output.emplace_back(source.substr(start_position, end_position - start_position));
start_position = end_position;
end_position = source.find(delimiter, start_position + 1);
start_position++;
} while (end_position != string::npos);
output.emplace_back(source.substr(start_position));
}
return output;
}