1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements.  See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership.  The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License.  You may obtain a copy of the License at
8 //
9 //   http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied.  See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17 
18 #include "./arrow_types.h"
19 
20 #if defined(ARROW_R_WITH_ARROW)
21 #include <arrow/type.h>
22 
23 // [[arrow::export]]
Field__initialize(const std::string & name,const std::shared_ptr<arrow::DataType> & field,bool nullable=true)24 std::shared_ptr<arrow::Field> Field__initialize(
25     const std::string& name, const std::shared_ptr<arrow::DataType>& field,
26     bool nullable = true) {
27   return arrow::field(name, field, nullable);
28 }
29 
30 // [[arrow::export]]
Field__ToString(const std::shared_ptr<arrow::Field> & field)31 std::string Field__ToString(const std::shared_ptr<arrow::Field>& field) {
32   return field->ToString();
33 }
34 
35 // [[arrow::export]]
Field__name(const std::shared_ptr<arrow::Field> & field)36 std::string Field__name(const std::shared_ptr<arrow::Field>& field) {
37   return field->name();
38 }
39 
40 // [[arrow::export]]
Field__Equals(const std::shared_ptr<arrow::Field> & field,const std::shared_ptr<arrow::Field> & other)41 bool Field__Equals(const std::shared_ptr<arrow::Field>& field,
42                    const std::shared_ptr<arrow::Field>& other) {
43   return field->Equals(other);
44 }
45 
46 // [[arrow::export]]
Field__nullable(const std::shared_ptr<arrow::Field> & field)47 bool Field__nullable(const std::shared_ptr<arrow::Field>& field) {
48   return field->nullable();
49 }
50 
51 // [[arrow::export]]
Field__type(const std::shared_ptr<arrow::Field> & field)52 std::shared_ptr<arrow::DataType> Field__type(const std::shared_ptr<arrow::Field>& field) {
53   return field->type();
54 }
55 
56 #endif
57