openMSX
Public Member Functions | Static Public Attributes | Friends | List of all members
TemporaryString Class Reference

TemporaryString. More...

#include <TemporaryString.hh>

Public Member Functions

 TemporaryString ()
 
 TemporaryString (const char *s)
 
 TemporaryString (zstring_view s)
 
 TemporaryString (size_t n_, std::invocable< char * > auto fillOp)
 
 TemporaryString (const TemporaryString &)=delete
 
 TemporaryString (TemporaryString &&)=delete
 
TemporaryStringoperator= (const TemporaryString &)=delete
 
TemporaryStringoperator= (TemporaryString &&)=delete
 
 ~TemporaryString ()=default
 
auto size () const
 
auto empty () const
 
const char * data () const
 
const char * c_str () const
 
std::string_view view () const
 
 operator std::string_view () const
 
 operator zstring_view () const
 
bool starts_with (std::string_view s) const
 
bool starts_with (char c) const
 
bool starts_with (const char *s) const
 
bool ends_with (std::string_view s) const
 
bool ends_with (char c) const
 
bool ends_with (const char *s) const
 

Static Public Attributes

static constexpr size_t BUFSIZE = 127
 

Friends

bool operator== (const TemporaryString &x, const TemporaryString &y)
 
bool operator== (const TemporaryString &x, const zstring_view &y)
 
bool operator== (const TemporaryString &x, const std::string &y)
 
bool operator== (const TemporaryString &x, const std::string_view &y)
 
bool operator== (const TemporaryString &x, const char *y)
 
std::ostream & operator<< (std::ostream &os, const TemporaryString &str)
 

Detailed Description

TemporaryString.

This a type meant to store temporary strings. Typically it stores the string in the object itself. Except when the string is too large, then it falls back to heap-allocation. So it's more or less like a std::string but with a relatively large (127 character) "small-string-buffer". (Typical std::string implementations only have a buffer for 15 or 23 characters).

Because of this internal buffer, TemporaryString objects are quite large. The intention is that they are only used as local variable (so stored on the stack). Not as member variables.

The API of this type is still very minimal. It can be extended when needed.

Definition at line 27 of file TemporaryString.hh.

Constructor & Destructor Documentation

◆ TemporaryString() [1/6]

TemporaryString::TemporaryString ( )
inlineexplicit

Definition at line 31 of file TemporaryString.hh.

◆ TemporaryString() [2/6]

TemporaryString::TemporaryString ( const char *  s)
inlineexplicit

Definition at line 38 of file TemporaryString.hh.

◆ TemporaryString() [3/6]

TemporaryString::TemporaryString ( zstring_view  s)
inlineexplicit

Definition at line 40 of file TemporaryString.hh.

◆ TemporaryString() [4/6]

TemporaryString::TemporaryString ( size_t  n_,
std::invocable< char * > auto  fillOp 
)
inlineexplicit

Definition at line 43 of file TemporaryString.hh.

References allocate_string_storage(), and BUFSIZE.

◆ TemporaryString() [5/6]

TemporaryString::TemporaryString ( const TemporaryString )
delete

◆ TemporaryString() [6/6]

TemporaryString::TemporaryString ( TemporaryString &&  )
delete

◆ ~TemporaryString()

TemporaryString::~TemporaryString ( )
default

Member Function Documentation

◆ c_str()

const char * TemporaryString::c_str ( ) const
inline

Definition at line 68 of file TemporaryString.hh.

Referenced by openmsx::ImGuiSymbols::paint().

◆ data()

const char * TemporaryString::data ( ) const
inline

Definition at line 67 of file TemporaryString.hh.

◆ empty()

auto TemporaryString::empty ( ) const
inline

Definition at line 65 of file TemporaryString.hh.

◆ ends_with() [1/3]

bool TemporaryString::ends_with ( char  c) const
inline

Definition at line 78 of file TemporaryString.hh.

References view().

◆ ends_with() [2/3]

bool TemporaryString::ends_with ( const char *  s) const
inline

Definition at line 79 of file TemporaryString.hh.

References view().

◆ ends_with() [3/3]

bool TemporaryString::ends_with ( std::string_view  s) const
inline

Definition at line 77 of file TemporaryString.hh.

References view().

◆ operator std::string_view()

TemporaryString::operator std::string_view ( ) const
inline

Definition at line 71 of file TemporaryString.hh.

◆ operator zstring_view()

TemporaryString::operator zstring_view ( ) const
inline

Definition at line 72 of file TemporaryString.hh.

◆ operator=() [1/2]

TemporaryString & TemporaryString::operator= ( const TemporaryString )
delete

◆ operator=() [2/2]

TemporaryString & TemporaryString::operator= ( TemporaryString &&  )
delete

◆ size()

auto TemporaryString::size ( ) const
inline

Definition at line 64 of file TemporaryString.hh.

◆ starts_with() [1/3]

bool TemporaryString::starts_with ( char  c) const
inline

Definition at line 75 of file TemporaryString.hh.

References view().

◆ starts_with() [2/3]

bool TemporaryString::starts_with ( const char *  s) const
inline

Definition at line 76 of file TemporaryString.hh.

References view().

◆ starts_with() [3/3]

bool TemporaryString::starts_with ( std::string_view  s) const
inline

Definition at line 74 of file TemporaryString.hh.

References view().

◆ view()

std::string_view TemporaryString::view ( ) const
inline

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const TemporaryString str 
)
friend

Definition at line 97 of file TemporaryString.hh.

◆ operator== [1/5]

bool operator== ( const TemporaryString x,
const char *  y 
)
friend

Definition at line 93 of file TemporaryString.hh.

◆ operator== [2/5]

bool operator== ( const TemporaryString x,
const std::string &  y 
)
friend

Definition at line 87 of file TemporaryString.hh.

◆ operator== [3/5]

bool operator== ( const TemporaryString x,
const std::string_view &  y 
)
friend

Definition at line 90 of file TemporaryString.hh.

◆ operator== [4/5]

bool operator== ( const TemporaryString x,
const TemporaryString y 
)
friend

Definition at line 81 of file TemporaryString.hh.

◆ operator== [5/5]

bool operator== ( const TemporaryString x,
const zstring_view y 
)
friend

Definition at line 84 of file TemporaryString.hh.

Member Data Documentation

◆ BUFSIZE

constexpr size_t TemporaryString::BUFSIZE = 127
staticconstexpr

Definition at line 29 of file TemporaryString.hh.

Referenced by TemporaryString().


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