bbstd::StringToVector< T > Class Template Reference

#include <bbstdStringToVector.h>

List of all members.

Public Member Functions

template<>
int8_t decode_item (const std::string &s)
template<>
uint8_t decode_item (const std::string &s)
template<>
int16_t decode_item (const std::string &s)
template<>
uint16_t decode_item (const std::string &s)
template<>
int32_t decode_item (const std::string &s)
template<>
uint32_t decode_item (const std::string &s)
template<>
long decode_item (const std::string &s)
template<>
float decode_item (const std::string &s)
template<>
double decode_item (const std::string &s)
template<>
std::string decode_item (const std::string &s)

Private Member Functions

 BBTK_TEMPLATE_BLACK_BOX_INTERFACE (StringToVector, bbtk::AtomicBlackBox, T)
 BBTK_DECLARE_INPUT (In, std::string)
 BBTK_DECLARE_OUTPUT (Out, std::vector< T >)
 BBTK_PROCESS (DoIt)
void DoIt ()
decode_item (const std::string &)


Detailed Description

template<class T>
class bbstd::StringToVector< T >

Definition at line 42 of file bbstdStringToVector.h.


Member Function Documentation

template<class T>
bbstd::StringToVector< T >::BBTK_TEMPLATE_BLACK_BOX_INTERFACE ( StringToVector< T >  ,
bbtk::AtomicBlackBox  ,
 
) [private]

template<class T>
bbstd::StringToVector< T >::BBTK_DECLARE_INPUT ( In  ,
std::string   
) [private]

template<class T>
bbstd::StringToVector< T >::BBTK_DECLARE_OUTPUT ( Out  ,
std::vector< T >   
) [private]

template<class T>
bbstd::StringToVector< T >::BBTK_PROCESS ( DoIt   )  [private]

template<class T>
void bbstd::StringToVector< T >::DoIt (  )  [inline, private]

Definition at line 70 of file bbstdStringToVector.h.

References bbstd::StringToVector< T >::decode_item().

00071   {
00072     //  std::cout << "StringToVector<"<<bbtk::TypeName<T>()<<">::DoIt()"<<std::endl;
00073     
00074     typedef T type;
00075     std::string delimiters(" ,;");
00076     std::string str(bbGetInputIn()); 
00077     //  std::cout << "'"<< str << "'"<<std::endl;
00078     // Skip delimiters at beginning.
00079     std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
00080     // Find first "non-delimiter".
00081     std::string::size_type pos     = str.find_first_of(delimiters, lastPos);
00082     bbmOutputOut.clear();
00083     while (std::string::npos != pos || std::string::npos != lastPos)
00084       {
00085         // Found a token, add it to the vector.
00086         bbmOutputOut.push_back( 
00087                                this->decode_item( str.substr(lastPos, pos - lastPos) ) );
00088         //      std::cout << this->bbGetOutputOut().back() << std::endl;
00089         // Skip delimiters.  Note the "not_of"
00090         lastPos = str.find_first_not_of(delimiters, pos);
00091         // Find next "non-delimiter"
00092         pos = str.find_first_of(delimiters, lastPos);
00093       }
00094     //  std::cout << "s=" << this->bbGetOutputOut().size() << std::endl;
00095   }

template<class T>
T bbstd::StringToVector< T >::decode_item ( const std::string &   )  [private]

template<>
int8_t bbstd::StringToVector< int8_t >::decode_item ( const std::string &  s  )  [inline]

Definition at line 45 of file bbstdStringToVector.cxx.

00046   {
00047     return (int8_t)atoi ( s.c_str() );
00048   }

template<>
uint8_t bbstd::StringToVector< uint8_t >::decode_item ( const std::string &  s  )  [inline]

Definition at line 50 of file bbstdStringToVector.cxx.

00051   {
00052     return (uint8_t)atoi ( s.c_str() );
00053 }

template<>
int16_t bbstd::StringToVector< int16_t >::decode_item ( const std::string &  s  )  [inline]

Definition at line 55 of file bbstdStringToVector.cxx.

00056 {
00057   return (int16_t)atoi ( s.c_str() );
00058 }

template<>
uint16_t bbstd::StringToVector< uint16_t >::decode_item ( const std::string &  s  )  [inline]

Definition at line 60 of file bbstdStringToVector.cxx.

00061 {
00062   return (uint16_t)atoi ( s.c_str() );
00063 }

template<>
int32_t bbstd::StringToVector< int32_t >::decode_item ( const std::string &  s  )  [inline]

Definition at line 65 of file bbstdStringToVector.cxx.

00066 {
00067   return (int32_t)atoi ( s.c_str() );
00068 }

template<>
uint32_t bbstd::StringToVector< uint32_t >::decode_item ( const std::string &  s  )  [inline]

Definition at line 70 of file bbstdStringToVector.cxx.

00071 {
00072   return (uint32_t)atoi ( s.c_str() );
00073 }

template<>
long bbstd::StringToVector< long >::decode_item ( const std::string &  s  )  [inline]

Definition at line 75 of file bbstdStringToVector.cxx.

00076 {
00077   // std::cout << bbGetFullName() << " v="<<s<<std::endl;
00078   return (long)atoi ( s.c_str() );
00079 }

template<>
float bbstd::StringToVector< float >::decode_item ( const std::string &  s  )  [inline]

Definition at line 81 of file bbstdStringToVector.cxx.

00082 {
00083   return (float)atof ( s.c_str() );
00084 }

template<>
double bbstd::StringToVector< double >::decode_item ( const std::string &  s  )  [inline]

Definition at line 86 of file bbstdStringToVector.cxx.

00087 {
00088   return atof ( s.c_str() );
00089 }

template<>
std::string bbstd::StringToVector< std::string >::decode_item ( const std::string &  s  )  [inline]

Definition at line 91 of file bbstdStringToVector.cxx.

00092 {
00093   return s;
00094 }


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

Generated on Tue Oct 21 16:06:51 2008 for std by  doxygen 1.5.6