LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
DWARF/types/Enum.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_DWARF_TYPE_ENUM_H
16#define LIEF_DWARF_TYPE_ENUM_H
17
18#include "LIEF/visibility.h"
19#include "LIEF/optional.hpp"
20#include "LIEF/DWARF/Type.hpp"
21
22namespace LIEF {
23namespace dwarf {
24namespace types {
25
26namespace details {
27class EnumEntry;
28}
29
31class LIEF_API Enum : public Type {
32 public:
33 template<typename... Args,
34 typename = typename std::
35 enable_if<std::is_constructible<Type, Args&&...>::value>::type>
36 Enum(Args&&... args) :
37 Type(std::forward<Args>(args)...) {}
38
39 Enum(const Enum&) = delete;
40 Enum& operator=(const Enum&) = delete;
41
42 Enum(Enum&&) noexcept = default;
43 Enum& operator=(Enum&&) noexcept = default;
44
48 public:
49 Entry(std::unique_ptr<details::EnumEntry> impl);
50 Entry(Entry&& other) noexcept;
51 Entry& operator=(Entry&& other) noexcept;
52
53 Entry(const Entry&) = delete;
54 Entry& operator=(const Entry&) = delete;
55
57 std::string name() const;
58
61
63
64 private:
65 std::unique_ptr<details::EnumEntry> impl_;
66 };
67
69 std::vector<Entry> entries() const;
70
73
75 optional<Entry> find_entry(int64_t value) const;
76
77 static bool classof(const Type* type) {
78 return type->kind() == Type::KIND::ENUM;
79 }
80
81 ~Enum() override;
82
83 protected:
84 mutable std::unique_ptr<Type> underlying_;
85};
86
87}
88}
89}
90#endif
@ ENUM
Definition DWARF/Type.hpp:155
Type(std::unique_ptr< details::Type > impl)
This class represents an enum entry which is essentially composed of a name and its value (integer).
Definition DWARF/types/Enum.hpp:47
Entry & operator=(Entry &&other) noexcept
Entry(Entry &&other) noexcept
Entry(const Entry &)=delete
optional< int64_t > value() const
Enum entry's value (if any).
Entry(std::unique_ptr< details::EnumEntry > impl)
std::string name() const
Enum entry's name.
Entry & operator=(const Entry &)=delete
const Type * underlying_type() const
The underlying type that is used to encode this enum.
Enum(Args &&... args)
Definition DWARF/types/Enum.hpp:36
Enum(Enum &&) noexcept=default
optional< Entry > find_entry(int64_t value) const
Try to find the enum matching the given value.
std::vector< Entry > entries() const
Return the different entries associated with this enum.
static bool classof(const Type *type)
Definition DWARF/types/Enum.hpp:77
Enum & operator=(const Enum &)=delete
Enum(const Enum &)=delete
Definition optional.hpp:23
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition DWARF/types/ClassLike.hpp:26
Definition DWARF/types/Array.hpp:23
Namespace for the DWARF debug format.
Definition DWARF/CompilationUnit.hpp:28
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:45