LIEF: Library to Instrument Executable Formats Version 0.15.1
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:
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*;
40 using implementation = details::FunctionIt;
41
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
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
66
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
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
86 std::string name() const;
87
89 uint32_t RVA() const;
90
92 uint32_t code_size() const;
93
95 std::string section_name() const;
96
99
100 private:
101 std::unique_ptr<details::Function> impl_;
102};
103
104}
105}
106#endif
107
Definition PDB/Function.hpp:42
pointer operator->() const
Definition PDB/Function.hpp:46
Definition PDB/Function.hpp:33
std::unique_ptr< Function > value_type
Definition PDB/Function.hpp:36
Iterator operator++(int)
Definition PDB/Function.hpp:67
friend bool operator==(const Iterator &LHS, const Iterator &RHS)
std::forward_iterator_tag iterator_category
Definition PDB/Function.hpp:35
details::FunctionIt implementation
Definition PDB/Function.hpp:40
Iterator(const Iterator &)
std::unique_ptr< Function > operator*() const
PointerProxy operator->() const
Definition PDB/Function.hpp:75
std::ptrdiff_t difference_type
Definition PDB/Function.hpp:37
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.
LIEF namespace.
Definition Abstract/Binary.hpp:32
This structure holds a debug location (source filename & line)
Definition debug_loc.hpp:23
#define LIEF_API
Definition visibility.h:41