ATLAS Offline Software
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 
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 {
45  if (!first.empty()) splitVec.push_back(first);
46  input = second;
47  } while(!input.empty());
48  return splitVec;
49  }
50 }
51 
python.SystemOfUnits.second
int second
Definition: SystemOfUnits.py:120
trim
std::string trim(const std::string &str, const std::string &whitespace=" \t")
Definition: BTaggingTruthTaggingTool.cxx:1149
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
StrUtil.h
DeMoScan.first
bool first
Definition: DeMoScan.py:534
GRLStrUtil
Definition: StrUtil.h:10
Trk::split
@ split
Definition: LayerMaterialProperties.h:38