LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
ResourceVar.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2025 R. Thomas
2 * Copyright 2017 - 2025 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_VAR_H
17#define LIEF_PE_RESOURCE_VAR_H
18#include <ostream>
19#include <vector>
20
21#include "LIEF/visibility.h"
22#include "LIEF/errors.hpp"
23
24namespace LIEF {
25class BinaryStream;
26namespace PE {
27
34 public:
36 using values_t = std::vector<uint32_t>;
37
39
40 ResourceVar() = default;
41
42 ResourceVar(const ResourceVar&) = default;
43 ResourceVar& operator=(const ResourceVar&) = default;
44
47
48 ~ResourceVar() = default;
49
51 const std::u16string& key() const {
52 return key_;
53 }
54
58 uint16_t type() const {
59 return type_;
60 }
61
63 std::string key_u8() const;
64
71 const values_t& values() const {
72 return values_;
73 }
74
76 return values_;
77 }
78
79 ResourceVar& key(std::u16string key) {
80 key_ = std::move(key);
81 return *this;
82 }
83
84 ResourceVar& type(uint16_t ty) {
85 type_ = ty;
86 return *this;
87 }
88
89 void add_value(uint32_t val) {
90 values_.push_back(val);
91 }
92
93 LIEF_API friend
94 std::ostream& operator<<(std::ostream& os, const ResourceVar& entry);
95
96 private:
97 uint16_t type_ = 0;
98 std::u16string key_;
99 values_t values_;
100};
101}
102}
103
104#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
ResourceVar & operator=(const ResourceVar &)=default
ResourceVar(const ResourceVar &)=default
std::vector< uint32_t > values_t
Translation values as a vector of uint32_t.
Definition ResourceVar.hpp:36
friend std::ostream & operator<<(std::ostream &os, const ResourceVar &entry)
ResourceVar & key(std::u16string key)
Definition ResourceVar.hpp:79
ResourceVar & type(uint16_t ty)
Definition ResourceVar.hpp:84
static result< ResourceVar > parse(BinaryStream &stream)
values_t & values()
Definition ResourceVar.hpp:75
std::string key_u8() const
The key as an utf8 string.
uint16_t type() const
The type of data in the version resource:
Definition ResourceVar.hpp:58
ResourceVar(ResourceVar &&)=default
const std::u16string & key() const
The Unicode string L"Translation".
Definition ResourceVar.hpp:51
void add_value(uint32_t val)
Definition ResourceVar.hpp:89
const values_t & values() const
Return the translation values.
Definition ResourceVar.hpp:71
ResourceVar & operator=(ResourceVar &&)=default
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF namespace.
Definition Abstract/Binary.hpp:40
tl::expected< T, lief_errors > result
Wrapper that contains an Object (T) or an error.
Definition errors.hpp:75
#define LIEF_API
Definition visibility.h:41