8#ifndef INCLUDED_BSLSTL_STRINGREF
9#define INCLUDED_BSLSTL_STRINGREF
305#include <bslscm_version.h>
330#if defined(BSLS_PLATFORM_OS_AIX)
336using BloombergLP::bslstl_stringview_relops::operator==;
337using BloombergLP::bslstl_stringview_relops::operator!=;
338using BloombergLP::bslstl_stringview_relops::operator<;
339using BloombergLP::bslstl_stringview_relops::operator>;
340using BloombergLP::bslstl_stringview_relops::operator<=;
341using BloombergLP::bslstl_stringview_relops::operator>=;
371template <
class CHAR_TYPE>
400 void write(std::basic_ostream<CHAR_TYPE>& stream)
const;
426 template <
class INT_TYPE>
458#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
459 StringRefImp(
const std::pmr::basic_string<CHAR_TYPE>& str);
504 template <
class INT_TYPE>
558 operator std::basic_string<CHAR_TYPE>()
const;
590 const CHAR_TYPE *
data()
const;
635 template <
class CHAR_TYPE>
643 template <
class CHAR_TYPE>
652 template <
class CHAR_TYPE>
660template <
class CHAR_TYPE>
664template <
class CHAR_TYPE>
668template <
class CHAR_TYPE>
672template <
class CHAR_TYPE>
675 const std::basic_string<CHAR_TYPE>& rhs);
676template <
class CHAR_TYPE>
680template <
class CHAR_TYPE>
684template <
class CHAR_TYPE>
687 const CHAR_TYPE *rhs);
692template <
class CHAR_TYPE,
class HASHALG>
711template <
class CHAR_TYPE>
714 std::basic_ostream<CHAR_TYPE>& stream)
const
717 stream.write(data(), length());
725template <
class CHAR_TYPE>
732template <
class CHAR_TYPE>
733template <
class INT_TYPE>
736 const CHAR_TYPE *data,
740:
Base(data, data + length)
746template <
class CHAR_TYPE>
749:
Base(data, data + length)
754template <
class CHAR_TYPE>
763template <
class CHAR_TYPE>
766:
Base(data, data +
Base::cStringLength(data))
771template <
class CHAR_TYPE>
779template <
class CHAR_TYPE>
782:
Base(str.data(), str.data() + str.length())
786template <
class CHAR_TYPE>
789:
Base(str.data(), str.data() + str.length())
793#ifdef BSLS_LIBRARYFEATURES_HAS_CPP17_PMR_STRING
794template <
class CHAR_TYPE>
797 const std::pmr::basic_string<CHAR_TYPE>& str)
798: Base(str.data(), str.data() + str.length())
803template <
class CHAR_TYPE>
809:
Base(original.begin() + startIndex,
810 original.begin() + startIndex +
811 std::min(numCharacters, original.length() - startIndex))
818template <
class CHAR_TYPE>
819template <
class INT_TYPE>
822 const CHAR_TYPE *data,
832template <
class CHAR_TYPE>
841template <
class CHAR_TYPE>
848template <
class CHAR_TYPE>
856 data + std::char_traits<CHAR_TYPE>::length(data));
859template <
class CHAR_TYPE>
866template <
class CHAR_TYPE>
873template <
class CHAR_TYPE>
881template <
class CHAR_TYPE>
888 return begin()[index];
893template <
class CHAR_TYPE>
897 return std::basic_string<CHAR_TYPE>(begin(), end());
902template <
class CHAR_TYPE>
910template <
class CHAR_TYPE>
915 return Base::data() + Base::size();
918template <
class CHAR_TYPE>
926template <
class CHAR_TYPE>
934template <
class CHAR_TYPE>
941template <
class CHAR_TYPE>
945 return begin() == end();
948template <
class CHAR_TYPE>
952 return begin() == end();
955template <
class CHAR_TYPE>
960 return end() - begin();
963template <
class CHAR_TYPE>
968 return end() - begin();
971template <
class CHAR_TYPE>
980 int result = std::char_traits<CHAR_TYPE>::compare(
983 std::min(this->length(), other.
length()));
985 if (result == 0 && this->length() != other.
length()) {
986 result = this->length() < other.
length() ? -1 : 1;
995template <
class CHAR_TYPE>
1008 const const_iterator end = a.
end();
1009 for (const_iterator pc = a.
begin(); pc < end; ++pc, ++b) {
1029 return std::char_traits<CHAR_TYPE>::compare(pc,
1038template <
class CHAR_TYPE>
1049template <
class CHAR_TYPE>
1057 const const_iterator end = a.
end();
1059 for (const_iterator pc = a.
begin(); pc < end; ++pc, c = *++b) {
1060 if (0 == c || *pc != c) {
1070template <
class CHAR_TYPE>
1073 const StringRefImp<CHAR_TYPE>& rhs)
1077 result.
reserve(lhs.length() + rhs.length());
1078 result.
assign(lhs.begin(), lhs.end());
1079 result.
append(rhs.begin(), rhs.end());
1084template <
class CHAR_TYPE>
1088 const StringRefImp<CHAR_TYPE>& rhs)
1090 return StringRefImp<CHAR_TYPE>(lhs) + rhs;
1093template <
class CHAR_TYPE>
1099 return lhs + StringRefImp<CHAR_TYPE>(rhs);
1102template <
class CHAR_TYPE>
1106 const StringRefImp<CHAR_TYPE>& rhs)
1108 return StringRefImp<CHAR_TYPE>(lhs) + rhs;
1111template <
class CHAR_TYPE>
1115 const std::basic_string<CHAR_TYPE>& rhs)
1117 return lhs + StringRefImp<CHAR_TYPE>(rhs);
1120template <
class CHAR_TYPE>
1124 const StringRefImp<CHAR_TYPE>& rhs)
1129 return StringRefImp<CHAR_TYPE>(lhs) + rhs;
1132template <
class CHAR_TYPE>
1136 const CHAR_TYPE *rhs)
1141 return lhs + StringRefImp<CHAR_TYPE>(rhs);
1144template <
class CHAR_TYPE,
class HASHALG>
1147 const StringRefImp<CHAR_TYPE>& input)
1149 using ::BloombergLP::bslh::hashAppend;
1150 hashAlg(input.data(),
sizeof(CHAR_TYPE)*input.length());
1154#if defined(BSLS_COMPILERFEATURES_SUPPORT_EXTERN_TEMPLATE)
1161operator+(
const StringRefImp<char>& lhs,
const StringRefImp<char>& rhs);
1165operator+(
const StringRefImp<wchar_t>& lhs,
const StringRefImp<wchar_t>& rhs);
1171#ifndef BDE_OPENSOURCE_PUBLICATION
1176#ifdef bslstl_StringRefImp
1177#undef bslstl_StringRefImp
1180#define bslstl_StringRefImp bslstl::StringRefImp
1182#ifdef bslstl_StringRefWide
1183#undef bslstl_StringRefWide
1186#define bslstl_StringRefWide bslstl::StringRefWide
1188#ifdef bslstl_StringRef
1189#undef bslstl_StringRef
1192#define bslstl_StringRef bslstl::StringRef
Definition bslstl_stringview.h:441
Definition bslstl_string.h:1281
size_type length() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_string.h:6601
void reserve(size_type newCapacity=0)
Definition bslstl_string.h:5407
basic_string & assign(const basic_string &replacement)
Definition bslstl_string.h:5716
CHAR_TYPE * data() BSLS_KEYWORD_NOEXCEPT
Definition bslstl_string.h:6477
basic_string & append(const basic_string &suffix)
Definition bslstl_string.h:5574
Definition bslstl_stringrefdata.h:212
Definition bslstl_stringref.h:372
const CHAR_TYPE & const_reference
Definition bslstl_stringref.h:382
bsl::reverse_iterator< const_iterator > const_reverse_iterator
Definition bslstl_stringref.h:385
bool empty() const
Definition bslstl_stringref.h:943
BSLMF_NESTED_TRAIT_DECLARATION(StringRefImp, bsl::is_trivially_copyable)
size_type size() const
Definition bslstl_stringref.h:966
void reset()
Definition bslstl_stringref.h:875
const_reverse_iterator rend() const
Definition bslstl_stringref.h:929
std::ptrdiff_t difference_type
Definition bslstl_stringref.h:386
const_reference operator[](size_type index) const
Definition bslstl_stringref.h:884
StringRefImp(const StringRefImp &original)=default
const CHAR_TYPE & reference
Definition bslstl_stringref.h:381
int compare(const StringRefImp &other) const
Definition bslstl_stringref.h:973
const CHAR_TYPE * const_iterator
Definition bslstl_stringref.h:384
const CHAR_TYPE * data() const
Definition bslstl_stringref.h:936
const CHAR_TYPE value_type
Definition bslstl_stringref.h:380
const_iterator end() const
Definition bslstl_stringref.h:913
bool isEmpty() const
Definition bslstl_stringref.h:950
StringRefImp()
Definition bslstl_stringref.h:727
const CHAR_TYPE * iterator
Definition bslstl_stringref.h:383
size_type length() const
Definition bslstl_stringref.h:958
void assign(const CHAR_TYPE *data, INT_TYPE length, typename bsl::enable_if< bsl::is_integral< INT_TYPE >::value, bslmf::Nil >::type=bslmf::Nil())
Definition bslstl_stringref.h:821
~StringRefImp()=default
Destroy this object.
StringRefImp & operator=(const StringRefImp &rhs)=default
std::size_t size_type
Standard Library general container requirements.
Definition bslstl_stringref.h:389
const_reverse_iterator rbegin() const
Definition bslstl_stringref.h:921
const_iterator begin() const
Definition bslstl_stringref.h:905
#define BSLS_ASSERT_SAFE(X)
Definition bsls_assert.h:1762
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
void hashAppend(HASH_ALGORITHM &hashAlg, const baljsn::EncoderTestAddress &object)
Definition baljsn_encoder_testtypes.h:9236
Definition bslstl_algorithm.h:82
StringRefImp< char > StringRef
Definition bslstl_stringref.h:699
RandomAccessIterator< T, ITER_IMP, TAG_TYPE > operator+(const RandomAccessIterator< T, ITER_IMP, TAG_TYPE > &lhs, std::ptrdiff_t rhs)
void hashAppend(HASHALG &hashAlg, const StringRefImp< CHAR_TYPE > &input)
Pass the specified input to the specified hashAlg
StringRefImp< wchar_t > StringRefWide
Definition bslstl_stringref.h:700
Definition bdldfp_decimal.h:5188
Definition bslmf_enableif.h:525
Definition bslmf_isintegral.h:130
Definition bslmf_istriviallycopyable.h:329
This struct is empty and represents a nil type.
Definition bslmf_nil.h:131
Definition bslstl_stringref.h:627
static int compare(const StringRefImp< CHAR_TYPE > &a, const CHAR_TYPE *b)
Definition bslstl_stringref.h:996
static bool compareEqual(const StringRefImp< CHAR_TYPE > &a, const StringRefImp< CHAR_TYPE > &b)
Definition bslstl_stringref.h:1040