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
19#include "LIEF/iterators.hpp"
20#include "LIEF/visibility.h"
21
22#include <cstdint>
23#include <string>
24#include <memory>
25
26namespace LIEF {
27namespace pdb {
28class Type;
29namespace types {
30
31namespace details {
32class Attribute;
33class AttributeIt;
34}
35
39 public:
40 class Iterator final
41 : public iterator_facade_base<Iterator, std::forward_iterator_tag, Attribute,
42 std::ptrdiff_t, const Attribute*,
43 const Attribute&> {
44 public:
45 using implementation = details::AttributeIt;
46 using iterator_facade_base::operator++;
47
49
50 LIEF_API Iterator(std::unique_ptr<details::AttributeIt> impl);
51
54
56 LIEF_API Iterator& operator=(Iterator&&) noexcept;
57
59
60 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
61 friend bool operator!=(const Iterator& LHS, const Iterator& RHS) {
62 return !(LHS == RHS);
63 }
64
65 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
67
69
70 // NOLINTNEXTLINE(bugprone-derived-method-shadowing-base-method)
71 LIEF_API const Attribute* operator->() const LIEF_LIFETIMEBOUND;
72
75 LIEF_API std::unique_ptr<Attribute> yield();
76
77 private:
78 void load() const;
79
80 std::unique_ptr<details::AttributeIt> impl_;
81 mutable std::unique_ptr<Attribute> cached_;
82 };
83
84 public:
85 Attribute(std::unique_ptr<details::Attribute> impl);
86
88 std::string name() const;
89
91 std::unique_ptr<Type> type() const LIEF_LIFETIMEBOUND;
92
94 uint64_t field_offset() const;
95
97
98 private:
99 std::unique_ptr<details::Attribute> impl_;
100};
101
102}
103}
104}
105#endif
CRTP base class which implements the entire standard iterator facade in terms of a minimal subset of ...
Definition iterators.hpp:729
This is the base class for any PDB type.
Definition PDB/Type.hpp:36
std::unique_ptr< Attribute > yield()
Transfer ownership of the attribute at the current position to the caller. Returns nullptr if the ite...
details::AttributeIt implementation
Definition PDB/types/Attribute.hpp:45
Iterator(std::unique_ptr< details::AttributeIt > impl)
const Attribute & operator*() const
Iterator & operator=(const Iterator &)
This class represents an attribute (LF_MEMBER) in an aggregate (class, struct, union,...
Definition PDB/types/Attribute.hpp:38
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.
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition PDB/types/Attribute.hpp:31
Definition PDB/types/Array.hpp:24
Definition BuildMetadata.hpp:25
LIEF namespace.
Definition Abstract/Binary.hpp:41
#define LIEF_API
Definition visibility.h:45