OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
SDDSColumnSet.cpp
Go to the documentation of this file.
1//
2// Class SDDSColumnSet
3// This class writes rows of SDDS files.
4//
5// Copyright (c) 2019, Christof Metzger-Kraus, Open Sourcerer
6// All rights reserved
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
19
21 const std::string& name, const std::string& type, const std::string& unit,
22 const std::string& desc, std::ios_base::fmtflags flags, unsigned short prec) {
23 if (name2idx_m.find(name) != name2idx_m.end()) {
24 throw OpalException(
25 "SDDSColumnSet::addColumn", "column name '" + name + "' already exists");
26 }
27
28 name2idx_m.insert(std::make_pair(name, columns_m.size()));
29 columns_m.emplace_back(SDDSColumn(name, type, unit, desc, flags, prec));
30}
31
32void SDDSColumnSet::writeHeader(std::ostream& os, const std::string& indent) const {
33 for (unsigned int i = 0; i < columns_m.size(); ++i) {
34 auto& col = columns_m[i];
35 col.writeHeader(os, i + 1, indent);
36 }
37}
38
39void SDDSColumnSet::writeRow(std::ostream& os) const {
40 for (auto& col : columns_m) {
41 os << col;
42 }
43 os << std::endl;
44}
std::map< std::string, size_t > name2idx_m
std::vector< SDDSColumn > columns_m
void writeRow(std::ostream &os) const
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