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 43 of file PndStringSeparator.h.

Constructor & Destructor Documentation

◆ PndStringSeparator() [1/2]

PndStringSeparator::PndStringSeparator ( )
inline

Definition at line 45 of file PndStringSeparator.h.

Referenced by ~PndStringSeparator().

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

◆ ~PndStringSeparator()

PndStringSeparator::~PndStringSeparator ( )
inline

Definition at line 46 of file PndStringSeparator.h.

References PndStringSeparator().

46 {}

◆ PndStringSeparator() [2/2]

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

Member Function Documentation

◆ GetIfFirst()

bool PndStringSeparator::GetIfFirst ( )
inlineprotected

Definition at line 73 of file PndStringSeparator.h.

73 { return fFirstDel; }

◆ GetIfLast()

bool PndStringSeparator::GetIfLast ( )
inlineprotected

Definition at line 74 of file PndStringSeparator.h.

74 { 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 50 of file PndStringSeparator.h.

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

50 { fStrings.clear(); }

◆ SetDelimiter()

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

Definition at line 49 of file PndStringSeparator.h.

49 { fDelimiter = ADelimiter; }

◆ SetInput()

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

Definition at line 48 of file PndStringSeparator.h.

48 { fInput = AInput; }

◆ TestFirst()

void PndStringSeparator::TestFirst ( )
inlineprotected

Definition at line 59 of file PndStringSeparator.h.

60  {
61  if (fInput.find_first_of(fDelimiter) == 0)
62  fFirstDel = true;
63  else
64  fFirstDel = false;
65  }

◆ TestLast()

void PndStringSeparator::TestLast ( )
inlineprotected

Definition at line 66 of file PndStringSeparator.h.

67  {
68  if (fInput.find_last_of(fDelimiter) == fInput.size() - 1)
69  fLastDel = true;
70  else
71  fLastDel = false;
72  }

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