Created
August 16, 2011 17:33
-
-
Save yangacer/1149630 to your computer and use it in GitHub Desktop.
boost iostreams newline filter and array source
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* FreeBSD 8.2 | |
* g++ -I /usr/local/include newline_array_src.cpp | |
**/ | |
#include <boost/iostreams/filtering_stream.hpp> | |
#include <boost/iostreams/filter/newline.hpp> | |
#include <boost/iostreams/device/array.hpp> | |
#include <string> | |
#include <cstring> | |
#include <iostream> | |
int main() | |
{ | |
using namespace boost::iostreams; | |
using namespace std; | |
char const *text = "line1 abc\r\nline2 abc\r\n"; | |
filtering_istream in; | |
in.push(newline_filter(newline::posix)); | |
in.push(array_source(text, strlen(text))); | |
string line; | |
while(getline(in, line)){ | |
cout<<line<<endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment