StringParse Class Reference

#include <StringParse.h>

List of all members.

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

Private Attributes

std::string m_lstring
std::vector< std::stringm_lsubstring
int m_nword
std::string m_past_end


Detailed Description

Definition at line 19 of file StringParse.h.


Constructor & Destructor Documentation

StringParse::StringParse ( std::string  input  ) 

Definition at line 17 of file StringParse.cxx.

References m_lstring, m_lsubstring, m_nword, m_past_end, RealDBUtil::npos, and boss::pos.

00017                                         {
00018   m_past_end="?!?";
00019   m_lstring=input;
00020   m_nword=0;
00021   std::string::size_type pos=0;
00022   std::string::size_type prev_pos=0;
00023   while((pos=input.find_first_of(' ',pos)) != std::string::npos){
00024       m_lsubstring.push_back(input.substr(prev_pos,pos-prev_pos));
00025       prev_pos=++pos;
00026     }
00027     // special handling for last substring
00028     m_lsubstring.push_back(input.substr(prev_pos,pos-prev_pos));
00029   m_nword=m_lsubstring.size();
00030 }

StringParse::StringParse (  ) 

StringParse::~StringParse (  ) 

Definition at line 66 of file StringParse.cxx.

00066                          {
00067 }


Member Function Documentation

int StringParse::intpiece ( const int &  num  ) 

Definition at line 39 of file StringParse.cxx.

References EvtCyclic3::c_str(), genRecEmupikp::i, m_lsubstring, and m_nword.

00039                                         {  
00040 if(num <= m_nword){
00041      int i= atoi(m_lsubstring[num-1].c_str());
00042      return i;
00043   }
00044   else { 
00045     return -1;
00046   }
00047 }

long StringParse::longpiece ( const int &  num  ) 

Definition at line 48 of file StringParse.cxx.

References EvtCyclic3::c_str(), genRecEmupikp::i, m_lsubstring, and m_nword.

00048                                           {  
00049 if(num <= m_nword){
00050      int i= atol(m_lsubstring[num-1].c_str());
00051      return i;
00052   }
00053   else { 
00054     return -1;
00055   }
00056 }

float StringParse::numpiece ( const int &  num  ) 

Definition at line 57 of file StringParse.cxx.

References EvtCyclic3::c_str(), m_lsubstring, m_nword, and x.

00057                                           {  
00058 if(num <= m_nword){
00059      float x= atof(m_lsubstring[num-1].c_str());
00060      return x;
00061   }
00062   else { 
00063     return -1.1;
00064   }
00065 }

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

Definition at line 31 of file StringParse.cxx.

References m_lsubstring, m_nword, and m_past_end.

00031                                           {
00032   if(num <= m_nword){
00033     return m_lsubstring[num-1];
00034   }
00035   else { 
00036     return m_past_end;
00037   }
00038 }

unsigned StringParse::string_size ( void   )  const [inline]

Definition at line 39 of file StringParse.h.

References m_nword.

00040 { return m_nword; }


Member Data Documentation

std::string StringParse::m_lstring [private]

Definition at line 31 of file StringParse.h.

Referenced by StringParse().

std::vector<std::string> StringParse::m_lsubstring [private]

Definition at line 32 of file StringParse.h.

Referenced by intpiece(), longpiece(), numpiece(), piece(), and StringParse().

int StringParse::m_nword [private]

Definition at line 33 of file StringParse.h.

Referenced by intpiece(), longpiece(), numpiece(), piece(), string_size(), and StringParse().

std::string StringParse::m_past_end [private]

Definition at line 34 of file StringParse.h.

Referenced by piece(), and StringParse().


Generated on Tue Nov 29 23:35:55 2016 for BOSS_7.0.2 by  doxygen 1.4.7