LIEF: Library to Instrument Executable Formats
Version 1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
lief-install
x86_64
static
include
LIEF
PDB
PDB/Type.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_TYPE_H
16
#define LIEF_PDB_TYPE_H
17
#include <cstdint>
18
#include <memory>
19
#include <string>
20
#include <type_traits>
21
#include <utility>
22
23
#include "
LIEF/iterators.hpp
"
24
#include "
LIEF/visibility.h
"
25
#include "
LIEF/optional.hpp
"
26
#include "
LIEF/DebugDeclOpt.hpp
"
27
28
namespace
LIEF
{
29
namespace
pdb
{
30
31
namespace
details
{
32
class
Type;
33
class
TypeIt;
34
}
35
37
class
LIEF_API
Type
{
38
public
:
39
class
Iterator
final
40
:
public
iterator_facade_base
<Iterator, std::forward_iterator_tag, Type,
41
std::ptrdiff_t, const Type*, const Type&> {
42
public
:
43
using
implementation
= details::TypeIt;
44
using
iterator_facade_base::operator++;
45
46
LIEF_API
Iterator
();
47
48
LIEF_API
Iterator
(std::unique_ptr<details::TypeIt> impl);
49
50
LIEF_API
Iterator
(
const
Iterator
&);
51
LIEF_API
Iterator
&
operator=
(
const
Iterator
&);
52
53
LIEF_API
Iterator
(
Iterator
&&) noexcept;
54
LIEF_API
Iterator
& operator=(
Iterator
&&) noexcept;
55
56
LIEF_API
~
Iterator
();
57
58
friend
LIEF_API
bool
operator==(const
Iterator
& LHS, const
Iterator
& RHS);
59
60
friend
bool
operator!=(const
Iterator
& LHS, const
Iterator
& RHS) {
61
return
!(LHS == RHS);
62
}
63
64
// NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
65
LIEF_API
Iterator
&
operator++
();
66
67
LIEF_API
const
Type
&
operator*
()
const
;
68
69
// NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
70
LIEF_API
const
Type
*
operator->
()
const
;
71
74
LIEF_API
std::unique_ptr<Type>
yield
();
75
76
private
:
77
void
load()
const
;
78
79
std::unique_ptr<details::TypeIt> impl_;
80
mutable
std::unique_ptr<Type> cached_;
81
};
82
83
LIEF_LOCAL
Type
(std::unique_ptr<details::Type> impl);
84
85
enum class
KIND
{
86
UNKNOWN = 0,
87
CLASS,
88
POINTER,
89
SIMPLE,
90
ENUM,
91
FUNCTION,
92
MODIFIER,
93
BITFIELD,
94
ARRAY,
95
UNION,
96
STRUCTURE,
97
INTERFACE,
98
};
99
100
KIND
kind
()
const
;
101
104
optional<uint64_t>
size
()
const
;
105
107
optional<std::string>
name
()
const
;
108
110
std::string
to_decl
(
const
DeclOpt
& opt =
DeclOpt
())
const
;
111
112
template
<
class
T>
113
const
T*
as
()
const
{
114
if
(T::classof(
this
)) {
115
return
static_cast<
const
T*
>
(
this
);
116
}
117
return
nullptr
;
118
}
119
120
static
std::unique_ptr<Type>
create
(std::unique_ptr<details::Type> impl);
121
122
virtual
~Type
();
123
124
protected
:
125
std::unique_ptr<details::Type> impl_;
126
};
127
128
}
129
}
130
#endif
DebugDeclOpt.hpp
LIEF::iterator_facade_base
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition
iterators.hpp:729
LIEF::optional
Definition
optional.hpp:23
LIEF::pdb::Type::Iterator::Iterator
Iterator(const Iterator &)
LIEF::pdb::Type::Iterator::Iterator
Iterator(Iterator &&) noexcept
LIEF::pdb::Type::Iterator::operator=
Iterator & operator=(const Iterator &)
LIEF::pdb::Type::Iterator::operator++
Iterator & operator++()
LIEF::pdb::Type::Iterator::Iterator
Iterator()
LIEF::pdb::Type::Iterator::Iterator
Iterator(std::unique_ptr< details::TypeIt > impl)
LIEF::pdb::Type::Iterator::operator->
const Type * operator->() const
LIEF::pdb::Type::Iterator::operator*
const Type & operator*() const
LIEF::pdb::Type::Iterator::yield
std::unique_ptr< Type > yield()
Transfer ownership of the type at the current position to the caller. Returns nullptr if the iterator...
LIEF::pdb::Type::Iterator::implementation
details::TypeIt implementation
Definition
PDB/Type.hpp:43
LIEF::pdb::Type::as
const T * as() const
Definition
PDB/Type.hpp:113
LIEF::pdb::Type::Type
Type(std::unique_ptr< details::Type > impl)
LIEF::pdb::Type::to_decl
std::string to_decl(const DeclOpt &opt=DeclOpt()) const
Generates a C/C++ definition for this type.
LIEF::pdb::Type::KIND
KIND
Definition
PDB/Type.hpp:85
LIEF::pdb::Type::~Type
virtual ~Type()
LIEF::pdb::Type::create
static std::unique_ptr< Type > create(std::unique_ptr< details::Type > impl)
LIEF::pdb::Type::size
optional< uint64_t > size() const
Size of the type. This size should match the value of sizeof(...) applied to this type.
LIEF::pdb::Type::name
optional< std::string > name() const
Type's name (if present).
LIEF::pdb::Type::kind
KIND kind() const
iterators.hpp
LIEF::pdb::details
Definition
BuildMetadata.hpp:26
LIEF::pdb
Definition
BuildMetadata.hpp:24
LIEF
LIEF namespace.
Definition
Abstract/Binary.hpp:40
optional.hpp
LIEF::DeclOpt
Configuration options for generated code from debug info.
Definition
DebugDeclOpt.hpp:25
visibility.h
LIEF_API
#define LIEF_API
Definition
visibility.h:45
LIEF_LOCAL
#define LIEF_LOCAL
Definition
visibility.h:46
Generated by
1.17.0