DGtal  1.0.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 2696 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,
Value value 
)
inline

Definition at line 2697 of file Shortcuts.h.

2698  {
2699  std::string str;
2700  std::getline( input, str );
2701  // construct a stream from the string
2702  std::stringstream strstr(str);
2703  // use stream iterators to copy the stream to the vector as whitespace separated strings
2704  std::istream_iterator<std::string> it(strstr);
2705  std::istream_iterator<std::string> end;
2706  std::vector<std::string> results(it, end);
2707  std::stringstream sstr( results[ 0 ] );
2708  sstr >> value;
2709  return ( results.size() == 1 ) && input.good();
2710  }

◆ operator()() [2/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 2712 of file Shortcuts.h.

2713  {
2714  std::string str;
2715  std::getline( input, str );
2716  // construct a stream from the string
2717  std::stringstream strstr(str);
2718  // use stream iterators to copy the stream to the vector as whitespace separated strings
2719  std::istream_iterator<std::string> it(strstr);
2720  std::istream_iterator<std::string> end;
2721  std::vector<std::string> results(it, end);
2722  values.resize( results.size() );
2723  for ( unsigned int i = 0; i < results.size(); ++i ) {
2724  std::stringstream sstr( results[ i ] );
2725  sstr >> values[ i ];
2726  }
2727  return input.good();
2728  }

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