Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
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 *
 

Private Member Functions

void takeOwnership ()
 
auto isOwned () const noexcept-> bool
 
auto isSubstring () const noexcept-> bool
 

Private Attributes

char const * m_start
 
size_type m_size
 
char * m_data = nullptr
 

Static Private Attributes

static constexpr char const *const s_empty = ""
 

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.

Definition at line 491 of file catch.hpp.

Member Typedef Documentation

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

Definition at line 493 of file catch.hpp.

Constructor & Destructor Documentation

Catch::StringRef::StringRef ( )
inlinenoexcept

Definition at line 508 of file catch.hpp.

509  : StringRef( s_empty, 0 )
510  {}
static constexpr char const *const s_empty
Definition: catch.hpp:505
StringRef() noexcept
Definition: catch.hpp:508
Catch::StringRef::StringRef ( StringRef const &  other)
inlinenoexcept

Definition at line 512 of file catch.hpp.

513  : m_start( other.m_start ),
514  m_size( other.m_size )
515  {}
char const * m_start
Definition: catch.hpp:498
size_type m_size
Definition: catch.hpp:499
Catch::StringRef::StringRef ( StringRef &&  other)
inlinenoexcept

Definition at line 517 of file catch.hpp.

518  : m_start( other.m_start ),
519  m_size( other.m_size ),
520  m_data( other.m_data )
521  {
522  other.m_data = nullptr;
523  }
char * m_data
Definition: catch.hpp:501
char const * m_start
Definition: catch.hpp:498
size_type m_size
Definition: catch.hpp:499
Catch::StringRef::StringRef ( char const *  rawChars)
noexcept
Catch::StringRef::StringRef ( char const *  rawChars,
size_type  size 
)
inlinenoexcept

Definition at line 527 of file catch.hpp.

528  : m_start( rawChars ),
529  m_size( size )
530  {}
auto size() const noexcept-> size_type
Definition: catch.hpp:563
char const * m_start
Definition: catch.hpp:498
size_type m_size
Definition: catch.hpp:499
Catch::StringRef::StringRef ( std::string const &  stdString)
inlinenoexcept

Definition at line 532 of file catch.hpp.

533  : m_start( stdString.c_str() ),
534  m_size( stdString.size() )
535  {}
char const * m_start
Definition: catch.hpp:498
size_type m_size
Definition: catch.hpp:499
Catch::StringRef::~StringRef ( )
inlinenoexcept

Definition at line 537 of file catch.hpp.

537  {
538  delete[] m_data;
539  }
char * m_data
Definition: catch.hpp:501

Member Function Documentation

auto Catch::StringRef::c_str ( ) const -> char const *
auto Catch::StringRef::currentData ( ) const -> char const *
noexcept
auto Catch::StringRef::empty ( ) const -> bool
inlinenoexcept

Definition at line 560 of file catch.hpp.

560  {
561  return m_size == 0;
562  }
size_type m_size
Definition: catch.hpp:499
auto Catch::StringRef::isOwned ( ) const -> bool
privatenoexcept
auto Catch::StringRef::isSubstring ( ) const -> bool
privatenoexcept
auto Catch::StringRef::numberOfCharacters ( ) const -> size_type
noexcept
Catch::StringRef::operator std::string ( ) const
auto Catch::StringRef::operator!= ( StringRef const &  other) const -> bool
noexcept
auto Catch::StringRef::operator= ( StringRef const &  other) -> StringRef&
inlinenoexcept

Definition at line 541 of file catch.hpp.

References m_start.

541  {
542  delete[] m_data;
543  m_data = nullptr;
544  m_start = other.m_start;
545  m_size = other.m_size;
546  return *this;
547  }
char * m_data
Definition: catch.hpp:501
char const * m_start
Definition: catch.hpp:498
size_type m_size
Definition: catch.hpp:499
auto Catch::StringRef::operator== ( StringRef const &  other) const -> bool
noexcept
auto Catch::StringRef::operator[] ( size_type  index) const -> char
noexcept
auto Catch::StringRef::size ( ) const -> size_type
inlinenoexcept

Definition at line 563 of file catch.hpp.

References Catch::operator+(), Catch::operator+=(), and Catch::operator<<().

563  {
564  return m_size;
565  }
size_type m_size
Definition: catch.hpp:499
auto Catch::StringRef::substr ( size_type  start,
size_type  size 
) const -> StringRef
noexcept
void Catch::StringRef::swap ( StringRef other)
noexcept
void Catch::StringRef::takeOwnership ( )
private

Friends And Related Function Documentation

friend struct StringRefTestAccess
friend

Definition at line 496 of file catch.hpp.

Member Data Documentation

char* Catch::StringRef::m_data = nullptr
private

Definition at line 501 of file catch.hpp.

size_type Catch::StringRef::m_size
private

Definition at line 499 of file catch.hpp.

char const* Catch::StringRef::m_start
private

Definition at line 498 of file catch.hpp.

Referenced by operator=().

constexpr char const* const Catch::StringRef::s_empty = ""
staticprivate

Definition at line 505 of file catch.hpp.


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