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

typedef size_t size_type
typedef std::ptrdiff_t difference_type
typedef const char * const_iterator
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator

Public Member Functions

 string_ref ()
 string_ref (const string_ref &str)
 string_ref (const char *str)
 string_ref (const char *str, size_type len)
 string_ref (const char *begin, const char *end)
 string_ref (const std::string &str)
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 ends_with (string_ref 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

typedef const char* string_ref::const_iterator

Definition at line 23 of file string_ref.hh.

typedef std::reverse_iterator<const_iterator> string_ref::const_reverse_iterator

Definition at line 24 of file string_ref.hh.

typedef std::ptrdiff_t string_ref::difference_type

Definition at line 22 of file string_ref.hh.

typedef size_t string_ref::size_type

Definition at line 21 of file string_ref.hh.

Constructor & Destructor Documentation

string_ref::string_ref ( )
inline

Definition at line 29 of file string_ref.hh.

Referenced by substr().

string_ref::string_ref ( const string_ref str)
inline

Definition at line 31 of file string_ref.hh.

string_ref::string_ref ( const char *  str)
inline

Definition at line 33 of file string_ref.hh.

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

Definition at line 35 of file string_ref.hh.

string_ref::string_ref ( const char *  begin,
const char *  end 
)
inline

Definition at line 37 of file string_ref.hh.

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

Definition at line 39 of file string_ref.hh.

Member Function Documentation

char string_ref::back ( ) const
inline
const_iterator string_ref::begin ( ) const
inline
void string_ref::clear ( )
inline
int string_ref::compare ( string_ref  x) const

Definition at line 41 of file string_ref.cc.

Referenced by operator<().

const char* string_ref::data ( ) const
inline
bool string_ref::empty ( ) const
inline
const_iterator string_ref::end ( ) const
inline
bool string_ref::ends_with ( string_ref  x) const

Definition at line 142 of file string_ref.cc.

References data(), and size().

Referenced by StringOp::endsWith(), and openmsx::Reactor::getHwConfigs().

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

Definition at line 79 of file string_ref.cc.

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

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

Definition at line 107 of file string_ref.cc.

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

Referenced by openmsx::FileOperations::expandTilde(), find_last_of(), and StringOp::splitOnFirst().

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

Definition at line 113 of file string_ref.cc.

References find().

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

Definition at line 121 of file string_ref.cc.

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

Referenced by StringOp::splitOnLast().

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

Definition at line 127 of file string_ref.cc.

References rfind().

char string_ref::front ( ) const
inline

Definition at line 66 of file string_ref.hh.

Referenced by StringOp::startsWith().

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

Definition at line 42 of file string_ref.hh.

References data(), and size().

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

Definition at line 61 of file string_ref.hh.

void string_ref::pop_back ( )
inline

Definition at line 78 of file string_ref.hh.

References remove_suffix().

Referenced by StringOp::trimRight().

void string_ref::pop_front ( )
inline

Definition at line 79 of file string_ref.hh.

References remove_prefix().

Referenced by StringOp::trimLeft().

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().

void string_ref::remove_prefix ( size_type  n)

Definition at line 19 of file string_ref.cc.

References clear().

Referenced by pop_front().

void string_ref::remove_suffix ( size_type  n)

Definition at line 29 of file string_ref.cc.

References clear().

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

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().

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

Definition at line 101 of file string_ref.cc.

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

size_type string_ref::size ( ) const
inline
bool string_ref::starts_with ( string_ref  x) const

Definition at line 136 of file string_ref.cc.

References data(), and size().

Referenced by openmsx::JoystickConfigChecker::check(), and StringOp::startsWith().

string string_ref::str ( ) const
string_ref string_ref::substr ( size_type  pos,
size_type  n = npos 
) const

Member Data Documentation

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

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