sparrow 0.3.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
17#if defined(__cpp_lib_format)
18# include <format>
19#endif
20
25
26namespace sparrow
27{
29 {
30 public:
31
34 using size_type = std::size_t;
36
37 struct_value() = default;
38 struct_value(const std::vector<child_ptr>& children, size_type index);
39
40 [[nodiscard]] size_type size() const;
41 [[nodiscard]] bool empty() const;
42
43 [[nodiscard]] const_reference operator[](size_type i) const;
44
45 [[nodiscard]] const_reference front() const;
46 [[nodiscard]] const_reference back() const;
47
48 private:
49
50 const std::vector<child_ptr>* p_children = nullptr;
51 size_type m_index = 0u;
52 };
53
55 bool operator==(const struct_value& lhs, const struct_value& rhs);
56}
57
58#if defined(__cpp_lib_format)
59
60template <>
61struct std::formatter<sparrow::struct_value>
62{
63 constexpr auto parse(std::format_parse_context& ctx)
64 {
65 return ctx.begin(); // Simple implementation
66 }
67
68 SPARROW_API auto format(const sparrow::struct_value& ar, std::format_context& ctx) const
69 -> decltype(ctx.out());
70};
71
72namespace sparrow
73{
74 SPARROW_API std::ostream& operator<<(std::ostream& os, const sparrow::struct_value& value);
75}
76
77#endif
Smart pointer behaving like a copiable std::unique_ptr.
Definition memory.hpp:127
size_type size() const
cloning_ptr< array_wrapper > child_ptr
array_traits::value_type value_type
const_reference front() const
array_traits::const_reference const_reference
struct_value(const std::vector< child_ptr > &children, size_type index)
const_reference operator[](size_type i) const
const_reference back() 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 &stream, T n)
Definition large_int.hpp:93
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