core/vsl/vsl_indent.h

Go to the documentation of this file.
00001 // This is core/vsl/vsl_indent.h
00002 #ifndef vsl_indent_h_
00003 #define vsl_indent_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \author Tim Cootes
00010 
00011 #include <vcl_iosfwd.h>
00012 
00013 //: Put indents into output streams, to produce more legible printed output
00014 //  Its use is best described by example:
00015 // \code
00016 // vcl_cout<<vsl_indent()<<"No Indent\n";
00017 // vsl_indent_inc(vcl_cout);
00018 // vcl_cout<<vsl_indent()<<"1 Indent\n";
00019 // vsl_indent_inc(vcl_cout);
00020 // vcl_cout<<vsl_indent()<<"2 Indent\n";
00021 // vsl_indent_dec(vcl_cout);
00022 // vcl_cout<<vsl_indent()<<"1 Indent\n";
00023 // vsl_indent_dec(vcl_cout);
00024 // vcl_cout<<vsl_indent()<<"No Indent\n";
00025 // \endcode
00026 //
00027 // This produces output of the form
00028 // \verbatim
00029 // No Indent
00030 //   1 Indent
00031 //     2 Indent
00032 //   1 Indent
00033 // No Indent
00034 // \endverbatim
00035 //
00036 // Example of use in class output:
00037 // \code
00038 // class Fred
00039 // {
00040 // public:
00041 //  void print(vcl_ostream& os) const { os<<vsl_indent()<<"Fred's data"; }
00042 // };
00043 //
00044 // vcl_ostream& operator<<(vcl_ostream& os, const Fred& fred)
00045 // {
00046 //  os<<"Fred: \n";
00047 //  vsl_indent_inc(os);
00048 //  fred.print(os);
00049 //  vsl_indent_dec(os);
00050 //  return os;
00051 // }
00052 //
00053 // class Jim
00054 // {
00055 // private:
00056 //  Fred fred_;
00057 // public:
00058 //  void print(vcl_ostream& os) const
00059 //  {
00060 //    os<<vsl_indent(os)<<fred_<<vcl_endl;
00061 //    os<<vsl_indent(os)<<"Jim's other data"; }
00062 //  };
00063 //
00064 // vcl_ostream& operator<<(vcl_ostream& os, const Jim& jim)
00065 // {
00066 //  os<<"Jim: \n";
00067 //  vsl_indent_inc(os);
00068 //  jim.print(os);
00069 //  vsl_indent_dec(os);
00070 //  return os;
00071 // }
00072 //
00073 // main()
00074 // {
00075 //  Jim jim;
00076 //  vcl_cout<<jim<<vcl_endl;
00077 // }
00078 // \endcode
00079 //
00080 // This produces output:
00081 // \verbatim
00082 //  Jim:
00083 //    Fred's data
00084 //    Jim's other data
00085 // \endverbatim
00086 
00087 class vsl_indent
00088 {
00089 };
00090 
00091 //: Increments current indent for given stream
00092 void vsl_indent_inc(vcl_ostream& os);
00093 
00094 //: Decrements current indent for given stream
00095 void vsl_indent_dec(vcl_ostream& os);
00096 
00097 //: Set number of spaces per increment step
00098 void vsl_indent_set_tab(vcl_ostream& os,int);
00099 
00100 //: Number of spaces per increment step
00101 int vsl_indent_tab(vcl_ostream& os);
00102 
00103 //: Set indentation to zero
00104 void vsl_indent_clear(vcl_ostream& os);
00105 
00106 //: Outputs current indent to os
00107 vcl_ostream& operator<<(vcl_ostream& os, const vsl_indent& indent);
00108 
00109 //: Tidy up the internal indent map to remove potential memory leaks
00110 //  The details of indents for each stream are stored in a static
00111 //  map.  When testing for memory leaks, this is flagged, creating
00112 //  lots of noise in the output of memory leak checkers.
00113 //  This call empties the map, removing the potential leak.
00114 //  Pragmatically it is called in the vsl_delete_all_loaders()
00115 void vsl_indent_clear_all_data();
00116 
00117 #endif // vsl_indent_h_

Generated on Mon Sep 8 05:05:50 2008 for core/vsl by  doxygen 1.5.1