DGtal 2.1.0
Loading...
Searching...
No Matches
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 3406 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 3422 of file Shortcuts.h.

3423 {
3424 std::string str;
3425 std::getline( input, str );
3426 // construct a stream from the string
3427 std::stringstream strstr(str);
3428 // use stream iterators to copy the stream to the vector as whitespace separated strings
3429 std::istream_iterator<std::string> it(strstr);
3430 std::istream_iterator<std::string> end;
3431 std::vector<std::string> results(it, end);
3432 values.resize( results.size() );
3433 for ( unsigned int i = 0; i < results.size(); ++i ) {
3434 std::stringstream sstr( results[ i ] );
3435 sstr >> values[ i ];
3436 }
3437 return input.good();
3438 }

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

3408 {
3409 std::string str;
3410 std::getline( input, str );
3411 // construct a stream from the string
3412 std::stringstream strstr(str);
3413 // use stream iterators to copy the stream to the vector as whitespace separated strings
3414 std::istream_iterator<std::string> it(strstr);
3415 std::istream_iterator<std::string> end;
3416 std::vector<std::string> results(it, end);
3417 std::stringstream sstr( results[ 0 ] );
3418 sstr >> value;
3419 return ( results.size() == 1 ) && input.good();
3420 }

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