FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PndStringVector Class Reference

#include <PndStringVector.h>

Public Member Functions

 PndStringVector ()
 
 ~PndStringVector ()
 
 PndStringVector (std::string AInput, std::string ADelimiter=" ")
 
void SetInput (std::string AInput)
 
void SetDelimiter (std::string ADelimiter)
 
void ResetVector ()
 
std::vector< std::string > GetStringVector (void)
 
void TestFirst ()
 
void TestLast ()
 
void Print ()
 

Private Member Functions

std::string GetString (void)
 

Private Attributes

std::string::size_type fStartPos
 
std::vector< std::string > fStrings
 
std::string fInput
 
std::string fDelimiter
 
std::string fOutput
 
bool fFirstDel
 
bool fLastDel
 

Detailed Description

Definition at line 30 of file PndStringVector.h.

Constructor & Destructor Documentation

PndStringVector::PndStringVector ( )
inline

Definition at line 33 of file PndStringVector.h.

33 :fFirstDel(false),fLastDel(false){};
PndStringVector::~PndStringVector ( )
inline

Definition at line 34 of file PndStringVector.h.

34 {};
PndStringVector::PndStringVector ( std::string  AInput,
std::string  ADelimiter = " " 
)

Definition at line 5 of file PndStringVector.cxx.

References SetDelimiter(), and SetInput().

6 {
7  SetInput (AInput);
8  SetDelimiter (ADelimiter);
9 }
void SetInput(std::string AInput)
void SetDelimiter(std::string ADelimiter)

Member Function Documentation

std::string PndStringVector::GetString ( void  )
private

Definition at line 12 of file PndStringVector.cxx.

References fDelimiter, fInput, fStartPos, and pos.

Referenced by GetStringVector().

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 }
TVector3 pos
std::string fDelimiter
std::string::size_type fStartPos
std::string fInput
std::vector< std::string > PndStringVector::GetStringVector ( void  )

Definition at line 36 of file PndStringVector.cxx.

References fStartPos, fStrings, GetString(), ResetVector(), TestFirst(), and TestLast().

Referenced by PndHypGeoHandling::GetPath().

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 }
std::string::size_type fStartPos
std::vector< std::string > fStrings
std::string GetString(void)
void PndStringVector::Print ( )

Definition at line 58 of file PndStringVector.cxx.

References fInput, fStrings, and i.

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 }
Int_t i
Definition: run_full.C:25
std::vector< std::string > fStrings
std::string fInput
void PndStringVector::ResetVector ( )
inline

Definition at line 38 of file PndStringVector.h.

References fStrings.

Referenced by GetStringVector().

38 {fStrings.clear();};
std::vector< std::string > fStrings
void PndStringVector::SetDelimiter ( std::string  ADelimiter)
inline

Definition at line 37 of file PndStringVector.h.

References fDelimiter.

Referenced by PndStringVector().

37 {fDelimiter = ADelimiter;};
std::string fDelimiter
void PndStringVector::SetInput ( std::string  AInput)
inline

Definition at line 36 of file PndStringVector.h.

References fInput.

Referenced by PndStringVector().

36 {fInput = AInput;};
std::string fInput
void PndStringVector::TestFirst ( )
inline

Definition at line 40 of file PndStringVector.h.

References fDelimiter, fFirstDel, and fInput.

Referenced by GetStringVector().

40 {if(fInput.find_first_of(fDelimiter)==0) fFirstDel=true; else fFirstDel=false;}
std::string fDelimiter
std::string fInput
void PndStringVector::TestLast ( )
inline

Definition at line 41 of file PndStringVector.h.

References fDelimiter, fInput, and fLastDel.

Referenced by GetStringVector().

41 {if(fInput.find_last_of(fDelimiter)==fInput.size()-1) fLastDel = true; else fLastDel = false;}
std::string fDelimiter
std::string fInput

Member Data Documentation

std::string PndStringVector::fDelimiter
private

Definition at line 48 of file PndStringVector.h.

Referenced by GetString(), SetDelimiter(), TestFirst(), and TestLast().

bool PndStringVector::fFirstDel
private

Definition at line 51 of file PndStringVector.h.

Referenced by TestFirst().

std::string PndStringVector::fInput
private

Definition at line 47 of file PndStringVector.h.

Referenced by GetString(), Print(), SetInput(), TestFirst(), and TestLast().

bool PndStringVector::fLastDel
private

Definition at line 52 of file PndStringVector.h.

Referenced by TestLast().

std::string PndStringVector::fOutput
private

Definition at line 49 of file PndStringVector.h.

std::string::size_type PndStringVector::fStartPos
private

Definition at line 45 of file PndStringVector.h.

Referenced by GetString(), and GetStringVector().

std::vector<std::string> PndStringVector::fStrings
private

Definition at line 46 of file PndStringVector.h.

Referenced by GetStringVector(), Print(), and ResetVector().


The documentation for this class was generated from the following files: