LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
PublicSymbol.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_PUBLIC_SYMBOL_H
16#define LIEF_PDB_PUBLIC_SYMBOL_H
17#include <cstdint>
18#include <memory>
19#include <string>
20#include <ostream>
21
22#include "LIEF/visibility.h"
23
24namespace LIEF {
25namespace pdb {
26
27namespace details {
28class PublicSymbol;
29class PublicSymbolIt;
30}
31
35 public:
37 public:
38 using iterator_category = std::forward_iterator_tag;
39 using value_type = std::unique_ptr<PublicSymbol>;
40 using difference_type = std::ptrdiff_t;
43 using implementation = details::PublicSymbolIt;
44
45 class LIEF_API PointerProxy {
46 // Inspired from LLVM's iterator_facade_base
47 friend class Iterator;
48
49 public:
51 return R.get();
52 }
53
54 private:
55 value_type R;
56
57 template<typename RefT>
58 PointerProxy(RefT&& R) :
59 R(std::forward<RefT>(R)) {
60 } // NOLINT(bugprone-forwarding-reference-overload)
61 };
62
65 Iterator(std::unique_ptr<details::PublicSymbolIt> impl);
67
68 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
69
70 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
71 return !(LHS == RHS);
72 }
73
75
77 Iterator tmp = *static_cast<Iterator*>(this);
78 ++*static_cast<Iterator*>(this);
79 return tmp;
80 }
81
82 std::unique_ptr<PublicSymbol> operator*() const;
83
85 return static_cast<const Iterator*>(this)->operator*();
86 }
87
88 private:
89 std::unique_ptr<details::PublicSymbolIt> impl_;
90 };
91 PublicSymbol(std::unique_ptr<details::PublicSymbol> impl);
93
94 enum class FLAGS : uint32_t {
95 NONE = 0,
96 CODE = 1 << 0,
97 FUNCTION = 1 << 1,
98 MANAGED = 1 << 2,
99 MSIL = 1 << 3,
100 };
101
103 std::string name() const;
104
106 std::string demangled_name() const;
107
111 std::string section_name() const;
112
116 uint32_t RVA() const;
117
118 std::string to_string() const;
119
120 LIEF_API friend std::ostream& operator<<(std::ostream& os,
121 const PublicSymbol& sym) {
122 os << sym.to_string();
123 return os;
124 }
125
126 private:
127 std::unique_ptr<details::PublicSymbol> impl_;
128};
129
130}
131}
132#endif
pointer operator->() const
Definition PublicSymbol.hpp:50
friend class Iterator
Definition PublicSymbol.hpp:47
Iterator(std::unique_ptr< details::PublicSymbolIt > impl)
friend bool operator==(const Iterator &LHS, const Iterator &RHS)
PublicSymbol & reference
Definition PublicSymbol.hpp:42
std::unique_ptr< PublicSymbol > operator*() const
Iterator operator++(int)
Definition PublicSymbol.hpp:76
PublicSymbol * pointer
Definition PublicSymbol.hpp:41
std::forward_iterator_tag iterator_category
Definition PublicSymbol.hpp:38
std::unique_ptr< PublicSymbol > value_type
Definition PublicSymbol.hpp:39
PointerProxy operator->() const
Definition PublicSymbol.hpp:84
std::ptrdiff_t difference_type
Definition PublicSymbol.hpp:40
friend bool operator!=(const Iterator &LHS, const Iterator &RHS)
Definition PublicSymbol.hpp:70
details::PublicSymbolIt implementation
Definition PublicSymbol.hpp:43
friend std::ostream & operator<<(std::ostream &os, const PublicSymbol &sym)
Definition PublicSymbol.hpp:120
PublicSymbol(std::unique_ptr< details::PublicSymbol > impl)
std::string name() const
Name of the symbol.
std::string demangled_name() const
Demangled representation of the symbol.
std::string to_string() const
std::string section_name() const
Name of the section in which this symbol is defined (e.g. .text).
FLAGS
Definition PublicSymbol.hpp:94
uint32_t RVA() const
Relative Virtual Address of this symbol.
Definition BuildMetadata.hpp:26
Definition BuildMetadata.hpp:24
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:45