-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutil.h
More file actions
36 lines (26 loc) · 895 Bytes
/
util.h
File metadata and controls
36 lines (26 loc) · 895 Bytes
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
#ifndef MYSHELL_UTIL_CPP
#define MYSHELL_UTIL_CPP
#include <string>
#include <functional>
#include <vector>
#include <sys/types.h>
#include <dirent.h>
#include "Token.h"
std::vector<Token> replace_wildcards(const std::string &data);
bool is_with_symbol(const std::string &str, char sym);
template<typename T>
std::vector<std::vector<T>> split(std::vector<T> &container, std::function<bool(const T &)> const &func) {
std::vector<std::vector<T>> ret;
size_t last = 0;
for (size_t i = 0; i < container.size(); i++) {
if (func(container[i])) {
ret.emplace_back(container.begin() + last, container.begin() + i);
last = i + 1;
}
}
ret.emplace_back(container.begin() + last, container.end());
return ret;
}
bool matches(char *text, char *pattern);
std::string join(const std::vector<std::string> &array, char separator);
#endif