File indexing completed on 2025-08-28 08:27:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #pragma once
0019
0020 #include <tuple>
0021 #include "arrow/util/string.h"
0022
0023 using arrow::internal::ToChars;
0024
0025 namespace arrow {
0026 namespace internal {
0027
0028 namespace detail {
0029
0030 template <typename OStream, typename Tuple, size_t N>
0031 struct TuplePrinter {
0032 static void Print(OStream* os, const Tuple& t) {
0033 TuplePrinter<OStream, Tuple, N - 1>::Print(os, t);
0034 *os << std::get<N - 1>(t);
0035 }
0036 };
0037
0038 template <typename OStream, typename Tuple>
0039 struct TuplePrinter<OStream, Tuple, 0> {
0040 static void Print(OStream* os, const Tuple& t) {}
0041 };
0042
0043 }
0044
0045
0046
0047
0048 template <typename OStream, typename... Args>
0049 void PrintTuple(OStream* os, const std::tuple<Args&...>& tup) {
0050 detail::TuplePrinter<OStream, std::tuple<Args&...>, sizeof...(Args)>::Print(os, tup);
0051 }
0052
0053 template <typename Range, typename Separator>
0054 struct PrintVector {
0055 const Range& range_;
0056 const Separator& separator_;
0057
0058 template <typename Os>
0059 friend Os& operator<<(Os& os, PrintVector l) {
0060 bool first = true;
0061 os << "[";
0062 for (const auto& element : l.range_) {
0063 if (first) {
0064 first = false;
0065 } else {
0066 os << l.separator_;
0067 }
0068 os << ToChars(element);
0069 }
0070 os << "]";
0071 return os;
0072 }
0073 };
0074 template <typename Range, typename Separator>
0075 PrintVector(const Range&, const Separator&) -> PrintVector<Range, Separator>;
0076 }
0077 }