ndn::util::IndentedStream Class Reference

Output to stream with specified indent or prefix. More...

#include <ndn-cxx/util/indented-stream.hpp>

+ Inheritance diagram for ndn::util::IndentedStream:
+ Collaboration diagram for ndn::util::IndentedStream:

Public Member Functions

 IndentedStream (std::ostream &os, const std::string &indent)
 
 ~IndentedStream () override
 

Detailed Description

Output to stream with specified indent or prefix.

For example, the following code:

std::cout << "Hello" << std::endl;
IndentedStream os1(std::cout, " [prefix] ");
os1 << "," << "\n";
{
  IndentedStream os2(os1, " [another prefix] ");
  os2 << "World!" << "\n";
}
// either os1 needs to go out of scope or call os1.flush()

Will produce the following output:

Hello
 [prefix] ,
 [prefix] [another prefix] World!

Based on http://stackoverflow.com/a/2212940/2150331

Definition at line 54 of file indented-stream.hpp.

Constructor & Destructor Documentation

◆ IndentedStream()

ndn::util::IndentedStream::IndentedStream ( std::ostream &  os,
const std::string &  indent 
)

Definition at line 33 of file indented-stream.cpp.

◆ ~IndentedStream()

ndn::util::IndentedStream::~IndentedStream ( )
override

Definition at line 39 of file indented-stream.cpp.