sparrow
2.4.0
C++20 idiomatic APIs for the Apache Arrow Columnar Format
Toggle main menu visibility
Loading...
Searching...
No Matches
struct_value.hpp
Go to the documentation of this file.
1
// Copyright 2024 Man Group Operations Limited
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or mplied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
15
#pragma once
16
17
#include "
sparrow/layout/layout_utils.hpp
"
18
#include "
sparrow/utils/functor_index_iterator.hpp
"
19
#if defined(__cpp_lib_format)
20
# include <format>
21
#endif
22
23
#include "
sparrow/config/config.hpp
"
24
#include "
sparrow/layout/array_wrapper.hpp
"
25
#include "
sparrow/types/data_traits.hpp
"
26
#include "
sparrow/utils/memory.hpp
"
27
28
namespace
sparrow
29
{
30
class
SPARROW_API
struct_value
31
{
32
public
:
33
34
using
value_type
=
array_traits::value_type
;
35
using
const_reference
=
array_traits::const_reference
;
36
using
size_type
= std::size_t;
37
using
child_ptr
= cloning_ptr<array_wrapper>;
38
using
const_functor_type
=
detail::layout_bracket_functor<const struct_value, const_reference>
;
39
using
const_iterator
=
functor_index_iterator<const_functor_type>
;
40
using
const_reverse_iterator
= std::reverse_iterator<const_iterator>;
41
42
struct_value
() =
default
;
43
struct_value
(
const
std::vector<child_ptr>& children,
size_type
index);
44
45
[[nodiscard]]
size_type
size
()
const
;
46
[[nodiscard]]
bool
empty
()
const
;
47
48
[[nodiscard]]
const_reference
operator[]
(
size_type
i)
const
;
49
[[nodiscard]]
const_reference
at
(
size_type
i)
const
;
50
[[nodiscard]]
const_reference
at
(std::string_view name)
const
;
51
52
[[nodiscard]]
const_reference
front
()
const
;
53
[[nodiscard]]
const_reference
back
()
const
;
54
55
[[nodiscard]]
const_iterator
begin
()
const
;
56
[[nodiscard]]
const_iterator
cbegin
()
const
;
57
58
[[nodiscard]]
const_iterator
end
()
const
;
59
[[nodiscard]]
const_iterator
cend
()
const
;
60
61
[[nodiscard]]
const_reverse_iterator
rbegin
()
const
;
62
[[nodiscard]]
const_reverse_iterator
crbegin
()
const
;
63
64
[[nodiscard]]
const_reverse_iterator
rend
()
const
;
65
[[nodiscard]]
const_reverse_iterator
crend
()
const
;
66
67
[[nodiscard]]
auto
names
()
const
68
{
69
const
auto
result = (*p_children)
70
| std::views::transform(
71
[](
const
auto
& child)
72
{
73
return
child->get_arrow_proxy().name();
74
}
75
);
76
return
result;
77
}
78
79
private
:
80
81
const
std::vector<child_ptr>* p_children =
nullptr
;
82
size_type m_index = 0u;
83
};
84
85
SPARROW_API
86
bool
operator==
(
const
struct_value
& lhs,
const
struct_value
& rhs);
87
}
88
89
#if defined(__cpp_lib_format)
90
91
template
<>
92
struct
std::formatter<
sparrow
::struct_value>
93
{
94
constexpr
auto
parse(std::format_parse_context& ctx)
95
{
96
return
ctx.begin();
// Simple implementation
97
}
98
99
SPARROW_API
auto
format(
const
sparrow::struct_value& ar, std::format_context& ctx)
const
100
->
decltype
(ctx.out());
101
};
102
103
namespace
sparrow
104
{
105
SPARROW_API
std::ostream&
operator<<
(std::ostream& os,
const
struct_value
& value);
106
}
107
108
#endif
array_wrapper.hpp
sparrow::detail::layout_bracket_functor
Definition
layout_utils.hpp:56
sparrow::functor_index_iterator
Definition
functor_index_iterator.hpp:29
sparrow::struct_value
Definition
struct_value.hpp:31
sparrow::struct_value::size
size_type size() const
sparrow::struct_value::child_ptr
cloning_ptr< array_wrapper > child_ptr
Definition
struct_value.hpp:37
sparrow::struct_value::value_type
array_traits::value_type value_type
Definition
struct_value.hpp:34
sparrow::struct_value::crend
const_reverse_iterator crend() const
sparrow::struct_value::cbegin
const_iterator cbegin() const
sparrow::struct_value::at
const_reference at(std::string_view name) const
sparrow::struct_value::struct_value
struct_value()=default
sparrow::struct_value::front
const_reference front() const
sparrow::struct_value::crbegin
const_reverse_iterator crbegin() const
sparrow::struct_value::end
const_iterator end() const
sparrow::struct_value::const_iterator
functor_index_iterator< const_functor_type > const_iterator
Definition
struct_value.hpp:39
sparrow::struct_value::const_reference
array_traits::const_reference const_reference
Definition
struct_value.hpp:35
sparrow::struct_value::struct_value
struct_value(const std::vector< child_ptr > &children, size_type index)
sparrow::struct_value::empty
bool empty() const
sparrow::struct_value::rend
const_reverse_iterator rend() const
sparrow::struct_value::cend
const_iterator cend() const
sparrow::struct_value::const_functor_type
detail::layout_bracket_functor< const struct_value, const_reference > const_functor_type
Definition
struct_value.hpp:38
sparrow::struct_value::operator[]
const_reference operator[](size_type i) const
sparrow::struct_value::names
auto names() const
Definition
struct_value.hpp:67
sparrow::struct_value::rbegin
const_reverse_iterator rbegin() const
sparrow::struct_value::const_reverse_iterator
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition
struct_value.hpp:40
sparrow::struct_value::back
const_reference back() const
sparrow::struct_value::size_type
std::size_t size_type
Definition
struct_value.hpp:36
sparrow::struct_value::begin
const_iterator begin() const
sparrow::struct_value::at
const_reference at(size_type i) const
config.hpp
SPARROW_API
#define SPARROW_API
Definition
config.hpp:38
data_traits.hpp
functor_index_iterator.hpp
layout_utils.hpp
memory.hpp
sparrow
Definition
array.hpp:21
sparrow::operator==
SPARROW_API bool operator==(const array &lhs, const array &rhs)
Compares the content of two arrays.
sparrow::operator<<
std::ostream & operator<<(std::ostream &os, const nullval_t &)
Definition
nullable.hpp:1597
sparrow::array_traits::const_reference
mpl::rename< mpl::unique< mpl::transform< detail::array_const_reference_t, all_base_types_t > >, nullable_variant > const_reference
Definition
data_traits.hpp:276
sparrow::array_traits::value_type
mpl::rename< mpl::transform< detail::array_value_type_t, all_base_types_t >, nullable_variant > value_type
Definition
data_traits.hpp:274
sparrow
layout
struct_value.hpp
Generated by
1.17.0