OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
SDDSColumnSet.cpp
Go to the documentation of this file.
2 
3 void SDDSColumnSet::addColumn(const std::string& name,
4  const std::string& type,
5  const std::string& unit,
6  const std::string& desc,
7  std::ios_base::fmtflags flags,
8  unsigned short prec) {
9 
10  if (name2idx_m.find(name) != name2idx_m.end()) {
11  throw OpalException("SDDSColumnSet::addColumn",
12  "column name '" + name + "' already exists");
13  }
14 
15  name2idx_m.insert(std::make_pair(name, columns_m.size()));
16  columns_m.emplace_back(SDDSColumn(name, type, unit, desc, flags, prec));
17 }
18 
19 
20 void SDDSColumnSet::writeHeader(std::ostream& os,
21  const std::string& indent) const {
22  for (unsigned int i = 0; i < columns_m.size(); ++ i) {
23  auto & col = columns_m[i];
24  col.writeHeader(os, i + 1, indent);
25  }
26 }
27 
28 
29 void SDDSColumnSet::writeRow(std::ostream& os) const {
30  for (auto & col: columns_m) {
31  os << col;
32  }
33  os << std::endl;
34 }
void writeRow(std::ostream &os) const
std::vector< SDDSColumn > columns_m
Definition: SDDSColumnSet.h:35
The base class for all OPAL exceptions.
Definition: OpalException.h:28
std::map< std::string, unsigned int > name2idx_m
Definition: SDDSColumnSet.h:36
const std::string name
void addColumn(const std::string &name, const std::string &type, const std::string &unit, const std::string &desc, std::ios_base::fmtflags flags=std::ios_base::scientific, unsigned short precision=15)
void writeHeader(std::ostream &os, const std::string &indent) const
Inform & endl(Inform &inf)
Definition: Inform.cpp:42