From 11b5a91c5884d496744911f261ed6c2b053b9940 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 19 Aug 2010 06:28:17 +0000 Subject: Wow, it pretty much all works. the float format is a little funny, I treat it as a string, with a string header and then string data that is then turned into a float. It's pretty much how it's going to work, unless I come up with something revolutionary. --- src/float.cpp | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/float.cpp') diff --git a/src/float.cpp b/src/float.cpp index e69de29..e257b37 100644 --- a/src/float.cpp +++ b/src/float.cpp @@ -0,0 +1,37 @@ +#include "gats/float.h" +#include "gats/integer.h" + +Gats::Float::Float() : + fVal( 0.0 ) +{ +} + +Gats::Float::Float( double f ) : + fVal( f ) +{ +} + +Gats::Float::~Float() +{ +} + +void Gats::Float::write( Bu::Stream &rOut ) const +{ + char buf[50]; + + int iSize = snprintf( buf, 50, "%la", fVal ); + + rOut.write("f", 1 ); + Gats::Integer::writePackedInt( rOut, iSize ); + rOut.write( buf, iSize ); +} + +void Gats::Float::read( Bu::Stream &rIn, char cType ) +{ + int iSize; + Gats::Integer::readPackedInt( rIn, iSize ); + char buf[50]; + rIn.read( buf, iSize ); + sscanf( buf, "%la", &fVal ); +} + -- cgit v1.2.3