LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
PDB/types/Attribute.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_ATTRIBUTE_H
16#define LIEF_PDB_TYPE_ATTRIBUTE_H
17
18#include "LIEF/visibility.h"
19
20#include <cstdint>
21#include <string>
22#include <memory>
23
24namespace LIEF {
25namespace pdb {
26class Type;
27namespace types {
28
29namespace details {
30class Attribute;
31class AttributeIt;
32}
33
37 public:
39 public:
40 using iterator_category = std::forward_iterator_tag;
41 using value_type = std::unique_ptr<Attribute>;
42 using difference_type = std::ptrdiff_t;
45 using implementation = details::AttributeIt;
46
47 class LIEF_API PointerProxy {
48 // Inspired from LLVM's iterator_facade_base
49 friend class Iterator;
50
51 public:
53 return R.get();
54 }
55
56 private:
57 value_type R;
58
59 template<typename RefT>
60 PointerProxy(RefT&& R) :
61 R(std::forward<RefT>(R)) {
62 } // NOLINT(bugprone-forwarding-reference-overload)
63 };
65 Iterator(Iterator&&) noexcept;
66 Iterator(std::unique_ptr<details::AttributeIt> impl);
68
69 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
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<Attribute> operator*() const;
83
85 return static_cast<const Iterator*>(this)->operator*();
86 }
87
88 private:
89 std::unique_ptr<details::AttributeIt> impl_;
90 };
91
92 public:
93 Attribute(std::unique_ptr<details::Attribute> impl);
94
96 std::string name() const;
97
99 std::unique_ptr<Type> type() const;
100
102 uint64_t field_offset() const;
103
105
106 private:
107 std::unique_ptr<details::Attribute> impl_;
108};
109
110}
111}
112}
113#endif
This is the base class for any PDB type.
Definition PDB/Type.hpp:34
Definition PDB/types/Attribute.hpp:47
pointer operator->() const
Definition PDB/types/Attribute.hpp:52
friend class Iterator
Definition PDB/types/Attribute.hpp:49
std::ptrdiff_t difference_type
Definition PDB/types/Attribute.hpp:42
std::forward_iterator_tag iterator_category
Definition PDB/types/Attribute.hpp:40
details::AttributeIt implementation
Definition PDB/types/Attribute.hpp:45
std::unique_ptr< Attribute > operator*() const
std::unique_ptr< Attribute > value_type
Definition PDB/types/Attribute.hpp:41
Attribute & reference
Definition PDB/types/Attribute.hpp:44
Iterator operator++(int)
Definition PDB/types/Attribute.hpp:76
Attribute * pointer
Definition PDB/types/Attribute.hpp:43
PointerProxy operator->() const
Definition PDB/types/Attribute.hpp:84
This class represents an attribute (LF_MEMBER) in an aggregate (class, struct, union,...
Definition PDB/types/Attribute.hpp:36
std::unique_ptr< Type > type() const
Type of this attribute.
std::string name() const
Name of the attribute.
Attribute(std::unique_ptr< details::Attribute > impl)
uint64_t field_offset() const
Offset of this attribute in the aggregate.
Definition PDB/types/Attribute.hpp:29
Definition PDB/types/Array.hpp:23
Definition BuildMetadata.hpp:24
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:43