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

Merge branch 'cell-ranges' into cell-construction

parents 5a97abdd fdfcefa7
No related branches found
No related tags found
No related merge requests found
......@@ -265,7 +265,7 @@ public:
return ret;
}
value_type operator*()
value_type operator*() const
{
if (eof_) {
throw std::out_of_range("attempt to read past eof");
......@@ -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);
}
......@@ -320,27 +320,32 @@ private:
class cell_record_range_raw
{
public:
using value_type = cell_record;
using reference = value_type &;
using const_referene = const value_type &;
using iterator = cell_record_stream_iterator;
using const_iterator = const cell_record_stream_iterator;
using value_type = cell_record;
using reference = value_type &;
using const_reference = const value_type &;
using iterator = cell_record_stream_iterator;
using const_iterator = const cell_record_stream_iterator;
cell_record_range_raw(std::istream &is)
: is_(is)
{ }
iterator begin()
iterator begin() const
{
return cell_record_stream_iterator(is_);
}
iterator end()
iterator end() const
{
iterator::eof_tag eof;
return cell_record_stream_iterator(is_, eof);
}
bool empty() const
{
return begin() == end();
}
private:
std::istream &is_;
};
......@@ -379,6 +384,11 @@ public:
return cells_.size();
}
bool empty() const
{
return cells_.empty();
}
private:
std::vector<cell_record> cells_;
};
......
......@@ -371,4 +371,11 @@ TEST(cell_record_ranges, raw)
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