vsl_indent Class Reference

#include <vsl_indent.h>


Detailed Description

Put indents into output streams, to produce more legible printed output.

Its use is best described by example:

 vcl_cout<<vsl_indent()<<"No Indent\n";
 vsl_indent_inc(vcl_cout);
 vcl_cout<<vsl_indent()<<"1 Indent\n";
 vsl_indent_inc(vcl_cout);
 vcl_cout<<vsl_indent()<<"2 Indent\n";
 vsl_indent_dec(vcl_cout);
 vcl_cout<<vsl_indent()<<"1 Indent\n";
 vsl_indent_dec(vcl_cout);
 vcl_cout<<vsl_indent()<<"No Indent\n";

This produces output of the form

   No Indent
     1 Indent
       2 Indent
     1 Indent
   No Indent
   

Example of use in class output:

 class Fred
 {
 public:
  void print(vcl_ostream& os) const { os<<vsl_indent()<<"Fred's data"; }
 };

 vcl_ostream& operator<<(vcl_ostream& os, const Fred& fred)
 {
  os<<"Fred: \n";
  vsl_indent_inc(os);
  fred.print(os);
  vsl_indent_dec(os);
  return os;
 }

 class Jim
 {
 private:
  Fred fred_;
 public:
  void print(vcl_ostream& os) const
  {
    os<<vsl_indent(os)<<fred_<<vcl_endl;
    os<<vsl_indent(os)<<"Jim's other data"; }
  };

 vcl_ostream& operator<<(vcl_ostream& os, const Jim& jim)
 {
  os<<"Jim: \n";
  vsl_indent_inc(os);
  jim.print(os);
  vsl_indent_dec(os);
  return os;
 }

 main()
 {
  Jim jim;
  vcl_cout<<jim<<vcl_endl;
 }

This produces output:

    Jim:
      Fred's data
      Jim's other data
   

Definition at line 87 of file vsl_indent.h.


The documentation for this class was generated from the following file:
Generated on Thu Aug 21 05:05:56 2008 for core/vsl by  doxygen 1.5.1