LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
PDB/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_PDB_TYPE_ENUM_H
16#define LIEF_PDB_TYPE_ENUM_H
17
18#include "LIEF/PDB/Type.hpp"
20#include "LIEF/visibility.h"
21
22#include <string_view>
23
24namespace LIEF::pdb::types {
25
26namespace details {
27class EnumEntry;
28}
29
31class LIEF_API Enum : public Type {
32 public:
33 template<typename... Args,
34 typename = std::enable_if_t<std::is_constructible_v<Type, Args&&...>>>
35 Enum(Args&&... args) :
36 Type(std::forward<Args>(args)...) {}
37
41 public:
42 Entry(std::unique_ptr<details::EnumEntry> impl LIEF_LIFETIMEBOUND);
43 Entry(Entry&& other) noexcept;
44 Entry& operator=(Entry&& other) noexcept;
45
47 std::string_view name() const LIEF_LIFETIMEBOUND;
48
50 int64_t value() const;
51
53
54 private:
55 std::unique_ptr<details::EnumEntry> impl_;
56 };
57
59 std::string_view unique_name() const LIEF_LIFETIMEBOUND;
60
62 std::vector<Entry> entries() const LIEF_LIFETIMEBOUND;
63
66
68 std::optional<Entry> find_entry(int64_t value) const LIEF_LIFETIMEBOUND;
69
70 static bool classof(const Type* type) {
71 return type->kind() == Type::KIND::ENUM;
72 }
73
74 ~Enum() override;
75
76 protected:
77 mutable std::unique_ptr<Type> underlying_;
78};
79
80}
81
82
83#endif
Type(std::unique_ptr< details::Type > impl)
@ ENUM
Definition PDB/Type.hpp:89
This class represents an enum entry which is essentially composed of a name and its value (integer).
Definition PDB/types/Enum.hpp:40
std::string_view name() const
Enum entry's name.
Entry(Entry &&other) noexcept
int64_t value() const
Enum entry's value (if any).
Entry & operator=(Entry &&other) noexcept
Entry(std::unique_ptr< details::EnumEntry > impl)
std::vector< Entry > entries() const
Return the different entries associated with this enum.
const Type * underlying_type() const
The underlying type that is used to encode this enum.
std::optional< Entry > find_entry(int64_t value) const
Try to find the enum matching the given value.
std::string_view unique_name() const
Enum's mangled name.
Enum(Args &&... args)
Definition PDB/types/Enum.hpp:35
static bool classof(const Type *type)
Definition PDB/types/Enum.hpp:70
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition PDB/types/Attribute.hpp:31
Definition PDB/types/Array.hpp:23
#define LIEF_API
Definition visibility.h:45