OPALX (Object Oriented Parallel Accelerator Library for Exascal) master (dc2a29eed580)
OPALX
Loading...
Searching...
No Matches
SDDSColumn.h
Go to the documentation of this file.
1//
2// Class SDDSColumn
3// This class writes column entries 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//
18#ifndef SDDSWRITERCOLUMN_H
19#define SDDSWRITERCOLUMN_H
20
21#include <ostream>
22#include <string>
23#include <tuple>
24#include <variant>
25
27public:
29 const std::string& name, const std::string& type, const std::string& unit,
30 const std::string& desc, std::ios_base::fmtflags flags, unsigned short precision);
31
32 template <typename T>
33 void addValue(const T& val);
34
35 void writeHeader(std::ostream& os, unsigned int colNr, const std::string& indent) const;
36
37protected:
38 void writeValue(std::ostream& os) const;
39
40private:
41 friend std::ostream& operator<<(std::ostream& os, const SDDSColumn& col);
42
43 typedef std::tuple<std::string, std::string, std::string> desc_t;
44
45 typedef std::variant<float, double, int, long unsigned int, char, std::string> variant_t;
46 std::string name_m;
49
50 std::ios_base::fmtflags writeFlags_m;
51 unsigned short writePrecision_m;
52
53 mutable bool set_m;
54};
55
56template <typename T>
57void SDDSColumn::addValue(const T& val) {
58 value_m = val;
59 set_m = true;
60}
61
62std::ostream& operator<<(std::ostream& os, const SDDSColumn& col);
63
64#endif
double T
Definition OPALTypes.h:8
std::ostream & operator<<(std::ostream &os, const SDDSColumn &col)
variant_t value_m
Definition SDDSColumn.h:48
void writeHeader(std::ostream &os, unsigned int colNr, const std::string &indent) const
desc_t description_m
Definition SDDSColumn.h:47
std::tuple< std::string, std::string, std::string > desc_t
Definition SDDSColumn.h:43
std::string name_m
Definition SDDSColumn.h:46
unsigned short writePrecision_m
Definition SDDSColumn.h:51
void writeValue(std::ostream &os) const
void addValue(const T &val)
Definition SDDSColumn.h:57
friend std::ostream & operator<<(std::ostream &os, const SDDSColumn &col)
std::variant< float, double, int, long unsigned int, char, std::string > variant_t
Definition SDDSColumn.h:45
std::ios_base::fmtflags writeFlags_m
Definition SDDSColumn.h:50