Hyper API for C++  0.0.16638
Hyper client library for C++ applications
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. More...
 
int compare (const string_view &other) const noexcept
 Compares two character sequences. More...
 
 operator std::string () const
 Implicit conversion to std::string.
 
bool empty ()
 Returns whether the view is empty.
 

Friends

bool operator== (const string_view &a, const string_view &b) noexcept
 Equality operator.
 
bool operator> (const string_view &a, const string_view &b) noexcept
 Greater operator.
 
bool operator!= (const string_view &a, const string_view &b) noexcept
 Not equal operator.
 
bool operator< (const string_view &a, const string_view &b) noexcept
 Smaller operator.
 
bool operator<= (const string_view &a, const string_view &b) noexcept
 Smaller or equal operator.
 
bool operator>= (const string_view &a, const string_view &b) noexcept
 Greater or equal operator.
 
std::ostream & operator<< (std::ostream &os, const string_view &v)
 Stream output operator.
 

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.

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.


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