LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
ResourceDialogRegular.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 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_PE_RESOURCE_DIALOG_REGULAR_H
16#define LIEF_PE_RESOURCE_DIALOG_REGULAR_H
17
18#include <memory>
19
21#include "LIEF/errors.hpp"
22#include "LIEF/iterators.hpp"
23#include "LIEF/visibility.h"
24
25namespace LIEF {
26class BinaryStream;
27
28namespace PE {
29
35 public:
37
43 public:
44 Item() = default;
45 Item(const Item&) = default;
46 Item& operator=(const Item&) = default;
47
48 Item(Item&&) = default;
49 Item& operator=(Item&&) = default;
50
52
53 std::string to_string() const override;
54
55 ~Item() override = default;
56 };
57
61 uint16_t point_size = 0;
62 std::u16string name;
63
64 bool is_defined() const {
65 return point_size != 0;
66 }
67
68 operator bool() const {
69 return is_defined();
70 }
71
72 std::string to_string() const;
73
74 LIEF_API friend std::ostream& operator<<(std::ostream& os,
75 const font_t& font) {
76 os << font.to_string();
77 return os;
78 }
79 };
80
81 using items_t = std::vector<Item>;
84
87
90
93
94 static std::unique_ptr<ResourceDialogRegular> create(BinaryStream& stream);
95
96 std::unique_ptr<ResourceDialog> clone() const override {
97 return std::make_unique<ResourceDialogRegular>(*this);
98 }
99
100 static bool classof(const ResourceDialog* dialog) {
101 return dialog->type() == ResourceDialog::TYPE::REGULAR;
102 }
103
104 std::string to_string() const override;
105
107 uint32_t nb_items() const {
108 return items_.size();
109 }
110
113 return items_;
114 }
115
117 return items_;
118 }
119
121 void add_item(const Item& item) {
122 items_.push_back(item);
123 }
124
126 const font_t& font() const {
127 return font_;
128 }
129
130 ResourceDialogRegular& font(uint16_t pointsize, std::u16string name) {
131 font_.name = std::move(name);
132 font_.point_size = pointsize;
133 return *this;
134 }
135
137 font_ = std::move(f);
138 return *this;
139 }
140
141 void accept(Visitor& visitor) const override;
142
143 ~ResourceDialogRegular() override = default;
144
145 protected:
146 font_t font_;
147 items_t items_;
148};
149
150}
151}
152
153
154#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:34
This class represents a DLGTEMPLATE item: DLGITEMTEMPLATE.
Definition ResourceDialogRegular.hpp:42
Item & operator=(const Item &)=default
std::string to_string() const override
Item & operator=(Item &&)=default
static result< Item > parse(BinaryStream &stream)
std::vector< Item > items_t
Definition ResourceDialogRegular.hpp:81
~ResourceDialogRegular() override=default
static bool classof(const ResourceDialog *dialog)
Definition ResourceDialogRegular.hpp:100
it_const_items items() const
Definition ResourceDialogRegular.hpp:116
ResourceDialogRegular(const ResourceDialogRegular &)=default
ResourceDialogRegular & font(font_t f)
Definition ResourceDialogRegular.hpp:136
it_items items()
Iterator over the different control items.
Definition ResourceDialogRegular.hpp:112
ref_iterator< items_t & > it_items
Definition ResourceDialogRegular.hpp:82
ResourceDialogRegular & operator=(const ResourceDialogRegular &)=default
void add_item(const Item &item)
Add a new control item to the dialog.
Definition ResourceDialogRegular.hpp:121
std::unique_ptr< ResourceDialog > clone() const override
Definition ResourceDialogRegular.hpp:96
uint32_t nb_items() const
Number of control items.
Definition ResourceDialogRegular.hpp:107
ResourceDialogRegular()
Definition ResourceDialogRegular.hpp:85
ResourceDialogRegular(ResourceDialogRegular &&)=default
const font_t & font() const
Additional font information.
Definition ResourceDialogRegular.hpp:126
std::string to_string() const override
ResourceDialogRegular & font(uint16_t pointsize, std::u16string name)
Definition ResourceDialogRegular.hpp:130
const_ref_iterator< const items_t & > it_const_items
Definition ResourceDialogRegular.hpp:83
void accept(Visitor &visitor) const override
ResourceDialogRegular & operator=(ResourceDialogRegular &&)=default
static std::unique_ptr< ResourceDialogRegular > create(BinaryStream &stream)
This class represents an element of the dialog. It can be for instance, a button, or a caption.
Definition ResourceDialog.hpp:168
TYPE
Enum for discriminating the kind of the Dialog (regular vs extended).
Definition ResourceDialog.hpp:66
@ REGULAR
Definition ResourceDialog.hpp:68
TYPE type() const
Definition ResourceDialog.hpp:372
Definition Visitor.hpp:211
Iterator which returns reference on container's values.
Definition iterators.hpp:120
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:78
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:31
LIEF namespace.
Definition Abstract/Binary.hpp:41
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which returns a const ref on container's values.
Definition iterators.hpp:385
This structure represents additional font information that might be embedded at the end of the DLGTEM...
Definition ResourceDialogRegular.hpp:60
bool is_defined() const
Definition ResourceDialogRegular.hpp:64
std::u16string name
Definition ResourceDialogRegular.hpp:62
uint16_t point_size
Definition ResourceDialogRegular.hpp:61
friend std::ostream & operator<<(std::ostream &os, const font_t &font)
Definition ResourceDialogRegular.hpp:74
This structure wraps either an ordinal value (uint16_t) or a string. The ordinal value should refer t...
Definition ResourceDialog.hpp:50
#define LIEF_API
Definition visibility.h:44