Garfield
0.3
Toolkit for the detailed simulation of particle detectors based on ionization measurement in gases and semiconductors
Loading...
Searching...
No Matches
Utilities.hh
Go to the documentation of this file.
1
#ifndef G_UTILITIES_H
2
#define G_UTILITIES_H
3
4
#include <algorithm>
5
#include <sstream>
6
#include <string>
7
#include <vector>
8
9
namespace
Garfield
{
10
11
inline
void
ltrim
(std::string& line) {
12
line.erase(line.begin(), std::find_if(line.begin(), line.end(), [](
int
ch) {
13
return !std::isspace(ch);
14
}));
15
}
16
17
inline
void
rtrim
(std::string& line) {
18
line.erase(std::find_if(line.rbegin(), line.rend(),
19
[](
int
ch) { return !std::isspace(ch); })
20
.base(),
21
line.end());
22
}
23
24
inline
std::vector<std::string>
tokenize
(
const
std::string& line) {
25
std::vector<std::string> words;
26
std::istringstream ss(line);
27
for
(std::string word; ss >> word;) {
28
words.push_back(word);
29
}
30
return
words;
31
}
32
33
inline
bool
startsWith
(
const
std::string& line,
const
std::string& s) {
34
return
(line.rfind(s, 0) == 0);
35
}
36
37
}
// namespace Garfield
38
39
#endif
Garfield
Definition
AvalancheGrid.hh:9
Garfield::tokenize
std::vector< std::string > tokenize(const std::string &line)
Definition
Utilities.hh:24
Garfield::startsWith
bool startsWith(const std::string &line, const std::string &s)
Definition
Utilities.hh:33
Garfield::ltrim
void ltrim(std::string &line)
Definition
Utilities.hh:11
Garfield::rtrim
void rtrim(std::string &line)
Definition
Utilities.hh:17
Include
Garfield
Utilities.hh
Generated by
1.14.0