LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
Category.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_CATEGORY_H
16#define LIEF_OBJC_CATEGORY_H
18#include <LIEF/visibility.h>
19#include <LIEF/iterators.hpp>
20
21#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 Category;
34class CategoryIt;
35}
36
40 public:
41 class Iterator final
42 : public iterator_facade_base<Iterator, std::bidirectional_iterator_tag,
43 Category, std::ptrdiff_t, const Category*,
44 const Category&> {
45 public:
46 using implementation = details::CategoryIt;
47 using iterator_facade_base::operator++;
48 using iterator_facade_base::operator--;
49
51
52 LIEF_API Iterator(std::unique_ptr<details::CategoryIt> impl);
53
56
58 LIEF_API Iterator& operator=(Iterator&&) noexcept;
59
61
62 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
63
64 friend bool operator!=(const Iterator& LHS, const Iterator& RHS) {
65 return !(LHS == RHS);
66 }
67
68 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
70
71 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
73
74 LIEF_API const Category& operator*() const;
75
76 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
78
81 LIEF_API std::unique_ptr<Category> yield();
82
83 private:
84 void load() const;
85
86 std::unique_ptr<details::CategoryIt> impl_;
87 mutable std::unique_ptr<Category> cached_;
88 };
89
90 public:
93
96
99
100 Category(std::unique_ptr<details::Category> impl);
101
103 std::string name() const;
104
106 std::string class_name() const;
107
110
113
116
120 std::string to_decl(const DeclOpt& opt = DeclOpt()) const;
121
123
124 private:
125 std::unique_ptr<details::Category> impl_;
126};
127
128}
129}
130#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
std::unique_ptr< Category > yield()
Transfer ownership of the category at the current position to the caller. Returns nullptr if the iter...
Iterator(std::unique_ptr< details::CategoryIt > impl)
const Category * operator->() const
Iterator & operator=(const Iterator &)
Iterator(Iterator &&) noexcept
details::CategoryIt implementation
Definition Category.hpp:46
const Category & operator*() const
This class represents an Objective-C category (e.g. @interface NSString (MyAdditions)).
Definition Category.hpp:39
std::string class_name() const
(demangled) name of the class extended by this category
iterator_range< Property::Iterator > properties_t
Iterator for the properties declared by this category.
Definition Category.hpp:98
std::string to_decl(const DeclOpt &opt=DeclOpt()) const
Generate a header-like string for this specific category.
properties_t properties() const
Iterator over the properties of this category.
std::string name() const
Name of the category.
iterator_range< Method::Iterator > methods_t
Iterator for the category's methods.
Definition Category.hpp:92
protocols_t protocols() const
Iterator over the different protocols adopted by this category.
Category(std::unique_ptr< details::Category > impl)
methods_t methods() const
Iterator over the different methods defined by this category.
iterator_range< Protocol::Iterator > protocols_t
Iterator for the protocols adopted by this category.
Definition Category.hpp:95
#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