53 template <
typename charT,
typename Traits = std::
char_traits<
charT>,
typename Alloc = std::allocator<
charT> >
57 typedef typename std::basic_string<charT, Traits, Alloc>
string_type;
64 typedef typename string_type::pointer
pointer;
65 typedef typename string_type::iterator
iterator;
78 typedef std::pair<string_view_type, Alloc> view_contents_type;
79 typedef std::variant<std::monostate, string_type, view_contents_type> contents_type;
93 iContents{ str.iContents }
97 iContents{
std::move(str.iContents) }
116 template <
typename SFINAE =
void*>
117 basic_quick_string(
const charT*
begin,
const charT*
end,
const Alloc& a = Alloc(),
typename std::enable_if<!std::is_same<view_const_iterator, const charT*>::value, SFINAE>::type=0) :
125 template<
class InputIterator>
133 contents_type{ view_contents_type{
std::get<view_contents_type>(str.iContents).first, a } } }
146 iContents = str.iContents;
173 size_type size()
const {
return is_view() ? get_view_string().end() - get_view_string().begin() : get_string().size(); }
174 size_type length()
const {
return is_view() ? get_view_string().end() - get_view_string().begin() : get_string().length(); }
181 void clear() { get_string().clear(); }
182 bool empty()
const {
return is_view() ? get_view_string().begin() == get_view_string().end() : get_string().empty(); }
187 return get_view_string()[pos];
189 return get_string()[pos];
193 return get_string()[pos];
198 return get_view_string().at(n);
200 return get_string().at(n);
204 return get_string().at(n);
209 return get_view_string().back();
211 return get_string().back();
215 return get_string().back();
229 template<
class InputIterator>
239 template<
class InputIterator>
250 template<
class InputIterator>
267 template<
class InputIterator>
272 return get_view_string().copy(s, n, pos);
274 return get_string().copy(s, n, pos);
283 return get_string().c_str();
288 return get_view_string().data();
290 return get_string().data();
295 return std::get<view_contents_type>(iContents).second;
297 return get_string().get_allocator();
309 return get_view_string().find(str, pos);
311 return get_string().find(str, pos);
316 return get_view_string().find(s, pos, n);
318 return get_string().find(s, pos, n);
323 return get_view_string().find(s, pos);
325 return get_string().find(s, pos);
330 return get_view_string().find(c, pos);
332 return get_string().find(c, pos);
344 return get_view_string().rfind(str, pos);
346 return get_string().rfind(str, pos);
351 return get_view_string().rfind(s, pos, n);
353 return get_string().rfind(s, pos, n);
358 return get_view_string().rfind(s, pos);
360 return get_string().rfind(s, pos);
365 return get_view_string().rfind(c, pos);
367 return get_string().rfind(c, pos);
379 return get_view_string().find_first_of(str, pos);
381 return get_string().find_first_of(str, pos);
386 return get_view_string().find_first_of(s, pos, n);
388 return get_string().find_first_of(s, pos, n);
393 return get_view_string().find_first_of(s, pos);
395 return get_string().find_first_of(s, pos);
400 return get_view_string().find_first_of(c, pos);
402 return get_string().find_first_of(c, pos);
414 return get_view_string().find_last_of(str, pos);
416 return get_string().find_last_of(str, pos);
421 return get_view_string().find_last_of(s, pos, n);
423 return get_string().find_last_of(s, pos, n);
428 return get_view_string().find_last_of(s, pos);
430 return get_string().find_last_of(s, pos);
435 return get_view_string().find_last_of(c, pos);
437 return get_string().find_last_of(c, pos);
449 return get_view_string().find_first_not_of(str, pos);
451 return get_string().find_first_not_of(str, pos);
456 return get_view_string().find_first_not_of(s, pos, n);
458 return get_string().find_first_not_of(s, pos, n);
463 return get_view_string().find_first_not_of(s, pos);
465 return get_string().find_first_not_of(s, pos);
470 return get_view_string().find_first_not_of(c, pos);
472 return get_string().find_first_not_of(c, pos);
484 return get_view_string().find_last_of(str, pos);
486 return get_string().find_last_of(str, pos);
491 return get_view_string().find_last_of(s, pos, n);
493 return get_string().find_last_of(s, pos, n);
498 return get_view_string().find_last_of(s, pos);
500 return get_string().find_last_of(s, pos);
505 return get_view_string().find_last_of(c, pos);
507 return get_string().find_last_of(c, pos);
512 return string_type{ get_view_string().substr(pos, n) };
514 return get_string().substr(pos, n);
526 return get_view_string().compare(str);
528 return get_string().compare(str);
557 return std::lexicographical_compare_three_way(
begin(),
end(), that.
begin(), that.
end());
563 return std::holds_alternative<view_contents_type>(iContents);
588 return get_view_string();
597 return std::get<string_type>(iContents);
606 return std::get<view_contents_type>(iContents).first;
607 throw not_view_string();
614 mutable contents_type iContents;
617 template <
typename charT,
typename Traits,
typename Alloc>
620 template<
class charT,
630 template<
class charT,
633 std::basic_string<charT, Traits, Alloc> operator+(
634 const std::basic_string<charT, Traits, Alloc>& _Left,
637 return _Left +
static_cast<std::basic_string<charT, Traits, Alloc>
>(_Right);
640 template<
class charT,
643 std::basic_string<charT, Traits, Alloc> operator+(
647 return _Left +
static_cast<std::basic_string<charT, Traits, Alloc>
>(_Right);
650 template<
class charT,
653 std::basic_string<charT, Traits, Alloc> operator+(
657 return _Left +
static_cast<std::basic_string<charT, Traits, Alloc>
>(_Right);
660 template<
class charT,
663 std::basic_string<charT, Traits, Alloc> operator+(
665 const std::basic_string<charT, Traits, Alloc>& _Right)
667 return static_cast<std::basic_string<charT, Traits, Alloc>
>(_Left) + _Right;
670 template<
class charT,
673 std::basic_string<charT, Traits, Alloc> operator+(
677 return static_cast<std::basic_string<charT, Traits, Alloc>
>(_Left) + _Right;
680 template<
class charT,
683 std::basic_string<charT, Traits, Alloc> operator+(
687 return static_cast<std::basic_string<charT, Traits, Alloc>
>(_Left) + _Right;
690 template <
typename charT>
697 for (
typename std::basic_string<charT>::const_iterator i = Characters.begin(); i != Characters.end(); ++i)
698 iMap[
static_cast<typename std::make_unsigned<charT>::type
>(*i)] =
true;
701 bool find(charT Character)
const
703 return iMap[
static_cast<typename std::make_unsigned<charT>::type
>(Character)];
706 std::array<bool, 256> iMap;
715 for (std::basic_string<wchar_t>::const_iterator i = Characters.begin(); i != Characters.end(); ++i)
719 bool find(
wchar_t Character)
const
721 return iMap.find(Character) != iMap.end();
724 std::set<wchar_t> iMap;
727 template <
typename Elem,
typename Traits,
typename Alloc>
728 inline std::basic_ostream<Elem, Traits>& operator<<(std::basic_ostream<Elem, Traits>& aStream,
const basic_quick_string<Elem, Traits, Alloc>& aString)
730 aStream << std::basic_string<Elem, Traits>{ aString.data(), aString.size() };
736 template <
typename charT,
typename Traits,
typename Alloc>
bool find(wchar_t Character) const
basic_character_map(const std::basic_string< wchar_t > &Characters)
bool find(charT Character) const
basic_character_map(const std::basic_string< charT > &Characters)
int compare(const string_type &str) const
size_type find_last_not_of(const charT *s, size_type pos=npos) const
basic_quick_string & assign(const string_type &str, size_type pos, size_type n)
size_type find(charT c, size_type pos=0) const
basic_quick_string & append(const charT *s, size_type n)
size_type find(const string_type &str, size_type pos=0) const
size_type find_last_of(const charT *s, size_type pos, size_type n) const
size_type find_last_of(charT c, size_type pos=npos) const
view_const_reverse_iterator rend() const
basic_quick_string & assign(InputIterator first, InputIterator last)
basic_quick_string & replace(size_type pos, size_type n1, size_type n2, charT c)
basic_quick_string & append(const charT *s)
size_type capacity() const
basic_quick_string(const basic_quick_string &str, const Alloc &a)
basic_quick_string & operator=(const basic_quick_string &str)
basic_quick_string(basic_quick_string &&str)
const charT * data() const
basic_quick_string & replace(size_type pos1, size_type n1, const basic_quick_string &str)
basic_quick_string(charT *begin, charT *end, const Alloc &a=Alloc())
basic_quick_string & assign(size_type n, charT c)
basic_quick_string(const basic_quick_string &str, size_type pos, size_type n=npos)
size_type find_last_of(const charT *s, size_type pos=npos) const
std::reverse_iterator< const_iterator > const_reverse_iterator
static const size_type npos
size_type find_first_of(const string_type &str, size_type pos=0) const
string_type::const_pointer const_pointer
std::basic_string_view< charT, Traits > string_view_type
size_type find_last_not_of(charT c, size_type pos=npos) const
iterator insert(const_iterator p, size_type n, charT c)
string_type::iterator iterator
basic_quick_string & insert(size_type pos1, const string_type &str)
const_reference back() const
basic_quick_string & append(const string_type &str)
basic_quick_string & replace(size_type pos1, size_type n1, const string_type &str, size_type pos2, size_type n2)
basic_quick_string & replace(iterator i1, iterator i2, const basic_quick_string &str)
basic_quick_string & insert(size_type pos, const charT *s)
size_type rfind(const charT *s, size_type pos=npos) const
basic_quick_string & assign(const charT *s)
basic_quick_string & append(const basic_quick_string &str)
string_type substr(size_type pos=0, size_type n=npos) const
int compare(size_type pos1, size_type n1, const charT *s, size_type n2) const
basic_quick_string & operator=(charT c)
basic_quick_string & append(InputIterator first, InputIterator last)
basic_quick_string & replace(size_type pos, size_type n1, const charT *s)
size_type find_first_of(const basic_quick_string &str, size_type pos=0) const
string_type::difference_type difference_type
const_reference operator[](size_type pos) const
iterator erase(iterator p)
basic_quick_string & operator+=(const basic_quick_string &str)
size_type find_last_not_of(const string_type &str, size_type pos=npos) const
size_type max_size() const
basic_quick_string(size_type n, charT c, const Alloc &a=Alloc())
void swap(basic_quick_string &str)
basic_quick_string & replace(iterator i1, iterator i2, const string_type &str)
basic_quick_string & assign(const string_type &str)
view_const_iterator begin() const
basic_quick_string & operator+=(const charT *s)
void reserve(size_type res_arg=0)
std::reverse_iterator< iterator > reverse_iterator
size_type find_first_of(const charT *s, size_type pos, size_type n) const
size_type find_first_not_of(const string_type &str, size_type pos=0) const
reference at(size_type n)
basic_quick_string & operator+=(const string_type &str)
size_type rfind(const charT *s, size_type pos, size_type n) const
view_const_reverse_iterator crend() const
string_type::value_type value_type
basic_quick_string & erase(size_type pos=0, size_type n=npos)
basic_quick_string & replace(iterator i1, iterator i2, const charT *s)
string_type::const_iterator const_iterator
view_const_iterator cend() const
string_view_type::const_iterator view_const_iterator
int compare(size_type pos1, size_type n1, const string_type &str) const
const charT * c_str() const
basic_quick_string & append(const basic_quick_string &str, size_type pos, size_type n)
size_type rfind(const basic_quick_string &str, size_type pos=npos) const
string_view_type to_std_string_view() const
string_view_type::const_pointer view_const_pointer
int compare(size_type pos1, size_type n1, const string_type &str, size_type pos2, size_type n2) const
basic_quick_string & replace(iterator i1, iterator i2, const charT *s, size_type n)
string_type::const_reference const_reference
size_type copy(charT *s, size_type n, size_type pos=0) const
iterator insert(const_iterator p, InputIterator first, InputIterator last)
allocator_type get_allocator() const
std::reverse_iterator< view_const_iterator > view_const_reverse_iterator
size_type find_first_of(const charT *s, size_type pos=0) const
size_type find_last_of(const basic_quick_string &str, size_type pos=npos) const
size_type find_last_not_of(const charT *s, size_type pos, size_type n) const
basic_quick_string & operator+=(charT c)
size_type find_first_not_of(const basic_quick_string &str, size_type pos=0) const
basic_quick_string(InputIterator begin, InputIterator end, const Alloc &a=Alloc())
view_const_reverse_iterator crbegin() const
string_type::pointer pointer
iterator erase(iterator first, iterator last)
string_type::size_type size_type
size_type find(const charT *s, size_type pos, size_type n) const
string_view_type::const_reference view_const_reference
basic_quick_string & replace(iterator i1, iterator i2, InputIterator j1, InputIterator j2)
view_const_iterator end() const
basic_quick_string & replace(size_type pos1, size_type n1, const string_type &str)
basic_quick_string & replace(size_type pos1, size_type n1, const basic_quick_string &str, size_type pos2, size_type n2)
basic_quick_string & operator=(const charT *s)
basic_quick_string & insert(size_type pos1, const basic_quick_string &str, size_type pos2, size_type n)
basic_quick_string(const Alloc &a=Alloc())
basic_quick_string & assign(const charT *s, size_type n)
basic_quick_string & append(size_type n, charT c)
view_const_iterator cbegin() const
string_type::traits_type traits_type
basic_quick_string(view_const_iterator begin, view_const_iterator end, const Alloc &a=Alloc())
basic_quick_string & insert(size_type pos1, const string_type &str, size_type pos2, size_type n)
size_type find_last_of(const string_type &str, size_type pos=npos) const
size_type rfind(const string_type &str, size_type pos=npos) const
bool operator==(const basic_quick_string &that) const
int compare(const basic_quick_string &str) const
size_type rfind(charT c, size_type pos=npos) const
std::strong_ordering operator<=>(const basic_quick_string &that) const
basic_quick_string & insert(size_type pos1, const basic_quick_string &str)
basic_quick_string(const charT *begin, const charT *end, const Alloc &a=Alloc(), typename std::enable_if<!std::is_same< view_const_iterator, const charT * >::value, SFINAE >::type=0)
basic_quick_string(const charT *s, size_type n, const Alloc &a=Alloc())
string_type::reference reference
size_type find_first_not_of(charT c, size_type pos=0) const
basic_quick_string(const basic_quick_string &str)
basic_quick_string & insert(size_type pos, size_type n, charT c)
basic_quick_string & assign(const basic_quick_string &str, size_type pos, size_type n)
size_type find_first_not_of(const charT *s, size_type pos=0) const
string_type::allocator_type allocator_type
basic_quick_string & append(const string_type &str, size_type pos, size_type n)
reference operator[](size_type pos)
size_type find_last_not_of(const basic_quick_string &str, size_type pos=npos) const
int compare(const charT *s) const
basic_quick_string & replace(size_type pos, size_type n1, const charT *s, size_type n2)
basic_quick_string & insert(size_type pos, const charT *s, size_type n)
size_type find_first_not_of(const charT *s, size_type pos, size_type n) const
std::basic_string< charT, Traits, Alloc > string_type
size_type find_first_of(charT c, size_type pos=0) const
const_reference at(size_type n) const
size_type find(const charT *s, size_type pos=0) const
reverse_iterator rbegin()
basic_quick_string(const charT *s, const Alloc &a=Alloc())
basic_quick_string & replace(iterator i1, iterator i2, size_type n, charT c)
void resize(size_type n, charT c)
int compare(size_type pos1, size_type n1, const charT *s) const
iterator insert(const_iterator p, charT c)
basic_quick_string(const_iterator begin, const_iterator end, const Alloc &a=Alloc())
size_type find(const basic_quick_string &str, size_type pos=0) const
basic_quick_string & assign(const basic_quick_string &str)
view_const_reverse_iterator rbegin() const
string_type to_std_string() const
basic_quick_string(const string_type &str)
to_const_reference_t< T > to_const(T &&object)
std::size_t hash_value(const neolib::basic_quick_string< charT, Traits, Alloc > &sv)
T fast_hash(const void *aInput, std::size_t aLength)
bool holds_alternative(const lexer_atom< Token, Scope, CharT > &aAtom)
basic_quick_string< char > quick_string
void swap(plf::hive< element_type, allocator_type > &a, plf::hive< element_type, allocator_type > &b) noexcept(std::allocator_traits< allocator_type >::propagate_on_container_swap::value||std::allocator_traits< allocator_type >::is_always_equal::value)