openMSX
Public Types | Public Member Functions | Static Public Attributes | List of all members
zstring_view Class Reference

Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string. More...

#include <zstring_view.hh>

Public Types

using size_type = size_t
 
using const_iterator = const char *
 

Public Member Functions

 zstring_view (const char *s)
 
constexpr zstring_view (const char *s, size_t n)
 
 zstring_view (const std::string &s)
 
constexpr auto begin () const
 
constexpr auto end () const
 
constexpr auto size () const
 
constexpr auto empty () const
 
constexpr char operator[] (size_type i) const
 
constexpr char front () const
 
constexpr char back () const
 
constexpr const char * data () const
 
constexpr const char * c_str () const
 
constexpr auto find (char c, size_type pos=0) const
 
constexpr zstring_view substr (size_type pos) const
 
 operator std::string () const
 
constexpr std::string_view view () const
 
constexpr operator std::string_view () const
 

Static Public Attributes

static constexpr auto npos = std::string_view::npos
 

Detailed Description

Like std::string_view, but with the extra guarantee that it refers to a zero-terminated string.

In other words it has this additional invariant: data()[size()] == '\0'

Current version only implements a subset of the std::string_view API. That is because:

Definition at line 20 of file zstring_view.hh.

Member Typedef Documentation

◆ const_iterator

using zstring_view::const_iterator = const char*

Definition at line 24 of file zstring_view.hh.

◆ size_type

using zstring_view::size_type = size_t

Definition at line 23 of file zstring_view.hh.

Constructor & Destructor Documentation

◆ zstring_view() [1/3]

zstring_view::zstring_view ( const char *  s)
inline

Definition at line 28 of file zstring_view.hh.

Referenced by substr().

◆ zstring_view() [2/3]

constexpr zstring_view::zstring_view ( const char *  s,
size_t  n 
)
inlineconstexpr

Definition at line 30 of file zstring_view.hh.

◆ zstring_view() [3/3]

zstring_view::zstring_view ( const std::string &  s)
inline

Definition at line 32 of file zstring_view.hh.

Member Function Documentation

◆ back()

constexpr char zstring_view::back ( ) const
inlineconstexpr

Definition at line 46 of file zstring_view.hh.

◆ begin()

constexpr auto zstring_view::begin ( ) const
inlineconstexpr

Definition at line 35 of file zstring_view.hh.

◆ c_str()

constexpr const char* zstring_view::c_str ( ) const
inlineconstexpr

◆ data()

constexpr const char* zstring_view::data ( ) const
inlineconstexpr

Definition at line 47 of file zstring_view.hh.

Referenced by openmsx::Interpreter::registerSetting().

◆ empty()

constexpr auto zstring_view::empty ( ) const
inlineconstexpr

Definition at line 39 of file zstring_view.hh.

Referenced by openmsx::ReadDir::ReadDir().

◆ end()

constexpr auto zstring_view::end ( ) const
inlineconstexpr

Definition at line 36 of file zstring_view.hh.

◆ find()

constexpr auto zstring_view::find ( char  c,
size_type  pos = 0 
) const
inlineconstexpr

Definition at line 50 of file zstring_view.hh.

References view().

Referenced by openmsx::FileOperations::openFile().

◆ front()

constexpr char zstring_view::front ( ) const
inlineconstexpr

Definition at line 45 of file zstring_view.hh.

◆ operator std::string()

zstring_view::operator std::string ( ) const
inlineexplicit

Definition at line 59 of file zstring_view.hh.

◆ operator std::string_view()

constexpr zstring_view::operator std::string_view ( ) const
inlineconstexpr

Definition at line 65 of file zstring_view.hh.

References view().

◆ operator[]()

constexpr char zstring_view::operator[] ( size_type  i) const
inlineconstexpr

Definition at line 41 of file zstring_view.hh.

◆ size()

constexpr auto zstring_view::size ( ) const
inlineconstexpr

Definition at line 38 of file zstring_view.hh.

◆ substr()

constexpr zstring_view zstring_view::substr ( size_type  pos) const
inlineconstexpr

Definition at line 54 of file zstring_view.hh.

References zstring_view().

◆ view()

constexpr std::string_view zstring_view::view ( ) const
inlineconstexpr

Definition at line 62 of file zstring_view.hh.

Referenced by find(), and operator std::string_view().

Member Data Documentation

◆ npos

constexpr auto zstring_view::npos = std::string_view::npos
staticconstexpr

Definition at line 26 of file zstring_view.hh.


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