OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
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 <tuple>
23#include <string>
24#include <variant>
25
27public:
28 SDDSColumn(const std::string& name,
29 const std::string& type,
30 const std::string& unit,
31 const std::string& desc,
32 std::ios_base::fmtflags flags,
33 unsigned short precision);
34
35 template<typename T>
36 void addValue(const T& val);
37
38 void writeHeader(std::ostream& os,
39 unsigned int colNr,
40 const std::string& indent) const;
41
42protected:
43 void writeValue(std::ostream& os) const;
44
45private:
46 friend
47 std::ostream& operator<<(std::ostream& os,
48 const SDDSColumn& col);
49
50 typedef std::tuple<std::string,
51 std::string,
52 std::string> desc_t;
53
54 typedef std::variant<float,
55 double,
56 long unsigned int,
57 char,
58 std::string> variant_t;
59 std::string name_m;
62
63 std::ios_base::fmtflags writeFlags_m;
64 unsigned short writePrecision_m;
65
66 mutable bool set_m;
67};
68
69template<typename T>
70void SDDSColumn::addValue(const T& val) {
71 value_m = val;
72 set_m = true;
73}
74
75std::ostream& operator<<(std::ostream& os,
76 const SDDSColumn& col);
77
78#endif
std::ostream & operator<<(std::ostream &os, const SDDSColumn &col)
const std::string name
variant_t value_m
Definition SDDSColumn.h:61
void writeHeader(std::ostream &os, unsigned int colNr, const std::string &indent) const
desc_t description_m
Definition SDDSColumn.h:60
std::tuple< std::string, std::string, std::string > desc_t
Definition SDDSColumn.h:52
std::variant< float, double, long unsigned int, char, std::string > variant_t
Definition SDDSColumn.h:58
std::string name_m
Definition SDDSColumn.h:59
unsigned short writePrecision_m
Definition SDDSColumn.h:64
void writeValue(std::ostream &os) const
void addValue(const T &val)
Definition SDDSColumn.h:70
friend std::ostream & operator<<(std::ostream &os, const SDDSColumn &col)
std::ios_base::fmtflags writeFlags_m
Definition SDDSColumn.h:63