changed to using sstream
This commit is contained in:
parent
86fa476c67
commit
153b80440c
22 changed files with 253 additions and 31 deletions
|
|
@ -10,7 +10,7 @@ DOCDIR = ~/public_html/eodocs
|
|||
#Directory for indices -- not useful for the user
|
||||
IDXDIR = ~/index
|
||||
|
||||
EXTRA_DIST=LICENSE
|
||||
EXTRA_DIST=LICENSE
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
|
|
|||
37
eo/acinclude.m4
Normal file
37
eo/acinclude.m4
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_have_sstream.html
|
||||
dnl
|
||||
AC_DEFUN([AC_CXX_HAVE_SSTREAM],
|
||||
[AC_CACHE_CHECK(whether the compiler has stringstream,
|
||||
ac_cv_cxx_have_sstream,
|
||||
[AC_REQUIRE([AC_CXX_NAMESPACES])
|
||||
AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_COMPILE([#include <sstream>
|
||||
#ifdef HAVE_NAMESPACES
|
||||
using namespace std;
|
||||
#endif],[stringstream message; message << "Hello"; return 0;],
|
||||
ac_cv_cxx_have_sstream=yes, ac_cv_cxx_have_sstream=no)
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
if test "$ac_cv_cxx_have_sstream" = yes; then
|
||||
AC_DEFINE(HAVE_SSTREAM,,[define if the compiler has stringstream])
|
||||
fi
|
||||
])
|
||||
dnl Available from the GNU Autoconf Macro Archive at:
|
||||
dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_namespaces.html
|
||||
dnl
|
||||
AC_DEFUN([AC_CXX_NAMESPACES],
|
||||
[AC_CACHE_CHECK(whether the compiler implements namespaces,
|
||||
ac_cv_cxx_namespaces,
|
||||
[AC_LANG_SAVE
|
||||
AC_LANG_CPLUSPLUS
|
||||
AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}],
|
||||
[using namespace Outer::Inner; return i;],
|
||||
ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no)
|
||||
AC_LANG_RESTORE
|
||||
])
|
||||
if test "$ac_cv_cxx_namespaces" = yes; then
|
||||
AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces])
|
||||
fi
|
||||
])
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
##
|
||||
###############################################################################
|
||||
|
||||
SUBDIRS = gprop mastermind gpsymreg
|
||||
SUBDIRS = mastermind gpsymreg gprop
|
||||
|
||||
###############################################################################
|
||||
|
||||
|
|
|
|||
|
|
@ -22,9 +22,11 @@ AC_CHECK_LIB(eoutils, main)
|
|||
dnl Replace `main' with a function in -lm:
|
||||
AC_CHECK_LIB(m, main)
|
||||
|
||||
|
||||
dnl Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS(limits.h)
|
||||
#AC_CXX_HAVE_SSTREAM
|
||||
|
||||
dnl Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
|
|
@ -34,5 +36,5 @@ AC_TYPE_SIZE_T
|
|||
dnl Checks for library functions.
|
||||
AC_CHECK_FUNCS(select)
|
||||
|
||||
AC_OUTPUT(src/obsolete/Makefile doc/Makefile src/Makefile src/utils/Makefile src/other/Makefile win/Makefile src/gp/Makefile src/es/Makefile src/ga/Makefile test/Makefile contrib/Makefile Makefile app/Makefile app/gprop/Makefile app/mastermind/Makefile app/gpsymreg/Makefile)
|
||||
AC_OUTPUT(doc/Makefile src/Makefile src/utils/Makefile src/other/Makefile win/Makefile src/gp/Makefile src/es/Makefile src/ga/Makefile test/Makefile contrib/Makefile Makefile app/Makefile app/gprop/Makefile app/mastermind/Makefile app/gpsymreg/Makefile src/do/Makefile)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@
|
|||
|
||||
EXTRA_DIST = eo.cfg foot.html html/* latex/*
|
||||
|
||||
all: doc
|
||||
|
||||
doc: eo.cfg
|
||||
doxygen eo.cfg
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
##
|
||||
###############################################################################
|
||||
|
||||
SUBDIRS = es ga gp utils other
|
||||
SUBDIRS = es ga gp utils other do
|
||||
CPPFLAGS = -O2
|
||||
|
||||
lib_LIBRARIES = libeo.a
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
#endif
|
||||
|
||||
#include <signal.h>
|
||||
#include <stream.h>
|
||||
#include <iostream>
|
||||
|
||||
// --- Global variables - but don't know what else to do - MS ---
|
||||
bool arret_demande = false;
|
||||
|
|
@ -44,7 +44,7 @@ void signal_handler( int sig )
|
|||
// --- On veut la paix, jusqu'a la fin ---
|
||||
signal( SIGINT, SIG_IGN );
|
||||
signal( SIGQUIT, SIG_IGN );
|
||||
cerr << "Ctrl C entered ... closing down" << endl ;
|
||||
std::cerr << "Ctrl C entered ... closing down" << std::endl ;
|
||||
arret_demande = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#define _EOPOP_H
|
||||
|
||||
#include <vector>
|
||||
#include <strstream>
|
||||
#include <algorithm>
|
||||
#include <iterator> // needed for GCC 3.2
|
||||
|
||||
|
|
@ -262,7 +261,6 @@ class eoPop: public std::vector<EOT>, public eoObject, public eoPersistent
|
|||
//@{
|
||||
/**
|
||||
* Read object. The EOT class must have a ctor from a stream;
|
||||
in this case, a strstream is used.
|
||||
* @param _is A std::istream.
|
||||
*/
|
||||
virtual void readFrom(std::istream& _is)
|
||||
|
|
|
|||
|
|
@ -95,10 +95,15 @@ public :
|
|||
*/
|
||||
void setCurrentFileName()
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::ostringstream oscount;
|
||||
#else
|
||||
char buff[255];
|
||||
std::ostrstream oscount(buff, 254);
|
||||
#endif
|
||||
oscount << counter;
|
||||
oscount << std::ends;
|
||||
|
||||
currentFileName = dirname + "/" + filename + oscount.str();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,14 +104,23 @@ private:
|
|||
inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra)
|
||||
/////////////////////////////////////////////////////////
|
||||
{
|
||||
char snum[255];
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::ostringstream os;
|
||||
#else
|
||||
char snum[255];
|
||||
std::ostrstream os(snum, 254);
|
||||
#endif
|
||||
|
||||
os << "300x200-0+" << numWindow*220 << std::ends;
|
||||
numWindow++;
|
||||
char *args[6];
|
||||
args[0] = strdup( "gnuplot" );
|
||||
args[1] = strdup( "-geometry" );
|
||||
#ifdef HAVE_SSTREAM
|
||||
args[2] = strdup( os.str().c_str());
|
||||
#else
|
||||
args[2] = strdup( os.str() );
|
||||
#endif
|
||||
args[3] = strdup( "-title" );
|
||||
args[4] = strdup( _title.c_str() );
|
||||
args[5] = 0;
|
||||
|
|
@ -139,7 +148,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.6 2003-02-27 19:21:18 okoenig Exp $
|
||||
* Ident........: $Id: eoGnuplot.h,v 1.7 2003-02-28 16:49:14 maartenkeijzer Exp $
|
||||
* ----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -105,8 +105,13 @@ inline void eoGnuplot1DMonitor::FirstPlot()
|
|||
{
|
||||
throw std::runtime_error("Must have some stats to plot!\n");
|
||||
}
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::ostringstream os;
|
||||
#else
|
||||
char buff[1024];
|
||||
std::ostrstream os(buff, 1024);
|
||||
#endif
|
||||
|
||||
os << "plot";
|
||||
for (unsigned i=1; i<vec.size(); i++) {
|
||||
os << " '" << getFileName().c_str() <<
|
||||
|
|
@ -116,7 +121,11 @@ inline void eoGnuplot1DMonitor::FirstPlot()
|
|||
}
|
||||
os << "\n";
|
||||
os << '\0';
|
||||
#ifdef HAVE_SSTREAM
|
||||
PipeComSend( gpCom, os.str().c_str());
|
||||
#else
|
||||
PipeComSend( gpCom, buff );
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -100,9 +100,13 @@ class eoGnuplot1DSnapshot: public eoFileSnapshot, public eoGnuplot
|
|||
|
||||
virtual void handleBounds(eoRealVectorBounds & _bounds)
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::ostringstream os;
|
||||
#else
|
||||
// use strstream and not std::stringstream until strstream is in all distributions
|
||||
char buf[1024];
|
||||
std::ostrstream os(buf, 1023);
|
||||
#endif
|
||||
// std::ostrstream os;
|
||||
os << "set autoscale\nset yrange [" ;
|
||||
if (_bounds.isMinBounded(0))
|
||||
|
|
@ -129,13 +133,24 @@ inline eoMonitor& eoGnuplot1DSnapshot::operator() (void)
|
|||
eoFileSnapshot::operator()();
|
||||
|
||||
// sends plot order to gnuplot
|
||||
#ifdef HAVE_SSTREAM
|
||||
//std::string buff; // need local memory
|
||||
std::ostringstream os;
|
||||
#else
|
||||
char buff[1024];
|
||||
std::ostrstream os(buff, 1024);
|
||||
#endif
|
||||
|
||||
os << "set title 'Gen. " << getCounter() << "'; plot '"
|
||||
<< getFileName() << "' notitle with points ps " << pointSize << "\n";
|
||||
os << '\0';
|
||||
// mk: had to use getFilename().c_str(), because it seems the string(stream) lib is screwed in gcc3.2
|
||||
<< getFileName().c_str() << "' notitle with points ps " << pointSize;
|
||||
os << std::endl;
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
PipeComSend( gpCom, os.str().c_str());
|
||||
#else
|
||||
PipeComSend( gpCom, buff );
|
||||
|
||||
#endif
|
||||
return (*this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -152,7 +152,12 @@ public:
|
|||
interpret_as_rate = true;
|
||||
_value.resize(pos); // get rid of %
|
||||
}
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::istringstream is(_value);
|
||||
#else
|
||||
std::istrstream is(_value.c_str());
|
||||
#endif
|
||||
is >> rate;
|
||||
// now store
|
||||
if (interpret_as_rate)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,13 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
#include <math.h> // for floor
|
||||
#include <string>
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
#include <sstream>
|
||||
#else
|
||||
#include <strstream>
|
||||
#endif
|
||||
|
||||
#include <vector>
|
||||
#include <iterator> // for GCC 3.2
|
||||
#include <stdexcept>
|
||||
|
|
@ -156,8 +162,12 @@ public :
|
|||
|
||||
std::string getValue(void) const
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::ostringstream os;
|
||||
#else
|
||||
char buf[1024];
|
||||
std::ostrstream os(buf, 1023);
|
||||
#endif
|
||||
os << repValue;
|
||||
os << std::ends;
|
||||
return os.str();
|
||||
|
|
@ -165,7 +175,11 @@ public :
|
|||
|
||||
void setValue(std::string _value)
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::istringstream is(_value);
|
||||
#else
|
||||
std::istrstream is(_value.c_str());
|
||||
#endif
|
||||
is >> repValue;
|
||||
}
|
||||
|
||||
|
|
@ -191,8 +205,11 @@ void eoValueParam<bool>::setValue(std::string _value)
|
|||
repValue = true;
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::istringstream is(_value);
|
||||
#else
|
||||
std::istrstream is(_value.c_str());
|
||||
#endif
|
||||
is >> repValue;
|
||||
}
|
||||
|
||||
|
|
@ -202,8 +219,12 @@ template <>
|
|||
std::string eoValueParam<std::pair<double, double> >::getValue(void) const
|
||||
{
|
||||
// use own buffer as MSVC's buffer leaks!
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::ostringstream os;
|
||||
#else
|
||||
char buff[1024];
|
||||
std::ostrstream os(buff, 1024);
|
||||
#endif
|
||||
os << repValue.first << ' ' << repValue.second << std::ends;
|
||||
return os.str();
|
||||
}
|
||||
|
|
@ -212,7 +233,11 @@ std::string eoValueParam<std::pair<double, double> >::getValue(void) const
|
|||
template <>
|
||||
void eoValueParam<std::pair<double, double> >::setValue(std::string _value)
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::istringstream is(_value);
|
||||
#else
|
||||
std::istrstream is(_value.c_str());
|
||||
#endif
|
||||
is >> repValue.first;
|
||||
is >> repValue.second;
|
||||
}
|
||||
|
|
@ -223,7 +248,11 @@ void eoValueParam<std::pair<double, double> >::setValue(std::string _value)
|
|||
template <>
|
||||
std::string eoValueParam<std::vector<std::vector<double> > >::getValue(void) const
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::ostringstream os;
|
||||
#else
|
||||
std::ostrstream os;
|
||||
#endif
|
||||
os << repValue.size() << ' ';
|
||||
for (unsigned i = 0; i < repValue.size(); ++i)
|
||||
{
|
||||
|
|
@ -239,7 +268,11 @@ std::string eoValueParam<std::vector<std::vector<double> > >::getValue(void) con
|
|||
template <>
|
||||
void eoValueParam<std::vector<std::vector<double> > >::setValue(std::string _value)
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::istringstream is(_value);
|
||||
#else
|
||||
std::istrstream is(_value.c_str());
|
||||
#endif
|
||||
unsigned i,j,sz;
|
||||
is >> sz;
|
||||
repValue.resize(sz);
|
||||
|
|
@ -262,7 +295,11 @@ void eoValueParam<std::vector<std::vector<double> > >::setValue(std::string _val
|
|||
template <>
|
||||
std::string eoValueParam<std::vector<double> >::getValue(void) const
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::ostringstream os;
|
||||
#else
|
||||
std::ostrstream os;
|
||||
#endif
|
||||
os << repValue.size() << ' ';
|
||||
std::copy(repValue.begin(), repValue.end(), std::ostream_iterator<double>(os, " "));
|
||||
os << std::ends;
|
||||
|
|
@ -273,7 +310,11 @@ std::string eoValueParam<std::vector<double> >::getValue(void) const
|
|||
template <>
|
||||
void eoValueParam<std::vector<double> >::setValue(std::string _value)
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::istringstream is(_value);
|
||||
#else
|
||||
std::istrstream is(_value.c_str());
|
||||
#endif
|
||||
unsigned sz;
|
||||
is >> sz;
|
||||
repValue.resize(sz);
|
||||
|
|
@ -286,7 +327,11 @@ void eoValueParam<std::vector<double> >::setValue(std::string _value)
|
|||
template <>
|
||||
std::string eoValueParam<std::vector<eoMinimizingFitness> >::getValue(void) const
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::ostringstream os;
|
||||
#else
|
||||
std::ostrstream os;
|
||||
#endif
|
||||
os << repValue.size() << ' ';
|
||||
std::copy(repValue.begin(), repValue.end(), std::ostream_iterator<eoMinimizingFitness>(os, " "));
|
||||
os << std::ends;
|
||||
|
|
@ -298,7 +343,11 @@ std::string eoValueParam<std::vector<eoMinimizingFitness> >::getValue(void) cons
|
|||
template <>
|
||||
void eoValueParam<std::vector<eoMinimizingFitness> >::setValue(std::string _value)
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::istringstream is(_value);
|
||||
#else
|
||||
std::istrstream is(_value.c_str());
|
||||
#endif
|
||||
unsigned sz;
|
||||
is >> sz;
|
||||
repValue.resize(sz);
|
||||
|
|
|
|||
|
|
@ -94,8 +94,12 @@ eoParser::eoParser ( unsigned _argc, char **_argv , string _programDescription,
|
|||
}
|
||||
|
||||
// now read arguments on command-line
|
||||
#ifdef HAVE_SSTREAM
|
||||
stringstream stream;
|
||||
#else
|
||||
strstream stream;
|
||||
|
||||
#endif
|
||||
|
||||
for (i = 1; i < _argc; ++i)
|
||||
{
|
||||
stream << _argv[i] << '\n';
|
||||
|
|
|
|||
|
|
@ -62,12 +62,27 @@ public :
|
|||
Adds a \n before so it does not get mixed up with the rest of the stats
|
||||
that are written by the monitor it is probably used from.
|
||||
*/
|
||||
#ifdef HAVE_SSTREAM
|
||||
void operator()(const eoPop<EOT>& _pop)
|
||||
{
|
||||
char buffer[1023]; // about one K of space per member
|
||||
value() = "\n# ====== Pop dump =====\n";
|
||||
unsigned howMany=combien?combien:_pop.size();
|
||||
for (unsigned i = 0; i < howMany; ++i)
|
||||
value() = "\n# ====== pop dump =====\n";
|
||||
unsigned howmany=combien?combien:_pop.size();
|
||||
for (unsigned i = 0; i < howmany; ++i)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << _pop[i] << std::endl << std::ends;
|
||||
|
||||
// paranoid:
|
||||
value() += os.str();
|
||||
}
|
||||
}
|
||||
#else
|
||||
void operator()(const eoPop<EOT>& _pop)
|
||||
{
|
||||
char buffer[1023]; // about one k of space per member
|
||||
value() = "\n# ====== pop dump =====\n";
|
||||
unsigned howmany=combien?combien:_pop.size();
|
||||
for (unsigned i = 0; i < howmany; ++i)
|
||||
{
|
||||
std::ostrstream os(buffer, 1022); // leave space for emergency terminate
|
||||
os << _pop[i] << std::endl << std::ends;
|
||||
|
|
@ -77,6 +92,8 @@ void operator()(const eoPop<EOT>& _pop)
|
|||
value() += buffer;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
unsigned combien;
|
||||
};
|
||||
|
|
@ -106,6 +123,21 @@ public :
|
|||
Adds a \n before so it does not get mixed up with the rest of the stats
|
||||
that are written by the monitor it is probably used from.
|
||||
*/
|
||||
#ifdef HAVE_SSTREAM
|
||||
void operator()(const std::vector<const EOT*>& _pop)
|
||||
{
|
||||
value() = ""; // empty
|
||||
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;
|
||||
|
||||
// paranoid:
|
||||
value() += os.str();
|
||||
}
|
||||
}
|
||||
#else
|
||||
void operator()(const std::vector<const EOT*>& _pop)
|
||||
{
|
||||
char buffer[1023]; // about one K of space per member
|
||||
|
|
@ -121,6 +153,7 @@ public :
|
|||
value() += buffer;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
private:
|
||||
unsigned combien;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,13 @@
|
|||
#endif
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
#include <sstream>
|
||||
#else
|
||||
#include <strstream>
|
||||
#endif
|
||||
|
||||
#include "eoRealBounds.h"
|
||||
#include "eoRealVectorBounds.h"
|
||||
|
||||
|
|
@ -27,7 +33,11 @@ bool remove_leading(std::string & _s, const std::string _delim)
|
|||
|
||||
double read_double(std::string _s)
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::istringstream is(_s);
|
||||
#else
|
||||
std::istrstream is(_s.c_str());
|
||||
#endif
|
||||
double r;
|
||||
is >> r;
|
||||
return r;
|
||||
|
|
@ -35,7 +45,11 @@ double read_double(std::string _s)
|
|||
|
||||
int read_int(std::string _s)
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::istringstream is(_s);
|
||||
#else
|
||||
std::istrstream is(_s.c_str());
|
||||
#endif
|
||||
int i;
|
||||
is >> i;
|
||||
return i;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,12 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
#include <sstream>
|
||||
#else
|
||||
#include <strstream>
|
||||
#endif
|
||||
|
||||
#include "eoState.h"
|
||||
#include "eoObject.h"
|
||||
|
|
@ -126,9 +131,11 @@ void eoState::load(std::istream& is)
|
|||
removeComment(str, getCommentString());
|
||||
fullstring += str + "\n";
|
||||
}
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
istringstream the_stream(fullstring);
|
||||
#else
|
||||
istrstream the_stream(fullstring.c_str(), fullstring.size());
|
||||
|
||||
#endif
|
||||
object->readFrom(the_stream);
|
||||
}
|
||||
}
|
||||
|
|
@ -163,7 +170,11 @@ string eoState::createObjectName(eoObject* obj)
|
|||
{
|
||||
if (obj == 0)
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
ostringstream os;
|
||||
#else
|
||||
ostrstream os;
|
||||
#endif
|
||||
os << objectMap.size();
|
||||
return os.str();
|
||||
}
|
||||
|
|
@ -175,7 +186,11 @@ string eoState::createObjectName(eoObject* obj)
|
|||
unsigned count = 1;
|
||||
while (it != objectMap.end())
|
||||
{
|
||||
#ifdef HAVE_SSTREAM
|
||||
ostringstream os;
|
||||
#else
|
||||
ostrstream os;
|
||||
#endif
|
||||
os << obj->className().c_str() << count++ << ends;
|
||||
|
||||
name = os.str();
|
||||
|
|
|
|||
|
|
@ -2,8 +2,11 @@
|
|||
#pragma warning(disable:4786)
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
#include <sstream>
|
||||
#else
|
||||
#include <strstream>
|
||||
#endif
|
||||
|
||||
#include <utils/eoState.h>
|
||||
#include <utils/eoUpdater.h>
|
||||
|
|
@ -17,8 +20,12 @@ void eoTimedStateSaver::operator()(void)
|
|||
if (now >= last_time + interval)
|
||||
{
|
||||
last_time = now;
|
||||
|
||||
ostrstream os;
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
ostringstream os;
|
||||
#else
|
||||
ostrstream os;
|
||||
#endif
|
||||
os << prefix << (now - first_time) << '.' << extension << ends;
|
||||
state.save(os.str());
|
||||
}
|
||||
|
|
@ -26,7 +33,11 @@ void eoTimedStateSaver::operator()(void)
|
|||
|
||||
void eoCountedStateSaver::doItNow(void)
|
||||
{
|
||||
ostrstream os;
|
||||
#ifdef HAVE_SSTREAM
|
||||
ostringstream os;
|
||||
#else
|
||||
ostrstream os;
|
||||
#endif
|
||||
os << prefix << counter << '.' << extension << ends;
|
||||
state.save(os.str());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -176,10 +176,15 @@ void init(eoPop<Dummy> & _pop, unsigned _pSize)
|
|||
}
|
||||
for (unsigned i=0; i<_pSize; i++)
|
||||
{
|
||||
char s[255];
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::ostringstream os;
|
||||
#else
|
||||
char s[255];
|
||||
std::ostrstream os(s, 254);
|
||||
#endif
|
||||
|
||||
os << i << std::ends;
|
||||
_pop[i] = Dummy(s);
|
||||
_pop[i] = Dummy(os.str());
|
||||
_pop[i].fitness(i);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <iostream> // std::cout
|
||||
#include <strstream> // ostrstream, istrstream
|
||||
#include <eo> // general EO
|
||||
#include "../contrib/MGE/VirusOp.h"
|
||||
#include "../contrib/MGE/eoVirus.h"
|
||||
|
|
|
|||
|
|
@ -24,7 +24,13 @@
|
|||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include <iostream> // std::cout
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
#include <sstream>
|
||||
#else
|
||||
#include <strstream> // ostrstream, istrstream
|
||||
#endif
|
||||
|
||||
#include <eo> // general EO
|
||||
#include <ga.h> // bitstring representation & operators
|
||||
#include <utils/eoRndGenerators.h>
|
||||
|
|
@ -56,11 +62,19 @@ void main_function()
|
|||
|
||||
std::cout << "chrom: " << chrom << std::endl
|
||||
<< "chrom2: " << chrom2 << std::endl;
|
||||
|
||||
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::ostringstream os;
|
||||
#else
|
||||
char buff[1024];
|
||||
std::ostrstream os(buff, 1024);
|
||||
#endif
|
||||
os << chrom;
|
||||
#ifdef HAVE_SSTREAM
|
||||
std::istringstream is(os.str());
|
||||
#else
|
||||
std::istrstream is(os.str());
|
||||
#endif
|
||||
is >> chrom2; chrom.fitness(binary_value(chrom2));
|
||||
|
||||
std::cout << "\nTesting reading, writing\n";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue