sparrow 0.9.0
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
41 struct_value() = default;
42 struct_value(const std::vector<child_ptr>& children, size_type index);
43
44 [[nodiscard]] size_type size() const;
45 [[nodiscard]] bool empty() const;
46
47 [[nodiscard]] const_reference operator[](size_type i) const;
48
49 [[nodiscard]] const_reference front() const;
50 [[nodiscard]] const_reference back() const;
51
52 [[nodiscard]] const_iterator begin() const;
53 [[nodiscard]] const_iterator cbegin() const;
54
55 [[nodiscard]] const_iterator end() const;
56 [[nodiscard]] const_iterator cend() const;
57
58 private:
59
60 const std::vector<child_ptr>* p_children = nullptr;
61 size_type m_index = 0u;
62 };
63
65 bool operator==(const struct_value& lhs, const struct_value& rhs);
66}
67
68#if defined(__cpp_lib_format)
69
70template <>
71struct std::formatter<sparrow::struct_value>
72{
73 constexpr auto parse(std::format_parse_context& ctx)
74 {
75 return ctx.begin(); // Simple implementation
76 }
77
78 SPARROW_API auto format(const sparrow::struct_value& ar, std::format_context& ctx) const
79 -> decltype(ctx.out());
80};
81
82namespace sparrow
83{
84 SPARROW_API std::ostream& operator<<(std::ostream& os, const sparrow::struct_value& value);
85}
86
87#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_iterator cbegin() const
const_reference front() 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_iterator cend() const
detail::layout_bracket_functor< const struct_value, const_reference > const_functor_type
const_reference operator[](size_type i) const
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 sparrow::nullval_t &)
Definition nullable.hpp:933
mpl::rename< 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