Commit 0ee8863f authored by kraus's avatar kraus
Browse files

Merge branch 'cherry-pick-6c8f8d0e' into 'OPAL-2.2'

Merge branch 'patch-468' into 'Opal-2.2'

See merge request !285
parents 8905208e 07a0788e
...@@ -35,37 +35,37 @@ void ElementPositionWriter::fillHeader() { ...@@ -35,37 +35,37 @@ void ElementPositionWriter::fillHeader() {
"1", "1",
"quadrupole field present", "quadrupole field present",
std::ios_base::fixed, std::ios_base::fixed,
4); 0);
columns_m.addColumn("sextupole", columns_m.addColumn("sextupole",
"float", "float",
"1", "1",
"sextupole field present", "sextupole field present",
std::ios_base::fixed, std::ios_base::fixed,
4); 1);
columns_m.addColumn("octupole", columns_m.addColumn("octupole",
"float", "float",
"1", "1",
"octupole field present", "octupole field present",
std::ios_base::fixed, std::ios_base::fixed,
4); 2);
columns_m.addColumn("decapole", columns_m.addColumn("decapole",
"float", "float",
"1", "1",
"decapole field present", "decapole field present",
std::ios_base::fixed, std::ios_base::fixed,
4); 0);
columns_m.addColumn("multipole", columns_m.addColumn("multipole",
"float", "float",
"1", "1",
"higher multipole field present", "higher multipole field present",
std::ios_base::fixed, std::ios_base::fixed,
4); 0);
columns_m.addColumn("solenoid", columns_m.addColumn("solenoid",
"float", "float",
"1", "1",
"solenoid field present", "solenoid field present",
std::ios_base::fixed, std::ios_base::fixed,
4); 0);
columns_m.addColumn("rfcavity", columns_m.addColumn("rfcavity",
"float", "float",
"1", "1",
...@@ -77,13 +77,13 @@ void ElementPositionWriter::fillHeader() { ...@@ -77,13 +77,13 @@ void ElementPositionWriter::fillHeader() {
"1", "1",
"monitor present", "monitor present",
std::ios_base::fixed, std::ios_base::fixed,
4); 0);
columns_m.addColumn("other", columns_m.addColumn("other",
"float", "float",
"1", "1",
"other element present", "other element present",
std::ios_base::fixed, std::ios_base::fixed,
4); 0);
columns_m.addColumn("element_names", columns_m.addColumn("element_names",
"string", "string",
"", "",
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include "Utilities/OpalException.h" #include "Utilities/OpalException.h"
#include <iomanip> #include <iomanip>
#include <list>
SDDSColumn::SDDSColumn(const std::string& name, SDDSColumn::SDDSColumn(const std::string& name,
const std::string& type, const std::string& type,
...@@ -14,7 +15,37 @@ SDDSColumn::SDDSColumn(const std::string& name, ...@@ -14,7 +15,37 @@ SDDSColumn::SDDSColumn(const std::string& name,
writeFlags_m(flags), writeFlags_m(flags),
writePrecision_m(prec), writePrecision_m(prec),
set_m(false) set_m(false)
{ } {
std::list<std::ios_base::fmtflags> numericalBase({std::ios_base::dec,
std::ios_base::hex,
std::ios_base::oct});
std::list<std::ios_base::fmtflags> floatFormat({std::ios_base::fixed,
std::ios_base::scientific});
std::list<std::ios_base::fmtflags> adjustmentFlags({std::ios_base::internal,
std::ios_base::left,
std::ios_base::right});
// This code ensures that for each group of flags only one flag is given
for (std::ios_base::fmtflags flag: numericalBase) {
if (writeFlags_m & flag) {
writeFlags_m = (flag | (writeFlags_m & ~std::ios_base::basefield));
break;
}
}
for (std::ios_base::fmtflags flag: floatFormat) {
if (writeFlags_m & flag) {
writeFlags_m = (flag | (writeFlags_m & ~std::ios_base::floatfield));
break;
}
}
for (std::ios_base::fmtflags flag: adjustmentFlags) {
if (writeFlags_m & flag) {
writeFlags_m = (flag | (writeFlags_m & ~std::ios_base::adjustfield));
break;
}
}
}
void SDDSColumn::writeHeader(std::ostream& os, void SDDSColumn::writeHeader(std::ostream& os,
...@@ -38,7 +69,7 @@ void SDDSColumn::writeValue(std::ostream& os) const { ...@@ -38,7 +69,7 @@ void SDDSColumn::writeValue(std::ostream& os) const {
"value for column '" + name_m + "' isn't set"); "value for column '" + name_m + "' isn't set");
} }
os.setf(writeFlags_m); os.flags(writeFlags_m);
os.precision(writePrecision_m); os.precision(writePrecision_m);
os << value_m << std::setw(10) << "\t"; os << value_m << std::setw(10) << "\t";
set_m = false; set_m = false;
......
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