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
17#include <LIEF/visibility.h>
18#include <LIEF/iterators.hpp>
19
20#include <LIEF/ObjC/Method.hpp>
22#include <LIEF/ObjC/DeclOpt.hpp>
23
24#include <memory>
25#include <string>
26
27namespace LIEF {
28namespace objc {
29
30namespace details {
31class Protocol;
32class ProtocolIt;
33}
34
37 public:
38 class Iterator final
39 : public iterator_facade_base<Iterator, std::bidirectional_iterator_tag,
40 Protocol, std::ptrdiff_t, const Protocol*,
41 const Protocol&> {
42 public:
43 using implementation = details::ProtocolIt;
44 using iterator_facade_base::operator++;
45 using iterator_facade_base::operator--;
46
48
49 LIEF_API Iterator(std::unique_ptr<details::ProtocolIt> impl);
50
53
55 LIEF_API Iterator& operator=(Iterator&&) noexcept;
56
58
59 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
60
61 friend bool operator!=(const Iterator& LHS, const Iterator& RHS) {
62 return !(LHS == RHS);
63 }
64
65 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
67
68 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
70
71 LIEF_API const Protocol& operator*() const;
72
73 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
75
78 LIEF_API std::unique_ptr<Protocol> yield();
79
80 private:
81 void load() const;
82
83 std::unique_ptr<details::ProtocolIt> impl_;
84 mutable std::unique_ptr<Protocol> cached_;
85 };
86
87 public:
90
91 Protocol(std::unique_ptr<details::Protocol> impl);
92
94 std::string mangled_name() const;
95
98
101
104
108 std::string to_decl(const DeclOpt& opt = DeclOpt()) const;
109
111
112 private:
113 std::unique_ptr<details::Protocol> impl_;
114};
115
116}
117}
118#endif
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterators.hpp:729
Definition iterators.hpp:601
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:43
std::string to_decl(const DeclOpt &opt=DeclOpt()) const
Generate a header-like string for this specific protocol.
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:88
std::string mangled_name() const
Mangled name of the protocol.
iterator_range< Property::Iterator > properties_it
Definition Protocol.hpp:89
Definition ObjC/Class.hpp:32
Namespace related to ObjC metadata.
Definition MachO/Binary.hpp:42
LIEF namespace.
Definition Abstract/Binary.hpp:40
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