| 1 | //show composition of indent filter with ostream.
|
|---|
| 2 | #include <boost/iostreams/filter/indent.hpp>
|
|---|
| 3 | #include <boost/iostreams/filtering_stream.hpp>
|
|---|
| 4 | #include <boost/iostreams/compose.hpp>
|
|---|
| 5 | #include <iostream>
|
|---|
| 6 |
|
|---|
| 7 | void test_conversion(std::ostream& sout)
|
|---|
| 8 | {
|
|---|
| 9 | sout<<"inside test_conversion\n";
|
|---|
| 10 | }
|
|---|
| 11 |
|
|---|
| 12 | using namespace boost::iostreams;
|
|---|
| 13 |
|
|---|
| 14 | int main(void)
|
|---|
| 15 | {
|
|---|
| 16 | ; filtering_ostream mout
|
|---|
| 17 | ; mout.push
|
|---|
| 18 | ( compose
|
|---|
| 19 | ( indent_filter<>()
|
|---|
| 20 | , std::cout
|
|---|
| 21 | )
|
|---|
| 22 | )
|
|---|
| 23 | ; mout<<"line1\n"
|
|---|
| 24 | #if 0
|
|---|
| 25 | ; ++mout
|
|---|
| 26 | ; mout<<"line1.1"<<std::endl
|
|---|
| 27 | ; mout<<indent_in<<"line1.1.1"<<std::endl
|
|---|
| 28 | ; test_conversion(mout)
|
|---|
| 29 | #if 0
|
|---|
| 30 | ; mout<<"line1.1.2"<<std::endl
|
|---|
| 31 | #endif
|
|---|
| 32 | ; --mout
|
|---|
| 33 | ; unsigned u=22
|
|---|
| 34 | ; mout<<"line1.2:unsigned="<<u<<std::endl
|
|---|
| 35 | ; float f=3.1416
|
|---|
| 36 | ; mout<<"line1.3:float="<<f<<std::endl
|
|---|
| 37 | ; --mout
|
|---|
| 38 | ; --mout
|
|---|
| 39 | ; mout<<"line2\n"
|
|---|
| 40 | #endif
|
|---|
| 41 | ; return 0
|
|---|
| 42 | ;
|
|---|
| 43 | }
|
|---|
| 44 | //Expected output:
|
|---|
| 45 | /*
|
|---|
| 46 | line1
|
|---|
| 47 | line1.1
|
|---|
| 48 | line1.1.1
|
|---|
| 49 | inside test_conversion
|
|---|
| 50 | line1.2:unsigned=22
|
|---|
| 51 | line1.3:float=3.1416
|
|---|
| 52 | line2
|
|---|
| 53 | */
|
|---|
| 54 |
|
|---|