LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
PDB/Function.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2024 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_FUNCTION_H
16#define LIEF_PDB_FUNCTION_H
17#include <memory>
18#include <string>
19
20#include "LIEF/visibility.h"
21#include "LIEF/debug_loc.hpp"
22
23namespace LIEF {
24namespace pdb {
25
26namespace details {
27class Function;
28class FunctionIt;
29}
30
32 public:
33 class LIEF_API Iterator {
34 public:
35 using iterator_category = std::forward_iterator_tag;
36 using value_type = std::unique_ptr<Function>;
37 using difference_type = std::ptrdiff_t;
38 using pointer = Function*;
39 using reference = Function&;
40 using implementation = details::FunctionIt;
41
42 class LIEF_API PointerProxy {
43 // Inspired from LLVM's iterator_facade_base
44 friend class Iterator;
45 public:
46 pointer operator->() const { return R.get(); }
47
48 private:
49 value_type R;
50
51 template <typename RefT>
52 PointerProxy(RefT &&R) : R(std::forward<RefT>(R)) {} // NOLINT(bugprone-forwarding-reference-overload)
53 };
54
55 Iterator(const Iterator&);
56 Iterator(Iterator&&);
57 Iterator(std::unique_ptr<details::FunctionIt> impl);
59
60 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
61 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
62 return !(LHS == RHS);
63 }
64
65 Iterator& operator++();
66
67 Iterator operator++(int) {
68 Iterator tmp = *static_cast<Iterator*>(this);
69 ++*static_cast<Iterator *>(this);
70 return tmp;
71 }
72
73 std::unique_ptr<Function> operator*() const;
74
75 PointerProxy operator->() const {
76 return static_cast<const Iterator*>(this)->operator*();
77 }
78
79 private:
80 std::unique_ptr<details::FunctionIt> impl_;
81 };
82 Function(std::unique_ptr<details::Function> impl);
84 std::string name() const;
87 uint32_t RVA() const;
90 uint32_t code_size() const;
93 std::string section_name() const;
96 debug_location_t debug_location() const;
99
100 private:
101 std::unique_ptr<details::Function> impl_;
102};
103
104}
105}
106#endif
107
pointer operator->() const
Definition PDB/Function.hpp:46
Iterator operator++(int)
Definition PDB/Function.hpp:67
friend bool operator==(const Iterator &LHS, const Iterator &RHS)
Iterator(const Iterator &)
std::unique_ptr< Function > operator*() const
PointerProxy operator->() const
Definition PDB/Function.hpp:75
friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
Definition PDB/Function.hpp:61
Iterator(std::unique_ptr< details::FunctionIt > impl)
Definition PDB/Function.hpp:31
std::string section_name() const
The name of the section in which this function is defined.
uint32_t code_size() const
The size of the function.
Function(std::unique_ptr< details::Function > impl)
std::string name() const
The name of the function (this name is usually demangled)
debug_location_t debug_location() const
Original source code location.
uint32_t RVA() const
The Relative Virtual Address of the function.
Definition PDB/CompilationUnit.hpp:29
Definition PDB/CompilationUnit.hpp:27
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41