DGtal  1.4.beta
DGtal::Shortcuts< TKSpace >::ValueReader< Value > Struct Template Reference

#include <DGtal/helpers/Shortcuts.h>

Public Member Functions

bool operator() (std::istream &input, Value &value)
 
bool operator() (std::istream &input, std::vector< Value > &values)
 

Detailed Description

template<typename TKSpace>
template<typename Value>
struct DGtal::Shortcuts< TKSpace >::ValueReader< Value >

Definition at line 3063 of file Shortcuts.h.

Member Function Documentation

◆ operator()() [1/2]

template<typename TKSpace >
template<typename Value >
bool DGtal::Shortcuts< TKSpace >::ValueReader< Value >::operator() ( std::istream &  input,
std::vector< Value > &  values 
)
inline

Definition at line 3079 of file Shortcuts.h.

3080  {
3081  std::string str;
3082  std::getline( input, str );
3083  // construct a stream from the string
3084  std::stringstream strstr(str);
3085  // use stream iterators to copy the stream to the vector as whitespace separated strings
3086  std::istream_iterator<std::string> it(strstr);
3087  std::istream_iterator<std::string> end;
3088  std::vector<std::string> results(it, end);
3089  values.resize( results.size() );
3090  for ( unsigned int i = 0; i < results.size(); ++i ) {
3091  std::stringstream sstr( results[ i ] );
3092  sstr >> values[ i ];
3093  }
3094  return input.good();
3095  }

◆ operator()() [2/2]

template<typename TKSpace >
template<typename Value >
bool DGtal::Shortcuts< TKSpace >::ValueReader< Value >::operator() ( std::istream &  input,
Value value 
)
inline

Definition at line 3064 of file Shortcuts.h.

3065  {
3066  std::string str;
3067  std::getline( input, str );
3068  // construct a stream from the string
3069  std::stringstream strstr(str);
3070  // use stream iterators to copy the stream to the vector as whitespace separated strings
3071  std::istream_iterator<std::string> it(strstr);
3072  std::istream_iterator<std::string> end;
3073  std::vector<std::string> results(it, end);
3074  std::stringstream sstr( results[ 0 ] );
3075  sstr >> value;
3076  return ( results.size() == 1 ) && input.good();
3077  }

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