#include "num2str.h"
#if defined USE_STRSTREAM
#include <strstream>
#else
#include <sstream>
#endif
// #include <iomanip>

//////////////////////////////////////////////////////////////////////////
//
// Method: OPUS_STR::num2str
//
// Purpose:
//
//    Convert a number to a string in one simple call
//
// Returns:
//
//    A string object with the number written out.
//
// Exceptions thrown:
//
//    none
//
// Modification History:
//
// Date       PR      Who         Reason
// ---------  -------- ----------- ----------------------------------------
// 19May2006  54226    Sontag      Initial code
//
//////////////////////////////////////////////////////////////////////////

template<class T>
std::string OPUS_STR::num2str(const T& number) // I - the number to be written
{
#if defined USE_STRSTREAM
   std::ostrstream oss;
#else
   std::ostringstream oss;
#endif
   // these two considerations can be added later
// if (width > 0) oss << setw(width);
// if (fill)      oss << setfill(fill);
   oss << number;
#if defined USE_STRSTREAM
   oss << std::ends;
#endif
   std::string retval(oss.str());
#if defined USE_STRSTREAM
   oss.freeze(0);
#endif
   return retval; // returns a copy
}
