00001 #ifndef DVUTIL_IOMANIP_H
00002 #define DVUTIL_IOMANIP_H
00003
00004
00005 #include <iostream>
00006 #include <dvutil/basetype.h>
00007
00008 namespace Dv {
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 template<typename T>
00050 struct iomanip {
00051 typedef typename basetype<T>::base BT;
00052 typedef std::ostream& (*Print)(std::ostream&, const BT & );
00053 iomanip(Print f, const BT& t): print_(f), t_(t) {}
00054 Print print_;
00055 const BT& t_;
00056 };
00057
00058 template<typename T>
00059 std::ostream& operator<<(std::ostream& os, const Dv::iomanip<T>& io) {
00060 return io.print_(os, io.t_);
00061 }
00062
00063
00064 template<typename T>
00065 struct iomanip_c {
00066 typedef typename basetype<T>::base BT;
00067 typedef std::ostream& (*Print)(std::ostream&, const BT & );
00068 iomanip_c(Print f, const BT& t): print_(f), t_(t) {}
00069 Print print_;
00070 BT t_;
00071 };
00072
00073 template<typename T>
00074 std::ostream& operator<<(std::ostream& os, const Dv::iomanip_c<T>& io) {
00075 return io.print_(os, io.t_);
00076 }
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104 template<typename T>
00105 struct iomanip_m {
00106 typedef typename basetype<T>::base BT;
00107 typedef std::ostream& (T::*Print)(std::ostream&) const;
00108 iomanip_m(Print f, const BT& t): print_(f), t_(t) {}
00109 Print print_;
00110 const BT& t_;
00111 };
00112
00113 template<typename T>
00114 std::ostream& operator<<(std::ostream& os, const Dv::iomanip_m<T>& io) {
00115 return (io.t_.*(io.print_))(os);
00116 }
00117 }
00118 #endif