Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-28 08:27:09

0001 // Licensed to the Apache Software Foundation (ASF) under one
0002 // or more contributor license agreements.  See the NOTICE file
0003 // distributed with this work for additional information
0004 // regarding copyright ownership.  The ASF licenses this file
0005 // to you under the Apache License, Version 2.0 (the
0006 // "License"); you may not use this file except in compliance
0007 // with the License.  You may obtain a copy of the License at
0008 //
0009 //   http://www.apache.org/licenses/LICENSE-2.0
0010 //
0011 // Unless required by applicable law or agreed to in writing,
0012 // software distributed under the License is distributed on an
0013 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0014 // KIND, either express or implied.  See the License for the
0015 // specific language governing permissions and limitations
0016 // under the License. template <typename T>
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 }  // namespace detail
0044 
0045 // Print elements from a tuple to a stream, in order.
0046 // Typical use is to pack a bunch of existing values with std::forward_as_tuple()
0047 // before passing it to this function.
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>  // template to dodge inclusion of <ostream>
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);  // use ToChars to avoid locale dependence
0069     }
0070     os << "]";
0071     return os;
0072   }
0073 };
0074 template <typename Range, typename Separator>
0075 PrintVector(const Range&, const Separator&) -> PrintVector<Range, Separator>;
0076 }  // namespace internal
0077 }  // namespace arrow