|
BDE 4.14.0 Production release
|
Provide object for streaming objects using bdlb::PrintMethods.
bdlb::PrintMethods.bdlb::PrintAdapter.This component provides a template class that will enable any object that can be streamed using bdlb::PrintMethods to be streamed via <<.
Through using this class, one can stream an object using operator<< and at the same time specify level and spacesPerLevel arguments to appropriately indent and format the output.
This section illustrates intended use of this component.
Suppose we have a few bdlb::IdentSpan objects that we want to print, only we want to stream them with operator<< and we want to specify non-default values of level and spacesPerLevel to their streaming.
First, we create a typedef of 'PrintAdapter<IdentSpan>' to use:
Then, we create a line of dashes:
Now, we use the typedef to construct temporary PrintAdapter objects to stream our IndexSpan objects:
Finally, we see the output:
Suppose we have a few bdlb::IdentSpan objects that we want to print, only we want to stream them with operator<< and we want to specify non-default values of level and spacesPerLevel to their streaming.
First, we make a typedef to the namespace struct:
Then, we create a line of dashes:
Now, we call the static function PrintAdapterUtil::makeAdapter on the IndexSpan objects to stream which will return streamable PrintAdapter objects:
Finally, we see the output:
Suppose you have a few bdlb::IdentSpan objects that you want to print, only you want to stream them with operator<< and you want to specify non-default values of level and spacesPerLevel to their streaming.
First, we create a line of dashes:
Now, you call the constructor PrintAdapter on the IndexSpan objects to stream and CTAD will create the right template specification:
Finally, we see the output: