19 template <
class... Ts>
31 Table(std::vector<std::string> headers,
32 unsigned int static_column_size = 0,
33 unsigned int cell_padding = 1)
50 void addRow(Ts... entries) {
_data.emplace_back(std::make_tuple(entries...)); }
55 template <
typename StreamType>
69 stream << std::string(total_width,
'-') <<
"\n";
86 stream << std::string(total_width,
'-') <<
"\n";
89 for (
auto & row :
_data)
97 stream << std::string(total_width,
'-') <<
"\n";
109 assert(column_format.size() == std::tuple_size<DataTuple>::value);
123 assert(precision.size() == std::tuple_size<DataTuple>::value);
134 template <
typename T,
135 typename =
typename std::enable_if<
136 std::is_arithmetic<typename std::remove_reference<T>::type>::value>::type>
143 template <
typename T>
162 template <
typename TupleType,
typename StreamType>
165 std::integral_constant<
167 std::tuple_size<
typename std::remove_reference<TupleType>::type>::value>)
174 template <std::size_t I,
177 typename =
typename std::enable_if<
178 I != std::tuple_size<typename std::remove_reference<TupleType>::type>::value>::type>
179 void print_each(TupleType && t, StreamType & stream, std::integral_constant<size_t, I>)
181 auto & val = std::get<I>(t);
187 std::tuple_size<
typename std::remove_reference<TupleType>::type>::value);
196 std::tuple_size<
typename std::remove_reference<TupleType>::type>::value);
199 stream << std::scientific;
202 stream << std::fixed;
205 stream << std::fixed << std::setprecision(2);
209 << justify<decltype(val)>(0) << val << std::string(
_cell_padding,
' ') <<
"|";
215 stream.unsetf(std::ios_base::floatfield);
219 print_each(std::forward<TupleType>(t), stream, std::integral_constant<size_t, I + 1>());
225 template <
typename TupleType,
typename StreamType>
228 print_each(std::forward<TupleType>(t), stream, std::integral_constant<size_t, 0>());
237 size_t sizeOfData(
const T & data, decltype(((T *)
nullptr)->size()) * =
nullptr)
249 typename std::enable_if<std::is_integral<T>::value>::type * =
nullptr)
254 return std::log10(data) + 1;
270 template <
typename TupleType>
272 std::vector<unsigned int> & ,
273 std::integral_constant<
275 std::tuple_size<
typename std::remove_reference<TupleType>::type>::value>)
282 template <std::size_t I,
284 typename =
typename std::enable_if<
285 I != std::tuple_size<typename std::remove_reference<TupleType>::type>::value>::type>
287 size_each(TupleType && t, std::vector<unsigned int> & sizes, std::integral_constant<size_t, I>)
297 size_each(std::forward<TupleType>(t), sizes, std::integral_constant<size_t, I + 1>());
303 template <
typename TupleType>
304 void size_each(TupleType && t, std::vector<unsigned int> & sizes)
306 size_each(std::forward<TupleType>(t), sizes, std::integral_constant<size_t, 0>());
324 for (
auto & row :
_data)