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

This class implements a subset of the proposal for std::string_ref (proposed for the next c++ standard (c++1y)). More...

#include <string_ref.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_ref ()
 
 string_ref (const string_ref &s)
 
 string_ref (const char *s)
 
 string_ref (const char *s, size_type len)
 
 string_ref (const char *first, const char *last)
 
 string_ref (const std::string &s)
 
string_refoperator= (const string_ref &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_ref x) const
 
string_ref substr (size_type pos, size_type n=npos) const
 
size_type find (string_ref s) const
 
size_type find (char c) const
 
size_type rfind (string_ref s) const
 
size_type rfind (char c) const
 
size_type find_first_of (string_ref s) const
 
size_type find_first_of (char c) const
 
size_type find_last_of (string_ref s) const
 
size_type find_last_of (char c) const
 
bool starts_with (string_ref x) const
 
bool starts_with (char x) const
 
bool ends_with (string_ref 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 subset of the proposal for std::string_ref (proposed for the next c++ standard (c++1y)).

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3334.html#classstd_1_1basic__string__ref_1ab23a4885309a116e8e67349fe0950290

It has an interface that is close to std::string, but it does not own the memory for the string. Basically it's just a wrapper around: const char* + length.

Definition at line 18 of file string_ref.hh.

Member Typedef Documentation

◆ const_iterator

using string_ref::const_iterator = const char*

Definition at line 23 of file string_ref.hh.

◆ const_reverse_iterator

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

Definition at line 24 of file string_ref.hh.

◆ difference_type

using string_ref::difference_type = std::ptrdiff_t

Definition at line 22 of file string_ref.hh.

◆ size_type

using string_ref::size_type = size_t

Definition at line 21 of file string_ref.hh.

Constructor & Destructor Documentation

◆ string_ref() [1/6]

string_ref::string_ref ( )
inline

Definition at line 29 of file string_ref.hh.

Referenced by substr().

◆ string_ref() [2/6]

string_ref::string_ref ( const string_ref s)
inline

Definition at line 31 of file string_ref.hh.

◆ string_ref() [3/6]

string_ref::string_ref ( const char *  s)
inline

Definition at line 33 of file string_ref.hh.

◆ string_ref() [4/6]

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

Definition at line 35 of file string_ref.hh.

◆ string_ref() [5/6]

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

Definition at line 37 of file string_ref.hh.

◆ string_ref() [6/6]

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

Definition at line 39 of file string_ref.hh.

Member Function Documentation

◆ back()

char string_ref::back ( ) const
inline

◆ begin()

const_iterator string_ref::begin ( ) const
inline

Definition at line 49 of file string_ref.hh.

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

◆ clear()

void string_ref::clear ( )
inline

Definition at line 75 of file string_ref.hh.

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

◆ compare()

int string_ref::compare ( string_ref  x) const

Definition at line 21 of file string_ref.cc.

References gl::min().

Referenced by pop_front().

◆ data()

const char* string_ref::data ( ) const
inline

◆ empty()

bool string_ref::empty ( ) const
inline

◆ end()

const_iterator string_ref::end ( ) const
inline

Definition at line 50 of file string_ref.hh.

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

◆ ends_with() [1/2]

bool string_ref::ends_with ( string_ref  x) const

Definition at line 126 of file string_ref.cc.

Referenced by StringOp::endsWith().

◆ ends_with() [2/2]

bool string_ref::ends_with ( char  x) const

Definition at line 131 of file string_ref.cc.

◆ find() [1/2]

string_ref::size_type string_ref::find ( string_ref  s) const

◆ find() [2/2]

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

Definition at line 59 of file string_ref.cc.

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

◆ find_first_of() [1/2]

string_ref::size_type string_ref::find_first_of ( string_ref  s) const

◆ find_first_of() [2/2]

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

Definition at line 93 of file string_ref.cc.

References find().

◆ find_last_of() [1/2]

string_ref::size_type string_ref::find_last_of ( string_ref  s) const

◆ find_last_of() [2/2]

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

Definition at line 107 of file string_ref.cc.

References rfind().

◆ front()

char string_ref::front ( ) const
inline

◆ operator=()

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

Definition at line 42 of file string_ref.hh.

References data(), and size().

◆ operator[]()

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

Definition at line 61 of file string_ref.hh.

◆ pop_back()

void string_ref::pop_back ( )
inline

Definition at line 85 of file string_ref.hh.

References remove_suffix().

Referenced by StringOp::trimRight().

◆ pop_front()

void string_ref::pop_front ( )
inline

◆ rbegin()

const_reverse_iterator string_ref::rbegin ( ) const
inline

Definition at line 51 of file string_ref.hh.

References end().

Referenced by find_last_of(), and rfind().

◆ remove_prefix()

void string_ref::remove_prefix ( size_type  n)
inline

◆ remove_suffix()

void string_ref::remove_suffix ( size_type  n)
inline

Definition at line 81 of file string_ref.hh.

Referenced by pop_back().

◆ rend()

const_reverse_iterator string_ref::rend ( ) const
inline

Definition at line 52 of file string_ref.hh.

References begin().

Referenced by find_last_of(), and rfind().

◆ rfind() [1/2]

string_ref::size_type string_ref::rfind ( string_ref  s) const

◆ rfind() [2/2]

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

Definition at line 81 of file string_ref.cc.

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

◆ size()

size_type string_ref::size ( ) const
inline

◆ starts_with() [1/2]

bool string_ref::starts_with ( string_ref  x) const

◆ starts_with() [2/2]

bool string_ref::starts_with ( char  x) const

Definition at line 121 of file string_ref.cc.

◆ str()

string string_ref::str ( ) const

Definition at line 12 of file string_ref.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_ref string_ref::substr ( size_type  pos,
size_type  n = npos 
) const

Member Data Documentation

◆ npos

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

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