Commit b094d1aa authored by kraus's avatar kraus
Browse files

check format flags in the header, adjust precision of written values since only 1 and -1

parent ae6eeff9
......@@ -29,43 +29,43 @@ void ElementPositionWriter::fillHeader() {
"1",
"dipole field present",
std::ios_base::fixed,
4);
0);
columns_m.addColumn("quadrupole",
"float",
"1",
"quadrupole field present",
std::ios_base::fixed,
4);
0);
columns_m.addColumn("sextupole",
"float",
"1",
"sextupole field present",
std::ios_base::fixed,
4);
0);
columns_m.addColumn("octupole",
"float",
"1",
"octupole field present",
std::ios_base::fixed,
4);
0);
columns_m.addColumn("decapole",
"float",
"1",
"decapole field present",
std::ios_base::fixed,
4);
0);
columns_m.addColumn("multipole",
"float",
"1",
"higher multipole field present",
std::ios_base::fixed,
4);
0);
columns_m.addColumn("solenoid",
"float",
"1",
"solenoid field present",
std::ios_base::fixed,
4);
0);
columns_m.addColumn("rfcavity",
"float",
"1",
......@@ -77,13 +77,13 @@ void ElementPositionWriter::fillHeader() {
"1",
"monitor present",
std::ios_base::fixed,
4);
0);
columns_m.addColumn("other",
"float",
"1",
"other element present",
std::ios_base::fixed,
4);
0);
columns_m.addColumn("element_names",
"string",
"",
......
......@@ -2,6 +2,7 @@
#include "Utilities/OpalException.h"
#include <iomanip>
#include <list>
SDDSColumn::SDDSColumn(const std::string& name,
const std::string& type,
......@@ -14,7 +15,36 @@ SDDSColumn::SDDSColumn(const std::string& name,
writeFlags_m(flags),
writePrecision_m(prec),
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});
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,
......
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