Hyper API for C++ 0.0.18825
Hyper client library for C++ applications
Loading...
Searching...
No Matches
hyperapi::string_view Class Referencefinal

Describes an object that can refer to a constant, contiguous sequence of char-like objects. More...

#include <string_view.hpp>

Public Member Functions

 string_view (const char *data, size_t length) noexcept
 Constructor.
 
 string_view (const char *c)
 Constructor, implicit conversion from a null terminated character array.
 
 string_view (const std::string &s)
 Constructor, implicit conversion from a std::string.
 
size_t size () const noexcept
 Returns the number of elements in the view.
 
const char * data () const noexcept
 Returns a pointer to the underlying character array.
 
int compare (const string_view &other) const noexcept
 Compares two character sequences.
 
 operator std::string () const
 Implicit conversion to std::string.
 
bool empty ()
 Returns whether the view is empty.
 

Detailed Description

Describes an object that can refer to a constant, contiguous sequence of char-like objects.

Surrogate for C++17 std::string_view

Definition at line 26 of file string_view.hpp.

Constructor & Destructor Documentation

◆ string_view() [1/3]

hyperapi::string_view::string_view ( const char *  data,
size_t  length 
)
inlinenoexcept

Constructor.

Definition at line 29 of file string_view.hpp.

◆ string_view() [2/3]

hyperapi::string_view::string_view ( const char *  c)
inline

Constructor, implicit conversion from a null terminated character array.

Definition at line 34 of file string_view.hpp.

◆ string_view() [3/3]

hyperapi::string_view::string_view ( const std::string &  s)
inline

Constructor, implicit conversion from a std::string.

Definition at line 39 of file string_view.hpp.

Member Function Documentation

◆ compare()

int hyperapi::string_view::compare ( const string_view other) const
noexcept

Compares two character sequences.

Returns
A negative value if this view is less than the other character sequence; zero if both character sequences are equal; a positive value if this view is greater than the other character sequence.

◆ data()

const char * hyperapi::string_view::data ( ) const
inlinenoexcept

Returns a pointer to the underlying character array.

The pointer is such that the range [data(); data() + size()) is valid and the values in it correspond to the values of the view.

Note that this character array is not guaranteed to be null-terminated.

Returns
A pointer to the underlying character array.

Definition at line 55 of file string_view.hpp.

◆ empty()

bool hyperapi::string_view::empty ( )
inline

Returns whether the view is empty.

Definition at line 99 of file string_view.hpp.

◆ operator std::string()

hyperapi::string_view::operator std::string ( ) const
inline

Implicit conversion to std::string.

Definition at line 68 of file string_view.hpp.

◆ size()

size_t hyperapi::string_view::size ( ) const
inlinenoexcept

Returns the number of elements in the view.

Definition at line 46 of file string_view.hpp.


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