Commit 86ec3c93 authored by snuverink_j's avatar snuverink_j
Browse files

fix #302 : remove __GNUC__<3 legacy code

parent c462f348
......@@ -17,11 +17,7 @@
// ------------------------------------------------------------------------
#include "AbstractObjects/AttributeBase.h"
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
// Class AttributeBase
// ------------------------------------------------------------------------
......@@ -36,20 +32,10 @@ AttributeBase::~AttributeBase()
std::string AttributeBase::getImage() const {
#if defined(__GNUC__) && __GNUC__ < 3
std::ostrstream os;
#else
std::ostringstream os;
#endif
print(os);
os << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
std::string img(os.str());
os.freeze(0);
return img;
#else
return os.str();
#endif
}
......
......@@ -15,11 +15,7 @@
#include "Utilities/Timer.h"
#include <iostream>
#include <fstream>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <iomanip>
#include <string>
......@@ -1037,19 +1033,8 @@ Aperture::A_row &Aperture::findRow(const PlaceRep &place) {
row.leave(*i);
}
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[128];
std::ostrstream os(buffer, sizeof(buffer));
#else
std::ostringstream os;
#endif
os << row << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
std::string name(buffer);
throw OpalException("Aperture::findRow()", "A_row \"" + name +
"\" not found in twiss table \"" + getOpalName() + "\".");
#else
throw OpalException("Aperture::findRow()", "A_row \"" + os.str() +
"\" not found in twiss table \"" + getOpalName() + "\".");
#endif
}
\ No newline at end of file
......@@ -12,11 +12,7 @@
#include "AbsBeamline/Cyclotron.h"
#include "Utilities/Timer.h"
#include <fstream>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <iomanip>
#include <string>
......@@ -773,19 +769,8 @@ MSplit::A_row &MSplit::findRow(const PlaceRep &place) {
row.leave(*i);
}
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[128];
std::ostrstream os(buffer, sizeof(buffer));
#else
std::ostringstream os;
#endif
os << row << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
std::string name(buffer);
throw OpalException("MSplit::findRow()", "A_row \"" + name +
"\" not found in twiss table \"" + getOpalName() + "\".");
#else
throw OpalException("MSplit::findRow()", "A_row \"" + os.str() +
"\" not found in twiss table \"" + getOpalName() + "\".");
#endif
}
\ No newline at end of file
......@@ -36,11 +36,7 @@
#include <cmath>
#include <cctype>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <vector>
#include <boost/regex.hpp>
......@@ -523,18 +519,9 @@ void OpalElement::printMultipoleStrength
double ss = Attributes::getReal(sSkew);
double strength = sqrt(sn * sn + ss * ss);
if(strength) {
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[80];
std::ostrstream ts(buffer, 80);
#else
std::ostringstream ts;
#endif
ts << strength;
#if defined(__GNUC__) && __GNUC__ < 3
std::string image(buffer);
#else
std::string image = ts.str();
#endif
if(length) {
image = "(" + image + ")*(" + length.getImage() + ")";
}
......@@ -688,18 +675,9 @@ void OpalElement::printAttribute
void OpalElement::printAttribute
(std::ostream &os, const std::string &name, double value, int &len) {
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[80];
std::ostrstream ss(buffer, sizeof(buffer));
#else
std::ostringstream ss;
#endif
ss << value << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
printAttribute(os, name, std::string(buffer), len);
#else
printAttribute(os, name, ss.str(), len);
#endif
}
......
......@@ -28,11 +28,7 @@
#include "Physics/Physics.h"
#include "Utilities/Options.h"
#include <iostream>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <vector>
......@@ -102,18 +98,9 @@ fillRegisteredAttributes(const ElementBase &base, ValueFlag flag) {
if(length != 0.0) scale *= length;
for(int order = 1; order <= field.order(); ++order) {
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[10];
std::ostrstream ss(buffer, 10);
#else
std::ostringstream ss;
#endif
ss << (order - 1) << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
std::string orderString(buffer);
#else
std::string orderString = ss.str();
#endif
std::string normName = "K" + orderString + "L";
registerRealAttribute(normName)->setReal(scale * field.normal(order));
......
......@@ -37,11 +37,7 @@
#include "Physics/Physics.h"
#include "Utilities/Options.h"
#include <iostream>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <vector>
......
......@@ -38,11 +38,7 @@
#include "Physics/Physics.h"
#include "Utilities/Options.h"
#include <iostream>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <vector>
......
......@@ -38,11 +38,7 @@
#include "Physics/Physics.h"
#include "Utilities/Options.h"
#include <iostream>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <vector>
......
......@@ -38,11 +38,7 @@
#include "Physics/Physics.h"
#include "Utilities/Options.h"
#include <iostream>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <vector>
......
......@@ -26,11 +26,7 @@
#include "Utilities/Options.h"
#include <cmath>
#include <iostream>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
// Class OpalOctupole
// ------------------------------------------------------------------------
......@@ -96,18 +92,9 @@ fillRegisteredAttributes(const ElementBase &base, ValueFlag flag) {
if(length != 0.0) scale *= length;
for(int order = 1; order <= field.order(); ++order) {
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[10];
std::ostrstream ss(buffer, 10);
#else
std::ostringstream ss;
#endif
ss << (order - 1) << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
std::string orderString(buffer);
#else
std::string orderString = ss.str();
#endif
std::string normName = "K" + orderString + "L";
registerRealAttribute(normName)->setReal(scale * field.normal(order));
......
......@@ -28,11 +28,7 @@
#include <cmath>
#include <iostream>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
// Class OpalQuadrupole
......@@ -114,18 +110,9 @@ fillRegisteredAttributes(const ElementBase &base, ValueFlag flag) {
if(length != 0.0) scale *= length;
for(int order = 1; order <= field.order(); ++order) {
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[10];
std::ostrstream ss(buffer, 10);
#else
std::ostringstream ss;
#endif
ss << (order - 1) << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
std::string orderString(buffer);
#else
std::string orderString = ss.str();
#endif
std::string normName = "K" + orderString + "L";
registerRealAttribute(normName)->setReal(scale * field.normal(order));
......
......@@ -26,11 +26,7 @@
#include "Utilities/Options.h"
#include <cmath>
#include <iostream>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
// Class OpalSextupole
......@@ -98,18 +94,9 @@ fillRegisteredAttributes(const ElementBase &base, ValueFlag flag) {
if(length != 0.0) scale *= length;
for(int order = 1; order <= field.order(); ++order) {
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[10];
std::ostrstream ss(buffer, 10);
#else
std::ostringstream ss;
#endif
ss << (order - 1) << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
std::string orderString(buffer);
#else
std::string orderString = ss.str();
#endif
std::string normName = "K" + orderString + "L";
registerRealAttribute(normName)->setReal(scale * field.normal(order));
......
......@@ -25,11 +25,7 @@
#include "Utilities/OpalException.h"
#include "AbstractObjects/OpalData.h"
#include <iosfwd>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <vector>
......@@ -137,19 +133,10 @@ namespace Expressions {
template <class T>
const std::string ARefExpr<T>::getImage() const {
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[128];
std::ostrstream os(buffer, sizeof(buffer));
#else
std::ostringstream os;
#endif
print(os);
os << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
return std::string(buffer);
#else
return os.str();
#endif
}
......
......@@ -60,11 +60,7 @@
#include <cerrno>
#include <cmath>
#include <list>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <vector>
......@@ -413,18 +409,9 @@ namespace Expressions {
parseDelimiter(stat, '(');
double value = parseRealConst(stat);
parseDelimiter(stat, ')');
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[128];
std::ostrstream os(buffer, sizeof(buffer));
#else
std::ostringstream os;
#endif
os << value << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
result += std::string(buffer);
#else
result += os.str();
#endif
} else {
result += temp;
}
......
......@@ -25,11 +25,7 @@
#include "Utilities/ParseError.h"
#include "Utilities/Options.h"
#include <iosfwd>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
namespace Expressions {
......@@ -138,19 +134,10 @@ namespace Expressions {
template <class T>
const std::string SRefExpr<T>::getImage() const {
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[128];
std::ostrstream os(buffer, sizeof(buffer));
#else
std::ostringstream os;
#endif
print(os);
os << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
return std::string(buffer);
#else
return os.str();
#endif
}
......
......@@ -31,11 +31,7 @@
#include "Beamlines/Beamline.h"
#include "Beamlines/FlaggedElmPtr.h"
#include <vector>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
extern Inform *gmsg;
......@@ -90,11 +86,7 @@ void FlatWriter::visitMapIntegrator(const MapIntegrator &i) {
// that it would be re-initialised each pass.
for(int k = 0; k < slices; ++k) {
#if defined(__GNUC__) && __GNUC__ < 3
ostrstream splitNameStream;
#else
std::ostringstream splitNameStream;
#endif
splitNameStream << name << ".." << k + 1 << std::ends ;
std::string splitName = splitNameStream.str();
......
......@@ -33,15 +33,9 @@
#include <cmath>
#include <iostream>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <vector>
extern Inform *gmsg;
// Class Sequence
// ------------------------------------------------------------------------
......@@ -359,23 +353,13 @@ double Sequence::findDriftLength(TLine::iterator drift) const {
driftLength = 0.0;
} else if(driftLength < 0.0) {
driftLength = 0.0;
#if defined(__GNUC__) && __GNUC__ < 3
static const int BUFSIZE = 512;
char buffer[BUFSIZE];
std::ostrstream os(buffer, BUFSIZE);
#else
std::ostringstream os;
#endif
os << "Inconsistent positions in sequence \"" << getOpalName() + "\";\n"
<< "previous element: \"" << prev_name + "\" at = "
<< prev->itsPosition << ",\n"
<< "following element: \"" << next_name + "\" at = "
<< next->itsPosition << "." << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
throw OpalException("Sequence::findDriftLength()", buffer);
#else
throw OpalException("Sequence::findDriftLength()", os.str());
#endif
// ada 15-6-2000 move driftLength = 0.0; bevore throw
}
......
......@@ -25,11 +25,7 @@
#include <fstream>
#include <iomanip>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <iostream>
......@@ -123,18 +119,9 @@ void Eigen::formatPrint(std::ostream &os, const Twiss *table) const {
os << '\n';
std::string name = row->getElement()->getName();
if(int occur = row->getCounter()) {
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[128];
std::ostrstream tos(buffer, 128);
#else
std::ostringstream tos;
#endif
tos << name << '[' << occur << ']' << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
name = buffer;
#else
name = tos.str();
#endif
}
if(name.length() > 16) {
......
......@@ -25,11 +25,7 @@
#include <fstream>
#include <iomanip>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <iostream>
// Class Envelope
......@@ -122,18 +118,9 @@ void Envelope::formatPrint(std::ostream &os, const Twiss *table) const {
os << '\n';
std::string name = row->getElement()->getName();
if(int occur = row->getCounter()) {
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[128];
std::ostrstream tos(buffer, 128);
#else
std::ostringstream tos;
#endif
tos << name << '[' << occur << ']' << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
name = buffer;
#else
name = tos.str();
#endif
}
if(name.length() > 16) {
......
......@@ -25,11 +25,7 @@
#include <fstream>
#include <iomanip>
#if defined(__GNUC__) && __GNUC__ < 3
#include <strstream>
#else
#include <sstream>
#endif
#include <iostream>
// Class MatrixCmd
......@@ -122,18 +118,9 @@ void MatrixCmd::formatPrint(std::ostream &os, const Twiss *table) const {
os << '\n';
std::string name = row->getElement()->getName();
if(int occur = row->getCounter()) {
#if defined(__GNUC__) && __GNUC__ < 3
char buffer[128];
std::ostrstream tos(buffer, 128);
#else
std::ostringstream tos;
#endif
tos << name << '[' << occur << ']' << std::ends;
#if defined(__GNUC__) && __GNUC__ < 3
name = buffer;
#else
name = tos.str();
#endif
}
if(name.length() > 16) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment