fixed (?) some problems with stringstreams and std::ends

This commit is contained in:
maartenkeijzer 2003-03-21 02:39:09 +00:00
commit eaabc7ae3b
10 changed files with 57 additions and 50 deletions

View file

@ -97,12 +97,13 @@ public :
{
#ifdef HAVE_SSTREAM
std::ostringstream oscount;
oscount << counter;
#else
char buff[255];
std::ostrstream oscount(buff, 254);
#endif
oscount << counter;
oscount << std::ends;
#endif
currentFileName = dirname + "/" + filename + oscount.str();
}

View file

@ -106,12 +106,13 @@ inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
{
#ifdef HAVE_SSTREAM
std::ostringstream os;
os << "300x200-0+" << numWindow*220;
#else
char snum[255];
std::ostrstream os(snum, 254);
os << "300x200-0+" << numWindow*220 << std::ends;
#endif
os << "300x200-0+" << numWindow*220 << std::ends;
numWindow++;
char *args[6];
args[0] = strdup( "gnuplot" );
@ -148,7 +149,7 @@ inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
* Created......: Mon Mar 13 13:50:11 1995
* Description..: Communication par pipe bidirectionnel avec un autre process
*
* Ident........: $Id: eoGnuplot.h,v 1.7 2003-02-28 16:49:14 maartenkeijzer Exp $
* Ident........: $Id: eoGnuplot.h,v 1.8 2003-03-21 02:39:09 maartenkeijzer Exp $
* ----------------------------------------------------------------------
*/

View file

@ -120,10 +120,10 @@ inline void eoGnuplot1DMonitor::FirstPlot()
os << ", ";
}
os << '\n';
os << std::ends;
#ifdef HAVE_SSTREAM
PipeComSend( gpCom, os.str().c_str());
#else
os << std::ends;
PipeComSend( gpCom, buff );
#endif
}

View file

@ -132,9 +132,9 @@ public:
virtual void printOn(std::ostream& _os) const
{
if (combien == 0)
_os << 100*rate << "% " << std::ends;
_os << 100*rate << "% ";
else
_os << combien << " " << std::ends;
_os << combien << " ";
return;
}

View file

@ -164,12 +164,13 @@ public :
{
#ifdef HAVE_SSTREAM
std::ostringstream os;
os << repValue;
#else
char buf[1024];
std::ostrstream os(buf, 1023);
#endif
os << repValue;
os << std::ends;
#endif
return os.str();
}
@ -221,11 +222,12 @@ std::string eoValueParam<std::pair<double, double> >::getValue(void) const
// use own buffer as MSVC's buffer leaks!
#ifdef HAVE_SSTREAM
std::ostringstream os;
os << repValue.first << ' ' << repValue.second;
#else
char buff[1024];
std::ostrstream os(buff, 1024);
#endif
os << repValue.first << ' ' << repValue.second << std::ends;
#endif
return os.str();
}
@ -260,7 +262,9 @@ std::string eoValueParam<std::vector<std::vector<double> > >::getValue(void) con
std::copy(repValue[i].begin(), repValue[i].end(), std::ostream_iterator<double>(os, " "));
}
#ifndef HAVE_SSTREAM
os << std::ends;
#endif
return os.str();
}
@ -302,7 +306,9 @@ std::string eoValueParam<std::vector<double> >::getValue(void) const
#endif
os << repValue.size() << ' ';
std::copy(repValue.begin(), repValue.end(), std::ostream_iterator<double>(os, " "));
#ifndef HAVE_SSTREAM
os << std::ends;
#endif
return os.str();
}
@ -334,7 +340,9 @@ std::string eoValueParam<std::vector<eoMinimizingFitness> >::getValue(void) cons
#endif
os << repValue.size() << ' ';
std::copy(repValue.begin(), repValue.end(), std::ostream_iterator<eoMinimizingFitness>(os, " "));
os << std::ends;
#ifndef HAVE_SSTREAM
os<< std::ends;
#endif
return os.str();
}

View file

@ -70,7 +70,7 @@ void operator()(const eoPop<EOT>& _pop)
for (unsigned i = 0; i < howmany; ++i)
{
std::ostringstream os;
os << _pop[i] << std::endl << std::ends;
os << _pop[i] << std::endl;
// paranoid:
value() += os.str();
@ -130,8 +130,8 @@ public :
unsigned howMany=combien?combien:_pop.size();
for (unsigned i = 0; i < howMany; ++i)
{
std::ostringstream os; // leave space for emergency terminate
os << *_pop[i] << std::endl << std::ends;
std::ostringstream os;
os << *_pop[i] << std::endl;
// paranoid:
value() += os.str();