BOSS 7.1.0
BESIII Offline Software System
Loading...
Searching...
No Matches
StringParse Class Reference

#include <StringParse.h>

Public Member Functions

 StringParse (std::string input)
 
 StringParse ()
 
 ~StringParse ()
 
std::string piece (const int &num)
 
int intpiece (const int &num)
 
long longpiece (const int &num)
 
float numpiece (const int &num)
 
unsigned string_size (void) const
 

Detailed Description

Definition at line 19 of file StringParse.h.

Constructor & Destructor Documentation

◆ StringParse() [1/2]

StringParse::StringParse ( std::string  input)

Definition at line 17 of file StringParse.cxx.

17 {
18 m_past_end="?!?";
19 m_lstring=input;
20 m_nword=0;
21 std::string::size_type pos=0;
22 std::string::size_type prev_pos=0;
23 while((pos=input.find_first_of(' ',pos)) != std::string::npos){
24 m_lsubstring.push_back(input.substr(prev_pos,pos-prev_pos));
25 prev_pos=++pos;
26 }
27 // special handling for last substring
28 m_lsubstring.push_back(input.substr(prev_pos,pos-prev_pos));
29 m_nword=m_lsubstring.size();
30}

◆ StringParse() [2/2]

StringParse::StringParse ( )

◆ ~StringParse()

StringParse::~StringParse ( )

Definition at line 66 of file StringParse.cxx.

66 {
67}

Member Function Documentation

◆ intpiece()

int StringParse::intpiece ( const int &  num)

Definition at line 39 of file StringParse.cxx.

39 {
40if(num <= m_nword){
41 int i= atoi(m_lsubstring[num-1].c_str());
42 return i;
43 }
44 else {
45 return -1;
46 }
47}
char * c_str(Index i)
Definition: EvtCyclic3.cc:252

◆ longpiece()

long StringParse::longpiece ( const int &  num)

Definition at line 48 of file StringParse.cxx.

48 {
49if(num <= m_nword){
50 int i= atol(m_lsubstring[num-1].c_str());
51 return i;
52 }
53 else {
54 return -1;
55 }
56}

◆ numpiece()

float StringParse::numpiece ( const int &  num)

Definition at line 57 of file StringParse.cxx.

57 {
58if(num <= m_nword){
59 float x= atof(m_lsubstring[num-1].c_str());
60 return x;
61 }
62 else {
63 return -1.1;
64 }
65}
Double_t x[10]

◆ piece()

std::string StringParse::piece ( const int &  num)

Definition at line 31 of file StringParse.cxx.

31 {
32 if(num <= m_nword){
33 return m_lsubstring[num-1];
34 }
35 else {
36 return m_past_end;
37 }
38}

◆ string_size()

unsigned StringParse::string_size ( void  ) const
inline

Definition at line 39 of file StringParse.h.

40{ return m_nword; }

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