Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
AsciiWriterHelper.h
Go to the documentation of this file.
1
25#ifndef TABLE_ASCIIWRITERHELPER_H
26#define TABLE_ASCIIWRITERHELPER_H
27
29#include "ReaderHelper.h"
30#include "Table/Table.h"
31#include <sstream>
32#include <typeindex>
33#include <vector>
34
35namespace Euclid {
36namespace Table {
37
48
60
72
77struct ToStringVisitor : public boost::static_visitor<std::string> {
78 std::string operator()(const std::string& from) const {
80 q << quoted(from);
81 return q.str();
82 }
83
84 std::string operator()(const double from) const {
87 return q.str();
88 }
89
90 template <typename T>
93 auto it = v.begin();
94 if (it != v.end()) {
95 q << *it;
96 ++it;
97 }
98 while (it != v.end()) {
99 q << ',' << *it;
100 ++it;
101 }
102 return q.str();
103 }
104
105 template <typename T>
106 std::string operator()(const T& from) const {
108 q << from;
109 return q.str();
110 }
111};
112
113} // namespace Table
114} // end of namespace Euclid
115
116#endif /* TABLE_ASCIIWRITERHELPER_H */
T begin(T... args)
T end(T... args)
#define ELEMENTS_API
std::vector< size_t > calculateColumnLengths(const Table &table)
Calculates the sizes in characters each column of the table needs.
std::string quoted(const std::string &str)
std::string typeToKeyword(std::type_index type)
Converts a type to its string representation.
T setprecision(T... args)
T str(T... args)
std::string operator()(const T &from) const
std::string operator()(const double from) const
std::string operator()(const std::string &from) const
std::string operator()(const std::vector< T > &v) const