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#include "LIEF/span.hpp"
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::unique_ptr<ResourceDialogRegular>(
98 new ResourceDialogRegular(*this)
99 );
100 }
101
102 static bool classof(const ResourceDialog* dialog) {
103 return dialog->type() == ResourceDialog::TYPE::REGULAR;
104 }
105
106 std::string to_string() const override;
107
109 uint32_t nb_items() const {
110 return items_.size();
111 }
112
115 return items_;
116 }
117
119 return items_;
120 }
121
123 void add_item(const Item& item) {
124 items_.push_back(item);
125 }
126
128 const font_t& font() const {
129 return font_;
130 }
131
132 ResourceDialogRegular& font(uint16_t pointsize, std::u16string name) {
133 font_.name = std::move(name);
134 font_.point_size = pointsize;
135 return *this;
136 }
137
139 font_ = std::move(f);
140 return *this;
141 }
142
143 void accept(Visitor& visitor) const override;
144
145 ~ResourceDialogRegular() override = default;
146
147 protected:
148 font_t font_;
149 items_t items_;
150};
151
152}
153}
154
155
156#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
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:102
it_const_items items() const
Definition ResourceDialogRegular.hpp:118
ResourceDialogRegular(const ResourceDialogRegular &)=default
ResourceDialogRegular & font(font_t f)
Definition ResourceDialogRegular.hpp:138
it_items items()
Iterator over the different control items.
Definition ResourceDialogRegular.hpp:114
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:123
std::unique_ptr< ResourceDialog > clone() const override
Definition ResourceDialogRegular.hpp:96
uint32_t nb_items() const
Number of control items.
Definition ResourceDialogRegular.hpp:109
ResourceDialogRegular()
Definition ResourceDialogRegular.hpp:85
ResourceDialogRegular(ResourceDialogRegular &&)=default
const font_t & font() const
Additional font information.
Definition ResourceDialogRegular.hpp:128
std::string to_string() const override
ResourceDialogRegular & font(uint16_t pointsize, std::u16string name)
Definition ResourceDialogRegular.hpp:132
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:159
TYPE
Enum for discriminating the kind of the Dialog (regular vs extended).
Definition ResourceDialog.hpp:65
@ REGULAR
Definition ResourceDialog.hpp:67
TYPE type() const
Definition ResourceDialog.hpp:360
Definition Visitor.hpp:212
Iterator which returns reference on container's values.
Definition iterators.hpp:45
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:77
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF namespace.
Definition Abstract/Binary.hpp:40
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which return const ref on container's values.
Definition iterators.hpp:286
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:49
#define LIEF_API
Definition visibility.h:43