Lolly 1.4.27
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
lolly::data::string_view< T > Class Template Reference

#include <string_view.hpp>

Collaboration diagram for lolly::data::string_view< T >:
Collaboration graph
[legend]

Public Member Functions

 string_view (const T *a_, int N_)
 
template<size_t N_>
constexpr string_view (const T(&null_end_str)[N_])
 
 string_view (string_view< T > &&)=default
 
constexpr string_view (const std::basic_string< T > &str)
 
 operator std::basic_string< T > ()
 
string_view< T > operator() (int start, int end) const
 
 string_view ()=delete
 
 string_view (const string_view< T > &)=delete
 
string_viewoperator= (const string_view< T > &)=delete
 
string_viewoperator= (string_view< T > &&)=delete
 

Public Attributes

const int N
 
const T *const a
 

Detailed Description

template<typename T>
class lolly::data::string_view< T >

Readonly view of string, in which char is store in a continuous space. NUL is allowed in string. this view can be construct from lolly_string et al.

Definition at line 24 of file string_view.hpp.

Constructor & Destructor Documentation

◆ string_view() [1/6]

template<typename T >
lolly::data::string_view< T >::string_view ( const T * a_,
int N_ )
inline

construct from arbitary const pointer with length. NUL can occurs in given array

Definition at line 32 of file string_view.hpp.

32: N (N_), a (a_){};
The list class represents a linked list.
Definition list.hpp:48

◆ string_view() [2/6]

template<typename T >
template<size_t N_>
constexpr lolly::data::string_view< T >::string_view ( const T(&) null_end_str[N_])
inlineconstexpr

construct from string literal

Definition at line 37 of file string_view.hpp.

38 : N (N_ - 1), a (null_end_str){};

◆ string_view() [3/6]

template<typename T >
lolly::data::string_view< T >::string_view ( string_view< T > && )
default

◆ string_view() [4/6]

template<typename T >
constexpr lolly::data::string_view< T >::string_view ( const std::basic_string< T > & str)
inlineconstexpr

Definition at line 42 of file string_view.hpp.

43 : N (str.size ()), a (str.data ()){};

◆ string_view() [5/6]

template<typename T >
lolly::data::string_view< T >::string_view ( )
delete

empty view is not allowed.

◆ string_view() [6/6]

template<typename T >
lolly::data::string_view< T >::string_view ( const string_view< T > & )
delete

Member Function Documentation

◆ operator std::basic_string< T >()

Definition at line 44 of file string_view.hpp.

44{ return std::basic_string<T> (a, N); };

◆ operator()()

template<class T >
string_view< T > lolly::data::string_view< T >::operator() ( int start,
int end ) const

Definition at line 59 of file string_view.hpp.

59 {
60 if (end <= start) {
61 return string_view<T> (nullptr, 0);
62 }
63 start= max (min (N, start), 0);
64 end = max (min (N, end), 0);
65 return string_view<T> (a + start, end - start);
66}
SI min(SI i, SI j)
Returns the minimum of two signed integers.
Definition minmax.hpp:27
SI max(SI i, SI j)
Returns the maximum of two signed integers.
Definition minmax.hpp:40

◆ operator=() [1/2]

◆ operator=() [2/2]

template<typename T >
string_view & lolly::data::string_view< T >::operator= ( string_view< T > && )
delete

Member Data Documentation

◆ N

template<typename T >
const int lolly::data::string_view< T >::N

Definition at line 26 of file string_view.hpp.

◆ a

template<typename T >
const T* const lolly::data::string_view< T >::a

Definition at line 27 of file string_view.hpp.


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