#include #include #include #include struct SinkDev: public boost::iostreams::device { std::streamsize write(const char* s, std::streamsize n) { std::cerr << "SinkDev::write(): Recieved " << n << " characters.\n"; return n; } }; struct SourceDev: public boost::iostreams::device { std::streamsize read(char* s, std::streamsize n) { std::cerr << "SourceDev::read(): Sending " << n << " characters.\n"; char data[] = "wrlubriachlasluprlebriuq"; std::memcpy(s, data, n); return n; } }; int main() { using namespace boost; // This our test output stream iostreams::filtering_stream out; // Add a code converter filter with a 16 character buffer out.push(iostreams::code_converter(SinkDev(), 16), 0); // This our test output stream iostreams::filtering_stream in; // Add a code converter filter with a 16 character buffer in.push(iostreams::code_converter(SourceDev(), 16), 0); wchar_t data[] = L"wieriaciafrianoechlajoes"; // Test the output stream std::cerr << "main(): Sending 24 characters of data to output stream\n"; out.write(data, 24); std::cerr << "main(): Calling a sync on the output stream\n"; out.strict_sync(); std::cerr << "main(): Sending 21 characters of data to output stream\n"; out.write(data, 21); std::cerr << '\n'; // Test the input stream std::cerr << "main(): Asking for 24 characters of data from input stream\n"; in.read(data, 24); std::cerr << "main(): Calling a sync on the input stream\n"; in.strict_sync(); std::cerr << "main(): Asking for 9 characters of data from input stream\n"; in.read(data, 9); std::cerr << '\n'; std::cerr << "main(): At end of test case\n"; return 0; }