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 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_COFF_STRING_H
16#define LIEF_COFF_STRING_H
17#include <string_view>
18#include <cstdint>
19#include <ostream>
20#include <string>
21
22#include "LIEF/visibility.h"
23
24
25namespace LIEF::COFF {
26
35 public:
36 String() = default;
37 String(uint32_t offset, std::string str) :
38 str_(std::move(str)),
39 offset_(offset) {}
40
41 String(const String&) = default;
42 String& operator=(const String&) = default;
43
44 String(String&&) = default;
45 String& operator=(String&&) = default;
46
47 ~String() = default;
48
50 std::string_view str() const LIEF_LIFETIMEBOUND {
51 return str_;
52 }
53
55 std::string& str() LIEF_LIFETIMEBOUND {
56 return str_;
57 }
58
61 uint32_t offset() const {
62 return offset_;
63 }
64
66 str_ = std::move(str);
67 return *this;
68 }
69
70 String& offset(uint32_t value) LIEF_LIFETIMEBOUND {
71 offset_ = value;
72 return *this;
73 }
74
75 friend LIEF_API std::ostream& operator<<(std::ostream& os, const String& str) {
76 os << str.str();
77 return os;
78 }
79
80 private:
81 std::string str_;
82 uint32_t offset_ = 0;
83};
84}
85
86#endif
String & operator=(String &&)=default
String(uint32_t offset, std::string str)
Definition String.hpp:37
std::string_view str() const
The actual string.
Definition String.hpp:50
String(String &&)=default
String & operator=(const String &)=default
String & offset(uint32_t value)
Definition String.hpp:70
std::string & str()
Mutable access to the underlying string storage.
Definition String.hpp:55
friend std::ostream & operator<<(std::ostream &os, const String &str)
Definition String.hpp:75
String & str(std::string str)
Definition String.hpp:65
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:61
String(const String &)=default
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition AuxiliarySymbol.hpp:29
#define LIEF_API
Definition visibility.h:44