Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-27 08:47:24

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.
0017 
0018 // Private header, not to be exported
0019 
0020 #pragma once
0021 
0022 #include <utility>
0023 
0024 #include "arrow/scalar.h"
0025 #include "arrow/status.h"
0026 #include "arrow/type.h"
0027 #include "arrow/visitor_generate.h"
0028 
0029 namespace arrow {
0030 
0031 #define SCALAR_VISIT_INLINE(TYPE_CLASS)                                              \
0032   case TYPE_CLASS##Type::type_id:                                                    \
0033     return visitor->Visit(internal::checked_cast<const TYPE_CLASS##Scalar&>(scalar), \
0034                           std::forward<ARGS>(args)...);
0035 
0036 /// \brief Apply the visitors Visit() method specialized to the scalar type
0037 ///
0038 /// \tparam VISITOR Visitor type that implements Visit() for all scalar types.
0039 /// \tparam ARGS Additional arguments, if any, will be passed to the Visit function after
0040 /// the `scalar` argument
0041 /// \return Status
0042 ///
0043 /// A visitor is a type that implements specialized logic for each Arrow type.
0044 /// Example usage:
0045 ///
0046 /// ```
0047 /// class ExampleVisitor {
0048 ///   arrow::Status Visit(arrow::Int32Scalar scalar) { ... }
0049 ///   arrow::Status Visit(arrow::Int64Scalar scalar) { ... }
0050 ///   ...
0051 /// }
0052 /// ExampleVisitor visitor;
0053 /// VisitScalarInline(some_scalar, &visitor);
0054 /// ```
0055 template <typename VISITOR, typename... ARGS>
0056 inline Status VisitScalarInline(const Scalar& scalar, VISITOR* visitor, ARGS&&... args) {
0057   switch (scalar.type->id()) {
0058     ARROW_GENERATE_FOR_ALL_TYPES(SCALAR_VISIT_INLINE);
0059     default:
0060       break;
0061   }
0062   return Status::NotImplemented("Scalar visitor for type not implemented ",
0063                                 scalar.type->ToString());
0064 }
0065 
0066 #undef SCALAR_VISIT_INLINE
0067 
0068 }  // namespace arrow