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 ()=default
 
 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)
 
auto begin () const
 
auto end () const
 
auto rbegin () const
 
auto 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 16 of file string_view.hh.

Member Typedef Documentation

◆ const_iterator

using string_view::const_iterator = const char*

Definition at line 21 of file string_view.hh.

◆ const_reverse_iterator

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

Definition at line 22 of file string_view.hh.

◆ difference_type

using string_view::difference_type = std::ptrdiff_t

Definition at line 20 of file string_view.hh.

◆ size_type

using string_view::size_type = size_t

Definition at line 19 of file string_view.hh.

Constructor & Destructor Documentation

◆ string_view() [1/5]

string_view::string_view ( )
default

Referenced by substr().

◆ string_view() [2/5]

string_view::string_view ( const char *  s)
inline

Definition at line 28 of file string_view.hh.

◆ string_view() [3/5]

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

Definition at line 30 of file string_view.hh.

◆ string_view() [4/5]

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

Definition at line 32 of file string_view.hh.

◆ string_view() [5/5]

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

Definition at line 34 of file string_view.hh.

Member Function Documentation

◆ back()

char string_view::back ( ) const
inline

◆ begin()

auto string_view::begin ( ) const
inline

Definition at line 38 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 64 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.

Referenced by pop_front().

◆ data()

const char* string_view::data ( ) const
inline

◆ empty()

bool string_view::empty ( ) const
inline

◆ end()

auto string_view::end ( ) const
inline

Definition at line 39 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(), and openmsx::Reactor::getHwConfigs().

◆ 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(), ranges::find(), 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[]()

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

Definition at line 50 of file string_view.hh.

◆ pop_back()

void string_view::pop_back ( )
inline

Definition at line 74 of file string_view.hh.

References remove_suffix().

Referenced by StringOp::trimRight().

◆ pop_front()

void string_view::pop_front ( )
inline

◆ rbegin()

auto string_view::rbegin ( ) const
inline

Definition at line 40 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 70 of file string_view.hh.

Referenced by openmsx::Reactor::getHwConfigs(), and pop_back().

◆ rend()

auto string_view::rend ( ) const
inline

Definition at line 41 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(), ranges::find(), 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::XMLLoader::XMLElementParser::attribute(), openmsx::HardwareConfig::createDevices(), openmsx::NowindCommand::createDiskChanger(), data(), openmsx::DiskCommand::execute(), openmsx::FileOperations::expandCurrentDirFromDrive(), openmsx::FileOperations::expandTilde(), openmsx::SettingsManager::findSetting(), openmsx::Completer::formatListInColumns(), openmsx::FileOperations::getAbsolutePath(), openmsx::FileOperations::getConventionalPath(), openmsx::XMLElement::getCreateChild(), openmsx::XMLElement::getCreateChildWithAttribute(), openmsx::Reactor::getHwConfigs(), openmsx::MSXMultiIODevice::getName(), openmsx::MSXMultiMemDevice::getName(), openmsx::Keys::getName(), openmsx::FileOperations::getNativePath(), openmsx::FileBase::getOriginalName(), openmsx::HD::getTigerTreeHash(), openmsx::FileOperations::getUserHomeDir(), openmsx::CartridgeSlotManager::isExternalSlot(), openmsx::FileOperations::join(), openmsx::XmlInputArchive::load(), openmsx::MSXMotherBoard::loadExtension(), openmsx::detail::GetArg< std::string >::operator()(), openmsx::OSDConsoleRenderer::OSDConsoleRenderer(), openmsx::MidiOutLogger::plugHelper(), openmsx::MidiInReader::plugHelper(), openmsx::RS232Tester::plugHelper(), openmsx::GlobalCommandController::registerCompleter(), openmsx::HotKey::saveBindings(), openmsx::SCSIHD::SCSIHD(), openmsx::XMLElement::setAttribute(), openmsx::XMLElement::setChildData(), openmsx::OSDText::setProperty(), openmsx::OSDRectangle::setProperty(), openmsx::Setting::setValue(), openmsx::XMLLoader::XMLElementParser::start(), openmsx::DBParser::stop(), openmsx::XMLLoader::XMLElementParser::text(), 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: