PandaRoot
PndStringSeparator Class Reference

Separates a string into substrings at arbitrary delimiters. More...

#include <PndStringSeparator.h>

Public Member Functions

 PndStringSeparator ()
 
 ~PndStringSeparator ()
 
 PndStringSeparator (std::string AInput, std::string ADelimiter=" ")
 
void SetInput (std::string AInput)
 
void SetDelimiter (std::string ADelimiter)
 
void ResetVector ()
 
std::vector< std::string > GetStringVector (void)
 
std::string Replace (std::string from, std::string to)
 
void Print ()
 

Protected Member Functions

void TestFirst ()
 
void TestLast ()
 
bool GetIfFirst ()
 
bool GetIfLast ()
 

Detailed Description

Separates a string into substrings at arbitrary delimiters.

Separation into sub-strings

Separates an input string into substrings and stores them in a string vector. The separation criteria is a string of characters. If no delimiters are given the default delimiter " " is used.

## Example

std::vector<std::string> fOutput;
PndStringSeparator fInput("Column:Row Type: Test ", ": ");
fOutput = fInput.GetStringVector();
fOutput[0] = "Column"
fOutput[1] = "Row"
fOutput[2] = "Type"
fOutput[3] = "Test"
Author
Tobias Stockmanns t.sto.nosp@m.ckma.nosp@m.nns@f.nosp@m.z-ju.nosp@m.elich.nosp@m..de

Definition at line 31 of file PndStringSeparator.h.

Constructor & Destructor Documentation

◆ PndStringSeparator() [1/2]

PndStringSeparator::PndStringSeparator ( )
inline

Definition at line 33 of file PndStringSeparator.h.

Referenced by ~PndStringSeparator().

33 : fStartPos(0), fStrings(), fInput(), fDelimiter(), fOutput(), fFirstDel(false), fLastDel(false){}

◆ ~PndStringSeparator()

PndStringSeparator::~PndStringSeparator ( )
inline

Definition at line 34 of file PndStringSeparator.h.

References PndStringSeparator().

34 {}

◆ PndStringSeparator() [2/2]

PndStringSeparator::PndStringSeparator ( std::string  AInput,
std::string  ADelimiter = " " 
)
explicit

Member Function Documentation

◆ GetIfFirst()

bool PndStringSeparator::GetIfFirst ( )
inlineprotected

Definition at line 61 of file PndStringSeparator.h.

61 { return fFirstDel; }

◆ GetIfLast()

bool PndStringSeparator::GetIfLast ( )
inlineprotected

Definition at line 62 of file PndStringSeparator.h.

62 { return fLastDel; }

◆ GetStringVector()

std::vector<std::string> PndStringSeparator::GetStringVector ( void  )

Referenced by ResetVector().

◆ Print()

void PndStringSeparator::Print ( )

Referenced by ResetVector().

◆ Replace()

std::string PndStringSeparator::Replace ( std::string  from,
std::string  to 
)

Referenced by ResetVector().

◆ ResetVector()

void PndStringSeparator::ResetVector ( )
inline

Definition at line 38 of file PndStringSeparator.h.

References GetStringVector(), Print(), and Replace().

38 { fStrings.clear(); }

◆ SetDelimiter()

void PndStringSeparator::SetDelimiter ( std::string  ADelimiter)
inline

Definition at line 37 of file PndStringSeparator.h.

37 { fDelimiter = ADelimiter; }

◆ SetInput()

void PndStringSeparator::SetInput ( std::string  AInput)
inline

Definition at line 36 of file PndStringSeparator.h.

36 { fInput = AInput; }

◆ TestFirst()

void PndStringSeparator::TestFirst ( )
inlineprotected

Definition at line 47 of file PndStringSeparator.h.

48  {
49  if (fInput.find_first_of(fDelimiter) == 0)
50  fFirstDel = true;
51  else
52  fFirstDel = false;
53  }

◆ TestLast()

void PndStringSeparator::TestLast ( )
inlineprotected

Definition at line 54 of file PndStringSeparator.h.

55  {
56  if (fInput.find_last_of(fDelimiter) == fInput.size() - 1)
57  fLastDel = true;
58  else
59  fLastDel = false;
60  }

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