LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
Protocol.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2024 R. Thomas
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 implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_OBJC_PROTOCOL_H
16#define LIEF_OBJC_PROTOCOL_H
17#include <LIEF/visibility.h>
18#include <LIEF/ObjC/Method.hpp>
20#include <LIEF/iterators.hpp>
21
22#include <memory>
23#include <string>
24
25namespace LIEF {
26namespace objc {
27
28namespace details {
29class Protocol;
30class ProtocolIt;
31}
32
35 public:
37 public:
38 using iterator_category = std::bidirectional_iterator_tag;
39 using value_type = std::unique_ptr<Protocol>;
40 using difference_type = std::ptrdiff_t;
41 using pointer = Protocol*;
42 using reference = std::unique_ptr<Protocol>&;
43 using implementation = details::ProtocolIt;
44
46 // Inspired from LLVM's iterator_facade_base
47 friend class Iterator;
48 public:
49 pointer operator->() const { return R.get(); }
50
51 private:
52 value_type R;
53
54 template <typename RefT>
55 PointerProxy(RefT &&R) : R(std::forward<RefT>(R)) {} // NOLINT(bugprone-forwarding-reference-overload)
56 };
57
59 Iterator(Iterator&&) noexcept;
60 Iterator(std::unique_ptr<details::ProtocolIt> impl);
62
63 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
64
65 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
66 return !(LHS == RHS);
67 }
68
71
73 Iterator tmp = *static_cast<Iterator*>(this);
74 --*static_cast<Iterator *>(this);
75 return tmp;
76 }
77
79 Iterator tmp = *static_cast<Iterator*>(this);
80 ++*static_cast<Iterator *>(this);
81 return tmp;
82 }
83
84 std::unique_ptr<Protocol> operator*() const;
85
87 return static_cast<const Iterator*>(this)->operator*();
88 }
89
90 private:
91 std::unique_ptr<details::ProtocolIt> impl_;
92 };
93
94 public:
97
98 Protocol(std::unique_ptr<details::Protocol> impl);
99
101 std::string mangled_name() const;
102
105
108
111
113 private:
114 std::unique_ptr<details::Protocol> impl_;
115};
116
117}
118}
119#endif
Definition iterators.hpp:486
pointer operator->() const
Definition Protocol.hpp:49
Definition Protocol.hpp:36
std::ptrdiff_t difference_type
Definition Protocol.hpp:40
std::unique_ptr< Protocol > & reference
Definition Protocol.hpp:42
std::bidirectional_iterator_tag iterator_category
Definition Protocol.hpp:38
Iterator(Iterator &&) noexcept
std::unique_ptr< Protocol > value_type
Definition Protocol.hpp:39
std::unique_ptr< Protocol > operator*() const
Iterator operator--(int)
Definition Protocol.hpp:72
Iterator operator++(int)
Definition Protocol.hpp:78
details::ProtocolIt implementation
Definition Protocol.hpp:43
PointerProxy operator->() const
Definition Protocol.hpp:86
This class represents an Objective-C @protocol
Definition Protocol.hpp:34
methods_it optional_methods() const
Iterator over the methods that could be overridden.
methods_it required_methods() const
Iterator over the methods of this protocol that must be implemented.
properties_it properties() const
Iterator over the properties defined in this protocol.
Protocol(std::unique_ptr< details::Protocol > impl)
std::string mangled_name() const
Mangled name of the protocol.
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41