#include "gats/float.h" #include "gats/integer.h" #include Gats::Float::Float() : fVal( 0.0 ) { } Gats::Float::Float( double f ) : fVal( f ) { } Gats::Float::~Float() { } void Gats::Float::write( Bu::Stream &rOut ) const { if( sWriteCache.isEmpty() ) { char buf[50]; int iSize = snprintf( buf, 50, "%la", fVal ); sWriteCache.set( buf, iSize ); } rOut.write("f", 1 ); Gats::Integer::writePackedInt( rOut, sWriteCache.getSize() ); rOut.write( sWriteCache.getStr(), sWriteCache.getSize() ); } #include using namespace Bu; void Gats::Float::read( Bu::Stream &rIn, char cType ) { int iSize; Gats::Integer::readPackedInt( rIn, iSize ); char buf[50]; buf[rIn.read( buf, iSize )] = '\0'; sio << "Reading float, iSize = " << iSize << ", str = " << buf << sio.nl; sscanf( buf, "%la", &fVal ); } Bu::Formatter &operator<<( Bu::Formatter &f, const Gats::Float &flt ) { return f << "(float) " << flt.getValue(); }