8#ifndef INCLUDED_BDLB_INDEXSPANSTRINGUTIL
9#define INCLUDED_BDLB_INDEXSPANSTRINGUTIL
156#include <bdlscm_version.h>
162#include <bsl_functional.h>
163#include <bsl_string.h>
164#include <bsl_string_view.h>
190 template <
class CHAR_TYPE,
class CHAR_TRAITS>
200 template <
class CHAR_TYPE,
class CHAR_TRAITS>
210 template <
class CHAR_TYPE,
class CHAR_TRAITS>
223 template <
class CHAR_TYPE,
class CHAR_TRAITS>
233 template <
class CHAR_TYPE,
class CHAR_TRAITS>
237 CHAR_TRAITS>::const_iterator begin,
245 template <
class CHAR_TYPE,
class CHAR_TRAITS>
249 CHAR_TRAITS>::const_iterator begin,
251 CHAR_TRAITS>::const_iterator end);
258 template <
class CHAR_TYPE>
269 template <
class CHAR_TYPE>
280 template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
287 ALLOCATOR>::const_iterator begin,
289 template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
291 const std::basic_string<CHAR_TYPE,
294 typename std::basic_string<CHAR_TYPE,
296 ALLOCATOR>::const_iterator begin,
304 template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
311 ALLOCATOR>::const_iterator begin,
314 ALLOCATOR>::const_iterator end);
315 template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
317 const std::basic_string<CHAR_TYPE,
320 typename std::basic_string<CHAR_TYPE,
322 ALLOCATOR>::const_iterator begin,
323 typename std::basic_string<CHAR_TYPE,
325 ALLOCATOR>::const_iterator end);
394 std::string::const_iterator begin,
402 std::wstring::const_iterator begin,
404#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
406 std::pmr::string::const_iterator begin,
409 std::pmr::wstring::const_iterator begin,
432 std::string::const_iterator begin,
433 std::string::const_iterator end);
440 std::wstring::const_iterator begin,
441 std::wstring::const_iterator end);
442#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
444 std::pmr::string::const_iterator begin,
445 std::pmr::string::const_iterator end);
447 std::pmr::wstring::const_iterator begin,
448 std::pmr::wstring::const_iterator end);
461template <
class CHAR_TYPE,
class CHAR_TRAITS>
464IndexSpanStringUtil::bindImp(
475template <
class CHAR_TYPE,
class CHAR_TRAITS>
478IndexSpanStringUtil::createFromPosImp(
489 return IndexSpan(begin, end - begin);
492template <
class CHAR_TYPE,
class CHAR_TRAITS>
495IndexSpanStringUtil::createImp(
505 return IndexSpan(begin, length);
508template <
class CHAR_TYPE,
class CHAR_TRAITS>
511IndexSpanStringUtil::createImp(
519 bsl::less_equal<const_pointer> lessEqual;
520 bsl::greater_equal<const_pointer> greaterEqual;
522 const_pointer stringBegin =
string.data();
523 const_pointer stringEnd =
string.data() +
string.length();
524 const_pointer subStringBegin = subString.
data();
525 const_pointer subStringEnd = subString.
data() + subString.
length();
533 BSLS_ASSERT(lessEqual( subStringBegin, stringEnd ));
535 BSLS_ASSERT(greaterEqual(subStringBegin, stringBegin));
536 BSLS_ASSERT(greaterEqual(subStringEnd, stringBegin));
538 return IndexSpan(subStringBegin - stringBegin, subString.
length());
541template <
class CHAR_TYPE,
class CHAR_TRAITS>
544IndexSpanStringUtil::createImp(
547 CHAR_TRAITS>::const_iterator begin,
554 return IndexSpan(begin -
string.
begin(), length);
557template <
class CHAR_TYPE,
class CHAR_TRAITS>
560IndexSpanStringUtil::createImp(
563 CHAR_TRAITS>::const_iterator begin,
565 CHAR_TRAITS>::const_iterator end)
572 return IndexSpan(begin -
string.
begin(), end - begin);
575template <
class CHAR_TYPE>
578IndexSpanStringUtil::createImp(
587 return IndexSpan(begin -
string.
begin(), length);
590template <
class CHAR_TYPE>
593IndexSpanStringUtil::createImp(
603 return IndexSpan(begin -
string.
begin(), end - begin);
606template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
609IndexSpanStringUtil::createImp(
615 ALLOCATOR>::const_iterator begin,
622 return IndexSpan(begin -
string.
begin(), length);
625template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
628IndexSpanStringUtil::createImp(
629 const std::basic_string<CHAR_TYPE,
632 typename std::basic_string<CHAR_TYPE,
634 ALLOCATOR>::const_iterator begin,
641 return IndexSpan(begin -
string.
begin(), length);
644template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
647IndexSpanStringUtil::createImp(
653 ALLOCATOR>::const_iterator begin,
656 ALLOCATOR>::const_iterator end)
663 return IndexSpan(begin -
string.
begin(), end - begin);
666template <
class CHAR_TYPE,
class CHAR_TRAITS,
class ALLOCATOR>
669IndexSpanStringUtil::createImp(
670 const std::basic_string<CHAR_TYPE,
673 typename std::basic_string<CHAR_TYPE,
675 ALLOCATOR>::const_iterator begin,
676 typename std::basic_string<CHAR_TYPE,
678 ALLOCATOR>::const_iterator end)
685 return IndexSpan(begin -
string.
begin(), end - begin);
694 return bindImp(
string, span);
702 return bindImp(
string, span);
711 return createFromPosImp(
string, begin, end);
720 return createFromPosImp(
string, begin, end);
729 return createImp(
string, begin, length);
738 return createImp(
string, begin, length);
746 return createImp(
string, subString);
754 return createImp(
string, subString);
763 return createImp(
string, begin, length);
772 return createImp(
string, begin, length);
781 return createImp(
string, begin, length);
790 return createImp(
string, begin, length);
799 return createImp(
string, begin, length);
808 return createImp(
string, begin, length);
814 std::string::const_iterator begin,
817 return createImp(
string, begin, length);
823 std::wstring::const_iterator begin,
826 return createImp(
string, begin, length);
829#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
833 std::pmr::string::const_iterator begin,
836 return createImp(
string, begin, length);
842 std::pmr::wstring::const_iterator begin,
845 return createImp(
string, begin, length);
855 return createImp(
string, begin, end);
864 return createImp(
string, begin, end);
873 return createImp(
string, begin, end);
882 return createImp(
string, begin, end);
891 return createImp(
string, begin, end);
900 return createImp(
string, begin, end);
906 std::string::const_iterator begin,
907 std::string::const_iterator end)
909 return createImp(
string, begin, end);
915 std::wstring::const_iterator begin,
916 std::wstring::const_iterator end)
918 return createImp(
string, begin, end);
921#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
925 std::pmr::string::const_iterator begin,
926 std::pmr::string::const_iterator end)
928 return createImp(
string, begin, end);
934 std::pmr::wstring::const_iterator begin,
935 std::pmr::wstring::const_iterator end)
937 return createImp(
string, begin, end);
Definition bdlb_indexspan.h:309
size_type position() const
Return the position attribute.
Definition bdlb_indexspan.h:448
bsl::size_t size_type
The type of the position and length attributes.
Definition bdlb_indexspan.h:315
size_type length() const
Return the length attribute.
Definition bdlb_indexspan.h:442
Definition bslstl_stringview.h:441
const value_type * const_pointer
Definition bslstl_stringview.h:448
BSLS_KEYWORD_CONSTEXPR size_type length() const BSLS_KEYWORD_NOEXCEPT
Return the length of this view.
Definition bslstl_stringview.h:1685
BSLS_KEYWORD_CONSTEXPR const_pointer data() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_stringview.h:1760
const value_type * const_iterator
Definition bslstl_stringview.h:451
Definition bslstl_string.h:1281
const CHAR_TYPE * const_iterator
Definition bslstl_string.h:1311
Definition bslstl_stringref.h:372
const CHAR_TYPE * const_iterator
Definition bslstl_stringref.h:384
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
bsl::size_t size(const TYPE &array)
Return the number of elements in the specified array.
Definition bdlb_algorithmworkaroundutil.h:74
T::iterator begin(T &container)
Definition bslstl_iterator.h:1495
T::iterator end(T &container)
Definition bslstl_iterator.h:1523
Definition bdlb_indexspanstringutil.h:179
static bsl::string_view bind(const bsl::string_view &string, const IndexSpan &span)
Definition bdlb_indexspanstringutil.h:691
static IndexSpan createFromPositions(const bsl::string_view &string, IndexSpan::size_type begin, IndexSpan::size_type end)
Definition bdlb_indexspanstringutil.h:707
static IndexSpan create(const bsl::string_view &string, IndexSpan::size_type begin, IndexSpan::size_type length)
Definition bdlb_indexspanstringutil.h:725