26#ifndef ROUTER_SRC_HARNESS_INCLUDE_SECURE_STRING_H_ 
   27#define ROUTER_SRC_HARNESS_INCLUDE_SECURE_STRING_H_ 
   35#include "harness_export.h"   
   44template <
typename value_type, 
typename traits_type, 
typename allocator_type>
 
   47      std::is_same_v<value_type, typename traits_type::char_type>;
 
   48      std::is_same_v<value_type, typename allocator_type::value_type>;
 
   56template <
typename CharT, 
typename Traits = std::
char_traits<CharT>,
 
   57          typename Allocator = std::allocator<CharT>>
 
  118  template <
typename InputIt>
 
  125      const auto ptr = 
reinterpret_cast<pointer>(&*first);
 
  127      for (
auto p = 
data(); first != last; ++first, ++
p) {
 
  128        traits_type::assign(*
p, *first);
 
  145  template <
class StringTraits = std::
char_traits<value_type>,
 
  146            class StringAllocator = std::allocator<value_type>>
 
  148  SecureString(std::basic_string<value_type, StringTraits, StringAllocator> &&s,
 
  151    if (!s.empty()) [[
likely]] {
 
  182    if (!ss.empty()) [[
likely]] {
 
  197  template <
class StringTraits = std::
char_traits<value_type>,
 
  198            class StringAllocator = std::allocator<value_type>>
 
  201      std::basic_string<value_type, StringTraits, StringAllocator> &&s) {
 
  211    if (
this == std::addressof(ss)) [[
unlikely]] {
 
  235    if (
this == std::addressof(ss)) [[
unlikely]] {
 
  246    if (!ss.empty()) [[
likely]] {
 
  266    return l.length() == 
r.length() &&
 
  289  [[nodiscard]] 
inline bool empty() const noexcept { 
return 0 == 
length(); }
 
  297    if (
this == std::addressof(ss)) [[
unlikely]] {
 
  378      traits_type::assign(*
data(), *ptr);
 
Null-terminated string which is securely wiped on destruction.
Definition: secure_string.h:59
 
SecureString & operator=(SecureString &&ss) noexcept
Move assignment operator.
Definition: secure_string.h:234
 
AllocatorTraits::difference_type difference_type
Definition: secure_string.h:69
 
AllocatorTraits::size_type size_type
Definition: secure_string.h:68
 
size_type length_
Definition: secure_string.h:392
 
SecureString() noexcept
Default constructor.
Definition: secure_string.h:80
 
allocator_type & allocator() noexcept
Definition: secure_string.h:362
 
void clear() noexcept
Clears the string, securely wiping the data.
Definition: secure_string.h:322
 
void allocate(size_type length)
Definition: secure_string.h:371
 
const_pointer data() const noexcept
Definition: secure_string.h:364
 
friend bool operator!=(const SecureString &l, const SecureString &r) noexcept
Definition: secure_string.h:270
 
Traits::char_type value_type
Definition: secure_string.h:65
 
Allocator allocator_type
Definition: secure_string.h:66
 
AllocatorTraits::pointer pointer
Definition: secure_string.h:74
 
static void wipe(pointer ptr, size_type length) noexcept
Definition: secure_string.h:357
 
static constexpr bool propagate_on_swap() noexcept
Definition: secure_string.h:353
 
static constexpr value_type kNull
Definition: secure_string.h:389
 
assign(s.data(), s.length()+1)
 
size_type length() const noexcept
Provides length to the stored string.
Definition: secure_string.h:283
 
value_type & reference
Definition: secure_string.h:71
 
SecureString(const allocator_type &alloc) noexcept
Constructor with an allocator.
Definition: secure_string.h:85
 
const value_type & const_reference
Definition: secure_string.h:72
 
static constexpr bool propagate_on_copy() noexcept
Definition: secure_string.h:345
 
void swap(SecureString &ss) noexcept
Swaps the contents of this string with the provided one.
Definition: secure_string.h:296
 
~SecureString()
Releases the string, securely wiping the data.
Definition: secure_string.h:259
 
friend bool operator==(const SecureString &l, const SecureString &r) noexcept
Comparison operators.
Definition: secure_string.h:264
 
SecureString(const SecureString &ss)
Copy constructor.
Definition: secure_string.h:166
 
Traits traits_type
Definition: secure_string.h:64
 
SecureString & operator=(std::basic_string< value_type, StringTraits, StringAllocator > &&s)
Copies the provided string, wiping its memory.
Definition: secure_string.h:200
 
static constexpr bool propagate_on_move() noexcept
Definition: secure_string.h:349
 
bool empty() const noexcept
Checks if the stored string is empty.
Definition: secure_string.h:289
 
const_pointer c_str() const noexcept
Provides pointer to the stored string.
Definition: secure_string.h:278
 
SecureString & operator=(const SecureString &ss)
Copy assignment operator.
Definition: secure_string.h:210
 
const allocator_type & allocator() const noexcept
Definition: secure_string.h:361
 
std::allocator_traits< Allocator > AllocatorTraits
Definition: secure_string.h:61
 
SecureString(pointer ptr, size_type length, const allocator_type &alloc=allocator_type())
Copies the provided string, wiping the memory pointed by ptr.
Definition: secure_string.h:96
 
wipe(s.data(), s.length())
 
void set_data(pointer ptr) noexcept
Definition: secure_string.h:367
 
AllocatorTraits::const_pointer const_pointer
Definition: secure_string.h:75
 
void assign(const_pointer ptr, size_type length)
Definition: secure_string.h:376
 
void set_length(size_type length) noexcept
Definition: secure_string.h:369
 
SecureString(SecureString &&ss) noexcept
Move constructor.
Definition: secure_string.h:181
 
Alloc data_
Definition: secure_string.h:391
 
size_type size() const noexcept
Definition: secure_string.h:284
 
void set_empty() noexcept
Definition: secure_string.h:384
 
pointer data() noexcept
Definition: secure_string.h:365
 
Definition: secure_string.h:45
 
const char * p
Definition: ctype-mb.cc:1227
 
constexpr bool likely(bool expr)
Definition: my_compiler.h:57
 
constexpr bool unlikely(bool expr)
Definition: my_compiler.h:58
 
static int count
Definition: myisam_ftdump.cc:45
 
void copy(Shards< COUNT > &dst, const Shards< COUNT > &src) noexcept
Copy the counters, overwrite destination.
Definition: ut0counter.h:354
 
Definition: fts0fts.cc:237
 
bool distance(const dd::Spatial_reference_system *srs, const Geometry *g1, const Geometry *g2, double *distance, bool *is_null) noexcept
Computes the distance between two geometries.
Definition: distance.cc:40
 
ValueType value(const std::optional< ValueType > &v)
Definition: gtid.h:83
 
void HARNESS_EXPORT secure_wipe(void *ptr, std::size_t count)
Definition: secure_string.cc:37
 
Definition: gcs_xcom_synode.h:64
 
const mysql_service_registry_t * r
Definition: pfs_example_plugin_employee.cc:86
 
static int compare(size_t a, size_t b)
Function to compare two size_t integers for their relative order.
Definition: rpl_utility.cc:107
 
static void swap(String &a, String &b) noexcept
Definition: sql_string.h:650
 
Adapter for SecureMemoryPool which can be used by the STL allocators.
Definition: secure_allocator.h:37
 
Definition: secure_string.h:336
 
pointer ptr_
Definition: secure_string.h:342
 
constexpr Alloc(const allocator_type &a)
Definition: secure_string.h:337
 
constexpr Alloc(allocator_type &&a=allocator_type())
Definition: secure_string.h:339