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

This class implements a (close approximation) of the std::string_view class. More...

#include <string_view.hh>

Public Types

using size_type = size_t
 
using difference_type = std::ptrdiff_t
 
using const_iterator = const char *
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 

Public Member Functions

 string_view ()
 
 string_view (const string_view &s)
 
 string_view (const char *s)
 
 string_view (const char *s, size_type len)
 
 string_view (const char *first, const char *last)
 
 string_view (const std::string &s)
 
string_viewoperator= (const string_view &rhs)
 
const_iterator begin () const
 
const_iterator end () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
size_type size () const
 
bool empty () const
 
char operator[] (size_type i) const
 
char front () const
 
char back () const
 
const char * data () const
 
std::string str () const
 
void clear ()
 
void remove_prefix (size_type n)
 
void remove_suffix (size_type n)
 
void pop_back ()
 
void pop_front ()
 
int compare (string_view x) const
 
string_view substr (size_type pos, size_type n=npos) const
 
size_type find (string_view s) const
 
size_type find (char c) const
 
size_type rfind (string_view s) const
 
size_type rfind (char c) const
 
size_type find_first_of (string_view s) const
 
size_type find_first_of (char c) const
 
size_type find_last_of (string_view s) const
 
size_type find_last_of (char c) const
 
bool starts_with (string_view x) const
 
bool starts_with (char x) const
 
bool ends_with (string_view x) const
 
bool ends_with (char x) const
 

Static Public Attributes

static const size_type npos = size_type(-1)
 

Detailed Description

This class implements a (close approximation) of the std::string_view class.

https://en.cppreference.com/w/cpp/string/basic_string_view std::string_view is new in c++17. Once we can count on a c++17 compiler to compile openMSX, we can drop this class.

Definition at line 15 of file string_view.hh.

Member Typedef Documentation

◆ const_iterator

using string_view::const_iterator = const char*

Definition at line 20 of file string_view.hh.

◆ const_reverse_iterator

using string_view::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 21 of file string_view.hh.

◆ difference_type

using string_view::difference_type = std::ptrdiff_t

Definition at line 19 of file string_view.hh.

◆ size_type

using string_view::size_type = size_t

Definition at line 18 of file string_view.hh.

Constructor & Destructor Documentation

◆ string_view() [1/6]

string_view::string_view ( )
inline

Definition at line 26 of file string_view.hh.

Referenced by substr().

◆ string_view() [2/6]

string_view::string_view ( const string_view s)
inline

Definition at line 28 of file string_view.hh.

◆ string_view() [3/6]

string_view::string_view ( const char *  s)
inline

Definition at line 30 of file string_view.hh.

◆ string_view() [4/6]

string_view::string_view ( const char *  s,
size_type  len 
)
inline

Definition at line 32 of file string_view.hh.

◆ string_view() [5/6]

string_view::string_view ( const char *  first,
const char *  last 
)
inline

Definition at line 34 of file string_view.hh.

◆ string_view() [6/6]

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

Definition at line 36 of file string_view.hh.

Member Function Documentation

◆ back()

char string_view::back ( ) const
inline

◆ begin()

const_iterator string_view::begin ( ) const
inline

Definition at line 46 of file string_view.hh.

Referenced by begin(), find(), find_first_of(), find_last_of(), rend(), and rfind().

◆ clear()

void string_view::clear ( )
inline

Definition at line 72 of file string_view.hh.

Referenced by StringOp::splitOnFirst(), and StringOp::splitOnLast().

◆ compare()

int string_view::compare ( string_view  x) const

Definition at line 21 of file string_view.cc.

References gl::min().

Referenced by pop_front().

◆ data()

const char* string_view::data ( ) const
inline

◆ empty()

bool string_view::empty ( ) const
inline

◆ end()

const_iterator string_view::end ( ) const
inline

Definition at line 47 of file string_view.hh.

Referenced by end(), find(), find_first_of(), find_last_of(), rbegin(), and rfind().

◆ ends_with() [1/2]

bool string_view::ends_with ( string_view  x) const

Definition at line 126 of file string_view.cc.

Referenced by StringOp::endsWith().

◆ ends_with() [2/2]

bool string_view::ends_with ( char  x) const

Definition at line 131 of file string_view.cc.

◆ find() [1/2]

string_view::size_type string_view::find ( string_view  s) const

◆ find() [2/2]

string_view::size_type string_view::find ( char  c) const

Definition at line 59 of file string_view.cc.

References begin(), end(), and npos.

◆ find_first_of() [1/2]

