diff --git a/include/pit/iters.h b/include/pit/iters.h index e3dad4b..a2e7b58 100644 --- a/include/pit/iters.h +++ b/include/pit/iters.h @@ -72,19 +72,37 @@ namespace pit{ return *this; } }; - + + // Allocator could be generic on just * with + and += using a stack buf and the istream getline method but lazy template, class Allocator = std::allocator> class basic_stream_split { bool ended; - std::basic_istream stream; - + std::basic_istream& stream; + CharT delim; public: + // there's no reason to specify the ending argument unless you want to manually construct the .end state of this iterator + basic_stream_split(std::basic_istream& stream, CharT delim, bool ending=false): stream(stream), ended(ending), delim(delim){} bool operator==(basic_stream_split const& rhs){ return this->ended == rhs; } - // todo: +,-, +=, -=, * + std::basic_string operator*(){ + std::basic_string s; + std::getline(this->stream, s, this->delim); + return s; + } + // can't do -, or -= there's no reasonable way to undo istream reads + // can't do + without storing a line + void operator+=(std::size_t rhs){ + std::basic_string s; + for(size_t i =0;istream, s, this->delim); + return *this; + } }; - using stream_split = basic_stream_split; using wstream_split = basic_stream_split; + + template, class Allocator = std::allocator> + basic_stream_split split_stream(std::basic_istream& stream){ + + } }