On Fri, Jul 06, 2001 at 10:05:07AM -0400, Steve M. Robbins wrote:
> I implemented a workaround last night for systems that lack <sstream>,
> based on your suggestion of some weeks ago. I'd like to commit that
> before the next release.
To elaborate, what I did is define a new class CppUnit::OStringStream
which can be used in the following way.
CppUnit::OStringStream ost;
ost << "@Dummy@" << serialNumber++;
registerFactory( ost.str(), factory );
The definition of OStringStream is the following. Any comments?
/* Define CPPUNIT_SSTREAM as a stream with a "std::string str()"
* method.
*/
#include <string>
#if CPPUNIT_HAVE_SSTREAM
# include <sstream>
namespace CppUnit {
typedef std::ostringstream OStringStream;
}
#else
#if CPPUNIT_HAVE_STRSTREAM
# include <strstream.h>
namespace CppUnit {
class OStringStream : public std::ostrstream
{
public:
std::string str()
{
(*this) << '\0'; // necessary?
std::string msg(ostrstream::str());
ostrstream::freeze(false); //unfreeze stream [why?]
return msg;
}
};
}
#endif
#endif
--
by Rocket to the Moon,
by Airplane to the Rocket,
by Taxi to the Airport,
by Frontdoor to the Taxi,
by throwing back the blanket and laying down the legs ...
- They Might Be Giants
|