MySQL 9.3.0
Source Code Documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
mysql_harness::detail::SecureString< CharT, Traits, Allocator > Class Template Referencefinal

Null-terminated string which is securely wiped on destruction. More...

#include <secure_string.h>

Classes

struct  Alloc
 

Public Types

using traits_type = Traits
 
using value_type = Traits::char_type
 
using allocator_type = Allocator
 
using size_type = AllocatorTraits::size_type
 
using difference_type = AllocatorTraits::difference_type
 
using reference = value_type &
 
using const_reference = const value_type &
 
using pointer = AllocatorTraits::pointer
 
using const_pointer = AllocatorTraits::const_pointer
 

Public Member Functions

 SecureString () noexcept
 Default constructor. More...
 
 SecureString (const allocator_type &alloc) noexcept
 Constructor with an allocator. More...
 
 SecureString (pointer ptr, size_type length, const allocator_type &alloc=allocator_type())
 Copies the provided string, wiping the memory pointed by ptr. More...
 
template<typename InputIt >
 SecureString (InputIt first, InputIt last, const allocator_type &alloc=allocator_type())
 Copies the provided string, wiping the memory between first and last. More...
 
 assign (s.data(), s.length()+1)
 
 wipe (s.data(), s.length())
 
clear ()
 
 SecureString (const SecureString &ss)
 Copy constructor. More...
 
 SecureString (SecureString &&ss) noexcept
 Move constructor. More...
 
template<class StringTraits = std::char_traits<value_type>, class StringAllocator = std::allocator<value_type>>
requires SameValueType<value_type, StringTraits, StringAllocator>
SecureStringoperator= (std::basic_string< value_type, StringTraits, StringAllocator > &&s)
 Copies the provided string, wiping its memory. More...
 
SecureStringoperator= (const SecureString &ss)
 Copy assignment operator. More...
 
SecureStringoperator= (SecureString &&ss) noexcept
 Move assignment operator. More...
 
 ~SecureString ()
 Releases the string, securely wiping the data. More...
 
const_pointer c_str () const noexcept
 Provides pointer to the stored string. More...
 
size_type length () const noexcept
 Provides length to the stored string. More...
 
size_type size () const noexcept
 
bool empty () const noexcept
 Checks if the stored string is empty. More...
 
void swap (SecureString &ss) noexcept
 Swaps the contents of this string with the provided one. More...
 
void clear () noexcept
 Clears the string, securely wiping the data. More...
 

Public Attributes

