diff -u -r1.2 convert.cc --- src/convert.cc 23 Aug 2003 11:44:15 -0000 1.2 +++ src/convert.cc 26 Aug 2003 15:26:19 -0000 @@ -39,31 +39,12 @@ #include "io.h" #include -#ifdef HAVE_SSTREAM -#include -#else -#include -#endif - -#ifdef HAVE_OSTREAM -#include -#include -#else -#include -#include -#endif - using namespace ::std; using namespace Binc; //------------------------------------------------------------------------ -class dummybuf : public std::streambuf { -}; - -//------------------------------------------------------------------------ -BincStream::BincStream(void) : std::ostream(new dummybuf()) +BincStream::BincStream(void) { - terminated = false; } //------------------------------------------------------------------------ @@ -73,38 +54,61 @@ } //------------------------------------------------------------------------ -const string BincStream::str(void) +const string &BincStream::str(void) const { -#ifndef HAVE_SSTREAM - if (!terminated) { - nstr << '\0'; - terminated = true; - } -#endif - - return nstr.str(); + return nstr; } //------------------------------------------------------------------------ void BincStream::clear(void) { -#ifdef HAVE_SSTREAM - nstr.str(""); -#else - nstr.clear(); - nstr.seekg(0); - nstr.seekp(0); - nstr.rdbuf()->freeze(0); - terminated = false; -#endif + nstr = ""; } //------------------------------------------------------------------------ int BincStream::getSize(void) const { -#ifdef HAVE_SSTREAM - return nstr.str().size(); -#else - return (((unsigned int)-1)>>1) - 1; -#endif + return nstr.length(); +} + +//------------------------------------------------------------------------ +BincStream &BincStream::operator << (std::ostream&(*)(std::ostream&)) +{ + nstr += "\r\n"; + return *this; +} + +//------------------------------------------------------------------------ +BincStream &BincStream::operator << (const string &t) +{ + nstr += t; + return *this; +} + +//------------------------------------------------------------------------ +BincStream &BincStream::operator << (time_t t) +{ + nstr += toString((int) t); + return *this; +} + +//------------------------------------------------------------------------ +BincStream &BincStream::operator << (unsigned int t) +{ + nstr += toString(t); + return *this; +} + +//------------------------------------------------------------------------ +BincStream &BincStream::operator << (int t) +{ + nstr += toString(t); + return *this; +} + +//------------------------------------------------------------------------ +BincStream &BincStream::operator << (char t) +{ + nstr += t; + return *this; } diff -u -r1.2 convert.h --- src/convert.h 23 Aug 2003 11:44:15 -0000 1.2 +++ src/convert.h 26 Aug 2003 15:26:19 -0000 @@ -42,18 +42,6 @@ #include #include -#ifdef HAVE_SSTREAM -#include -#else -#include -#endif - -#ifdef HAVE_OSTREAM -#include -#else -#include -#endif - #include #include "address.h" @@ -64,18 +52,15 @@ //---------------------------------------------------------------------- inline std::string toString(int i_in) { -#ifdef HAVE_SSTREAM - std::stringstream s; -#else - std::strstream s; -#endif - s << i_in; - -#ifndef HAVE_SSTREAM - s << '\0'; -#endif - - return s.str(); + char intbuf[16]; + snprintf(intbuf, sizeof(intbuf), "%i", i_in); + return std::string(intbuf); + } + + //---------------------------------------------------------------------- + inline std::string toString(const char *i_in) + { + return std::string(i_in); } //---------------------------------------------------------------------- @@ -277,28 +262,22 @@ } //------------------------------------------------------------------------ - class BincStream : public std::ostream { -#ifdef HAVE_SSTREAM - std::stringstream nstr; -#else - std::strstream nstr; -#endif - - bool terminated; + class BincStream { + private: + std::string nstr; public: //-- - template - BincStream &operator << (const T &t) - { - nstr << t; - terminated = false; - return *this; - } + BincStream &operator << (std::ostream&(*)(std::ostream&)); + BincStream &operator << (const std::string &t); + BincStream &operator << (time_t t); + BincStream &operator << (unsigned int t); + BincStream &operator << (int t); + BincStream &operator << (char t); //-- - const std::string str(void); + const std::string &str(void) const; //-- int getSize(void) const; @@ -310,17 +289,6 @@ BincStream(void); ~BincStream(void); }; - - //---------------------------------------------------------------------- - inline std::string toFixedMaildirID(const std::string &maildirID) - { - if (maildirID.length() == 10) - return maildirID; - - BincStream b; - b << std::setw(10) << std::setfill('0') << atoi(maildirID); - return b.str(); - } } #endif diff -u -r1.1.1.1 io.cc --- src/io.cc 18 Aug 2003 18:06:05 -0000 1.1.1.1 +++ src/io.cc 26 Aug 2003 15:26:19 -0000 @@ -197,9 +197,9 @@ if (!enabled) return *this; if (useLogPrefix && outputBuffer.getSize() == 0) { - outputBuffer << setw(5) << setfill('0') << pid; + outputBuffer << pid; outputBuffer << " "; - outputBuffer << setw(5) << setfill('0') << seqnr++; + outputBuffer << seqnr++; if (logprefix != "") outputBuffer << " [" << logprefix << "]"; outputBuffer << " "; diff -u -r1.1.1.1 io.h --- src/io.h 18 Aug 2003 18:06:05 -0000 1.1.1.1 +++ src/io.h 26 Aug 2003 15:26:19 -0000 @@ -158,9 +158,9 @@ using namespace ::std; if (useLogPrefix && outputBuffer.getSize() == 0) { - outputBuffer << setw(5) << setfill('0') << pid; + outputBuffer << pid; outputBuffer << " "; - outputBuffer << setw(5) << setfill('0') << seqnr++; + outputBuffer << seqnr++; if (logprefix != "") outputBuffer << " [" << logprefix << "]"; outputBuffer << " "; diff -u -r1.1.1.1 recursivedescent.cc --- src/recursivedescent.cc 18 Aug 2003 18:06:05 -0000 1.1.1.1 +++ src/recursivedescent.cc 26 Aug 2003 15:26:19 -0000 @@ -122,7 +122,9 @@ BincStream daystr; - daystr << setw(2) << setfill('0') << day; + if (day < 10) + daystr << '0'; + daystr << day; s_in += daystr.str();