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/iterators.hpp"
23#include "LIEF/visibility.h"
24
25namespace LIEF {
26namespace pdb {
27
28namespace details {
29class PublicSymbol;
30class PublicSymbolIt;
31}
32
36 public:
37 class Iterator final
38 : public iterator_facade_base<Iterator, std::forward_iterator_tag,
39 PublicSymbol, std::ptrdiff_t,
40 const PublicSymbol*, const PublicSymbol&> {
41 public:
42 using implementation = details::PublicSymbolIt;
43 using iterator_facade_base::operator++;
44
46
47 LIEF_API Iterator(std::unique_ptr<details::PublicSymbolIt> impl);
48
51
53 LIEF_API Iterator& operator=(Iterator&&) noexcept;
54
56
57 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
58 LIEF_API Iterator& operator++();
59
60 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
61
62 friend bool operator!=(const Iterator& LHS, const Iterator& RHS) {
63 return !(LHS == RHS);
64 }
65
67
68 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
70
73 LIEF_API std::unique_ptr<PublicSymbol> yield();
74
75 private:
76 void load() const;
77
78 std::unique_ptr<details::PublicSymbolIt> impl_;
79 mutable std::unique_ptr<PublicSymbol> cached_;
80 };
81 PublicSymbol(std::unique_ptr<details::PublicSymbol> impl);
83
84 enum class FLAGS : uint32_t {
85 NONE = 0,
86 CODE = 1 << 0,
87 FUNCTION = 1 << 1,
88 MANAGED = 1 << 2,
89 MSIL = 1 << 3,
90 };
91
93 std::string name() const;
94
96 std::string demangled_name() const;
97
101 std::string section_name() const;
102
106 uint32_t RVA() const;
107
108 std::string to_string() const;
109
110 LIEF_API friend std::ostream& operator<<(std::ostream& os,
111 const PublicSymbol& sym) {
112 os << sym.to_string();
113 return os;
114 }
115
116 private:
117 std::unique_ptr<details::PublicSymbol> impl_;
118};
119
120}
121}
122#endif
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterators.hpp:729
std::unique_ptr< PublicSymbol > yield()
Transfer ownership of the public symbol at the current position to the caller. Returns nullptr if the...
Iterator(std::unique_ptr< details::PublicSymbolIt > impl)
const PublicSymbol & operator*() const
Iterator & operator=(const Iterator &)
Iterator(Iterator &&) noexcept
const PublicSymbol * operator->() const
details::PublicSymbolIt implementation
Definition PublicSymbol.hpp:42
friend std::ostream & operator<<(std::ostream &os, const PublicSymbol &sym)
Definition PublicSymbol.hpp:110
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:84
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