template<class StringTraits = std::char_traits<value_type>, class StringAllocator = std::allocator<value_type>>
 __pad0__: data_(alloc) { if (!s.empty()) { allocate(s.length())
 Copies the provided string, wiping its memory. More...
 
 else
 

Private Types

using AllocatorTraits = std::allocator_traits< Allocator >
 

Private Member Functions

const allocator_typeallocator () const noexcept
 
allocator_typeallocator () noexcept
 
const_pointer data () const noexcept
 
pointer data () noexcept
 
void set_data (pointer ptr) noexcept
 
void set_length (size_type length) noexcept
 
void allocate (size_type length)
 
void assign (const_pointer ptr, size_type length)
 
void set_empty () noexcept
 

Static Private Member Functions

static constexpr bool propagate_on_copy () noexcept
 
static constexpr bool propagate_on_move () noexcept
 
static constexpr bool propagate_on_swap () noexcept
 
static void wipe (pointer ptr, size_type length) noexcept
 

Private Attributes

Alloc data_
 
size_type length_
 

Static Private Attributes

static constexpr value_type kNull {}
 

Friends

bool operator== (const SecureString &l, const SecureString &r) noexcept
 Comparison operators. More...
 
bool operator!= (const SecureString &l, const SecureString &r) noexcept
 

Detailed Description

template<typename CharT, typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
requires SameValueType<CharT, Traits, Allocator>
class mysql_harness::detail::SecureString< CharT, Traits, Allocator >

Null-terminated string which is securely wiped on destruction.

Member Typedef Documentation

◆ allocator_type

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
using mysql_harness::detail::SecureString< CharT, Traits, Allocator >::allocator_type = Allocator

◆ AllocatorTraits

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
using mysql_harness::detail::SecureString< CharT, Traits, Allocator >::AllocatorTraits = std::allocator_traits<Allocator>
private

◆ const_pointer

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
using mysql_harness::detail::SecureString< CharT, Traits, Allocator >::const_pointer = AllocatorTraits::const_pointer

◆ const_reference

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
using mysql_harness::detail::SecureString< CharT, Traits, Allocator >::const_reference = const value_type &

◆ difference_type

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
using mysql_harness::detail::SecureString< CharT, Traits, Allocator >::difference_type = AllocatorTraits::difference_type

◆ pointer

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
using mysql_harness::detail::SecureString< CharT, Traits, Allocator >::pointer = AllocatorTraits::pointer

◆ reference

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
using mysql_harness::detail::SecureString< CharT, Traits, Allocator >::reference = value_type &

◆ size_type

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
using mysql_harness::detail::SecureString< CharT, Traits, Allocator >::size_type = AllocatorTraits::size_type

◆ traits_type

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
using mysql_harness::detail::SecureString< CharT, Traits, Allocator >::traits_type = Traits

◆ value_type

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
using mysql_harness::detail::SecureString< CharT, Traits, Allocator >::value_type = Traits::char_type

Constructor & Destructor Documentation

◆ SecureString() [1/6]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
mysql_harness::detail::SecureString< CharT, Traits, Allocator >::SecureString ( )
inlinenoexcept

Default constructor.

◆ SecureString() [2/6]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
mysql_harness::detail::SecureString< CharT, Traits, Allocator >::SecureString ( const allocator_type alloc)
inlineexplicitnoexcept

Constructor with an allocator.

◆ SecureString() [3/6]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
mysql_harness::detail::SecureString< CharT, Traits, Allocator >::SecureString ( pointer  ptr,
size_type  length,
const allocator_type alloc = allocator_type() 
)
inline

Copies the provided string, wiping the memory pointed by ptr.

Parameters
ptrPointer to an array of characters.
lengthNumber of characters in the array.
allocAllocator to use.

◆ SecureString() [4/6]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
template<typename InputIt >
mysql_harness::detail::SecureString< CharT, Traits, Allocator >::SecureString ( InputIt  first,
InputIt  last,
const allocator_type alloc = allocator_type() 
)
inline

Copies the provided string, wiping the memory between first and last.

Parameters
firstBeginning of a range.
lastEnd of a range.
allocAllocator to use.

◆ SecureString() [5/6]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
mysql_harness::detail::SecureString< CharT, Traits, Allocator >::SecureString ( const SecureString< CharT, Traits, Allocator > &  ss)
inline

Copy constructor.

◆ SecureString() [6/6]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
mysql_harness::detail::SecureString< CharT, Traits, Allocator >::SecureString ( SecureString< CharT, Traits, Allocator > &&  ss)
inlinenoexcept

Move constructor.

◆ ~SecureString()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
mysql_harness::detail::SecureString< CharT, Traits, Allocator >::~SecureString ( )
inline

Releases the string, securely wiping the data.

Member Function Documentation

◆ allocate()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
void mysql_harness::detail::SecureString< CharT, Traits, Allocator >::allocate ( size_type  length)
inlineprivate

◆ allocator() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
const allocator_type & mysql_harness::detail::SecureString< CharT, Traits, Allocator >::allocator ( ) const
inlineprivatenoexcept

◆ allocator() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
allocator_type & mysql_harness::detail::SecureString< CharT, Traits, Allocator >::allocator ( )
inlineprivatenoexcept

◆ assign() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
void mysql_harness::detail::SecureString< CharT, Traits, Allocator >::assign ( const_pointer  ptr,
size_type  length 
)
inlineprivate

◆ assign() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
mysql_harness::detail::SecureString< CharT, Traits, Allocator >::assign ( s.  data(),
s.length()+  1 
)

◆ c_str()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
const_pointer mysql_harness::detail::SecureString< CharT, Traits, Allocator >::c_str ( ) const
inlinenoexcept

Provides pointer to the stored string.

◆ clear() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
s mysql_harness::detail::SecureString< CharT, Traits, Allocator >::clear ( )

◆ clear() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
void mysql_harness::detail::SecureString< CharT, Traits, Allocator >::clear ( )
inlinenoexcept

Clears the string, securely wiping the data.

◆ data() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
const_pointer mysql_harness::detail::SecureString< CharT, Traits, Allocator >::data ( ) const
inlineprivatenoexcept

◆ data() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
pointer mysql_harness::detail::SecureString< CharT, Traits, Allocator >::data ( )
inlineprivatenoexcept

◆ empty()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
bool mysql_harness::detail::SecureString< CharT, Traits, Allocator >::empty ( ) const
inlinenoexcept

Checks if the stored string is empty.

◆ length()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
size_type mysql_harness::detail::SecureString< CharT, Traits, Allocator >::length ( ) const
inlinenoexcept

Provides length to the stored string.

◆ operator=() [1/3]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
SecureString & mysql_harness::detail::SecureString< CharT, Traits, Allocator >::operator= ( const SecureString< CharT, Traits, Allocator > &  ss)
inline

Copy assignment operator.

◆ operator=() [2/3]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
SecureString & mysql_harness::detail::SecureString< CharT, Traits, Allocator >::operator= ( SecureString< CharT, Traits, Allocator > &&  ss)
inlinenoexcept

Move assignment operator.

◆ operator=() [3/3]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
template<class StringTraits = std::char_traits<value_type>, class StringAllocator = std::allocator<value_type>>
requires SameValueType<value_type, StringTraits, StringAllocator>
SecureString & mysql_harness::detail::SecureString< CharT, Traits, Allocator >::operator= ( std::basic_string< value_type, StringTraits, StringAllocator > &&  s)
inline

Copies the provided string, wiping its memory.

Parameters
sString to be copied.

◆ propagate_on_copy()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
static constexpr bool mysql_harness::detail::SecureString< CharT, Traits, Allocator >::propagate_on_copy ( )
inlinestaticconstexprprivatenoexcept

◆ propagate_on_move()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
static constexpr bool mysql_harness::detail::SecureString< CharT, Traits, Allocator >::propagate_on_move ( )
inlinestaticconstexprprivatenoexcept

◆ propagate_on_swap()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
static constexpr bool mysql_harness::detail::SecureString< CharT, Traits, Allocator >::propagate_on_swap ( )
inlinestaticconstexprprivatenoexcept

◆ set_data()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
void mysql_harness::detail::SecureString< CharT, Traits, Allocator >::set_data ( pointer  ptr)
inlineprivatenoexcept

◆ set_empty()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
void mysql_harness::detail::SecureString< CharT, Traits, Allocator >::set_empty ( )
inlineprivatenoexcept

◆ set_length()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
void mysql_harness::detail::SecureString< CharT, Traits, Allocator >::set_length ( size_type  length)
inlineprivatenoexcept

◆ size()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
size_type mysql_harness::detail::SecureString< CharT, Traits, Allocator >::size ( ) const
inlinenoexcept

◆ swap()

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
void mysql_harness::detail::SecureString< CharT, Traits, Allocator >::swap ( SecureString< CharT, Traits, Allocator > &  ss)
inlinenoexcept

Swaps the contents of this string with the provided one.

Parameters
ssString to swap the contents with.

◆ wipe() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
static void mysql_harness::detail::SecureString< CharT, Traits, Allocator >::wipe ( pointer  ptr,
size_type  length 
)
inlinestaticprivatenoexcept

◆ wipe() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
mysql_harness::detail::SecureString< CharT, Traits, Allocator >::wipe ( s.  data(),
s.  length() 
)

Friends And Related Function Documentation

◆ operator!=

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
bool operator!= ( const SecureString< CharT, Traits, Allocator > &  l,
const SecureString< CharT, Traits, Allocator > &  r 
)
friend

◆ operator==

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
bool operator== ( const SecureString< CharT, Traits, Allocator > &  l,
const SecureString< CharT, Traits, Allocator > &  r 
)
friend

Comparison operators.

Member Data Documentation

◆ __pad0__

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
template<class StringTraits = std::char_traits<value_type>, class StringAllocator = std::allocator<value_type>>
mysql_harness::detail::SecureString< CharT, Traits, Allocator >::__pad0__

Copies the provided string, wiping its memory.

Parameters
sString to be copied.
allocAllocator to use.

◆ data_

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
Alloc mysql_harness::detail::SecureString< CharT, Traits, Allocator >::data_
private

◆ else

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
mysql_harness::detail::SecureString< CharT, Traits, Allocator >::else
Initial value:
{
void set_empty() noexcept
Definition: secure_string.h:384

◆ kNull

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
constexpr value_type mysql_harness::detail::SecureString< CharT, Traits, Allocator >::kNull {}
staticconstexprprivate

◆ length_

template<typename CharT , typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT>>
size_type mysql_harness::detail::SecureString< CharT, Traits, Allocator >::length_
private

The documentation for this class was generated from the following file: