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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef _ABKIO_H_
00058 #define _ABKIO_H_
00059 #include <iostream>
00060 #include <iomanip>
00061
00062 #include <stdio.h>
00063 #include <string.h>
00064 #include <vector>
00065 #include "abkassert.h"
00066
00067 using std::istream;
00068 using std::ostream;
00069 using std::setw;
00070 using std::flush;
00071 using std::endl;
00072 using std::cin;
00073 using std::cout;
00074 using std::cerr;
00075
00076 istream& eatblank(istream& i);
00077 istream& skiptoeol(istream& i);
00078
00079
00080
00081
00082
00083
00084
00085
00086 template<class Arg>
00087 class ManipFuncObj1
00088 {
00089 istream& (*_func) (istream&, Arg);
00090 Arg _arg;
00091 public:
00092 ManipFuncObj1(istream& (*f) (istream&,Arg), Arg arg):_func(f),_arg(arg) {}
00093 istream& operator()(istream& i) const { return (*_func)(i,_arg) ; }
00094 };
00095
00096 template<class Arg>
00097 istream& operator>>(istream& is, const ManipFuncObj1<Arg>& im)
00098 { return im(is); }
00099
00100 template<class Arg1,class Arg2>
00101 class ManipFuncObj2
00102 {
00103 istream& (*_func) (istream&, Arg1, Arg2);
00104 Arg1 _arg1;
00105 Arg2 _arg2;
00106 public:
00107 ManipFuncObj2(istream& (*f) (istream&, Arg1, Arg2), Arg1 arg1, Arg2 arg2)
00108 :_func(f),_arg1(arg1),_arg2(arg2) {}
00109 istream& operator()(istream& i) const { return (*_func)(i,_arg1,_arg2) ; }
00110 };
00111
00112 template<class Arg1, class Arg2>
00113 istream& operator>>(istream& is, const ManipFuncObj2<Arg1,Arg2>& im)
00114 { return im(is); }
00115
00116 ManipFuncObj1<int&> eathash (int& lineNo);
00117 ManipFuncObj1<int> needeol (int lineNo=-1);
00118 ManipFuncObj1<int> noeol (int lineNo=-1);
00119
00120 ManipFuncObj1<int> my_isnumber (int lineNo=-1);
00121 ManipFuncObj1<int> isword (int lineNo=-1);
00122
00123 ManipFuncObj2<const char *, int> needword(const char * word, int lineNo=-1);
00124 ManipFuncObj2<const char *, int> needcaseword(const char * word, int lineNo=-1);
00125
00126 template<class T>
00127 inline
00128 ostream& operator<<(ostream& out, const std::vector<T>& rhs)
00129 {
00130 unsigned size=rhs.size();
00131 for (unsigned i=0; i!=size; ++i)
00132 {
00133 if ( i % 10 == 0 )
00134 {
00135 if (i) out << endl;
00136 out<<" ";
00137 }
00138 out<<setw(6)<<rhs[i]<<" ";
00139 }
00140 out<<"\n";
00141 return out;
00142 }
00143
00144
00145 template<class Iter>
00146 inline
00147 unsigned printRange(ostream& out, Iter first, Iter last)
00148 {
00149 unsigned count=0;
00150 for (;first!=last; first++, count++)
00151 {
00152 if (count % 10 == 0)
00153 {
00154 if (count)
00155 out<<'\n';
00156 out<<" ";
00157 }
00158 out<<setw(6)<<*first<<' ';
00159 }
00160 out<<'\n';
00161 return count;
00162 }
00163
00164
00165 #endif