Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jac18281828/istream_block_iterator

Header only implementation of a istream_block_iterator
https://github.com/jac18281828/istream_block_iterator

Last synced: about 1 month ago
JSON representation

Header only implementation of a istream_block_iterator

Awesome Lists containing this project

README

        

# istream_block_iterator

Although c++ is already imbued with the kitchen sink, it seems to lack a chunked character iterator for input streams. Thus, I present an implementation of a 'chunked' stream iterator with configurable chunk size `n`

# Example

#### given an input stream, split it into a vector of strings at most 3 in length
```
constexpr auto N = 3;
const auto example = "AAABBBCCC";
std::istringstream ss(example);
std::vector blocks{};
std::copy(istream_block_iterator(ss, N), istream_block_iterator(),std::back_inserter(blocks));
```

`blocks` now has three entries, `"AAA"`, `"BBB"` and `"CCC"`.