DGtal  1.2.0
Public Member Functions
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 3014 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 3030 of file Shortcuts.h.

3031  {
3032  std::string str;
3033  std::getline( input, str );
3034  // construct a stream from the string
3035  std::stringstream strstr(str);
3036  // use stream iterators to copy the stream to the vector as whitespace separated strings
3037  std::istream_iterator<std::string> it(strstr);
3038  std::istream_iterator<std::string> end;
3039  std::vector<std::string> results(it, end);
3040  values.resize( results.size() );
3041  for ( unsigned int i = 0; i < results.size(); ++i ) {
3042  std::stringstream sstr( results[ i ] );
3043  sstr >> values[ i ];
3044  }
3045  return input.good();
3046  }

◆ 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 3015 of file Shortcuts.h.

3016  {
3017  std::string str;
3018  std::getline( input, str );
3019  // construct a stream from the string
3020  std::stringstream strstr(str);
3021  // use stream iterators to copy the stream to the vector as whitespace separated strings
3022  std::istream_iterator<std::string> it(strstr);
3023  std::istream_iterator<std::string> end;
3024  std::vector<std::string> results(it, end);
3025  std::stringstream sstr( results[ 0 ] );
3026  sstr >> value;
3027  return ( results.size() == 1 ) && input.good();
3028  }

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