LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
Protocol.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2026 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
18#include <LIEF/visibility.h>
19#include <LIEF/iterators.hpp>
20
21#include <LIEF/ObjC/Method.hpp>
23#include <LIEF/ObjC/DeclOpt.hpp>
24
25#include <memory>
26#include <string>
27
28namespace LIEF {
29namespace objc {
30
31namespace details {
32class Protocol;
33class ProtocolIt;
34}
35
38 public:
39 class Iterator final
40 : public iterator_facade_base<Iterator, std::bidirectional_iterator_tag,
41 Protocol, std::ptrdiff_t, const Protocol*,
42 const Protocol&> {
43 public:
44 using implementation = details::ProtocolIt;
45 using iterator_facade_base::operator++;
46 using iterator_facade_base::operator--;
47
49
50 LIEF_API Iterator(std::unique_ptr<details::ProtocolIt> impl);
51
54
56 LIEF_API Iterator& operator=(Iterator&&) noexcept;
57
59
60 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
61
62 friend bool operator!=(const Iterator& LHS, const Iterator& RHS) {
63 return !(LHS == RHS);
64 }
65
66 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
68
69 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
71
72 LIEF_API const Protocol& operator*() const;
73
74 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
76
79 LIEF_API std::unique_ptr<Protocol> yield();
80
81 private:
82 void load() const;
83
84 std::unique_ptr<details::ProtocolIt> impl_;
85 mutable std::unique_ptr<Protocol> cached_;
86 };
87
88 public:
92
93 Protocol(std::unique_ptr<details::Protocol> impl);
94
96 std::string mangled_name() const;
97
101
104
107
110
114 std::string to_decl(const DeclOpt& opt = DeclOpt()) const;
115
117
118 private:
119 std::unique_ptr<details::Protocol> impl_;
120};
121
122}
123}
124#endif
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterators.hpp:750
Definition iterators.hpp:603
const Protocol & operator*() const
Iterator(Iterator &&) noexcept
Iterator(std::unique_ptr< details::ProtocolIt > impl)
const Protocol * operator->() const
Iterator & operator=(const Iterator &)
std::unique_ptr< Protocol > yield()
Transfer ownership of the protocol at the current position to the caller. Returns nullptr if the iter...
details::ProtocolIt implementation
Definition Protocol.hpp:44
std::string to_decl(const DeclOpt &opt=DeclOpt()) const
Generate a header-like string for this specific protocol.
iterator_range< Iterator > protocols_it
Definition Protocol.hpp:91
protocols_it protocols() const
Iterator over the protocols adopted by this protocol (e.g. the <Bar, Baz> in @protocol Foo <Bar,...
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)
iterator_range< Method::Iterator > methods_it
Definition Protocol.hpp:89
std::string mangled_name() const
Mangled name of the protocol.
iterator_range< Property::Iterator > properties_it
Definition Protocol.hpp:90
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition Category.hpp:32
Namespace related to ObjC metadata.
Definition MachO/Binary.hpp:43
LIEF namespace.
Definition Abstract/Binary.hpp:41
This structure wraps options to tweak the generated output of functions like LIEF::objc::Metadata::to...
Definition DeclOpt.hpp:22
#define LIEF_API
Definition visibility.h:45