LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
PDB/types/Attribute.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2024 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 <string>
21#include <memory>
22
23namespace LIEF {
24namespace pdb {
25class Type;
26namespace types {
27
28namespace details {
29class Attribute;
30class AttributeIt;
31}
32class LIEF_API Attribute {
36 public:
37 class LIEF_API Iterator {
38 public:
39 using iterator_category = std::forward_iterator_tag;
40 using value_type = std::unique_ptr<Attribute>;
41 using difference_type = std::ptrdiff_t;
42 using pointer = Attribute*;
43 using reference = Attribute&;
44 using implementation = details::AttributeIt;
45
46 class LIEF_API PointerProxy {
47 // Inspired from LLVM's iterator_facade_base
48 friend class Iterator;
49 public:
50 pointer operator->() const { return R.get(); }
51
52 private:
53 value_type R;
54
55 template <typename RefT>
56 PointerProxy(RefT &&R) : R(std::forward<RefT>(R)) {} // NOLINT(bugprone-forwarding-reference-overload)
57 };
58 Iterator(const Iterator&);
59 Iterator(Iterator&&) noexcept;
60 Iterator(std::unique_ptr<details::AttributeIt> impl);
61 ~Iterator();
62
63 friend LIEF_API bool operator==(const Iterator& LHS, const Iterator& RHS);
64 friend LIEF_API bool operator!=(const Iterator& LHS, const Iterator& RHS) {
65 return !(LHS == RHS);
66 }
67
68 Iterator& operator++();
69
70 Iterator operator++(int) {
71 Iterator tmp = *static_cast<Iterator*>(this);
72 ++*static_cast<Iterator *>(this);
73 return tmp;
74 }
75
76 std::unique_ptr<Attribute> operator*() const;
77
78 PointerProxy operator->() const {
79 return static_cast<const Iterator*>(this)->operator*();
80 }
81
82 private:
83 std::unique_ptr<details::AttributeIt> impl_;
84 };
85 public:
86 Attribute(std::unique_ptr<details::Attribute> impl);
87 std::string name() const;
90 std::unique_ptr<Type> type() const;
93 uint64_t field_offset() const;
96
98
99 private:
100 std::unique_ptr<details::Attribute> impl_;
101};
102
103}
104}
105}
106#endif
107
This is the base class for any PDB type.
Definition PDB/Type.hpp:30
pointer operator->() const
Definition PDB/types/Attribute.hpp:50
std::unique_ptr< Attribute > operator*() const
Iterator operator++(int)
Definition PDB/types/Attribute.hpp:70
PointerProxy operator->() const
Definition PDB/types/Attribute.hpp:78
This class represents an attribute (LF_MEMBER) in an aggregate (class, struct, union,...
Definition PDB/types/Attribute.hpp:35
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:28
Definition PDB/types/Array.hpp:23
Definition PDB/CompilationUnit.hpp:27
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41