Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
doctest::String Class Reference

#include <doctest.h>

Data Structures

struct  view
 OCLINT avoid private static members. More...
 

Public Types

using size_type = DOCTEST_CONFIG_STRING_SIZE_TYPE
 

Public Member Functions

 String () noexcept
 
 ~String ()
 
 String (const char *in)
 
 String (const char *in, size_type in_size)
 
 String (std::istream &in, size_type in_size)
 
 String (const String &other)
 
Stringoperator= (const String &other)
 
Stringoperator+= (const String &other)
 
 String (String &&other) noexcept
 
Stringoperator= (String &&other) noexcept
 
char operator[] (size_type i) const
 
char & operator[] (size_type i)
 
const char * c_str () const
 
char * c_str ()
 
size_type size () const
 
size_type capacity () const
 
String substr (size_type pos, size_type cnt=npos) &&
 
String substr (size_type pos, size_type cnt=npos) const &
 
size_type find (char ch, size_type pos=0) const
 
size_type rfind (char ch, size_type pos=npos) const
 
int compare (const char *other, bool no_case=false) const
 
int compare (const String &other, bool no_case=false) const
 

Static Public Attributes

static DOCTEST_CONSTEXPR size_type npos = static_cast<size_type>(-1)
 

Private Member Functions

char * allocate (size_type sz)
 
bool isOnStack () const noexcept
 
void setOnHeap () noexcept
 
void setLast (size_type in=last) noexcept
 
void setSize (size_type sz) noexcept
 
void copy (const String &other)
 

Private Attributes

union { 
 
   char   buf [len
 
   view   data 
 
};  
 

Static Private Attributes

static DOCTEST_CONSTEXPR size_type len = 24
 
static DOCTEST_CONSTEXPR size_type last = len - 1
 OCLINT avoid private static members.
 

Friends

DOCTEST_INTERFACE std::ostreamoperator<< (std::ostream &s, const String &in)
 

Detailed Description

Definition at line 587 of file doctest.h.

Member Typedef Documentation

◆ size_type

Constructor & Destructor Documentation

◆ String() [1/6]

doctest::String::String ( )
noexcept

◆ ~String()

doctest::String::~String ( )

◆ String() [2/6]

doctest::String::String ( const char * in)

◆ String() [3/6]

doctest::String::String ( const char * in,
size_type in_size )

◆ String() [4/6]

doctest::String::String ( std::istream & in,
size_type in_size )

◆ String() [5/6]

doctest::String::String ( const String & other)

◆ String() [6/6]

doctest::String::String ( String && other)
noexcept

Member Function Documentation

◆ allocate()

char * doctest::String::allocate ( size_type sz)
private

◆ c_str() [1/2]

char * doctest::String::c_str ( )
inline

Definition at line 643 of file doctest.h.

643 {
644 if (isOnStack()) {
645 return reinterpret_cast<char*>(buf);
646 }
647 return data.ptr;
648 }
bool isOnStack() const noexcept
Definition doctest.h:611
char buf[len]
Definition doctest.h:605

◆ c_str() [2/2]

const char * doctest::String::c_str ( ) const
inline

Definition at line 642 of file doctest.h.

642{ return const_cast<String*>(this)->c_str(); } // NOLINT
const char * c_str() const
Definition doctest.h:642
String() noexcept

References c_str().

Referenced by c_str(), and doctest::AssertData::StringContains::c_str().

◆ capacity()

size_type doctest::String::capacity ( ) const

◆ compare() [1/2]

int doctest::String::compare ( const char * other,
bool no_case = false ) const

◆ compare() [2/2]

int doctest::String::compare ( const String & other,
bool no_case = false ) const

◆ copy()

void doctest::String::copy ( const String & other)
private

◆ find()

size_type doctest::String::find ( char ch,
size_type pos = 0 ) const

Referenced by doctest::toString().

◆ isOnStack()

bool doctest::String::isOnStack ( ) const
inlineprivatenoexcept

Definition at line 611 of file doctest.h.

611{ return (buf[last] & 128) == 0; }
static DOCTEST_CONSTEXPR size_type last
OCLINT avoid private static members.
Definition doctest.h:594

◆ operator+=()

String & doctest::String::operator+= ( const String & other)

◆ operator=() [1/2]

String & doctest::String::operator= ( const String & other)

◆ operator=() [2/2]

String & doctest::String::operator= ( String && other)
noexcept

◆ operator[]() [1/2]

char & doctest::String::operator[] ( size_type i)

◆ operator[]() [2/2]

char doctest::String::operator[] ( size_type i) const

◆ rfind()

size_type doctest::String::rfind ( char ch,
size_type pos = npos ) const

◆ setLast()

void doctest::String::setLast ( size_type in = last)
privatenoexcept

◆ setOnHeap()

void doctest::String::setOnHeap ( )
privatenoexcept

◆ setSize()

void doctest::String::setSize ( size_type sz)
privatenoexcept

◆ size()

size_type doctest::String::size ( ) const

Referenced by doctest::toString().

◆ substr() [1/2]

String doctest::String::substr ( size_type pos,
size_type cnt = npos ) &&

Referenced by doctest::toString().

◆ substr() [2/2]

String doctest::String::substr ( size_type pos,
size_type cnt = npos ) const &

Friends And Related Symbol Documentation

◆ operator<<

DOCTEST_INTERFACE std::ostream & operator<< ( std::ostream & s,
const String & in )
friend

Field Documentation

◆ [union]

union { ... } doctest::String

◆ buf

char doctest::String::buf[len]

Definition at line 605 of file doctest.h.

◆ data

view doctest::String::data

Definition at line 606 of file doctest.h.

◆ last

DOCTEST_CONSTEXPR size_type doctest::String::last = len - 1
staticprivate

OCLINT avoid private static members.

Definition at line 594 of file doctest.h.

◆ len

DOCTEST_CONSTEXPR size_type doctest::String::len = 24
staticprivate

Definition at line 593 of file doctest.h.

◆ npos

DOCTEST_CONSTEXPR size_type doctest::String::npos = static_cast<size_type>(-1)
static

Definition at line 619 of file doctest.h.


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