LIEF: Library to Instrument Executable Formats Version 0.17.0
|
Loading...
Searching...
No Matches
Go to the documentation of this file.
16#ifndef LIEF_PE_RESOURCE_STRING_TABLE_H
17#define LIEF_PE_RESOURCE_STRING_TABLE_H
35 public:
struct entry_t {
41 std::string
key_u8()
const;
49 return !key.empty() || !value.empty();
52 operator bool()
const {
57 return key_u8() +
": " + value_u8();
61 std::ostream&
operator<<(std::ostream& os,
const entry_t& entry)
68 using entries_t = std::vector<entry_t>;
69 using it_entries = ref_iterator<entries_t&>;
70 using it_const_entries = const_ref_iterator<const entries_t&>;
74 static result<ResourceStringTable>
parse(BinaryStream& stream);
77 ResourceStringTable&
operator=(
const ResourceStringTable&) =
default;
80 ResourceStringTable&
operator=(ResourceStringTable&&) =
default;
83 const std::u16string&
key()
const {
93 uint16_t
type()
const {
100 std::string
key_u8()
const;
113 optional<std::u16string>
get(
const std::u16string& key)
const {
114 auto it = std::find_if(entries_.begin(), entries_.end(),
115 [&key] (
const entry_t& entry) {
116 return entry.key == key;
119 if (it == entries_.end()) {
126 optional<std::string>
get(
const std::string& key)
const;
128 ResourceStringTable&
key(std::u16string value) {
129 key_ = std::move(value);
133 ResourceStringTable&
type(uint16_t value) {
139 entries_.push_back(std::move(entry));
142 void add_entry(std::u16string key, std::u16string value) {
143 entries_.push_back(entry_t{std::move(key), std::move(value)});
146 void accept(Visitor& visitor)
const override;
148 optional<std::string>
operator[](
const std::string& str)
const {
152 optional<std::u16string>
operator[](
const std::u16string& str)
const {
157 std::ostream&
operator<<(std::ostream& os,
const ResourceStringTable& table);
162 std::vector<entry_t> entries_;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
This class represents the StringTable structure. This structure can be seen as a dictionary of key,...
Definition ResourceStringTable.hpp:34
optional< std::u16string > operator[](const std::u16string &str) const
Definition ResourceStringTable.hpp:152
ResourceStringTable()=default
ResourceStringTable & key(std::u16string value)
Definition ResourceStringTable.hpp:128
ResourceStringTable & operator=(const ResourceStringTable &)=default
ResourceStringTable & type(uint16_t value)
Definition ResourceStringTable.hpp:133
ResourceStringTable(const ResourceStringTable &)=default
~ResourceStringTable() override=default
std::string key_u8() const
The key as an utf8 string.
ResourceStringTable(ResourceStringTable &&)=default
void add_entry(entry_t entry)
Definition ResourceStringTable.hpp:138
void add_entry(std::u16string key, std::u16string value)
Definition ResourceStringTable.hpp:142
friend std::ostream & operator<<(std::ostream &os, const ResourceStringTable &table)
const std::u16string & key() const
An 8-digit hexadecimal number stored as a Unicode string. The four most significant digits represent ...
Definition ResourceStringTable.hpp:90
ResourceStringTable & operator=(ResourceStringTable &&)=default
optional< std::string > operator[](const std::string &str) const
Definition ResourceStringTable.hpp:148
void accept(Visitor &visitor) const override
it_const_entries entries() const
Definition ResourceStringTable.hpp:109
static result< ResourceStringTable > parse(BinaryStream &stream)
optional< std::u16string > get(const std::u16string &key) const
Definition ResourceStringTable.hpp:113
uint16_t type() const
The type of data in the version resource:
Definition ResourceStringTable.hpp:97
optional< std::string > get(const std::string &key) const
it_entries entries()
Iterator over the different entry_t element of this table.
Definition ResourceStringTable.hpp:105
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF namespace.
Definition Abstract/Binary.hpp:36
tl::unexpected< lief_errors > nullopt()
Definition optional.hpp:36
std::string value_u8() const
Value in utf8 representation.
std::string key_u8() const
Key in utf8 representation.
friend std::ostream & operator<<(std::ostream &os, const entry_t &entry)
Definition ResourceStringTable.hpp:61
std::string to_string() const
Definition ResourceStringTable.hpp:56
bool is_defined() const
Definition ResourceStringTable.hpp:48
#define LIEF_API
Definition visibility.h:41