Skip to content
Snippets Groups Projects
Commit fdfcefa7 authored by Vasileios Karakasis's avatar Vasileios Karakasis
Browse files

Added empty() calls.

+ some const specifiers.
parent ece57518
No related branches found
No related tags found
No related merge requests found
...@@ -265,7 +265,7 @@ public: ...@@ -265,7 +265,7 @@ public:
return ret; return ret;
} }
value_type operator*() value_type operator*() const
{ {
if (eof_) { if (eof_) {
throw std::out_of_range("attempt to read past eof"); throw std::out_of_range("attempt to read past eof");
...@@ -283,7 +283,7 @@ public: ...@@ -283,7 +283,7 @@ public:
} }
} }
bool operator!=(const cell_record_stream_iterator &other) bool operator!=(const cell_record_stream_iterator &other) const
{ {
return !(*this == other); return !(*this == other);
} }
...@@ -320,27 +320,32 @@ private: ...@@ -320,27 +320,32 @@ private:
class cell_record_range_raw class cell_record_range_raw
{ {
public: public:
using value_type = cell_record; using value_type = cell_record;
using reference = value_type &; using reference = value_type &;
using const_referene = const value_type &; using const_reference = const value_type &;
using iterator = cell_record_stream_iterator; using iterator = cell_record_stream_iterator;
using const_iterator = const cell_record_stream_iterator; using const_iterator = const cell_record_stream_iterator;
cell_record_range_raw(std::istream &is) cell_record_range_raw(std::istream &is)
: is_(is) : is_(is)
{ } { }
iterator begin() iterator begin() const
{ {
return cell_record_stream_iterator(is_); return cell_record_stream_iterator(is_);
} }
iterator end() iterator end() const
{ {
iterator::eof_tag eof; iterator::eof_tag eof;
return cell_record_stream_iterator(is_, eof); return cell_record_stream_iterator(is_, eof);
} }
bool empty() const
{
return begin() == end();
}
private: private:
std::istream &is_; std::istream &is_;
}; };
...@@ -379,6 +384,11 @@ public: ...@@ -379,6 +384,11 @@ public:
return cells_.size(); return cells_.size();
} }
bool empty() const
{
return cells_.empty();
}
private: private:
std::vector<cell_record> cells_; std::vector<cell_record> cells_;
}; };
......
...@@ -371,4 +371,11 @@ TEST(cell_record_ranges, raw) ...@@ -371,4 +371,11 @@ TEST(cell_record_ranges, raw)
EXPECT_EQ(3u, e.lineno()); EXPECT_EQ(3u, e.lineno());
} }
} }
{
// Test empty range
std::stringstream is("");
EXPECT_TRUE(swc_get_records<swc_io_raw>(is).empty());
EXPECT_TRUE(swc_get_records<swc_io_clean>(is).empty());
}
} }
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment