sparrow ..
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
19#if defined(__cpp_lib_format)
20# include <format>
21#endif
22
27
28namespace sparrow
29{
31 {
32 public:
33
36 using size_type = std::size_t;
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
50 [[nodiscard]] const_reference front() const;
51 [[nodiscard]] const_reference back() const;
52
53 [[nodiscard]] const_iterator begin() const;
54 [[nodiscard]] const_iterator cbegin() const;
55
56 [[nodiscard]] const_iterator end() const;
57 [[nodiscard]] const_iterator cend() const;
58
59 [[nodiscard]] const_reverse_iterator rbegin() const;
60 [[nodiscard]] const_reverse_iterator crbegin() const;
61
62 [[nodiscard]] const_reverse_iterator rend() const;
63 [[nodiscard]] const_reverse_iterator crend() const;
64
65 private:
66
67 const std::vector<child_ptr>* p_children = nullptr;
68 size_type m_index = 0u;
69 };
70
72 bool operator==(const struct_value& lhs, const struct_value& rhs);
73}
74
75#if defined(__cpp_lib_format)
76
77template <>
78struct std::formatter<sparrow::struct_value>
79{
80 constexpr auto parse(std::format_parse_context& ctx)
81 {
82 return ctx.begin(); // Simple implementation
83 }
84
85 SPARROW_API auto format(const sparrow::struct_value& ar, std::format_context& ctx) const
86 -> decltype(ctx.out());
87};
88
89namespace sparrow
90{
91 SPARROW_API std::ostream& operator<<(std::ostream& os, const struct_value& value);
92}
93
94#endif
Smart pointer behaving like a copiable std::unique_ptr.
Definition memory.hpp:126
size_type size() const
cloning_ptr< array_wrapper > child_ptr
array_traits::value_type value_type
const_reverse_iterator crend() const
const_iterator cbegin() const
const_reference front() const
const_reverse_iterator crbegin() const
const_iterator end() const
functor_index_iterator< const_functor_type > const_iterator
array_traits::const_reference const_reference
struct_value(const std::vector< child_ptr > &children, size_type index)
const_reverse_iterator rend() const
const_iterator cend() const
detail::layout_bracket_functor< const struct_value, const_reference > const_functor_type
const_reference operator[](size_type i) const
const_reverse_iterator rbegin() const
std::reverse_iterator< const_iterator > const_reverse_iterator
const_reference back() const
const_iterator begin() const
#define SPARROW_API
Definition config.hpp:38
SPARROW_API bool operator==(const array &lhs, const array &rhs)
Compares the content of two arrays.
std::ostream & operator<<(std::ostream &os, const nullval_t &)
mpl::rename< mpl::unique< mpl::transform< detail::array_const_reference_t, all_base_types_t > >, nullable_variant > const_reference
mpl::rename< mpl::transform< detail::array_value_type_t, all_base_types_t >, nullable_variant > value_type