LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
DWARF/types/ClassLike.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_DWARF_TYPE_STRUCTURE_H
16#define LIEF_DWARF_TYPE_STRUCTURE_H
17
18#include "LIEF/visibility.h"
19#include "LIEF/DWARF/Type.hpp"
20
21namespace LIEF {
22namespace dwarf {
23namespace types {
24
25namespace details {
26class Member;
27}
28
31class LIEF_API ClassLike : public Type {
32 public:
33 using Type::Type;
34
36 class Member {
37 public:
38 Member(std::unique_ptr<details::Member> impl);
39 Member(Member&& other) noexcept;
40 Member& operator=(Member&& other) noexcept;
41
43 std::string name() const;
44
49
66
68 std::unique_ptr<Type> type() const;
69
70 bool is_external() const;
71
72 bool is_declaration() const;
73
75 private:
76 std::unique_ptr<details::Member> impl_;
77 };
78
79 static bool classof(const Type* type) {
80 const auto kind = type->kind();
81 return kind == Type::KIND::CLASS || kind == Type::KIND::STRUCT || kind == Type::KIND::UNION;
82 }
83
85 std::vector<Member> members() const;
86
88 std::unique_ptr<Member> find_member(uint64_t offset) const;
89
90 ~ClassLike() override;
91};
92
95 public:
96 using ClassLike::ClassLike;
97
98 static bool classof(const Type* type) {
99 return type->kind() == Type::KIND::STRUCT;
100 }
101
102 ~Structure() override;
103};
104
106class LIEF_API Class : public ClassLike {
107 public:
108 using ClassLike::ClassLike;
109
110 static bool classof(const Type* type) {
111 return type->kind() == Type::KIND::CLASS;
112 }
113
114 ~Class() override;
115};
116
118class LIEF_API Union : public ClassLike {
119 public:
120 using ClassLike::ClassLike;
121
122 static bool classof(const Type* type) {
123 return type->kind() == Type::KIND::UNION;
124 }
125
126 ~Union() override;
127};
128
129}
130}
131}
132#endif
133
134
This class represents a DWARF Type which includes:
Definition DWARF/Type.hpp:47
KIND kind() const
This represents a class/struct/union attribute.
Definition DWARF/types/ClassLike.hpp:36
Member(std::unique_ptr< details::Member > impl)
std::unique_ptr< Type > type() const
Type of the current member.
Member & operator=(Member &&other) noexcept
Member(Member &&other) noexcept
std::string name() const
Name of the member.
result< uint64_t > offset() const
Offset of the current member in the struct/union/class.
result< uint64_t > bit_offset() const
Offset of the current member in bits the struct/union/class.
This class abstracts a DWARF aggregate: DW_TAG_structure_type, DW_TAG_class_type, DW_TAG_union_type.
Definition DWARF/types/ClassLike.hpp:31
std::vector< Member > members() const
Return the list of all the attributes defined in this class-like type.
std::unique_ptr< Member > find_member(uint64_t offset) const
Try to find the attribute at the given offset.
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:79
This class represents a DWARF class type (DW_TAG_class_type)
Definition DWARF/types/ClassLike.hpp:106
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:110
This class represents a DWARF struct type (DW_TAG_structure_type)
Definition DWARF/types/ClassLike.hpp:94
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:98
This class represents a DWARF class type (DW_TAG_union_type)
Definition DWARF/types/ClassLike.hpp:118
static bool classof(const Type *type)
Definition DWARF/types/ClassLike.hpp:122
LIEF namespace.
Definition Abstract/Binary.hpp:32
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:74
#define LIEF_API
Definition visibility.h:41