-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOther.hpp
More file actions
90 lines (53 loc) · 1.4 KB
/
Other.hpp
File metadata and controls
90 lines (53 loc) · 1.4 KB
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
//
// Created by Павел Разуваев on 11/8/18.
//
#ifndef CPPLAB3_OTHER_HPP
#define CPPLAB3_OTHER_HPP
#include <vector>
#include <string>
#include <iostream>
#include <regex>
#include <fstream>
#include <cstring>
using namespace std;
void showVector(vector<int> &v) {
for (auto it = v.begin(); it != v.end(); ++it) {
cout << *it << endl;
}
}
vector<string> editVector(vector<string> &v) {
for (int i = 0; i < v.size(); i++) {
if ((v[i][0] == '\"') && (v[i][v[i].size() - 1] == '\"')) {
v[i].pop_back();
v[i].erase(0, 1);
}
}
return v;
}
vector<string> stringParse(string s) {
vector<string> lines;
regex rgx{"(?:^|,) *((?:[^\",]*?)|(?:\"[^\"]*?\"))(?=$|,)"};
copy(sregex_token_iterator{s.begin(), s.end(), rgx, 1}, {}, back_inserter(lines));
lines = editVector(lines);
return lines;
}
string stringCheckCommas(string s) {
if (s.find(',') != -1) {
s.push_back('\"');
s.insert(0, "\"");
}
return s;
}
vector<vector<string>> dataAddR(vector<vector<string>> Data) {
Data[Data.size() - 1][Data[Data.size() - 1].size() - 1] += "\r";
return Data;
}
string stringCreate(vector<string> v) {
string s;
for (auto it = v.begin(); it != v.end(); ++it) {
s += stringCheckCommas(*it) + ',';
}
s.pop_back();
return s;
}
#endif //CPPLAB3_OTHER_HPP