LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
PDB/types/Method.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_PDB_TYPE_METHOD_H
16#define LIEF_PDB_TYPE_METHOD_H
17
18#include "LIEF/visibility.h"
19
20#include <string>
21#include <memory>
22#include <cstdint>
23
24namespace LIEF {
25namespace pdb {
26class Type;
27namespace types {
28
29namespace details {
30class Method;
31class MethodIt;
32}
33
37 public:
39 public:
40 using iterator_category = std::forward_iterator_tag;
41 using value_type = std::unique_ptr<Method>;
42 using difference_type = std::ptrdiff_t;
43 using pointer = Method*;
44 using reference = Method&;
45 using implementation = details::MethodIt;
46
47 class LIEF_API PointerProxy {
48 // Inspired from LLVM's iterator_facade_base
49 friend class Iterator;
50 public:
51 pointer operator->() const { return R.get(); }
52
53 private:
54 value_type R;
55
56 template <typename RefT>
57 PointerProxy(RefT &&R) : R(std::forward<RefT>(R)) {} // NOLINT(bugprone-forwarding-reference-overload)
58 };
60 Iterator(Iterator&&) noexcept;
61 Iterator(std::unique_ptr<details::MethodIt> impl);
63
64 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
65
66 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
67 return !(LHS == RHS);
68 }
69
71
73 Iterator tmp = *static_cast<Iterator*>(this);
74 ++*static_cast<Iterator *>(this);
75 return tmp;
76 }
77
78 std::unique_ptr<Method> operator*() const;
79
81 return static_cast<const Iterator*>(this)->operator*();
82 }
83
84 private:
85 std::unique_ptr<details::MethodIt> impl_;
86 };
87 public:
89 enum class TYPE {
90 VANILLA = 0x00,
91 VIRTUAL = 0x01,
92 STATIC = 0x02,
93 FRIEND = 0x03,
94 INTRODUCING_VIRTUAL = 0x04,
95 PURE_VIRTUAL = 0x05,
96 PURE_INTRODUCING_VIRTUAL = 0x06
97 };
98
100 enum class ACCESS : uint8_t {
101 NONE = 0,
102 PRIVATE = 1,
103 PROTECTED = 2,
104 PUBLIC = 3
105 };
106
107 Method(std::unique_ptr<details::Method> impl);
108
110 std::string name() const;
111
113 TYPE type() const;
114
116 ACCESS access() const;
117
119
120 private:
121 std::unique_ptr<details::Method> impl_;
122};
123
124}
125}
126}
127#endif
128
This is the base class for any PDB type.
Definition PDB/Type.hpp:34
Definition PDB/types/Method.hpp:47
pointer operator->() const
Definition PDB/types/Method.hpp:51
friend class Iterator
Definition PDB/types/Method.hpp:49
std::unique_ptr< Method > value_type
Definition PDB/types/Method.hpp:41
std::ptrdiff_t difference_type
Definition PDB/types/Method.hpp:42
PointerProxy operator->() const
Definition PDB/types/Method.hpp:80
Method * pointer
Definition PDB/types/Method.hpp:43
std::unique_ptr< Method > operator*() const
Method & reference
Definition PDB/types/Method.hpp:44
details::MethodIt implementation
Definition PDB/types/Method.hpp:45
Iterator(Iterator &&) noexcept
Iterator operator++(int)
Definition PDB/types/Method.hpp:72
std::forward_iterator_tag iterator_category
Definition PDB/types/Method.hpp:40
TYPE type() const
Type/Properties of the method (virtual, static, etc.).
Method(std::unique_ptr< details::Method > impl)
std::string name() const
Name of the method.
ACCESS access() const
Visibility access (public, private, ...).
ACCESS
Visibility access for the method.
Definition PDB/types/Method.hpp:100
TYPE
The type (or property) of the method.
Definition PDB/types/Method.hpp:89
Definition PDB/types/Attribute.hpp:29
Definition PDB/types/Array.hpp:23
Definition BuildMetadata.hpp:24
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:41