#
# patch "ChangeLog"
# from [c7896a6483ac1de6792a5d294401e4e9d03eaac1]
# to [d495817d8d564432f79724cf232d8f42cfe9159e]
#
# patch "sanity.cc"
# from [941be97694585d71216f0d16c0ca6750f7101b19]
# to [f8b6dbcdd2dd836d7a5bd26316c8da713e548bb2]
#
# patch "sanity.hh"
# from [41ccd55d17d0e3068dcb95388058de1b0e9e0fee]
# to [842a7168fbbcd601cf425a76417d63871f85bebc]
#
===============================================
--- ChangeLog c7896a6483ac1de6792a5d294401e4e9d03eaac1
+++ ChangeLog d495817d8d564432f79724cf232d8f42cfe9159e
@@ -1,5 +1,10 @@
2005-07-24 Nathaniel Smith
+ * sanity.hh (class Musing, gasp, dump): Actually, take a
+ std::string instead of a std::ostream; fits our idioms better.
+
+2005-07-24 Nathaniel Smith
+
* sanity.cc (log, progress, warning): Append '\n' to strings when
necessary.
(gasp): Save string properly.
===============================================
--- sanity.cc 941be97694585d71216f0d16c0ca6750f7101b19
+++ sanity.cc f8b6dbcdd2dd836d7a5bd26316c8da713e548bb2
@@ -246,7 +246,11 @@
out << F("Current work set: %i items\n") % musings.size();
for (std::vector::const_iterator
i = musings.begin(); i != musings.end(); ++i)
- (*i)->gasp(out);
+ {
+ std::string tmp;
+ (*i)->gasp(tmp);
+ out << tmp;
+ }
gasp_dump = out.str();
L(F("finished saving work set"));
if (debug)
===============================================
--- sanity.hh 41ccd55d17d0e3068dcb95388058de1b0e9e0fee
+++ sanity.hh 842a7168fbbcd601cf425a76417d63871f85bebc
@@ -9,7 +9,7 @@
#include
#include
#include
-#include
+#include
#include "boost/format.hpp"
#include "boost/circular_buffer.hpp"
@@ -206,7 +206,7 @@
public:
MusingI();
virtual ~MusingI();
- virtual void gasp(std::ostream & out) const = 0;
+ virtual void gasp(std::string & out) const = 0;
};
template
@@ -215,7 +215,7 @@
public:
Musing(T const & obj, char const * name, char const * file, int line, char const * func)
: obj(obj), name(name), file(file), line(line), func(func) {}
- virtual void gasp(std::ostream & out) const;
+ virtual void gasp(std::string & out) const;
private:
T const & obj;
char const * name;
@@ -225,11 +225,13 @@
};
template void
-Musing::gasp(std::ostream & out) const
+Musing::gasp(std::string & out) const
{
- out << F("----- begin '%s' (in %s, at %s:%d)\n") % name % func % file % line;
- dump(obj, out);
- out << F("----- end '%s' (in %s, at %s:%d)\n") % name % func % file % line;
+ out = (F("----- begin '%s' (in %s, at %s:%d)\n") % name % func % file % line).str();
+ std::string tmp;
+ dump(obj, tmp);
+ out += tmp;
+ out += (F("----- end '%s' (in %s, at %s:%d)\n") % name % func % file % line).str();
}
// Yes, this is insane. No, it doesn't work if you do something more sane.
@@ -247,7 +249,9 @@
template void
dump(T const & obj, std::ostream & out)
{
- out << obj << "\n";
+ std::ostringstream out_s;
+ out_s << obj << "\n";
+ out = out_s.str();
}
#endif // __SANITY_HH__