Skip to content

Commit

Permalink
LineIterator allow different delimiter
Browse files Browse the repository at this point in the history
  • Loading branch information
kpu committed Jul 19, 2016
1 parent b638cec commit fac3d94
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion util/file_piece.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ParseNumberException::ParseNumberException(StringPiece value) throw() {
}

LineIterator &LineIterator::operator++() {
if (!backing_->ReadLineOrEOF(line_))
if (!backing_->ReadLineOrEOF(line_, delim_))
backing_ = NULL;
return *this;
}
Expand Down
3 changes: 2 additions & 1 deletion util/file_piece.hh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class LineIterator {
public:
LineIterator() : backing_(NULL) {}

explicit LineIterator(FilePiece &f) : backing_(&f) {
explicit LineIterator(FilePiece &f, char delim = '\n') : backing_(&f), delim_(delim) {
++*this;
}

Expand All @@ -55,6 +55,7 @@ class LineIterator {
private:
FilePiece *backing_;
StringPiece line_;
char delim_;
};

// Memory backing the returned StringPiece may vanish on the next call.
Expand Down

0 comments on commit fac3d94

Please sign in to comment.