openMSX
|
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) |
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.
using string_view::const_iterator = const char* |
Definition at line 21 of file string_view.hh.
using string_view::const_reverse_iterator = std::reverse_iterator<const_iterator> |
Definition at line 22 of file string_view.hh.
using string_view::difference_type = std::ptrdiff_t |
Definition at line 20 of file string_view.hh.
using string_view::size_type = size_t |
Definition at line 19 of file string_view.hh.
|
default |
Referenced by substr().
|
inline |
Definition at line 28 of file string_view.hh.
|
inline |
Definition at line 30 of file string_view.hh.
|
inline |
Definition at line 32 of file string_view.hh.
|
inline |
Definition at line 34 of file string_view.hh.
|
inline |
Definition at line 56 of file string_view.hh.
Referenced by StringOp::endsWith(), openmsx::FileOperations::join(), openmsx::DBParser::text(), and StringOp::trimRight().
|
inline |
Definition at line 38 of file string_view.hh.
Referenced by begin(), find(), find_first_of(), find_last_of(), rend(), and rfind().
|
inline |
Definition at line 64 of file string_view.hh.
Referenced by StringOp::splitOnFirst(), and StringOp::splitOnLast().
int string_view::compare | ( | string_view | x | ) | const |
Definition at line 21 of file string_view.cc.
Referenced by pop_front().
|
inline |
Definition at line 57 of file string_view.hh.
References str().
Referenced by openmsx::ConsoleLine::addChunk(), openmsx::FileOperations::expandCurrentDirFromDrive(), openmsx::FileOperations::expandTilde(), openmsx::SettingsManager::findSetting(), openmsx::Completer::formatListInColumns(), StringOp::caseless::operator()(), StringOp::casecmp::operator()(), operator<<(), openmsx::SocketConnection::output(), openmsx::Interpreter::registerSetting(), openmsx::Sha1Sum::Sha1Sum(), openmsx::DBParser::stop(), StringOp::stringToBool(), openmsx::DBParser::text(), openmsx::DiskManipulator::unregisterDrive(), openmsx::Interpreter::unregisterSetting(), and openmsx::MSXtar::~MSXtar().
|
inline |
Definition at line 45 of file string_view.hh.
Referenced by StringOp::endsWith(), openmsx::FileOperations::expandTilde(), find(), openmsx::UnicodeKeymap::getDeadkey(), openmsx::MSXMotherBoard::getJoystickPort(), openmsx::FileOperations::getUserHomeDir(), openmsx::FileOperations::join(), openmsx::MSXtar::mkdir(), openmsx::FileOperations::mkdirp(), openmsx::FileOperations::parseCommandFileArgument(), openmsx::OSDGUI::refresh(), openmsx::CommandLineParser::registerFileType(), rfind(), openmsx::SettingsConfig::saveSetting(), StringOp::split(), openmsx::DBParser::start(), StringOp::startsWith(), StringOp::trimLeft(), StringOp::trimRight(), openmsx::userFileContext(), openmsx::CliConnection::~CliConnection(), openmsx::DiskManipulator::~DiskManipulator(), openmsx::Interpreter::~Interpreter(), openmsx::MSXtar::~MSXtar(), and openmsx::OSDConsoleRenderer::~OSDConsoleRenderer().
|
inline |
Definition at line 39 of file string_view.hh.
Referenced by end(), find(), find_first_of(), find_last_of(), rbegin(), and rfind().
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().
bool string_view::ends_with | ( | char | x | ) | const |
Definition at line 131 of file string_view.cc.
string_view::size_type string_view::find | ( | string_view | s | ) | const |
Definition at line 38 of file string_view.cc.
References begin(), empty(), end(), npos, and size().
Referenced by openmsx::XMLLoader::XMLElementParser::doctype(), openmsx::DBParser::doctype(), find_first_of(), openmsx::CommandLineParser::getInterpreter(), openmsx::GlobalCommandController::tabCompletion(), StringOp::trimLeft(), StringOp::trimRight(), and openmsx::DiskManipulator::unregisterDrive().
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.
string_view::size_type string_view::find_first_of | ( | string_view | s | ) | const |
Definition at line 87 of file string_view.cc.
References begin(), end(), and npos.
Referenced by openmsx::FileOperations::expandTilde(), openmsx::Keys::getCode(), openmsx::OSDText::getType(), StringOp::splitOnFirst(), openmsx::DiskManipulator::unregisterDrive(), and openmsx::NowindHost::write().
string_view::size_type string_view::find_first_of | ( | char | c | ) | const |
Definition at line 93 of file string_view.cc.
References find().
string_view::size_type string_view::find_last_of | ( | string_view | s | ) | const |
Definition at line 101 of file string_view.cc.
References begin(), end(), npos, rbegin(), and rend().
Referenced by openmsx::NowindCommand::createDiskChanger(), openmsx::OSDText::getType(), StringOp::splitOnLast(), and openmsx::NowindHost::write().
string_view::size_type string_view::find_last_of | ( | char | c | ) | const |
Definition at line 107 of file string_view.cc.
References rfind().
|
inline |
Definition at line 55 of file string_view.hh.
Referenced by openmsx::UnicodeKeymap::getDeadkey(), openmsx::DBParser::start(), StringOp::startsWith(), and StringOp::trimLeft().
|
inline |
Definition at line 50 of file string_view.hh.
|
inline |
Definition at line 74 of file string_view.hh.
References remove_suffix().
Referenced by StringOp::trimRight().
|
inline |
Definition at line 75 of file string_view.hh.
References compare(), and remove_prefix().
Referenced by openmsx::UnicodeKeymap::getDeadkey(), openmsx::DBParser::start(), and StringOp::trimLeft().
|
inline |
Definition at line 40 of file string_view.hh.
References end().
Referenced by find_last_of(), and rfind().
|
inline |
Definition at line 65 of file string_view.hh.
Referenced by openmsx::UnicodeKeymap::getDeadkey(), pop_front(), openmsx::GlobalCommandController::registerCompleter(), openmsx::GlobalCommandController::tabCompletion(), openmsx::GlobalCommandController::unregisterCompleter(), and openmsx::Interpreter::unregisterSetting().
|
inline |
Definition at line 70 of file string_view.hh.
Referenced by openmsx::Reactor::getHwConfigs(), and pop_back().
|
inline |
Definition at line 41 of file string_view.hh.
References begin().
Referenced by find_last_of(), and rfind().
string_view::size_type string_view::rfind | ( | string_view | s | ) | const |
Definition at line 65 of file string_view.cc.
References begin(), empty(), end(), npos, and size().
Referenced by find_last_of(), openmsx::FileOperations::getDirName(), openmsx::FileOperations::getFilename(), openmsx::CommandLineParser::getInterpreter(), openmsx::CartridgeSlotManager::isExternalSlot(), openmsx::RecordedCommand::needRecord(), openmsx::FileOperations::stripExtension(), and openmsx::GlobalCommandController::tabCompletion().
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().
|
inline |
Definition at line 44 of file string_view.hh.
Referenced by openmsx::ConsoleLine::addChunk(), HexDump::decode(), Base64::decode(), openmsx::XMLLoader::XMLElementParser::doctype(), openmsx::FileOperations::expandCurrentDirFromDrive(), openmsx::FileOperations::expandTilde(), find(), openmsx::SettingsManager::findSetting(), openmsx::Completer::formatListInColumns(), openmsx::CommandLineParser::getInterpreter(), openmsx::CartridgeSlotManager::getSlotNum(), openmsx::CartridgeSlotManager::isExternalSlot(), StringOp::caseless::operator()(), StringOp::casecmp::operator()(), openmsx::ConditionalNegate< false >::operator()(), operator<<(), openmsx::SocketConnection::output(), openmsx::DirAsDSK::readSectorImpl(), rfind(), openmsx::Sha1Sum::Sha1Sum(), StringOp::stringToBool(), openmsx::GlobalCommandController::tabCompletion(), openmsx::DBParser::text(), openmsx::DiskManipulator::unregisterDrive(), and openmsx::MSXtar::~MSXtar().
bool string_view::starts_with | ( | string_view | x | ) | const |
Definition at line 116 of file string_view.cc.
Referenced by openmsx::Debugger::findProbe(), openmsx::SettingsManager::findSetting(), openmsx::UnicodeKeymap::getDeadkey(), openmsx::MSXtar::mkdir(), openmsx::GlobalCommandController::registerCompleter(), openmsx::JoyState::serialize(), openmsx::BaseSetting::setPrefix(), StringOp::startsWith(), openmsx::GlobalCommandController::tabCompletion(), openmsx::DBParser::text(), openmsx::GlobalCommandController::unregisterCompleter(), and openmsx::Interpreter::unregisterSetting().
bool string_view::starts_with | ( | char | x | ) | const |
Definition at line 121 of file string_view.cc.
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().
string_view string_view::substr | ( | size_type | pos, |
size_type | n = npos |
||
) | const |
Definition at line 32 of file string_view.cc.
References gl::min(), and string_view().
Referenced by openmsx::ConsoleLine::chunkText(), openmsx::NowindCommand::createDiskChanger(), openmsx::XMLLoader::XMLElementParser::doctype(), openmsx::DBParser::doctype(), openmsx::FileOperations::expandCurrentDirFromDrive(), openmsx::FileOperations::expandTilde(), openmsx::Debugger::findProbe(), openmsx::SettingsManager::findSetting(), openmsx::Keys::getCode(), openmsx::FileOperations::getDirName(), openmsx::FilePool::getFile(), openmsx::FileOperations::getFilename(), openmsx::CommandLineParser::getInterpreter(), openmsx::OSDText::getType(), openmsx::CartridgeSlotManager::isExternalSlot(), openmsx::RecordedCommand::needRecord(), openmsx::CDImageCLI::parseOption(), openmsx::CommandLineParser::registerFileType(), StringOp::splitOnFirst(), StringOp::splitOnLast(), openmsx::FileOperations::stripExtension(), openmsx::GlobalCommandController::tabCompletion(), openmsx::DiskManipulator::unregisterDrive(), and openmsx::NowindHost::write().
Definition at line 24 of file string_view.hh.
Referenced by openmsx::ConsoleLine::chunkText(), openmsx::XMLLoader::XMLElementParser::doctype(), openmsx::DBParser::doctype(), openmsx::FileOperations::expandTilde(), find(), find_first_of(), find_last_of(), openmsx::Keys::getCode(), openmsx::FileOperations::getDirName(), openmsx::FileOperations::getFilename(), openmsx::CommandLineParser::getInterpreter(), openmsx::OSDText::getType(), openmsx::CartridgeSlotManager::isExternalSlot(), openmsx::RecordedCommand::needRecord(), rfind(), StringOp::splitOnFirst(), StringOp::splitOnLast(), openmsx::FileOperations::stripExtension(), utf8::unchecked::substr(), openmsx::GlobalCommandController::tabCompletion(), StringOp::trimLeft(), StringOp::trimRight(), and openmsx::DiskManipulator::unregisterDrive().