FairRoot/PandaRoot
PndStringVector.cxx
Go to the documentation of this file.
1 #include "PndStringVector.h"
2 #include <iostream>
3 #include <sstream>
4 
5 PndStringVector::PndStringVector (std::string AInput, std::string ADelimiter)
6 {
7  SetInput (AInput);
8  SetDelimiter (ADelimiter);
9 }
10 
11 
12 std::string PndStringVector::GetString (void)
13 {
14  std::string::size_type pos;
15  std::string aString;
16  pos = fInput.find_first_of(fDelimiter.c_str(), fStartPos);
17  if (pos-fStartPos == 0) { //first value at StartPos is a Delimiter
18  fStartPos += 1;
19  return "";
20  }
21 
22  else if (pos != std::string::npos){ // a delimiter was found after StartPos
23  aString = fInput.substr(fStartPos, pos-fStartPos);
24  fStartPos = pos + 1;
25  return aString;
26  }
27 
28  else { //no delimiter was found after StartPos
29  aString = fInput.substr(fStartPos, pos-fStartPos);
30  fStartPos = pos;
31  return aString;
32  }
33 }
34 
35 
36 std::vector<std::string> PndStringVector::GetStringVector(void)
37 {
38  fStartPos = 0;
39  std::string value;
40  ResetVector();
41  TestFirst();
42  TestLast();
43 
44  std::cout<<" vector "<<std::endl;
45  std::cout<<" vector "<<std::endl;
46 
47  while (fStartPos != std::string::npos){
48  value = GetString();
49  if (value.length() > 0)
50  fStrings.push_back(value);
51  std::cout<<" vector "<<std::endl;
52 
53 
54  }
55  return fStrings;
56 }
57 
59 {
60  std::cout << "PndStringVector for: " << fInput << std::endl;
61  for (Int_t i = 0; i < (int)fStrings.size(); i++)
62  std::cout << i << ": " << fStrings[i] << std::endl;
63 }
TVector3 pos
Int_t i
Definition: run_full.C:25
std::string fDelimiter
std::vector< std::string > GetStringVector(void)
std::string::size_type fStartPos
std::vector< std::string > fStrings
std::string GetString(void)
std::string fInput
void SetInput(std::string AInput)
void SetDelimiter(std::string ADelimiter)