JSON Voorhees
Killer JSON for C++
jsonv::detail::string_view Class Reference

A non-owning reference to an std::string, as proposed to the C++ Standard Committee by Jeffrey Yasskin in N3921 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3921.html). More...

#include <jsonv/detail/string_view.hpp>

Public Types

using value_type = char
 
using pointer = const value_type *
 
using reference = const value_type &
 
using const_reference = const value_type &
 
using iterator = pointer
 
using const_iterator = pointer
 
using reverse_iterator = std::reverse_iterator< iterator >
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 

Public Member Functions

 string_view (pointer p) noexcept
 
constexpr string_view (pointer p, size_type len) noexcept
 
template<typename UAllocator >
 string_view (const std::basic_string< value_type, std::char_traits< value_type >, UAllocator > &src) noexcept(noexcept(src.data())&&noexcept(src.length()))
 
 string_view (const string_view &) noexcept=default
 
string_viewoperator= (const string_view &) noexcept=default
 
template<typename UAllocator >
 operator std::basic_string< value_type, std::char_traits< value_type >, UAllocator > () const
 
constexpr size_type size () const noexcept
 
constexpr size_type max_size () const noexcept
 
constexpr size_type length () const noexcept
 
constexpr bool empty () const noexcept
 
constexpr const_reference operator[] (size_type idx) const
 
const_reference at (size_type idx) const
 
constexpr const_reference front () const
 
constexpr const_reference back () const
 
constexpr pointer data () const
 
constexpr const_iterator begin () const
 
constexpr const_iterator cbegin () const
 
constexpr const_iterator end () const
 
constexpr const_iterator cend () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator rend () const
 
const_reverse_iterator crend () const
 
void clear ()
 
void remove_prefix (size_type n)
 
void remove_suffix (size_type n)
 
string_view substr (size_type idx, size_type count=npos) const
 
bool starts_with (value_type val) const
 
bool starts_with (const string_view &sub) const
 
bool ends_with (value_type val) const
 
bool ends_with (const string_view &sub) const
 
size_type find (const string_view &sub) const
 
size_type find (value_type val) const
 
size_type rfind (const string_view &sub) const
 
size_type rfind (value_type val) const
 
size_type find_first_of (value_type val) const
 
size_type find_first_of (const string_view &chars) const
 
size_type find_first_not_of (value_type val) const
 
size_type find_first_not_of (const string_view &chars) const
 
size_type find_last_of (value_type val) const
 
size_type find_last_of (const string_view &chars) const
 
size_type find_last_not_of (value_type val) const
 
size_type find_last_not_of (const string_view &chars) const
 
bool operator== (const string_view &other) const
 
bool operator!= (const string_view &other) const
 
bool operator< (const string_view &other) const
 
bool operator<= (const string_view &other) const
 
bool operator> (const string_view &other) const
 
bool operator>= (const string_view &other) const
 

Static Public Attributes

static constexpr size_type npos = size_type(~0)
 

Friends

std::ostream & operator<< (std::ostream &os, const string_view &self)
 

Detailed Description

A non-owning reference to an std::string, as proposed to the C++ Standard Committee by Jeffrey Yasskin in N3921 (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3921.html).

Unlike the one proposed, this is not templated over the char type, as this project only deals with UTF-8 encoded strings.

Definition at line 34 of file string_view.hpp.


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