string_view::size_type string_view::find_first_of ( string_view  s) const

◆ find_first_of() [2/2]

string_view::size_type string_view::find_first_of ( char  c) const

Definition at line 93 of file string_view.cc.

References find().

◆ find_last_of() [1/2]

string_view::size_type string_view::find_last_of ( string_view  s) const

◆ find_last_of() [2/2]

string_view::size_type string_view::find_last_of ( char  c) const

Definition at line 107 of file string_view.cc.

References rfind().

◆ front()

char string_view::front ( ) const
inline

◆ operator=()

string_view& string_view::operator= ( const string_view rhs)
inline

Definition at line 39 of file string_view.hh.

References data(), and size().

◆ operator[]()

char string_view::operator[] ( size_type  i) const
inline

Definition at line 58 of file string_view.hh.

◆ pop_back()

void string_view::pop_back ( )
inline

Definition at line 82 of file string_view.hh.

References remove_suffix().

Referenced by StringOp::trimRight().

◆ pop_front()

void string_view::pop_front ( )
inline

◆ rbegin()

const_reverse_iterator string_view::rbegin ( ) const
inline

Definition at line 48 of file string_view.hh.

References end().

Referenced by find_last_of(), and rfind().

◆ remove_prefix()

void string_view::remove_prefix ( size_type  n)
inline

◆ remove_suffix()

void string_view::remove_suffix ( size_type  n)
inline

Definition at line 78 of file string_view.hh.

Referenced by pop_back().

◆ rend()

const_reverse_iterator string_view::rend ( ) const
inline

Definition at line 49 of file string_view.hh.

References begin().

Referenced by find_last_of(), and rfind().

◆ rfind() [1/2]

string_view::size_type string_view::rfind ( string_view  s) const

◆ rfind() [2/2]

string_view::size_type string_view::rfind ( char  c) const

Definition at line 81 of file string_view.cc.

References begin(), npos, rbegin(), and rend().

◆ size()

size_type string_view::size ( ) const
inline

◆ starts_with() [1/2]

bool string_view::starts_with ( string_view  x) const

◆ starts_with() [2/2]

bool string_view::starts_with ( char  x) const

Definition at line 121 of file string_view.cc.

◆ str()

string string_view::str ( ) const

Definition at line 12 of file string_view.cc.

Referenced by openmsx::XMLElement::addAttribute(), openmsx::HardwareConfig::createDevices(), openmsx::NowindCommand::createDiskChanger(), openmsx::HardwareConfig::createExtensionConfig(), data(), openmsx::DiskCommand::execute(), openmsx::FileOperations::expandCurrentDirFromDrive(), openmsx::FileOperations::expandTilde(), openmsx::SettingsManager::findSetting(), openmsx::Completer::formatListInColumns(), openmsx::FileOperations::getAbsolutePath(), openmsx::FileOperations::getConventionalPath(), openmsx::AviRecorder::getFrameHeight(), openmsx::MSXMultiIODevice::getName(), openmsx::MSXMultiMemDevice::getName(), openmsx::FileOperations::getNativePath(), openmsx::FileBase::getOriginalName(), openmsx::FileOperations::getUserHomeDir(), openmsx::FileOperations::join(), openmsx::XmlInputArchive::load(), openmsx::OSDConsoleRenderer::OSDConsoleRenderer(), openmsx::MidiOutLogger::plugHelper(), openmsx::MidiInReader::plugHelper(), openmsx::RS232Tester::plugHelper(), openmsx::GlobalCommandController::registerCompleter(), openmsx::SCSIHD::SCSIHD(), openmsx::XMLElement::setAttribute(), openmsx::XMLElement::setData(), openmsx::XMLElement::setName(), openmsx::OSDText::setProperty(), openmsx::OSDRectangle::setProperty(), openmsx::DBParser::stop(), StringOp::toLower(), openmsx::Event::toString(), openmsx::GlobalCommandController::unregisterCommand(), openmsx::GlobalCommandController::unregisterCompleter(), openmsx::Debugger::unregisterDebuggable(), openmsx::DiskManipulator::unregisterDrive(), openmsx::MSXCliComm::update(), openmsx::GlobalCliComm::update(), openmsx::CliConnection::~CliConnection(), openmsx::OSDConsoleRenderer::~OSDConsoleRenderer(), and openmsx::WavAudioInput::~WavAudioInput().

◆ substr()

string_view string_view::substr ( size_type  pos,
size_type  n = npos 
) const

Member Data Documentation

◆ npos

const size_type string_view::npos = size_type(-1)
static

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