From: <pst...@us...> - 2009-01-01 03:47:24
|
Revision: 676 http://jazzplusplus.svn.sourceforge.net/jazzplusplus/?rev=676&view=rev Author: pstieber Date: 2009-01-01 03:47:21 +0000 (Thu, 01 Jan 2009) Log Message: ----------- 1. Changed the time converter to use an STL string instead of a char *. 2. Changed the tMtcTime class constructor to use an initializer list. 3. Used an output string stream instead of sprintf. Modified Paths: -------------- trunk/jazz/src/Track.cpp trunk/jazz/src/Track.h Modified: trunk/jazz/src/Track.cpp =================================================================== --- trunk/jazz/src/Track.cpp 2009-01-01 03:32:09 UTC (rev 675) +++ trunk/jazz/src/Track.cpp 2009-01-01 03:47:21 UTC (rev 676) @@ -33,7 +33,10 @@ #include <cassert> #include <cstdlib> +#include <sstream> +using namespace std; + int tParam::Write(JZWriteBase& Io) { return mMsb.Write(Io) + mLsb.Write(Io) + mDataMsb.Write(Io); @@ -128,7 +131,11 @@ fm = (int) ((double) msec / frametime); } -tMtcTime::tMtcTime(char *str, tMtcType t) +tMtcTime::tMtcTime(char* str, tMtcType t) + : hour(0), + min(0), + sec(0), + fm(0) { type = t; if (type < Mtc24) @@ -139,10 +146,6 @@ { type = Mtc30Ndf; } - hour = 0; - min = 0; - sec = 0; - fm = 0; sscanf(str, "%d:%d:%d.%d", &hour, &min, &sec, &fm); if (fm >= framesPerSecond[type]) { @@ -167,9 +170,11 @@ } } -void tMtcTime::ToString(char *str) +void tMtcTime::ToString(string& String) { - sprintf(str, "%d:%d:%d.%d", hour, min, sec, fm); + ostringstream Oss; + Oss << hour << ':' << min << ':' << sec << '.' << fm; + String = Oss.str(); } tMtcOffset *tMtcTime::ToOffset() Modified: trunk/jazz/src/Track.h =================================================================== --- trunk/jazz/src/Track.h 2009-01-01 03:32:09 UTC (rev 675) +++ trunk/jazz/src/Track.h 2009-01-01 03:47:21 UTC (rev 676) @@ -27,6 +27,8 @@ #include "DynamicArray.h" #include "NamedValue.h" +#include <string> + class JZTrackWindow; class wxDialog; @@ -379,8 +381,8 @@ tMtcTime( int millisek, tMtcType t ); tMtcTime( char *str, tMtcType t ); tMtcTime( unsigned h, unsigned m, unsigned s, unsigned f, unsigned t ); - void ToString( char *str ); - tMtcOffset *ToOffset(); + void ToString(std::string& String); + tMtcOffset* ToOffset(); int ToMillisec(); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |