LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
LangCodeItem.hpp
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 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_LANG_CODE_ITEM_H
17#define LIEF_PE_RESOURCE_LANG_CODE_ITEM_H
18#include <ostream>
19#include <unordered_map>
20
21#include "LIEF/visibility.h"
22
23#include "LIEF/Object.hpp"
24
25#include "LIEF/PE/enums.hpp"
26
27namespace LIEF {
28namespace PE {
29
30class ResourcesManager;
31struct ResourcesParser;
32
37class LIEF_API LangCodeItem : public Object {
38
39 friend class ResourcesManager;
40 friend struct ResourcesParser;
41
42 public:
43 using items_t = std::unordered_map<std::u16string, std::u16string>;
45 LangCodeItem(uint16_t type, std::u16string key) :
46 type_(type),
47 key_(std::move(key))
48 {}
49
50 LangCodeItem(const LangCodeItem&) = default;
51 LangCodeItem& operator=(const LangCodeItem&) = default;
52 ~LangCodeItem() override = default;
53
57 uint16_t type() const {
58 return type_;
59 }
60
66 const std::u16string& key() const {
67 return key_;
68 }
69
73
75 uint32_t lang() const;
76
78 uint32_t sublang() const;
79
80 const items_t& items() const {
81 return items_;
82 }
83
84 items_t& items() {
85 return items_;
86 }
87
88 void type(uint16_t type) {
89 type_ = type;
90 }
91
92 void key(const std::u16string& key) {
93 key_ = key;
94 }
95 void key(const std::string& key);
96
97 void code_page(CODE_PAGES code_page);
98 void lang(uint32_t lang);
99 void sublang(uint32_t lang);
100
101 void items(const items_t& items);
102
103 void accept(Visitor& visitor) const override;
104
105
106 LIEF_API friend std::ostream& operator<<(std::ostream& os, const LangCodeItem& item);
107
108 private:
109 uint16_t type_ = 0;
110 std::u16string key_;
111 items_t items_;
112};
113
114
115
116
117}
118}
119
120
121#endif
Definition Object.hpp:25
Class which represents the childs of the ResourceStringFileInfo.
Definition LangCodeItem.hpp:37
CODE_PAGES code_page() const
Code page for which LangCodeItem::items are defined
const std::u16string & key() const
A 8-digit hexadecimal number stored as an Unicode string.
Definition LangCodeItem.hpp:66
uint32_t sublang() const
Sublang for which LangCodeItem::items are defined.
uint16_t type() const
The type of data in the version resource.
Definition LangCodeItem.hpp:57
uint32_t lang() const
Lang for which LangCodeItem::items are defined.
The Resource Manager provides an enhanced API to manipulate the resource tree.
Definition ResourcesManager.hpp:38
CODE_PAGES
Code page from https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers.
Definition PE/enums.hpp:333
LIEF namespace.
Definition Abstract/Binary.hpp:32