C++ Essence Library
0.1.0
A Utility Library for Modern C++ Programming
Loading...
Searching...
No Matches
iterator.hpp
1
/*
2
* Copyright (c) 2024 The RefValue Project
3
*
4
* Permission is hereby granted, free of charge, to any person obtaining a copy
5
* of this software and associated documentation files (the "Software"), to deal
6
* in the Software without restriction, including without limitation the rights
7
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
* copies of the Software, and to permit persons to whom the Software is
9
* furnished to do so, subject to the following conditions:
10
*
11
* The above copyright notice and this permission notice shall be included in
12
* all copies or substantial portions of the Software.
13
*
14
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
* THE SOFTWARE.
21
*/
22
23
#pragma once
24
25
#include "../compat.hpp"
26
#include "global_ref.hpp"
27
#include "local_ref.hpp"
28
29
#include <compare>
30
#include <cstddef>
31
#include <iterator>
32
#include <type_traits>
33
34
#include <jni.h>
35
36
namespace
essence::jni {
37
struct
jobject_array_proxy
{
38
jobjectArray array;
39
};
40
41
class
jobject_array_iterator
{
42
public
:
43
struct
end_tag
{};
44
using
iterator_category = std::random_access_iterator_tag;
45
using
value_type
=
local_ref
;
46
using
pointer
=
value_type
*;
47
using
reference
=
value_type
&;
48
using
difference_type = jsize;
49
50
ES_API(JNISUPPORT)
jobject_array_iterator
() noexcept;
51
ES_API(JNISUPPORT) explicit
jobject_array_iterator
(jobjectArray array,
end_tag
= {});
52
ES_API(JNISUPPORT)
jobject_array_iterator
(jobjectArray array, jsize index);
53
ES_API(JNISUPPORT)
54
jobject_array_iterator
(
const
jobject_array_iterator
&);
55
ES_API(JNISUPPORT)
56
jobject_array_iterator
(
jobject_array_iterator
&&) noexcept;
57
ES_API(JNISUPPORT) ~
jobject_array_iterator
();
58
ES_API(JNISUPPORT)
jobject_array_iterator
& operator=(const
jobject_array_iterator
&);
59
ES_API(JNISUPPORT)
jobject_array_iterator
& operator=(
jobject_array_iterator
&&) noexcept;
60
ES_API(JNISUPPORT) value_type operator*() const;
61
ES_API(JNISUPPORT)
jobject_array_iterator
& operator++() noexcept;
62
ES_API(JNISUPPORT)
jobject_array_iterator
operator++(
int
) noexcept;
63
ES_API(JNISUPPORT)
jobject_array_iterator
& operator--() noexcept;
64
ES_API(JNISUPPORT)
jobject_array_iterator
operator--(
int
) noexcept;
65
ES_API(JNISUPPORT)
jobject_array_iterator
& operator+=(difference_type off) noexcept;
66
ES_API(JNISUPPORT)
jobject_array_iterator
operator+(difference_type off) const noexcept;
67
ES_API(JNISUPPORT)
68
friend
jobject_array_iterator
operator+(difference_type off,
jobject_array_iterator
next) noexcept;
69
ES_API(JNISUPPORT)
jobject_array_iterator
& operator-=(difference_type off) noexcept;
70
ES_API(JNISUPPORT)
jobject_array_iterator
operator-(difference_type off) const noexcept;
71
ES_API(JNISUPPORT)
72
difference_type operator-(const
jobject_array_iterator
& right) const noexcept;
73
ES_API(JNISUPPORT) value_type operator[](difference_type off) const;
74
constexpr
bool
operator==(const
jobject_array_iterator
&) const noexcept = default;
75
constexpr auto operator<=>(const
jobject_array_iterator
&) const noexcept = default;
76
77
private:
78
JNIEnv* env_;
79
jsize size_;
80
jsize index_;
81
jobjectArray array_;
82
};
83
84
ES_API(JNISUPPORT)
jobject_array_iterator
begin(const
local_ref_ex
<jobjectArray>& array);
85
ES_API(JNISUPPORT)
jobject_array_iterator
end(const
local_ref_ex
<jobjectArray>& array);
86
87
ES_API(JNISUPPORT)
jobject_array_iterator
begin(const
global_ref_ex
<jobjectArray>& array);
88
ES_API(JNISUPPORT)
jobject_array_iterator
end(const
global_ref_ex
<jobjectArray>& array);
89
90
ES_API(JNISUPPORT)
jobject_array_iterator
begin(
jobject_array_proxy
proxy);
91
ES_API(JNISUPPORT)
jobject_array_iterator
end(
jobject_array_proxy
proxy);
92
}
// namespace essence::jni
93
94
ES_API(JNISUPPORT) essence::jni::
jobject_array_iterator
begin(jobjectArray array);
95
ES_API(JNISUPPORT) essence::jni::
jobject_array_iterator
end(jobjectArray array);
essence::jni::global_ref_ex
Definition
global_ref.hpp:57
essence::jni::jobject_array_iterator
Definition
iterator.hpp:41
essence::jni::local_ref_ex
Definition
local_ref.hpp:57
essence::jni::local_ref
Definition
local_ref.hpp:35
essence::jni::jobject_array_iterator::end_tag
Definition
iterator.hpp:43
essence::jni::jobject_array_proxy
Definition
iterator.hpp:37
include
essence
jni
iterator.hpp
Generated by
1.12.0