LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
ResourceDialogRegular.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 * Copyright 2017 - 2026 Quarkslab
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef LIEF_PE_RESOURCE_DIALOG_REGULAR_H
17#define LIEF_PE_RESOURCE_DIALOG_REGULAR_H
18
19#include "LIEF/visibility.h"
21#include "LIEF/errors.hpp"
22#include "LIEF/iterators.hpp"
23
24namespace LIEF {
25class BinaryStream;
26
27namespace PE {
28
34 public:
36
42 public:
43 Item() = default;
44 Item(const Item&) = default;
45 Item& operator=(const Item&) = default;
46
47 Item(Item&&) = default;
48 Item& operator=(Item&&) = default;
49
51
52 std::string to_string() const override;
53
54 ~Item() override = default;
55 };
56
60 uint16_t point_size = 0;
61 std::u16string name;
62
63 bool is_defined() const {
64 return point_size != 0;
65 }
66
67 operator bool() const {
68 return is_defined();
69 }
70
71 std::string to_string() const;
72
73 LIEF_API friend std::ostream& operator<<(std::ostream& os,
74 const font_t& font) {
75 os << font.to_string();
76 return os;
77 }
78 };
79
80 using items_t = std::vector<Item>;
83
86
89
92
93 static std::unique_ptr<ResourceDialogRegular> create(BinaryStream& stream);
94
95 std::unique_ptr<ResourceDialog> clone() const override {
96 return std::unique_ptr<ResourceDialogRegular>(
97 new ResourceDialogRegular(*this)
98 );
99 }
100
101 static bool classof(const ResourceDialog* dialog) {
102 return dialog->type() == ResourceDialog::TYPE::REGULAR;
103 }
104
105 std::string to_string() const override;
106
108 uint32_t nb_items() const {
109 return items_.size();
110 }
111
114 return items_;
115 }
116
118 return items_;
119 }
120
122 void add_item(const Item& item) {
123 items_.push_back(item);
124 }
125
127 const font_t& font() const {
128 return font_;
129 }
130
131 ResourceDialogRegular& font(uint16_t pointsize, std::u16string name) {
132 font_.name = std::move(name);
133 font_.point_size = pointsize;
134 return *this;
135 }
136
138 font_ = std::move(f);
139 return *this;
140 }
141
142 void accept(Visitor& visitor) const override;
143
144 ~ResourceDialogRegular() override = default;
145
146 protected:
147 font_t font_;
148 items_t items_;
149};
150
151}
152}
153
154
155#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:35
This class represents a DLGTEMPLATE item: DLGITEMTEMPLATE.
Definition ResourceDialogRegular.hpp:41
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:80
~ResourceDialogRegular() override=default
static bool classof(const ResourceDialog *dialog)
Definition ResourceDialogRegular.hpp:101
it_const_items items() const
Definition ResourceDialogRegular.hpp:117
ResourceDialogRegular(const ResourceDialogRegular &)=default
ResourceDialogRegular & font(font_t f)
Definition ResourceDialogRegular.hpp:137
it_items items()
Iterator over the different control items.
Definition ResourceDialogRegular.hpp:113
ref_iterator< items_t & > it_items
Definition ResourceDialogRegular.hpp:81
ResourceDialogRegular & operator=(const ResourceDialogRegular &)=default
void add_item(const Item &item)
Add a new control item to the dialog.
Definition ResourceDialogRegular.hpp:122
std::unique_ptr< ResourceDialog > clone() const override
Definition ResourceDialogRegular.hpp:95
uint32_t nb_items() const
Number of control items.
Definition ResourceDialogRegular.hpp:108
ResourceDialogRegular()
Definition ResourceDialogRegular.hpp:84
ResourceDialogRegular(ResourceDialogRegular &&)=default
const font_t & font() const
Additional font information.
Definition ResourceDialogRegular.hpp:127
std::string to_string() const override
ResourceDialogRegular & font(uint16_t pointsize, std::u16string name)
Definition ResourceDialogRegular.hpp:131
const_ref_iterator< const items_t & > it_const_items
Definition ResourceDialogRegular.hpp:82
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:369
Definition Visitor.hpp:212
Iterator which returns reference on container's values.
Definition iterators.hpp:47
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:79
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
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:322
This structure represents additional font information that might be embedded at the end of the DLGTEM...
Definition ResourceDialogRegular.hpp:59
bool is_defined() const
Definition ResourceDialogRegular.hpp:63
std::u16string name
Definition ResourceDialogRegular.hpp:61
uint16_t point_size
Definition ResourceDialogRegular.hpp:60
friend std::ostream & operator<<(std::ostream &os, const font_t &font)
Definition ResourceDialogRegular.hpp:73
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:45