00001 #ifndef IOVAR_TMPL_HEADER
00002 #define IOVAR_TMPL_HEADER
00003
00004
00005
00012
00013
00014
00015
00016 #include <stdlib.h>
00017
00018 #ifdef _STANDARD_C_PLUS_PLUS
00019 #include <iostream>
00020 #else
00021 #include <iostream.h>
00022 #endif
00023
00024 #include <string>
00025 using namespace std;
00026 #ifndef NPOS
00027 #define NPOS string::npos
00028 #endif
00029
00030
00031
00032 #include "Rangedimexc.hh"
00033
00034
00035
00036 namespace RazorBack {
00037
00038
00039 template <class T_> class Iovar_;
00040 template <class T_>
00041 istream& operator>>(istream& In, Iovar_<T_>& Iov);
00042 template <class T_>
00043 ostream& operator<<(ostream& Out, const Iovar_<T_>& Iov);
00044
00066 template <class T_>
00067 class Iovar_
00068 {
00069
00070 private:
00071
00072 string Descr;
00073 bool Nocase;
00074 char Eqchar;
00075 T_ Value;
00076
00077
00078 public:
00079
00090 explicit Iovar_(const char *Dtok, T_ Defval=T_(0), bool Noc=false, char Eq='=');
00091
00093 const string& descr() const { return Descr; }
00094
00096 size_t dlen() const { return Descr.size(); }
00097
00103 bool match_descr(const string& Str) const;
00104
00109 bool nocase() const { return Nocase; }
00110
00112 char eqchar() const { return Eqchar; }
00113
00115 const T_& value() const { return Value; }
00116
00118 T_ value(const T_& V) { T_ Ov=Value; Value=V; return Ov; }
00119
00120
00121
00122
00123
00124
00125 friend
00126 istream& operator>> <>(istream& In, Iovar_<T_>& Iov);
00127
00128
00129
00130 friend
00131 ostream& operator<< <>(ostream& Out, const Iovar_<T_>& Iov);
00132
00133
00134 protected:
00135
00136 istream& read_value(istream& In);
00137 ostream& write_value(ostream& Out) const;
00138 };
00139
00140
00141 #ifndef RAZORBACK_LIB_COMPILE
00142
00143
00144
00145
00146
00147 template<> istream& Iovar_<bool>::read_value(istream& In);
00148 template<> ostream& Iovar_<bool>::write_value(ostream& Out) const;
00149 #endif
00150
00151 }
00152
00153 #ifdef INCLUDE_TMPL_DEFS
00154 #include "Iovar.cc"
00155 #endif
00156
00157
00158
00159 #endif // IOVAR_TMPL_HEADER