13#include <daw/daw_algorithm.h>
14#include <daw/daw_cpp_feature_check.h>
15#include <daw/daw_exception.h>
16#include <daw/daw_fnv1a_hash.h>
17#include <daw/daw_generic_hash.h>
18#include <daw/daw_logic.h>
19#include <daw/daw_math.h>
20#include <daw/daw_move.h>
21#include <daw/daw_swap.h>
22#include <daw/daw_traits.h>
23#include <daw/impl/daw_string_impl.h>
24#include <daw/iterator/daw_back_inserter.h>
25#include <daw/iterator/daw_iterator.h>
40#define DAW_REQ_UNARY_PRED( Pred, Type ) \
41 std::enable_if_t<traits::is_unary_predicate_v<Pred, Type>, std::nullptr_t> = \
47#define DAW_REQ_CONTIG_CHAR_RANGE( Range, CharT ) \
48 std::enable_if_t<sv2_details::is_string_view_like<Range, CharT>::value, \
49 std::nullptr_t> = nullptr
53#define DAW_REQ_CHAR_PTR( Pointer ) \
54 std::enable_if_t<sv2_details::is_char_pointer_v<Pointer, const_pointer>, \
55 std::nullptr_t> = nullptr
59#define DAW_REQ_CONTIG_CHAR_RANGE_CTOR( Type ) \
61 sv2_details::is_contigious_range_constructible<Type, CharT>::value, \
62 std::nullptr_t> = nullptr
73 template<
typename CharT, CharT... needles>
75 inline constexpr bool operator( )( CharT c )
const {
76 return ( ( c == needles ) | ... );
80 template<
auto needle,
auto... needles>
81 inline static constexpr any_of_t<
decltype( needle ), needle, needles...>
86 template<
typename CharT, CharT... needles>
88 inline constexpr bool operator( )( CharT c )
const {
89 return ( ( c != needles ) & ... );
93 template<
auto needle,
auto... needles>
94 inline static constexpr none_of_t<
decltype( needle ), needle, needles...>
97 namespace sv2_details {
99 constexpr std::size_t find_predicate_result_size( T
const & ) {
104 using has_datasize_test =
typename std::remove_reference<
105 decltype( std::data( std::declval<T const &>( ) ) +
106 std::size( std::declval<T const &>( ) ) )>::type;
109 using is_sv2_test =
typename T::i_am_a_daw_string_view2;
112 using is_sv2_t = daw::is_detected<is_sv2_test, T>;
114 template<
typename T,
typename CharT>
115 struct is_string_view_like
116 : std::conjunction<daw::is_detected<has_datasize_test, T>,
117 daw::not_trait<is_sv2_t<T>>> {};
119 static_assert( daw::is_detected_v<has_datasize_test, std::string> );
120 static_assert( daw::not_trait<is_sv2_t<std::string>>::value );
121 static_assert( is_string_view_like<std::string, char>::value );
123 template<
typename T,
typename CharT>
124 struct is_contigious_range_constructible
125 : std::is_constructible<T, CharT *, std::size_t> {};
127 template<
typename T,
typename Po
interType>
128 inline constexpr bool is_char_pointer_v =
129 std::is_pointer_v<T> and std::is_convertible_v<T, PointerType>;
136 template<
typename CharT,
string_view_bounds_type BoundsType>
143 std::add_lvalue_reference_t<std::add_const_t<CharT>>;
155 static constexpr auto bp_eq = []( CharT l, CharT r )
noexcept {
159 template<
string_view_bounds_type B>
160 static constexpr bool is_last_a_pointer_v =
161 B == string_view_bounds_type::pointer;
163 using last_type = std::conditional_t<is_last_a_pointer_v<BoundsType>,
164 const_pointer, size_type>;
165 static inline constexpr last_type default_last = [] {
166 if constexpr( is_last_a_pointer_v<BoundsType> ) {
172 using last_difference_type =
173 std::conditional_t<is_last_a_pointer_v<BoundsType>, difference_type,
176 template<
string_view_bounds_type Bounds,
typename LastType>
177 DAW_ATTRIB_INLINE
static constexpr last_type
178 make_last( const_pointer f, LastType l )
noexcept {
179 if constexpr( std::is_pointer_v<LastType> ) {
180 if constexpr( is_last_a_pointer_v<Bounds> ) {
184 return static_cast<last_type
>( l - f );
187 if constexpr( is_last_a_pointer_v<Bounds> ) {
188 return f +
static_cast<difference_type
>( l );
191 return static_cast<size_type
>( l );
196 template<
string_view_bounds_type Bounds>
197 DAW_ATTRIB_INLINE
constexpr const_pointer last_pointer( )
const {
198 if constexpr( is_last_a_pointer_v<Bounds> ) {
201 return m_first +
static_cast<difference_type
>( m_last );
205 template<
string_view_bounds_type Bounds>
206 DAW_ATTRIB_INLINE
static constexpr size_type
size( const_pointer f,
208 if constexpr( is_last_a_pointer_v<Bounds> ) {
209 return static_cast<size_type
>( l - f );
216 template<
string_view_bounds_type Bounds>
217 DAW_ATTRIB_INLINE
constexpr void dec_front( size_type n ) {
218 if constexpr( is_last_a_pointer_v<Bounds> ) {
219 m_first +=
static_cast<difference_type
>( n );
221 m_first +=
static_cast<difference_type
>( n );
226 template<
string_view_bounds_type Bounds>
227 DAW_ATTRIB_INLINE
constexpr void dec_back( size_type n ) {
228 if constexpr( is_last_a_pointer_v<Bounds> ) {
229 m_last -=
static_cast<difference_type
>( n );
235 const_pointer m_first =
nullptr;
236 last_type m_last = default_last;
240 ( std::numeric_limits<size_type>::max )( );
256 , m_last( make_last<BoundsType>(
nullptr,
nullptr ) ) {}
270 , m_last( make_last<BoundsType>( s, count ) ) {}
278 template<
typename CharPtr, DAW_REQ_CHAR_PTR( CharPtr )>
282 make_last<BoundsType>( s, details::strlen<size_type>( s ) ) ) {}
291 template<
string_view_bounds_type B>
294 : m_first( sv.data( ) )
295 , m_last( make_last<BoundsType>( sv.data( ),
296 ( std::min )( sv.size( ), count ) ) ) {
304 template<
typename StringView,
307 : m_first( std::data( sv ) )
308 , m_last( make_last<BoundsType>( m_first, std::size( sv ) ) ) {}
317 template<
typename StringView,
320 : m_first( std::data( sv ) )
321 , m_last( make_last<BoundsType>(
322 m_first, ( std::min )( std::size( sv ), count ) ) ) {}
330 template<std::
size_t N>
332 : m_first( string_literal )
333 , m_last( make_last<BoundsType>( string_literal, N - 1 ) ) {}
346 , m_last( make_last<BoundsType>( first, last ) ) {}
354 template<
typename T, DAW_REQ_CONTIG_CHAR_RANGE_CTOR( T )>
355 explicit constexpr operator T( ) const
356 noexcept(
std::is_nothrow_constructible_v<T, CharT *,
size_type> ) {
357 return T{ data( ),
size( ) };
397 return last_pointer<BoundsType>( );
405 return last_pointer<BoundsType>( );
437 return size<BoundsType>( m_first, m_last );
486 daw::exception::precondition_check<std::out_of_range>(
487 pos <
size( ),
"Attempt to access basic_string_view past end" );
488 return operator[]( pos );
502 return *std::prev( end( ) );
511 m_last = make_last<BoundsType>(
nullptr,
size_type{0} );
519 m_last = make_last<BoundsType>(
nullptr,
size_type{0} );
526 dec_front<BoundsType>( ( std::min )( n,
size( ) ) );
533 dec_front<BoundsType>( ( std::min )(
size_type{ 1U },
size( ) ) );
539 dec_back<BoundsType>( ( std::min )( n,
size( ) ) );
544 dec_back<BoundsType>( ( std::min )(
size_type{ 1U },
size( ) ) );
550 auto result = front( );
562 remove_prefix( count );
575 auto pos = find( where );
576 auto result = pop_front( pos );
586 auto pos = find( where );
587 auto result = pop_front( pos );
597 auto pos = find( where );
598 auto result = pop_front( pos );
599 remove_prefix( where.size( ) );
608 auto pos = find( where );
609 auto result = pop_front( pos );
624 template<
typename UnaryPredicate,
629 auto pos = find_first_of_if( DAW_MOVE( pred ) );
630 return pop_front( pos );
643 template<
typename UnaryPredicate,
647 auto result = pop_front_until( pred,
nodiscard );
648 remove_prefix( sv2_details::find_predicate_result_size( pred ) );
656 auto result = back( );
666 count = ( std::min )( count,
size( ) );
668 remove_suffix( count );
678 auto pos = rfind( where );
680 auto result{ *
this };
681 remove_prefix( npos );
684 return substr( pos + where.size( ) );
693 auto pos = rfind( where );
695 auto result{ *
this };
696 remove_prefix( npos );
699 return substr( pos + where.size( ) );
709 auto pos = rfind( where );
711 auto result{ *
this };
712 remove_prefix( npos );
715 auto result = substr( pos + where.size( ) );
716 remove_suffix(
size( ) - pos );
726 auto pos = rfind( where );
728 auto result{ *
this };
729 remove_prefix( npos );
732 auto result = substr( pos + 1 );
733 remove_suffix(
size( ) - pos );
745 template<
typename UnaryPredicate,
750 auto pos = find_last_of_if( DAW_MOVE( pred ) );
753 remove_prefix( npos );
757 substr( pos + sv2_details::find_predicate_result_size( pred ) );
758 remove_suffix(
size( ) - pos );
769 auto pos = find( where );
773 auto result = pop_front( pos );
774 remove_prefix( where.size( ) );
785 auto pos = rfind( where );
789 auto result = substr( pos + where.size( ) );
790 remove_suffix(
size( ) - pos );
800 auto pos = find( where );
801 remove_prefix( pos );
812 auto pos = find( where );
813 dec_front<BoundsType>( ( std::min )(
size( ), pos ) );
824 auto pos = find( where );
825 dec_front<BoundsType>( ( std::min )(
size( ), pos + where.size( ) ) );
836 auto pos = find( where );
837 dec_front<BoundsType>( ( std::min )(
size( ), pos ) );
846 template<
typename UnaryPredicate,
849 auto pos = find_first_of_if( pred );
850 dec_front<BoundsType>( ( std::min )(
851 size( ), pos + sv2_details::find_predicate_result_size( pred ) ) );
859 template<
typename UnaryPredicate,
863 auto pos = find_if( pred );
864 dec_front<BoundsType>( ( std::min )(
size( ), pos ) );
873 daw::exception::precondition_check<std::out_of_range>( new_size <=
875 m_last = make_last<BoundsType>(
882 daw::exception::precondition_check<std::out_of_range>(
883 pos <=
size( ),
"Attempt to access basic_string_view past end" );
890 daw::algorithm::copy( f, l, dest );
896 return copy( dest, count, 0 );
901 daw::exception::precondition_check<std::out_of_range>(
902 pos <=
size( ),
"Attempt to access basic_string_view past end" );
904 static_cast<size_type>( ( std::min )( count,
size( ) - pos ) );
905 return { m_first + pos, m_first + pos + rcount };
909 return substr( 0, npos );
913 return substr( pos, npos );
917 template<
typename Compare = std::less<
void>,
string_view_bounds_type BL,
918 string_view_bounds_type BR>
922 constexpr auto const str_compare = []( CharT
const *p0, CharT
const *p1,
923 size_type len, Compare &c ) {
924 auto const last = p0 + len;
925 while( p0 != last ) {
926 if( c( *p0, *p1 ) ) {
929 if( c( *p1, *p0 ) ) {
939 str_compare( lhs.
data( ), rhs.
data( ),
940 ( std::min )( lhs.size( ), rhs.size( ) ), cmp );
942 if( lhs.size( ) < rhs.size( ) ) {
945 if( rhs.size( ) < lhs.size( ) ) {
952 template<
typename Compare = std::less<>,
string_view_bounds_type B>
954 Compare cmp = Compare{ } )
const {
959 template<
typename Compare = std::less<>,
typename StringView,
960 DAW_REQ_CONTIG_CHAR_RANGE( StringView, CharT )>
962 Compare cmp = Compare{ } )
const {
967 template<
typename Compare = std::less<>, std::
size_t N>
969 Compare cmp = Compare{ } )
const {
973 template<
typename Compare = std::less<>>
976 Compare cmp = Compare{ } )
const {
977 return compare( substr( pos1, count1 ), v, cmp );
980 template<
typename Compare = std::less<>,
string_view_bounds_type Bounds>
984 Compare cmp = Compare{ } )
const {
985 return compare( substr( pos1, count1 ), v.
substr( pos2, count2 ), cmp );
988 template<
typename Compare = std::less<>>
991 Compare cmp = Compare{ } )
const {
992 return compare( substr( pos1, count1 ),
996 template<
typename Compare = std::less<>>
999 Compare cmp = Compare{ } )
const {
1000 return compare( substr( pos1, count1 ),
1005 template<
string_view_bounds_type Bounds>
1009 if(
size( ) < v.size( ) ) {
1016 details::search( begin( ) + pos, end( ), v.
begin( ), v.
end( ) );
1017 if( end( ) == result ) {
1020 return static_cast<size_type>( result - begin( ) );
1023 template<
string_view_bounds_type Bounds>
1026 return find( v, 0 );
1035 return find( c, 0 );
1052 template<
string_view_bounds_type Bounds>
1056 if(
size( ) < v.size( ) ) {
1059 pos = ( std::min )( pos,
size( ) - v.size( ) );
1066 if( details::compare( cur, v.
begin( ), v.size( ) ) == 0 ) {
1067 return static_cast<size_type>( cur - begin( ) );
1069 if( cur == begin( ) ) {
1081 template<
string_view_bounds_type Bounds>
1084 return rfind( v, npos );
1111 template<
string_view_bounds_type Bounds>
1117 auto const iter = details::find_first_of( begin( ) + pos, end( ),
1120 if( end( ) == iter ) {
1123 return static_cast<size_type>( std::distance( begin( ), iter ) );
1129 template<
string_view_bounds_type Bounds>
1132 return find_first_of( v, 0 );
1146 template<
string_view_bounds_type Bounds>
1149 if( pos + v.size( ) >=
size( ) or v.
empty( ) ) {
1153 details::search( begin( ) + pos, end( ), v.
begin( ), v.
end( ) );
1154 if( cend( ) == iter ) {
1157 return static_cast<size_type>( std::distance( begin( ), iter ) );
1160 template<
string_view_bounds_type Bounds>
1163 return search( v, 0 );
1175 template<
string_view_bounds_type Bounds>
1178 if( pos + v.size( ) >=
size( ) or v.
empty( ) ) {
1181 auto last_pos = pos;
1182 auto fpos = search( v, pos );
1183 while( fpos != npos ) {
1185 fpos = search( v, fpos );
1186 if( fpos == last_pos ) {
1193 template<
string_view_bounds_type Bounds>
1196 return search_last( v, 0 );
1208 template<
typename UnaryPredicate,
1213 (void)traits::is_unary_predicate_test<UnaryPredicate, CharT>( );
1215 if( pos >=
size( ) ) {
1219 details::find_first_of_if( cbegin( ) + pos, cend( ), pred );
1220 if( cend( ) == iter ) {
1223 return static_cast<size_type>( iter - cbegin( ) );
1226 template<
typename UnaryPredicate,
1230 return find_first_of_if( pred, 0 );
1233 template<
typename UnaryPredicate,
1238 traits::is_unary_predicate_test<UnaryPredicate, CharT>( );
1240 if( pos >=
size( ) ) {
1244 details::find_first_not_of_if( begin( ) + pos, end( ), pred );
1245 if( end( ) == iter ) {
1248 return static_cast<size_type>( std::distance( begin( ), iter ) );
1251 template<
typename UnaryPredicate,
1255 return find_first_not_of_if( pred, 0 );
1260 return find_first_of(
1266 return find_first_of(
1278 reverse_distance( const_reverse_iterator first,
1279 const_reverse_iterator last )
const {
1283 return (
size( ) - 1u ) -
1284 static_cast<size_t>( std::distance( first, last ) );
1288 template<
string_view_bounds_type Bounds>
1294 if( pos >=
size( ) ) {
1297 pos =
size( ) - ( pos + 1U );
1299 auto haystack = substr( pos );
1300 auto iter = daw::algorithm::find_first_of(
1301 haystack.rbegin( ), haystack.rend( ), s.
rbegin( ), s.
rend( ) );
1302 return iter == rend( ) ? npos : reverse_distance( rbegin( ), iter );
1305 template<
string_view_bounds_type Bounds>
1308 return find_last_of( s, npos );
1321 template<
size_type N>
1328 template<
size_type N>
1349 template<
typename UnaryPredicate,
1354 (void)traits::is_unary_predicate_test<UnaryPredicate, CharT>( );
1356 auto haystack = substr( 0, pos );
1357 auto iter = daw::algorithm::find_if( haystack.crbegin( ),
1358 haystack.crend( ), pred );
1359 return iter == crend( ) ? npos : reverse_distance( crbegin( ), iter );
1362 template<
typename UnaryPredicate,
1366 return find_last_of_if( pred, npos );
1369 template<
string_view_bounds_type Bounds>
1373 if( pos >=
size( ) ) {
1380 auto haystack = substr( pos );
1382 haystack.begin( ), haystack.end( ), v.
begin( ),
1383 std::next( v.
begin( ),
static_cast<ptrdiff_t
>( v.size( ) ) ), bp_eq );
1384 if( end( ) == iter ) {
1388 return static_cast<size_type>( std::distance( begin( ), iter ) );
1391 template<
string_view_bounds_type Bounds>
1394 return find_first_not_of( v, 0 );
1399 return find_first_not_of(
1405 return find_first_not_of(
1412 return find_first_not_of(
1422 template<
size_type N>
1425 return find_first_not_of(
1435 template<
size_type N>
1438 return find_first_not_of(
1442 template<
typename UnaryPredicate,
1450 if( pos >
size( ) ) {
1454 if( not pred( m_first[n] ) ) {
1461 template<
typename UnaryPredicate,
1465 return find_last_not_of_if( pred, npos );
1468 template<
string_view_bounds_type Bounds>
1476 if( pos >
size( ) ) {
1483 if( v.
find( m_first[n] ) == npos ) {
1490 template<
string_view_bounds_type Bounds>
1493 return find_last_not_of( v, npos );
1498 return find_last_not_of(
1504 return find_last_not_of( c, npos );
1510 return find_last_not_of(
1530 return front( ) == c;
1533 template<
string_view_bounds_type Bounds>
1536 if( s.size( ) >
size( ) ) {
1539 auto lhs = begin( );
1540 while( not s.
empty( ) ) {
1541 if( *lhs++ != s.
front( ) ) {
1557 return back( ) == c;
1560 template<
string_view_bounds_type Bounds>
1563 if( s.size( ) >
size( ) ) {
1566 auto lhs = rbegin( );
1567 while( not s.
empty( ) ) {
1568 if( *lhs++ != s.
back( ) ) {
1582 return compare( rhs ) == 0;
1585 template<
typename StringView,
1590 .compare( rhs ) == 0;
1600 return compare( rhs ) != 0;
1608 template<
typename StringView,
1613 .compare( rhs ) != 0;
1617 return compare( rhs ) < 0;
1625 template<
typename StringView,
1630 .compare( rhs ) < 0;
1635 return compare( rhs ) <= 0;
1643 template<
typename StringView,
1648 .compare( rhs ) <= 0;
1652 return compare( rhs ) > 0;
1660 template<
typename StringView,
1665 .compare( rhs ) > 0;
1670 return compare( rhs ) >= 0;
1678 template<
typename StringView,
1683 .compare( rhs ) >= 0;
1688 inline constexpr bool operator( )( CharT c )
const noexcept {
1689 return daw::nsc_or( c == CharT(
' ' ), c == CharT(
'\t' ),
1690 c == CharT(
'\n' ), c == CharT(
'\v' ),
1691 c == CharT(
'\f' ), c == CharT(
'\r' ) );
1696 template<
typename UnaryPred, DAW_REQ_UNARY_PRED( UnaryPred, CharT )>
1698 auto const last_pos = find_first_not_of_if( is_whitespace );
1699 remove_prefix( last_pos );
1703 remove_prefix_while( is_space{ } );
1707 auto result = *
this;
1712 template<
typename UnaryPred, DAW_REQ_UNARY_PRED( UnaryPred, CharT )>
1714 auto pos = find_last_not_of_if( is_whitespace );
1719 remove_suffix_while( is_space{ } );
1723 auto result = *
this;
1724 result = remove_suffix_while( is_space{ } );
1729 trim_prefix( is_space{ } );
1730 trim_suffix( is_space{ } );
1734 auto result = trim_prefix_copy( );
1735 result.trim_suffix( );
1741 template<
typename CharT>
1745 template<
typename CharT, std::
size_t N>
1750 namespace string_view_literals {
1752 operator"" _sv(
char const *str, std::size_t len )
noexcept {
1756#if defined( __cpp_char8_t )
1758 operator"" _sv( char8_t
const *str, std::size_t len )
noexcept {
1759 return u8string_view{ str, len };
1764 operator"" _sv( char16_t
const *str, std::size_t len )
noexcept {
1769 operator"" _sv( char32_t
const *str, std::size_t len )
noexcept {
1774 operator"" _sv(
wchar_t const *str, std::size_t len )
noexcept {
1782 template<
typename CharT, daw::sv2::
string_view_bounds_type Bounds>
1786 return daw::fnv1a_hash( s.data( ), s.size( ) );
1791#undef DAW_REQ_UNARY_PRED
1792#undef DAW_REQ_CONTIG_CHAR_RANGE
1793#undef DAW_REQ_CONTIG_CHAR_RANGE
1794#undef DAW_REQ_CONTIG_CHAR_RANGE_CTOR
#define DAW_REQ_UNARY_PRED(Pred, Type)
Require Pred to be a Unary Predicate.
Definition: daw_string_view2.h:40
#define DAW_REQ_CONTIG_CHAR_RANGE(Range, CharT)
Require a contiguous character range.
Definition: daw_string_view2.h:47
static constexpr none_of_t< decltype(needle), needle, needles... > none_of
Definition: daw_string_view2.h:95
constexpr nodiscard_t nodiscard
Definition: daw_string_view2.h:69
static constexpr any_of_t< decltype(needle), needle, needles... > any_of
Definition: daw_string_view2.h:82
basic_string_view< char16_t > u16string_view
Definition: daw_string_view2_fwd.h:47
@ size
Store the end of range as a size_type. This is optimal for where calls to size( ) or remove_suffix li...
basic_string_view(CharT const (&)[N]) -> basic_string_view< CharT, default_string_view_bounds_type >
Definition: daw_string_view2.h:64
Definition: daw_string_view2.h:1781
A predicate type used in the find based routine to return true when the element is one of the specifi...
Definition: daw_string_view2.h:74
The class template basic_string_view describes an object that can refer to a constant contiguous sequ...
Definition: daw_string_view2.h:137
constexpr size_type find_first_of(const_pointer str) const
Definition: daw_string_view2.h:1142
constexpr size_type find_last_not_of(CharT c, size_type pos) const
Definition: daw_string_view2.h:1497
constexpr size_type find(basic_string_view< CharT, Bounds > v) const
Definition: daw_string_view2.h:1025
constexpr size_type find_last_of_if(UnaryPredicate pred) const
Definition: daw_string_view2.h:1365
constexpr const_iterator cbegin() const
Returns an iterator to the first character of the view.
Definition: daw_string_view2.h:372
constexpr size_type find(const_pointer s) const
Definition: daw_string_view2.h:1048
constexpr basic_string_view(std::nullptr_t, size_type n) noexcept=delete
Prevents nullptr literals and a size_type to construct a string_view.
constexpr size_type length() const
Returns the number of CharT elements in the view.
Definition: daw_string_view2.h:442
constexpr void trim_suffix() noexcept
Definition: daw_string_view2.h:1718
constexpr bool ends_with(const_pointer s) const
Definition: daw_string_view2.h:1576
constexpr size_type find_last_of(CharT const (&s)[N])
Definition: daw_string_view2.h:1329
constexpr size_type find_last_not_of(const_pointer s, size_type pos) const
Definition: daw_string_view2.h:1515
std::ptrdiff_t difference_type
Definition: daw_string_view2.h:149
constexpr basic_string_view substr(size_type pos) const
Definition: daw_string_view2.h:912
std::reverse_iterator< iterator > reverse_iterator
Definition: daw_string_view2.h:146
constexpr const_pointer data() const
Returns a pointer to the underlying character range corresponding to the values of the view.
Definition: daw_string_view2.h:459
constexpr void resize(size_type new_size)
Set the size of the range.
Definition: daw_string_view2.h:872
constexpr bool empty() const
Checks if the view has no characters.
Definition: daw_string_view2.h:448
constexpr size_type find_first_of(basic_string_view< CharT, Bounds > v) const
Find the first item in v that is in string from beginning.
Definition: daw_string_view2.h:1131
constexpr void remove_prefix(size_type n)
Increment the data( ) pointer by n. If string_view is empty, it does nothing.
Definition: daw_string_view2.h:525
CharT value_type
Definition: daw_string_view2.h:138
std::add_lvalue_reference_t< std::add_const_t< CharT > > const_reference
Definition: daw_string_view2.h:143
constexpr size_type find_first_not_of(const_pointer s, size_type pos) const
Definition: daw_string_view2.h:1417
constexpr basic_string_view(StringView &&sv, size_type count) noexcept
Construct a string_view from a type that forms a contiguous range of characters.
Definition: daw_string_view2.h:319
constexpr size_type find_last_of(CharT c) const
Definition: daw_string_view2.h:1316
constexpr void remove_prefix()
Increment the data( ) pointer by 1. If string_view is empty, it does nothing.
Definition: daw_string_view2.h:532
constexpr size_type rfind(const_pointer s, size_type pos) const
Definition: daw_string_view2.h:1098
constexpr size_type find_first_not_of(CharT const(&&s)[N], size_type pos) const
Definition: daw_string_view2.h:1424
constexpr bool operator>=(basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1669
constexpr size_type find_last_of_if(UnaryPredicate pred, size_type pos) const
Definition: daw_string_view2.h:1351
std::size_t size_type
Definition: daw_string_view2.h:148
constexpr basic_string_view pop_front_until(basic_string_view where)
Searches for where, returns substring between front and where, then pops off the substring and the wh...
Definition: daw_string_view2.h:596
constexpr size_t search(const_pointer str, size_type pos) const
Definition: daw_string_view2.h:1166
constexpr size_type find_first_not_of(basic_string_view< CharT, Bounds > v, size_type pos) const
Definition: daw_string_view2.h:1371
constexpr friend bool operator!=(StringView &&lhs, basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1611
constexpr bool operator>(basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1651
constexpr void remove_suffix()
Decrement the size( ) by 1 if size( ) > 0.
Definition: daw_string_view2.h:543
constexpr void trim() noexcept
Definition: daw_string_view2.h:1728
constexpr basic_string_view & remove_prefix_until(basic_string_view where, nodiscard_t)
searches for where, and disregards everything prior to where
Definition: daw_string_view2.h:834
constexpr void remove_suffix(size_type n)
Decrement the size( ) by n. If string_view is empty, it does nothing.
Definition: daw_string_view2.h:538
constexpr const_iterator begin() const
Returns an iterator to the first character of the view.
Definition: daw_string_view2.h:366
constexpr basic_string_view pop_back_until(UnaryPredicate pred)
searches for last position UnaryPredicate would be true, returns substring between pred and end,...
Definition: daw_string_view2.h:748
constexpr const_reverse_iterator crbegin() const
Returns a reverse iterator to the first character of the reversed view. It corresponds to the last ch...
Definition: daw_string_view2.h:388
constexpr CharT pop_front()
Increment the data( ) pointer by 1.
Definition: daw_string_view2.h:549
constexpr size_type find_last_of(CharT const (&s)[N], size_type pos)
Definition: daw_string_view2.h:1322
constexpr size_type find_last_not_of(basic_string_view< CharT, Bounds > v, size_type pos) const
Definition: daw_string_view2.h:1470
constexpr size_type rfind(const_pointer s, size_type pos, size_type count) const
Definition: daw_string_view2.h:1076
constexpr size_t search_last(const_pointer str, size_type pos) const
Definition: daw_string_view2.h:1199
constexpr size_type find_first_not_of_if(UnaryPredicate pred) const
Definition: daw_string_view2.h:1254
constexpr basic_string_view(CharPtr s) noexcept
Construct a string_view with a range starting with s.
Definition: daw_string_view2.h:279
constexpr size_type find_first_not_of(basic_string_view< CharT, Bounds > v) const
Definition: daw_string_view2.h:1393
constexpr basic_string_view pop_front_until(CharT where)
Searches for where, returns substring between front and where, then pops off the substring and the wh...
Definition: daw_string_view2.h:607
constexpr size_type find_first_of(CharT c, size_type pos) const
Definition: daw_string_view2.h:1258
constexpr friend bool operator>=(StringView &&lhs, basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1681
constexpr bool operator==(basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1581
constexpr size_type rfind(basic_string_view< CharT, Bounds > v) const
Definition: daw_string_view2.h:1083
constexpr size_type find_first_of(const_pointer str, size_type pos) const
Definition: daw_string_view2.h:1135
constexpr basic_string_view(basic_string_view< CharT, B > sv, size_type count) noexcept
Converting substr constructor from any string_view with matching CharT types.
Definition: daw_string_view2.h:292
constexpr size_type search_last(basic_string_view< CharT, Bounds > v, size_type pos) const
Definition: daw_string_view2.h:1177
constexpr basic_string_view & remove_prefix_until(UnaryPredicate pred)
Removes all elements until pred is true or end reached.
Definition: daw_string_view2.h:848
constexpr size_type find_last_of(const_pointer s, size_type pos) const
Definition: daw_string_view2.h:1340
constexpr size_type find_last_not_of(basic_string_view< CharT, Bounds > v) const
Definition: daw_string_view2.h:1492
constexpr basic_string_view trim_copy() const noexcept
Definition: daw_string_view2.h:1733
constexpr const_iterator cend() const
Returns an iterator to the character following the last character of the view. This character acts as...
Definition: daw_string_view2.h:404
constexpr size_type find_first_not_of(CharT const(&&s)[N]) const
Definition: daw_string_view2.h:1437
constexpr size_type rfind(CharT c) const
Definition: daw_string_view2.h:1092
constexpr bool starts_with(CharT c) const
Definition: daw_string_view2.h:1526
constexpr size_type find_last_not_of(const_pointer s) const
Definition: daw_string_view2.h:1521
constexpr void remove_prefix_while(UnaryPred is_whitespace) noexcept
Definition: daw_string_view2.h:1697
constexpr void trim_prefix() noexcept
Definition: daw_string_view2.h:1702
constexpr size_type find(const_pointer s, size_type pos) const
Definition: daw_string_view2.h:1043
constexpr reverse_iterator rend() const
Returns a reverse iterator to the character following the last character of the reversed view....
Definition: daw_string_view2.h:415
constexpr basic_string_view pop_front_until(UnaryPredicate pred, nodiscard_t)
Increment data until the predicate is true or the string_view is empty. Return a new string_view form...
Definition: daw_string_view2.h:627
constexpr friend bool operator>(const_pointer lhs, basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1656
constexpr basic_string_view try_pop_back_until(basic_string_view where)
searches for last where, returns substring between where and end, then pops off the substring and the...
Definition: daw_string_view2.h:784
constexpr basic_string_view(const_pointer s, size_type count) noexcept
Construct a string_view.
Definition: daw_string_view2.h:268
static constexpr int compare(basic_string_view< CharT, BL > lhs, basic_string_view< CharT, BR > rhs, Compare cmp=Compare{ })
Definition: daw_string_view2.h:920
constexpr size_type rfind(CharT c, size_type pos) const
Definition: daw_string_view2.h:1087
constexpr const_reference at(size_type pos) const
Access to the elements of range.
Definition: daw_string_view2.h:485
constexpr bool starts_with(const_pointer s) const
Definition: daw_string_view2.h:1549
constexpr size_type find(basic_string_view< CharT, Bounds > v, size_type pos) const
Definition: daw_string_view2.h:1007
constexpr size_type find_first_of(const_pointer s, size_type pos, size_type count) const
Definition: daw_string_view2.h:1271
constexpr size_type find(CharT c) const
Definition: daw_string_view2.h:1034
constexpr size_type copy(pointer dest, size_type count) const
Definition: daw_string_view2.h:895
constexpr friend bool operator==(const_pointer lhs, basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1594
constexpr basic_string_view & remove_prefix_until(CharT where)
searches for where, and disregards everything until the end of that
Definition: daw_string_view2.h:799
constexpr basic_string_view pop_back_until(CharT where)
searches for the last where, returns substring between where and end, then pops off the substring and...
Definition: daw_string_view2.h:725
constexpr bool starts_with(basic_string_view< CharT, Bounds > s) const
Definition: daw_string_view2.h:1535
constexpr basic_string_view pop_front(size_type count)
Increment data( ) by count elements and return a new string_view that would be formed formed from the...
Definition: daw_string_view2.h:560
constexpr basic_string_view try_pop_front_until(basic_string_view where)
searches for where, returns substring between front and where, then pops off the substring and the wh...
Definition: daw_string_view2.h:768
constexpr void reset()
Reset the range to a default constructed state.
Definition: daw_string_view2.h:517
constexpr size_type copy(pointer dest, size_type count, size_type pos) const
Definition: daw_string_view2.h:880
constexpr int compare(size_type pos1, size_type count1, const_pointer s, size_type count2, Compare cmp=Compare{ }) const
Definition: daw_string_view2.h:997
constexpr size_type find_last_of(const_pointer s) const
Definition: daw_string_view2.h:1345
std::add_const_t< CharT > * const_pointer
Definition: daw_string_view2.h:140
constexpr size_type rfind(const_pointer s) const
Definition: daw_string_view2.h:1103
constexpr friend bool operator>=(const_pointer lhs, basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1674
constexpr bool operator!=(basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1599
constexpr size_type find_first_of_if(UnaryPredicate pred, size_type pos) const
Definition: daw_string_view2.h:1211
std::add_lvalue_reference_t< CharT > reference
Definition: daw_string_view2.h:141
constexpr basic_string_view & remove_prefix_until(basic_string_view where)
searches for where, and disregards everything until the end of that
Definition: daw_string_view2.h:823
constexpr int compare(size_type pos1, size_type count1, const_pointer s, Compare cmp=Compare{ }) const
Definition: daw_string_view2.h:989
constexpr basic_string_view pop_back_until(basic_string_view where, nodiscard_t)
searches for last where, returns substring between where and end, then pops off the substring
Definition: daw_string_view2.h:677
constexpr size_type find_last_not_of_if(UnaryPredicate pred, size_type pos) const
Definition: daw_string_view2.h:1445
constexpr size_type find(CharT c, size_type pos) const
Definition: daw_string_view2.h:1029
const_iterator iterator
Definition: daw_string_view2.h:145
constexpr size_type find_first_not_of(CharT c) const
Definition: daw_string_view2.h:1404
constexpr basic_string_view(basic_string_view::const_pointer first, basic_string_view::const_pointer last) noexcept
Construct a string_view from a range formed by two character pointers.
Definition: daw_string_view2.h:342
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: daw_string_view2.h:147
constexpr const_reference front() const
Access the first element in range.
Definition: daw_string_view2.h:494
constexpr const_reverse_iterator crend() const
Returns a reverse iterator to the character following the last character of the reversed view....
Definition: daw_string_view2.h:426
constexpr basic_string_view trim_suffix_copy() const noexcept
Definition: daw_string_view2.h:1722
constexpr const_reference operator[](size_type pos) const
Access to the elements of range.
Definition: daw_string_view2.h:477
constexpr size_type find_last_not_of(const_pointer s, size_type pos, size_type count) const
Definition: daw_string_view2.h:1508
constexpr bool ends_with(CharT c) const
Definition: daw_string_view2.h:1553
constexpr size_type find_last_of(const_pointer s, size_type pos, size_type count) const
Definition: daw_string_view2.h:1335
constexpr size_type find_last_not_of_if(UnaryPredicate pred) const
Definition: daw_string_view2.h:1464
constexpr bool operator<(basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1616
constexpr size_type find_first_not_of_if(UnaryPredicate pred, size_type pos) const
Definition: daw_string_view2.h:1236
constexpr basic_string_view pop_front_until(CharT where, nodiscard_t)
Searches for where, returns substring between front and where, then pops off the substring.
Definition: daw_string_view2.h:584
constexpr size_type find_last_of(basic_string_view< CharT, Bounds > s) const
Definition: daw_string_view2.h:1307
constexpr const_iterator end() const
Returns an iterator to the character following the last character of the view. This character acts as...
Definition: daw_string_view2.h:396
constexpr const_pointer data_end() const
Returns a pointer to the character following the last character of the view. This character acts as a...
Definition: daw_string_view2.h:467
constexpr size_type search_last(basic_string_view< CharT, Bounds > v) const
Definition: daw_string_view2.h:1195
constexpr int compare(size_type pos1, size_type count1, basic_string_view v, Compare cmp=Compare{ }) const
Definition: daw_string_view2.h:974
constexpr basic_string_view pop_back_until(basic_string_view where)
searches for last where, returns substring between where and end, then pops off the substring and the...
Definition: daw_string_view2.h:708
constexpr basic_string_view substr() const
Definition: daw_string_view2.h:908
constexpr basic_string_view pop_front_until(UnaryPredicate pred)
Increment data until the predicate is true or the string_view is empty. Return a new string_view form...
Definition: daw_string_view2.h:646
constexpr int compare(CharT const (&rhs)[N], Compare cmp=Compare{ }) const
Definition: daw_string_view2.h:968
constexpr friend bool operator==(StringView &&lhs, basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1588
constexpr size_type find_first_of(basic_string_view< CharT, Bounds > v, size_type pos) const
Find the first item in v that is in string from pos.
Definition: daw_string_view2.h:1113
constexpr basic_string_view & remove_prefix_until(CharT where, nodiscard_t)
searches for where, and disregards everything prior to where
Definition: daw_string_view2.h:810
constexpr size_type find_first_not_of(CharT c, size_type pos) const
Definition: daw_string_view2.h:1398
constexpr const_reference back() const
Access the last element in range.
Definition: daw_string_view2.h:501
constexpr size_type find_last_not_of(CharT c) const
Definition: daw_string_view2.h:1503
constexpr size_type find_first_of_if(UnaryPredicate pred) const
Definition: daw_string_view2.h:1229
constexpr size_type rfind(basic_string_view< CharT, Bounds > v, size_type pos) const
Definition: daw_string_view2.h:1054
constexpr size_type find(const_pointer s, size_type pos, size_type count) const
Definition: daw_string_view2.h:1038
constexpr size_type search(basic_string_view< CharT, Bounds > v, size_type pos) const
Definition: daw_string_view2.h:1148
constexpr basic_string_view pop_back(size_type count)
create a substr of the last count characters and remove them from end
Definition: daw_string_view2.h:665
constexpr int compare(StringView &&rhs, Compare cmp=Compare{ }) const
Definition: daw_string_view2.h:961
constexpr CharT pop_back()
Definition: daw_string_view2.h:655
CharT * pointer
Definition: daw_string_view2.h:139
const_pointer const_iterator
Definition: daw_string_view2.h:144
constexpr basic_string_view pop_back_until(CharT where, nodiscard_t)
searches for last where, returns substring between where and end, then pops off the substring
Definition: daw_string_view2.h:691
void i_am_a_daw_string_view2
A tag type for detecting string_view.
Definition: daw_string_view2.h:152
constexpr int compare(size_type pos1, size_type count1, basic_string_view< CharT, Bounds > v, size_type pos2, size_type count2, Compare cmp=Compare{ }) const
Definition: daw_string_view2.h:981
constexpr bool ends_with(basic_string_view< CharT, Bounds > s) const
Definition: daw_string_view2.h:1562
constexpr size_type size() const
Returns the number of CharT elements in the view.
Definition: daw_string_view2.h:436
constexpr size_type find_first_not_of(const_pointer s) const
Definition: daw_string_view2.h:1430
constexpr friend bool operator!=(const_pointer lhs, basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1604
constexpr basic_string_view substr(size_type pos, size_type count) const
Definition: daw_string_view2.h:900
constexpr size_type find_first_of(CharT c) const
Definition: daw_string_view2.h:1265
constexpr void remove_suffix_while(UnaryPred is_whitespace) noexcept
Definition: daw_string_view2.h:1713
constexpr basic_string_view(CharT const (&string_literal)[N]) noexcept
Construct a string_view from a character array. Assumes a string literal like array with last element...
Definition: daw_string_view2.h:331
constexpr int compare(basic_string_view< CharT, B > rhs, Compare cmp=Compare{ }) const
Definition: daw_string_view2.h:953
constexpr size_type find_first_not_of(const_pointer s, size_type pos, size_type count) const
Definition: daw_string_view2.h:1410
constexpr size_type find_last_of(CharT c, size_type pos) const
Definition: daw_string_view2.h:1311
constexpr basic_string_view pop_front_until(basic_string_view where, nodiscard_t)
Increment data( ) until the substring where is found and return a new string_view that would be forme...
Definition: daw_string_view2.h:574
constexpr size_type find_last_of(basic_string_view< CharT, Bounds > s, size_type pos) const
Definition: daw_string_view2.h:1290
constexpr basic_string_view() noexcept=default
Construct an empty string_view.
constexpr void clear()
Empty the range.
Definition: daw_string_view2.h:510
constexpr basic_string_view & remove_prefix_until(UnaryPredicate pred, nodiscard_t)
removes all elements prior to predicate returning true
Definition: daw_string_view2.h:861
constexpr size_t search_last(const_pointer str) const
Definition: daw_string_view2.h:1204
constexpr basic_string_view(StringView &&sv) noexcept
Construct a string_view from a type that forms a contiguous range of characters.
Definition: daw_string_view2.h:306
constexpr size_type search(basic_string_view< CharT, Bounds > v) const
Definition: daw_string_view2.h:1162
constexpr basic_string_view trim_prefix_copy() const noexcept
Definition: daw_string_view2.h:1706
constexpr friend bool operator>(StringView &&lhs, basic_string_view rhs) noexcept
Definition: daw_string_view2.h:1663
constexpr reverse_iterator rbegin() const
Returns a reverse iterator to the first character of the reversed view. It corresponds to the last ch...
Definition: daw_string_view2.h:380
constexpr size_t search(const_pointer str) const
Definition: daw_string_view2.h:1171
Tag type for specifying that the searched for term/item is not to be removed from string_view.
Definition: daw_string_view2.h:68
A predicate type used in the find based routine to return true when the element is none of the specif...
Definition: daw_string_view2.h:87