OpenVPN 3 Core Library
Loading...
Searching...
No Matches
openvpn::SafeString Class Reference

A string-like type that clears the buffer contents on delete. More...

#include <safestr.hpp>

Collaboration diagram for openvpn::SafeString:
[legend]

Public Member Functions

 SafeString ()
 
 SafeString (const char *str, const size_t size)
 
 SafeString (const char *str)
 
 SafeString (const std::string &str)
 
const char * c_str () const
 
std::string to_string () const
 
size_t length () const
 
bool empty () const
 
char & operator[] (size_t pos)
 
const char & operator[] (size_t pos) const
 
bool operator== (const char *str) const
 
bool operator!= (const char *str) const
 
bool operator== (const std::string &str) const
 
bool operator!= (const std::string &str) const
 
SafeStringoperator+= (char c)
 
SafeStringoperator+= (const char *s)
 
SafeStringoperator+= (const SafeString &str)
 
SafeStringappend (const char *s)
 
SafeStringappend (const SafeString &str)
 
SafeStringappend (const SafeString &str, size_t subpos, size_t sublen)
 
void reserve (const size_t n)
 
void wipe ()
 

Private Member Functions

void alloc ()
 
void trail ()
 

Private Attributes

BufferAllocated data
 

Static Private Attributes

static constexpr size_t INITIAL_CAPACITY = 32
 
static constexpr unsigned int BUF_FLAGS = BufAllocFlags::DESTRUCT_ZERO | BufAllocFlags::GROW
 

Detailed Description

A string-like type that clears the buffer contents on delete.

Definition at line 26 of file safestr.hpp.

Constructor & Destructor Documentation

◆ SafeString() [1/4]

openvpn::SafeString::SafeString ( )
inline

Definition at line 32 of file safestr.hpp.

◆ SafeString() [2/4]

openvpn::SafeString::SafeString ( const char *  str,
const size_t  size 
)
inline

Definition at line 36 of file safestr.hpp.

◆ SafeString() [3/4]

openvpn::SafeString::SafeString ( const char *  str)
inline

Definition at line 45 of file safestr.hpp.

◆ SafeString() [4/4]

openvpn::SafeString::SafeString ( const std::string &  str)
inline

Definition at line 50 of file safestr.hpp.

Member Function Documentation

◆ alloc()

void openvpn::SafeString::alloc ( )
inlineprivate

Definition at line 165 of file safestr.hpp.

Here is the caller graph for this function:

◆ append() [1/3]

SafeString & openvpn::SafeString::append ( const char *  s)
inline

Definition at line 127 of file safestr.hpp.

Here is the caller graph for this function:

◆ append() [2/3]

SafeString & openvpn::SafeString::append ( const SafeString str)
inline

Definition at line 135 of file safestr.hpp.

◆ append() [3/3]

SafeString & openvpn::SafeString::append ( const SafeString str,
size_t  subpos,
size_t  sublen 
)
inline

Definition at line 143 of file safestr.hpp.

◆ c_str()

const char * openvpn::SafeString::c_str ( ) const
inline

Definition at line 55 of file safestr.hpp.

Here is the caller graph for this function:

◆ empty()

bool openvpn::SafeString::empty ( ) const
inline

Definition at line 74 of file safestr.hpp.

Here is the caller graph for this function:

◆ length()

size_t openvpn::SafeString::length ( ) const
inline

Definition at line 69 of file safestr.hpp.

Here is the caller graph for this function:

◆ operator!=() [1/2]

bool openvpn::SafeString::operator!= ( const char *  str) const
inline

Definition at line 94 of file safestr.hpp.

Here is the caller graph for this function:

◆ operator!=() [2/2]

bool openvpn::SafeString::operator!= ( const std::string &  str) const
inline

Definition at line 104 of file safestr.hpp.

◆ operator+=() [1/3]

SafeString & openvpn::SafeString::operator+= ( char  c)
inline

Definition at line 109 of file safestr.hpp.

◆ operator+=() [2/3]

SafeString & openvpn::SafeString::operator+= ( const char *  s)
inline

Definition at line 117 of file safestr.hpp.

◆ operator+=() [3/3]

SafeString & openvpn::SafeString::operator+= ( const SafeString str)
inline

Definition at line 122 of file safestr.hpp.

◆ operator==() [1/2]

bool openvpn::SafeString::operator== ( const char *  str) const
inline

Definition at line 89 of file safestr.hpp.

◆ operator==() [2/2]

bool openvpn::SafeString::operator== ( const std::string &  str) const
inline

Definition at line 99 of file safestr.hpp.

◆ operator[]() [1/2]

char & openvpn::SafeString::operator[] ( size_t  pos)
inline

Definition at line 79 of file safestr.hpp.

◆ operator[]() [2/2]

const char & openvpn::SafeString::operator[] ( size_t  pos) const
inline

Definition at line 84 of file safestr.hpp.

◆ reserve()

void openvpn::SafeString::reserve ( const size_t  n)
inline

Definition at line 151 of file safestr.hpp.

◆ to_string()

std::string openvpn::SafeString::to_string ( ) const
inline

Definition at line 64 of file safestr.hpp.

Here is the caller graph for this function:

◆ trail()

void openvpn::SafeString::trail ( )
inlineprivate

Definition at line 171 of file safestr.hpp.

Here is the caller graph for this function:

◆ wipe()

void openvpn::SafeString::wipe ( )
inline

Definition at line 159 of file safestr.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ BUF_FLAGS

constexpr unsigned int openvpn::SafeString::BUF_FLAGS = BufAllocFlags::DESTRUCT_ZERO | BufAllocFlags::GROW
staticconstexprprivate

Definition at line 29 of file safestr.hpp.

◆ data

BufferAllocated openvpn::SafeString::data
private

Definition at line 176 of file safestr.hpp.

◆ INITIAL_CAPACITY

constexpr size_t openvpn::SafeString::INITIAL_CAPACITY = 32
staticconstexprprivate

Definition at line 28 of file safestr.hpp.


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