ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
GoodRunsLists
Root
StrUtil.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
GoodRunsLists/StrUtil.h
"
6
7
using namespace
std
;
8
9
namespace
GRLStrUtil
{
10
11
void
12
trim
(
string
& input) {
13
// trim leading and trailing whitespace
14
string::size_type position = input.find_first_not_of(
" \t\n"
);
15
if
( position == std::string::npos )
return
;
// skip, it's all whitespace
16
input.erase(0, position);
17
position= input.find_last_not_of(
" \t\n"
);
18
if
( position != std::string::npos)
19
input.erase( position+1 );
20
}
21
22
void
23
split
(
const
string
& input,
string
& first,
string
& second) {
24
// split input in two
25
string::size_type position = input.find_first_of(
" \t\n"
);
26
if
( position==std::string::npos ) {
27
first = input;
28
second =
""
;
29
}
else
{
30
first = input.substr( 0, position );
31
second = input.substr( position+1, input.size()-position );
32
// trim leading whitespace of second
33
position= second.find_first_not_of(
" \t\n"
);
34
second.erase(0, position);
35
}
36
}
37
38
vector<string>
39
split
(
string
input) {
40
trim
(input);
41
vector<string> splitVec;
42
string
first, second;
43
do
{
44
split
(input,first,second);
45
if
(!first.empty()) splitVec.push_back(first);
46
input = second;
47
}
while
(!input.empty());
48
return
splitVec;
49
}
50
}
51
StrUtil.h
GRLStrUtil
Definition
StrUtil.h:10
GRLStrUtil::split
void split(const std::string &input, std::string &first, std::string &second)
Definition
StrUtil.cxx:23
GRLStrUtil::trim
void trim(std::string &input)
Definition
StrUtil.cxx:12
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0