-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathutils.h
More file actions
34 lines (25 loc) · 780 Bytes
/
utils.h
File metadata and controls
34 lines (25 loc) · 780 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
#ifndef POLYGON_COVERAGE_SOLVERS_UTILS_H_
#define POLYGON_COVERAGE_SOLVERS_UTILS_H_
#include <string>
#include <algorithm>
#include <cctype>
namespace polygon_coverage_planning {
// trim from start (in place)
static inline void ltrim(std::string &s) {
s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](unsigned char ch) {
return !std::isspace(ch);
}));
}
// trim from end (in place)
static inline void rtrim(std::string &s) {
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char ch) {
return !std::isspace(ch);
}).base(), s.end());
}
// trim from both ends (in place)
static inline void trim(std::string &s) {
ltrim(s);
rtrim(s);
}
} // namespace polygon_coverage_planning
#endif // POLYGON_COVERAGE_SOLVERS_UTILS_H_