#include <wipeable_string.h>
Definition at line 40 of file wipeable_string.h.
◆ value_type
◆ wipeable_string() [1/7]
| epee::wipeable_string::wipeable_string |
( |
| ) |
|
|
inline |
◆ wipeable_string() [2/7]
| epee::wipeable_string::wipeable_string |
( |
const wipeable_string & | other | ) |
|
◆ wipeable_string() [3/7]
| epee::wipeable_string::wipeable_string |
( |
wipeable_string && | other | ) |
|
Definition at line 56 of file wipeable_string.cpp.
57{
58 if (&other == this)
59 return;
60 buffer = std::move(other.buffer);
61}
◆ wipeable_string() [4/7]
| epee::wipeable_string::wipeable_string |
( |
const std::string & | other | ) |
|
Definition at line 63 of file wipeable_string.cpp.
64{
65 grow(other.size());
68}
size_t size() const noexcept
void * memcpy(void *a, const void *b, size_t c)
◆ wipeable_string() [5/7]
| epee::wipeable_string::wipeable_string |
( |
std::string && | other | ) |
|
Definition at line 70 of file wipeable_string.cpp.
71{
72 grow(other.size());
75 if (!other.empty())
76 {
77 memwipe(&other[0], other.size());
78 other = std::string();
79 }
80}
void * memwipe(void *src, size_t n)
◆ wipeable_string() [6/7]
| epee::wipeable_string::wipeable_string |
( |
const char * | s | ) |
|
◆ wipeable_string() [7/7]
| epee::wipeable_string::wipeable_string |
( |
const char * | s, |
|
|
size_t | len ) |
◆ ~wipeable_string()
| epee::wipeable_string::~wipeable_string |
( |
| ) |
|
◆ append()
| void epee::wipeable_string::append |
( |
const char * | ptr, |
|
|
size_t | len ) |
Definition at line 144 of file wipeable_string.cpp.
145{
146 const size_t orgsz =
size();
148 grow(orgsz + len);
149 if (len > 0)
151}
const char * data() const noexcept
#define CHECK_AND_ASSERT_THROW_MES(expr, message)
◆ clear()
| void epee::wipeable_string::clear |
( |
| ) |
|
◆ data() [1/2]
| const char * epee::wipeable_string::data |
( |
| ) |
const |
|
inlinenoexcept |
◆ data() [2/2]
| char * epee::wipeable_string::data |
( |
| ) |
|
|
inlinenoexcept |
◆ empty()
| bool epee::wipeable_string::empty |
( |
| ) |
const |
|
inlinenoexcept |
◆ hex_to_pod() [1/2]
| bool epee::wipeable_string::hex_to_pod |
( |
T & | pod | ) |
const |
|
inline |
Definition at line 86 of file wipeable_string.h.
87 {
88 static_assert(std::is_pod<T>::value, "expected pod type");
89 if (
size() !=
sizeof(
T) * 2)
90 return false;
91 boost::optional<epee::wipeable_string> blob =
parse_hexstr();
92 if (!blob)
93 return false;
94 if (blob->size() !=
sizeof(
T))
95 return false;
96 pod = *(
const T*)blob->data();
97 return true;
98 }
boost::optional< wipeable_string > parse_hexstr() const
◆ hex_to_pod() [2/2]
| bool epee::wipeable_string::hex_to_pod |
( |
tools::scrubbed< T > & | pod | ) |
const |
|
inline |
Definition at line 70 of file wipeable_string.h.
bool hex_to_pod(T &pod) const
T & unwrap(mlocked< T > &src)
◆ length()
| size_t epee::wipeable_string::length |
( |
| ) |
const |
|
inlinenoexcept |
◆ operator!=()
| bool epee::wipeable_string::operator!= |
( |
const wipeable_string & | other | ) |
const |
|
inlinenoexcept |
◆ operator+=() [1/4]
| void epee::wipeable_string::operator+= |
( |
char | c | ) |
|
◆ operator+=() [2/4]
| void epee::wipeable_string::operator+= |
( |
const char * | s | ) |
|
◆ operator+=() [3/4]
◆ operator+=() [4/4]
| void epee::wipeable_string::operator+= |
( |
const std::string & | s | ) |
|
◆ operator=() [1/2]
Definition at line 256 of file wipeable_string.cpp.
257{
258 if (&other != this)
259 buffer = other.buffer;
260 return *this;
261}
◆ operator=() [2/2]
Definition at line 249 of file wipeable_string.cpp.
250{
251 if (&other != this)
252 buffer = std::move(other.buffer);
253 return *this;
254}
◆ operator==()
| bool epee::wipeable_string::operator== |
( |
const wipeable_string & | other | ) |
const |
|
inlinenoexcept |
◆ parse_hexstr()
Definition at line 202 of file wipeable_string.cpp.
203{
205 return boost::none;
206 boost::optional<epee::wipeable_string>
res = epee::wipeable_string(
"");
207 const size_t len =
size();
208 const char *d =
data();
209 res->grow(0, len / 2);
210 for (size_t i = 0; i < len; i += 2)
211 {
212 char c = atolower(d[i]);
213 const char *ptr0 = strchr(hex, c);
214 if (!ptr0)
215 return boost::none;
216 c = atolower(d[i+1]);
217 const char *ptr1 = strchr(hex, c);
218 if (!ptr1)
219 return boost::none;
220 res->push_back(((ptr0-hex)<<4) | (ptr1-hex));
221 }
223}
◆ pop_back()
| char epee::wipeable_string::pop_back |
( |
| ) |
|
Definition at line 225 of file wipeable_string.cpp.
226{
227 const size_t sz =
size();
229 const char c = buffer.back();
231 return c;
232}
◆ push_back()
| void epee::wipeable_string::push_back |
( |
char | c | ) |
|
◆ reserve()
| void epee::wipeable_string::reserve |
( |
size_t | sz | ) |
|
◆ resize()
| void epee::wipeable_string::resize |
( |
size_t | sz | ) |
|
◆ size()
| size_t epee::wipeable_string::size |
( |
| ) |
const |
|
inlinenoexcept |
◆ split()
| void epee::wipeable_string::split |
( |
std::vector< wipeable_string > & | fields | ) |
const |
Definition at line 183 of file wipeable_string.cpp.
184{
185 fields.clear();
187 const char *ptr =
data();
188 bool space = true;
189 while (len--)
190 {
191 const char c = *ptr++;
192 if (c != ' ')
193 {
194 if (space)
195 fields.push_back({});
196 fields.back().push_back(c);
197 }
198 space = c == ' ';
199 }
200}
◆ trim()
| void epee::wipeable_string::trim |
( |
| ) |
|
Definition at line 168 of file wipeable_string.cpp.
169{
170 size_t prefix = 0;
171 while (prefix <
size() &&
data()[prefix] ==
' ')
172 ++prefix;
173 if (prefix > 0)
174 memmove(buffer.data(), buffer.data() + prefix,
size() - prefix);
175
176 size_t suffix = 0;
177 while (suffix <
size()-prefix &&
data()[
size() - 1 - prefix - suffix] ==
' ')
178 ++suffix;
179
181}
void * memmove(void *a, const void *b, size_t c)
◆ wipe()
| void epee::wipeable_string::wipe |
( |
| ) |
|
The documentation for this class was generated from the following files:
- /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/contrib/epee/include/wipeable_string.h
- /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/contrib/epee/src/wipeable_string.cpp