LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
PDB/CompilationUnit.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_COMPILATION_UNIT_H
16#define LIEF_PDB_COMPILATION_UNIT_H
17#include <memory>
18#include <string>
19#include <vector>
20
21#include "LIEF/iterators.hpp"
22#include "LIEF/PDB/Function.hpp"
23
24#include "LIEF/visibility.h"
25
26namespace LIEF {
27namespace pdb {
28
29namespace details {
30class CompilationUnit;
31class CompilationUnitIt;
32}
33
36 public:
38 public:
39 using iterator_category = std::bidirectional_iterator_tag;
40 using value_type = std::unique_ptr<CompilationUnit>;
41 using difference_type = std::ptrdiff_t;
44 using implementation = details::CompilationUnitIt;
45
47 // Inspired from LLVM's iterator_facade_base
48 friend class Iterator;
49 public:
50 pointer operator->() const { return R.get(); }
51
52 private:
53 value_type R;
54
55 template <typename RefT>
56 PointerProxy(RefT &&R) : R(std::forward<RefT>(R)) {} // NOLINT(bugprone-forwarding-reference-overload)
57 };
58
61 Iterator(std::unique_ptr<details::CompilationUnitIt> impl);
63
64 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
65 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
66 return !(LHS == RHS);
67 }
68
71
73 Iterator tmp = *static_cast<Iterator*>(this);
74 --*static_cast<Iterator *>(this);
75 return tmp;
76 }
77
79 Iterator tmp = *static_cast<Iterator*>(this);
80 ++*static_cast<Iterator *>(this);
81 return tmp;
82 }
83
84 std::unique_ptr<CompilationUnit> operator*() const;
85
87 return static_cast<const Iterator*>(this)->operator*();
88 }
89
90 private:
91 std::unique_ptr<details::CompilationUnitIt> impl_;
92 };
93
96
98
99 CompilationUnit(std::unique_ptr<details::CompilationUnit> impl);
101
104 std::string module_name() const;
105
109 std::string object_filename() const;
110
114
119
120 private:
121 std::unique_ptr<details::CompilationUnit> impl_;
122};
123
124}
125}
126#endif
127
Definition iterators.hpp:486
Definition PDB/CompilationUnit.hpp:46
pointer operator->() const
Definition PDB/CompilationUnit.hpp:50
Definition PDB/CompilationUnit.hpp:37
Iterator operator--(int)
Definition PDB/CompilationUnit.hpp:72
std::unique_ptr< CompilationUnit > value_type
Definition PDB/CompilationUnit.hpp:40
Iterator operator++(int)
Definition PDB/CompilationUnit.hpp:78
PointerProxy operator->() const
Definition PDB/CompilationUnit.hpp:86
friend bool operator==(const Iterator &LHS, const Iterator &RHS)
details::CompilationUnitIt implementation
Definition PDB/CompilationUnit.hpp:44
std::bidirectional_iterator_tag iterator_category
Definition PDB/CompilationUnit.hpp:39
Iterator(std::unique_ptr< details::CompilationUnitIt > impl)
std::ptrdiff_t difference_type
Definition PDB/CompilationUnit.hpp:41
std::unique_ptr< CompilationUnit > operator*() const
friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
Definition PDB/CompilationUnit.hpp:65
This class represents a CompilationUnit (or Module) in a PDB file.
Definition PDB/CompilationUnit.hpp:35
sources_iterator sources() const
Iterator over the sources files that compose this compilation unit. These files also include headers ...
CompilationUnit(std::unique_ptr< details::CompilationUnit > impl)
std::string object_filename() const
Name of path to the original binary object (COFF, Archive) in which the compilation unit was located ...
std::string module_name() const
Name (or path) to the COFF object (.obj) associated with this compilation unit (e....
function_iterator functions() const
Return an iterator over the function defined in this compilation unit. If the PDB does not contain or...
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41