// -*- C++ -*- // // $Id: m_data.h,v 1.1.1.1 2006/01/11 09:34:31 mervart Exp $ // #if !defined(__m_data_h__) // protects the header from been included more than once #define __m_data_h__ #include #include #include #include #include #include #include #include #include #include #if defined(__GNUC_MINOR__) && ( __GNUC_MINOR__ < 91 ) #else using namespace std; #endif template void WriteNative(ostream &os,const T & data) { #if 1 os.write(reinterpret_cast(&data),sizeof(data)); #else int i; os << typeid(data).name() << " " << sizeof(data) << " "; for(i= 0;i void WriteNative(ostream & os,const map &m) { WriteNative(os,m.size()); typedef typename map::iterator I; I i; for(i=m.begin();i Wrapper for Scalar types T template class C_Data { public: typedef T DataType; explicit C_Data(DataType _data= 0):data(_data) {} C_Data(const C_Data & org):data(org.get()) {} C_Data &operator= ( const C_Data &newValue) { set(newValue.get()); return *this; } // bool operator == (T other) { return get() == other.get(); } // bool operator != (T other) { return get() != other.get(); } ~C_Data() {} void writeNative(ostream &os) const { WriteNative(os,data); } void set(const DataType &newValue) { data = newValue; } const DataType &get() const { return data; } protected: DataType data; } ; template bool operator<(const C_Data &d1,const C_Data &d2) { return d1.get() < d2.get(); } template bool operator>(const C_Data &d1,const C_Data &d2) { return d1.get() > d2.get(); } template bool operator==(const C_Data &d1,const C_Data &d2) { return d1.get() == d2.get(); } template bool operator!=(const C_Data &d1,const C_Data &d2) { return d1.get() != d2.get(); } template bool operator<=(const C_Data &d1,const C_Data &d2) { return ( d1.get() == d2.get() ) || ( d1.get() < d2.get() ) ; } template C_Data operator-(const C_Data &d1,const C_Data &d2) { return C_Data(d1.get() - d2.get()); } template void WriteNative(ostream &os,const C_Data c_data) { c_data.writeNative(os); } template void divmod(const long numer,const long denom,T2 ",T3 &rem) { ldiv_t res; ldiv(numer,denom); quot = res.quot; rem = res.rem; } #endif