ManaPlus
Data Structures | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
doctest::String Class Reference

#include <doctest.h>

Data Structures

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

Public Member Functions

 String ()
 
 ~String ()
 
 String (const char *in)
 
 String (const String &other)
 
Stringoperator= (const String &other)
 
Stringoperator+= (const String &other)
 
String operator+ (const String &other) const
 
 String (String &&other)
 
Stringoperator= (String &&other)
 
char operator[] (unsigned i) const
 
char & operator[] (unsigned i)
 
const char * c_str () const
 
char * c_str ()
 
unsigned size () const
 
unsigned capacity () const
 
int compare (const char *other, bool no_case=false) const
 
int compare (const String &other, bool no_case=false) const
 

Private Member Functions

bool isOnStack () const
 
void setOnHeap ()
 
void setLast (unsigned in=last)
 
void copy (const String &other)
 

Private Attributes

union {
   char   buf [len]
 
   view   data
 
}; 
 

Static Private Attributes

static const unsigned len = 24
 
static const unsigned last = len - 1
 OCLINT avoid private static members. More...
 

Detailed Description

Definition at line 447 of file doctest.h.

Constructor & Destructor Documentation

◆ String() [1/4]

doctest::String::String ( )

◆ ~String()

doctest::String::~String ( )

◆ String() [2/4]

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

◆ String() [3/4]

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

◆ String() [4/4]

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

Member Function Documentation

◆ c_str() [1/2]

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

Definition at line 491 of file doctest.h.

491  {
492  if(isOnStack())
493  return reinterpret_cast<char*>(buf);
494  return data.ptr;
495  }
char buf[len]
Definition: doctest.h:461
bool isOnStack() const
Definition: doctest.h:465

References data.

◆ c_str() [2/2]

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

Definition at line 490 of file doctest.h.

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

References c_str().

Referenced by c_str().

◆ capacity()

unsigned 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

◆ isOnStack()

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

Definition at line 465 of file doctest.h.

465 { return (buf[last] & 128) == 0; }
static const unsigned last
OCLINT avoid private static members.
Definition: doctest.h:450

◆ operator+()

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

◆ 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)

◆ operator[]() [1/2]

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

◆ operator[]() [2/2]

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

◆ setLast()

void doctest::String::setLast ( unsigned  in = last)
private

◆ setOnHeap()

void doctest::String::setOnHeap ( )
private

◆ size()

unsigned doctest::String::size ( ) const

Field Documentation

◆ 

union { ... }

◆ buf

char doctest::String::buf[len]

Definition at line 461 of file doctest.h.

◆ data

view doctest::String::data

Definition at line 462 of file doctest.h.

◆ last

const unsigned doctest::String::last = len - 1
staticprivate

OCLINT avoid private static members.

Definition at line 450 of file doctest.h.

◆ len

const unsigned doctest::String::len = 24
staticprivate

Definition at line 449 of file doctest.h.


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