LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
String.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_COFF_STRING_H
17#define LIEF_COFF_STRING_H
18#include <string_view>
19#include <cstdint>
20#include <ostream>
21#include <string>
22
23#include "LIEF/visibility.h"
24
25
26namespace LIEF::COFF {
27
36 public:
37 String() = default;
38 String(uint32_t offset, std::string str) :
39 str_(std::move(str)),
40 offset_(offset) {}
41
42 String(const String&) = default;
43 String& operator=(const String&) = default;
44
45 String(String&&) = default;
46 String& operator=(String&&) = default;
47
48 ~String() = default;
49
51 std::string_view str() const LIEF_LIFETIMEBOUND {
52 return str_;
53 }
54
56 std::string& str() LIEF_LIFETIMEBOUND {
57 return str_;
58 }
59
62 uint32_t offset() const {
63 return offset_;
64 }
65
67 str_ = std::move(str);
68 return *this;
69 }
70
71 String& offset(uint32_t value) LIEF_LIFETIMEBOUND {
72 offset_ = value;
73 return *this;
74 }
75
76 friend LIEF_API std::ostream& operator<<(std::ostream& os, const String& str) {
77 os << str.str();
78 return os;
79 }
80
81 private:
82 std::string str_;
83 uint32_t offset_ = 0;
84};
85}
86
87#endif
String & operator=(String &&)=default
String(uint32_t offset, std::string str)
Definition String.hpp:38
std::string_view str() const
The actual string.
Definition String.hpp:51
String(String &&)=default
String & operator=(const String &)=default
String & offset(uint32_t value)
Definition String.hpp:71
std::string & str()
Mutable access to the underlying string storage.
Definition String.hpp:56
friend std::ostream & operator<<(std::ostream &os, const String &str)
Definition String.hpp:76
String & str(std::string str)
Definition String.hpp:66
uint32_t offset() const
The offset of this string the in the COFF string table. This offset includes the first 4-bytes that h...
Definition String.hpp:62
String(const String &)=default
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition AuxiliarySymbol.hpp:30
#define LIEF_API
Definition visibility.h:45