openMSX
Public Member Functions | Static Public Attributes | 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
 

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 26 of file TemporaryString.hh.

Constructor & Destructor Documentation

◆ TemporaryString() [1/6]

TemporaryString::TemporaryString ( )
inlineexplicit

Definition at line 30 of file TemporaryString.hh.

◆ TemporaryString() [2/6]

TemporaryString::TemporaryString ( const char *  s)
inlineexplicit

Definition at line 37 of file TemporaryString.hh.

◆ TemporaryString() [3/6]

TemporaryString::TemporaryString ( zstring_view  s)
inlineexplicit

Definition at line 39 of file TemporaryString.hh.

◆ TemporaryString() [4/6]

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

Definition at line 42 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 67 of file TemporaryString.hh.

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

◆ data()

const char * TemporaryString::data ( ) const
inline

Definition at line 66 of file TemporaryString.hh.

◆ empty()

auto TemporaryString::empty ( ) const
inline

Definition at line 64 of file TemporaryString.hh.

◆ ends_with() [1/3]

bool TemporaryString::ends_with ( char  c) const
inline

Definition at line 77 of file TemporaryString.hh.

References view().

◆ ends_with() [2/3]

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

Definition at line 78 of file TemporaryString.hh.

References view().

◆ ends_with() [3/3]

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

Definition at line 76 of file TemporaryString.hh.

References view().

◆ operator std::string_view()

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

Definition at line 70 of file TemporaryString.hh.

◆ operator zstring_view()

TemporaryString::operator zstring_view ( ) const
inline

Definition at line 71 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 63 of file TemporaryString.hh.

◆ starts_with() [1/3]

bool TemporaryString::starts_with ( char  c) const
inline

Definition at line 74 of file TemporaryString.hh.

References view().

◆ starts_with() [2/3]

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

Definition at line 75 of file TemporaryString.hh.

References view().

◆ starts_with() [3/3]

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

Definition at line 73 of file TemporaryString.hh.

References view().

◆ view()

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

Member Data Documentation

◆ BUFSIZE

constexpr size_t TemporaryString::BUFSIZE = 127
staticconstexpr

Definition at line 28 of file TemporaryString.hh.

Referenced by TemporaryString().


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