gtsam_points
Loading...
Searching...
No Matches
split.hpp
Go to the documentation of this file.
1#ifndef GLK_SPLIT_HPP
2#define GLK_SPLIT_HPP
3
4
5#include <vector>
6#include <string>
7
8namespace glk {
9
10inline std::vector<std::string> split(const std::string& str, char delimiter = '\n') {
11 std::vector<std::string> lines;
12 size_t start = 0;
13 size_t end = 0;
14 while ((end = str.find(delimiter, start)) != std::string::npos) {
15 lines.push_back(str.substr(start, end - start));
16 start = end + 1;
17 }
18 lines.push_back(str.substr(start));
19 return lines;
20}
21
22inline std::vector<std::string> split_lines(const std::string& str) {
23 return split(str, '\n');
24}
25
26inline std::string trim(std::string str) {
27 str.erase(0, str.find_first_not_of(" \n\r\t"));
28 str.erase(str.find_last_not_of(" \n\r\t") + 1);
29 return str;
30}
31}
32
33#endif
Definition async_buffer_copy.hpp:6
std::string trim(std::string str)
Definition split.hpp:26
std::vector< std::string > split(const std::string &str, char delimiter='\n')
Definition split.hpp:10
std::vector< std::string > split_lines(const std::string &str)
Definition split.hpp:22
std::enable_if_t< needs_aligned_allocator< T >::value, std::shared_ptr< T > > make_shared(Args &&... args)
Definition make_shared.hpp:20