00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _dgChannelManip_h_
00027 #define _dgChannelManip_h_
00028
00035 #include "dgChannel.h"
00036
00037 namespace DGD {
00038
00049 template <class Arg_type>
00050 class channel_manip {
00051 public:
00052 typedef void (channel::*method_type)( Arg_type );
00053 public:
00054 method_type m_method;
00055 Arg_type m_argument;
00056
00057 explicit channel_manip( method_type method, Arg_type arg ):
00058 m_method(method), m_argument(arg) {}
00059 };
00060
00069 class channel_manip_void {
00070 public:
00071 typedef void (channel::*method_type)();
00072
00073 public:
00074 method_type m_method;
00075
00076 explicit channel_manip_void( method_type m ):
00077 m_method(m) {}
00078 };
00079
00089 class channel_manip_nop {
00090 public:
00091 channel_manip_nop() {}
00092 };
00093
00097 typedef channel_manip<bool> channel_manip_bool;
00098
00102 typedef channel_manip<unsigned int> channel_manip_uint;
00103
00107 inline std::ostream& operator <<( std::ostream& cnl,
00108 const channel_manip_void& manip ) {
00109
00110 (dynamic_cast<channel&>(cnl).*(manip.m_method))();
00111 return cnl;
00112 }
00113
00117 inline std::ostream& operator <<( std::ostream& cnl,
00118 const channel_manip_bool& manip ) {
00119 (dynamic_cast<channel&>(cnl).*(manip.m_method))( manip.m_argument );
00120 return cnl;
00121 }
00122
00126 inline std::ostream& operator <<( std::ostream& cnl,
00127 const channel_manip_uint& manip ) {
00128 (dynamic_cast<channel&>(cnl).*(manip.m_method))( manip.m_argument );
00129 return cnl;
00130 }
00131
00139 inline channel& operator <<( std::ostream& cnl,
00140 const channel_manip_nop& manip ) {
00141
00142 return dynamic_cast<channel&>(cnl);
00143 }
00144
00149 const channel_manip_void incr = channel_manip_void( &channel::incr_indent );
00150
00155 const channel_manip_void decr = channel_manip_void( &channel::decr_indent );
00156
00204 const channel_manip_nop dgd = channel_manip_nop();
00205
00210 inline channel_manip_uint step( unsigned int s ) {
00211 return channel_manip_uint( &channel::indent_step, s );
00212 }
00213
00218 inline channel_manip_uint indent( unsigned int s ) {
00219 return channel_manip_uint( &channel::indent, s );
00220 }
00221
00226 inline channel_manip_uint minwidth( unsigned int s ) {
00227 return channel_manip_uint( &channel::min_width, s );
00228 }
00229
00234 inline channel_manip_uint maxwidth( unsigned int s ) {
00235 return channel_manip_uint( &channel::max_width, s );
00236 }
00237
00242 inline channel_manip_bool wrap( bool s ) {
00243 return channel_manip_bool( &channel::wrap, s );
00244 }
00245
00250 inline channel_manip_bool word_wrap( bool s ) {
00251 return channel_manip_bool( &channel::word_wrap, s );
00252 }
00253
00254 };
00255
00256 #endif
00257
00258
00259
00260
00261
00262
00263
00264