Catch::StringRef Class Reference

#include <catch.hpp>

Public Types

using size_type = std::size_t
 

Public Member Functions

 StringRef () noexcept
 
 StringRef (StringRef const &other) noexcept
 
 StringRef (StringRef &&other) noexcept
 
 StringRef (char const *rawChars) noexcept
 
 StringRef (char const *rawChars, size_type size) noexcept
 
 StringRef (std::string const &stdString) noexcept
 
 ~StringRef () noexcept
 
auto operator= (StringRef const &other) noexcept -> StringRef &
 
 operator std::string () const
 
void swap (StringRef &other) noexcept
 
auto operator== (StringRef const &other) const noexcept -> bool
 
auto operator!= (StringRef const &other) const noexcept -> bool
 
auto operator[] (size_type index) const noexcept -> char
 
auto empty () const noexcept -> bool
 
auto size () const noexcept -> size_type
 
auto numberOfCharacters () const noexcept -> size_type
 
auto c_str () const -> char const *
 
auto substr (size_type start, size_type size) const noexcept -> StringRef
 
auto currentData () const noexcept -> char const *
 

Friends

struct StringRefTestAccess
 

Detailed Description

A non-owning string class (similar to the forthcoming std::string_view) Note that, because a StringRef may be a substring of another string, it may not be null terminated. c_str() must return a null terminated string, however, and so the StringRef will internally take ownership (taking a copy), if necessary. In theory this ownership is not externally visible - but it does mean (substring) StringRefs should not be shared between threads.

Member Typedef Documentation

◆ size_type

using Catch::StringRef::size_type = std::size_t

Constructor & Destructor Documentation

◆ StringRef() [1/6]

Catch::StringRef::StringRef ( )
inlinenoexcept

Referenced by Catch::operator""_sr().

◆ StringRef() [2/6]

Catch::StringRef::StringRef ( StringRef const &  other)
inlinenoexcept

◆ StringRef() [3/6]

Catch::StringRef::StringRef ( StringRef &&  other)
inlinenoexcept

◆ StringRef() [4/6]

Catch::StringRef::StringRef ( char const *  rawChars)
noexcept

◆ StringRef() [5/6]

Catch::StringRef::StringRef ( char const *  rawChars,
size_type  size 
)
inlinenoexcept

◆ StringRef() [6/6]

Catch::StringRef::StringRef ( std::string const &  stdString)
inlinenoexcept

◆ ~StringRef()

Catch::StringRef::~StringRef ( )
inlinenoexcept

Member Function Documentation

◆ c_str()

auto Catch::StringRef::c_str ( ) const -> char const *

◆ currentData()

auto Catch::StringRef::currentData ( ) const -> char const *
noexcept

◆ empty()

auto Catch::StringRef::empty ( ) const -> bool
inlinenoexcept

◆ numberOfCharacters()

auto Catch::StringRef::numberOfCharacters ( ) const -> size_type
noexcept

◆ operator std::string()

Catch::StringRef::operator std::string ( ) const

◆ operator!=()

auto Catch::StringRef::operator!= ( StringRef const &  other) const -> bool
noexcept

◆ operator=()

auto Catch::StringRef::operator= ( StringRef const &  other) -> StringRef&
inlinenoexcept

◆ operator==()

auto Catch::StringRef::operator== ( StringRef const &  other) const -> bool
noexcept

◆ operator[]()

auto Catch::StringRef::operator[] ( size_type  index) const -> char
noexcept

◆ size()

auto Catch::StringRef::size ( ) const -> size_type
inlinenoexcept

Referenced by Catch::operator""_sr().

◆ substr()

auto Catch::StringRef::substr ( size_type  start,
size_type  size 
) const -> StringRef
noexcept

◆ swap()

void Catch::StringRef::swap ( StringRef other)
noexcept

Friends And Related Function Documentation

◆ StringRefTestAccess

friend struct StringRefTestAccess
friend

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