diff --git a/include/osmosdr/osmosdr_ranges.h b/include/osmosdr/osmosdr_ranges.h index b7939df..c84eb95 100644 --- a/include/osmosdr/osmosdr_ranges.h +++ b/include/osmosdr/osmosdr_ranges.h @@ -107,6 +107,9 @@ namespace osmosdr{ */ double clip(double value, bool clip_step = false) const; + /*! return a vector containing all values of the range */ + std::vector values() const; + //! Convert this meta-range to a printable string const std::string to_pp_string(void) const; diff --git a/lib/osmosdr_ranges.cc b/lib/osmosdr_ranges.cc index 0b7ecbb..c018c29 100644 --- a/lib/osmosdr_ranges.cc +++ b/lib/osmosdr_ranges.cc @@ -154,6 +154,27 @@ double meta_range_t::clip(double value, bool clip_step) const{ return last_stop; } +std::vector meta_range_t::values() const { + std::vector values; + + BOOST_FOREACH(const range_t &r, (*this)) { + if (r.start() != r.stop()) { + if ( r.step() == 0 ) { + values.push_back( r.start() ); + values.push_back( r.stop() ); + } else { + for ( double val = r.start(); val <= r.stop(); val += r.step() ) { + values.push_back( val ); + } + } + } else { + values.push_back( r.start() ); + } + } + + return values; +} + const std::string meta_range_t::to_pp_string(void) const{ std::stringstream ss; BOOST_FOREACH(const range_t &r, (*this)){