Garfield++
5.0
A toolkit for the detailed simulation of particle detectors based on ionisation 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 <functional>
6
#include <string>
7
#include <sstream>
8
#include <vector>
9
10
namespace
Garfield
{
11
12
inline
void
ltrim
(std::string& line) {
13
line.erase(line.begin(),
14
std::find_if(line.begin(), line.end(),
15
[](
int
ch) {return !std::isspace(ch);}));
16
}
17
18
inline
void
rtrim
(std::string& line) {
19
line.erase(
20
std::find_if(line.rbegin(), line.rend(),
21
[](
int
ch) {return !std::isspace(ch);}).base(),
22
line.end());
23
}
24
25
inline
std::vector<std::string>
tokenize
(
const
std::string& line) {
26
std::vector<std::string> words;
27
std::istringstream ss(line);
28
for
(std::string word; ss >> word;) {
29
words.push_back(word);
30
}
31
return
words;
32
}
33
34
inline
bool
startsWith
(
const
std::string& line,
35
const
std::string& s) {
36
return
(line.rfind(s, 0) == 0);
37
}
38
39
}
40
41
#endif
Garfield
Definition
HeedChamber.hh:11
Garfield::tokenize
std::vector< std::string > tokenize(const std::string &line)
Definition
Utilities.hh:25
Garfield::startsWith
bool startsWith(const std::string &line, const std::string &s)
Definition
Utilities.hh:34
Garfield::ltrim
void ltrim(std::string &line)
Definition
Utilities.hh:12
Garfield::rtrim
void rtrim(std::string &line)
Definition
Utilities.hh:18
garfieldpp-5.0
Include
Garfield
Utilities.hh
Generated by
1.13.2