LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
ObjC/Class.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_CLASS_H
16#define LIEF_OBJC_CLASS_H
17
18#include <LIEF/visibility.h>
19
20#include <LIEF/ObjC/IVar.hpp>
22#include <LIEF/ObjC/Method.hpp>
24#include <LIEF/ObjC/DeclOpt.hpp>
25
26#include <memory>
27#include <string>
28
29namespace LIEF {
30namespace objc {
31
32namespace details {
33class Class;
34class ClassIt;
35}
36
39 public:
40 class Iterator final
41 : public iterator_facade_base<Iterator, std::bidirectional_iterator_tag, Class,
42 std::ptrdiff_t, const Class*, const Class&> {
43 public:
44 using implementation = details::ClassIt;
45 using iterator_facade_base::operator++;
46 using iterator_facade_base::operator--;
47
49
50 LIEF_API Iterator(std::unique_ptr<details::ClassIt> 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 Class& operator*() const;
73
74 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
75 LIEF_API const Class* operator->() const;
76
79 LIEF_API std::unique_ptr<Class> yield();
80
81 private:
82 void load() const;
83
84 std::unique_ptr<details::ClassIt> impl_;
85 mutable std::unique_ptr<Class> cached_;
86 };
87
88 public:
91
94
97
100
101 Class(std::unique_ptr<details::Class> impl);
102
104 std::string name() const;
105
107 std::string demangled_name() const;
108
110 std::unique_ptr<Class> super_class() const;
111
112 bool is_meta() const;
113
116
119
122
124 ivars_t ivars() const;
125
129 std::string to_decl(const DeclOpt& opt = DeclOpt()) const;
130
132
133 private:
134 std::unique_ptr<details::Class> impl_;
135};
136
137}
138}
139#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
std::unique_ptr< Class > yield()
Transfer ownership of the class at the current position to the caller. Returns nullptr if the iterato...
const Class * operator->() const
details::ClassIt implementation
Definition ObjC/Class.hpp:44
const Class & operator*() const
Iterator(std::unique_ptr< details::ClassIt > impl)
Iterator(const Iterator &)
Iterator(Iterator &&) noexcept
Iterator & operator=(const Iterator &)
This class represents an Objective-C class (@interface).
Definition ObjC/Class.hpp:38
iterator_range< Method::Iterator > methods_t
Iterator for the class's methods.
Definition ObjC/Class.hpp:90
bool is_meta() const
std::string name() const
Name of the class.
properties_t properties() const
Iterator over the properties of this class.
Class(std::unique_ptr< details::Class > impl)
std::string to_decl(const DeclOpt &opt=DeclOpt()) const
Generate a header-like string for this specific class.
std::unique_ptr< Class > super_class() const
Parent class in case of inheritance.
iterator_range< Property::Iterator > properties_t
Iterator for the properties declared by this class.
Definition ObjC/Class.hpp:96
ivars_t ivars() const
Iterator over the different instance variables defined in this class.
iterator_range< Protocol::Iterator > protocols_t
Iterator for the protocols implemented by this class.
Definition ObjC/Class.hpp:93
iterator_range< IVar::Iterator > ivars_t
Iterator for the instance variables defined by this class.
Definition ObjC/Class.hpp:99
methods_t methods() const
Iterator over the different methods defined by this class.
std::string demangled_name() const
Demangled name of the class.
protocols_t protocols() const
Iterator over the different protocols implemented by this class.
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