proxygen
folly::basic_fbstring< E, T, A, Storage > Class Template Reference

#include <FBString.h>

Classes

struct  Invariant
 

Public Types

typedef T traits_type
 
typedef traits_type::char_type value_type
 
typedef A allocator_type
 
typedef A::size_type size_type
 
typedef A::difference_type difference_type
 
typedef A::reference reference
 
typedef A::const_reference const_reference
 
typedef A::pointer pointer
 
typedef A::const_pointer const_pointer
 
typedef Eiterator
 
typedef const Econst_iterator
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 
typedef std::true_type IsRelocatable
 

Public Member Functions

 basic_fbstring () noexcept
 
 basic_fbstring (const A &) noexcept
 
 basic_fbstring (const basic_fbstring &str)
 
 basic_fbstring (basic_fbstring &&goner) noexcept
 
template<typename A2 >
 basic_fbstring (const std::basic_string< E, T, A2 > &str)
 
 basic_fbstring (const basic_fbstring &str, size_type pos, size_type n=npos, const A &=A())
 
FOLLY_MALLOC_NOINLINE basic_fbstring (const value_type *s, const A &=A())
 
FOLLY_MALLOC_NOINLINE basic_fbstring (const value_type *s, size_type n, const A &=A())
 
FOLLY_MALLOC_NOINLINE basic_fbstring (size_type n, value_type c, const A &=A())
 
template<class InIt >
FOLLY_MALLOC_NOINLINE basic_fbstring (InIt begin, InIt end, typename std::enable_if< !std::is_same< InIt, value_type * >::value, const A >::type &=A())
 
FOLLY_MALLOC_NOINLINE basic_fbstring (const value_type *b, const value_type *e, const A &=A())
 
 basic_fbstring (value_type *s, size_type n, size_type c, AcquireMallocatedString a)
 
FOLLY_MALLOC_NOINLINE basic_fbstring (std::initializer_list< value_type > il)
 
 ~basic_fbstring () noexcept
 
basic_fbstringoperator= (const basic_fbstring &lhs)
 
basic_fbstringoperator= (basic_fbstring &&goner) noexcept
 
template<typename A2 >
basic_fbstringoperator= (const std::basic_string< E, T, A2 > &rhs)
 
std::basic_string< E, T, AtoStdString () const
 
basic_fbstringoperator= (const value_type *s)
 
template<typename TP >
std::enable_if< std::is_same< typename std::decay< TP >::type, typename folly::basic_fbstring< E, T, A, Storage >::value_type >::value, basic_fbstring< E, T, A, Storage > & >::type operator= (TP c)
 
basic_fbstringoperator= (std::initializer_list< value_type > il)
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator crbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
const_reverse_iterator crend () const
 
const value_typefront () const
 
const value_typeback () const
 
value_typefront ()
 
value_typeback ()
 
void pop_back ()
 
size_type size () const
 
size_type length () const
 
size_type max_size () const
 
void resize (size_type n, value_type c=value_type())
 
size_type capacity () const
 
void reserve (size_type res_arg=0)
 
void shrink_to_fit ()
 
void clear ()
 
bool empty () const
 
const_reference operator[] (size_type pos) const
 
reference operator[] (size_type pos)
 
const_reference at (size_type n) const
 
reference at (size_type n)
 
basic_fbstringoperator+= (const basic_fbstring &str)
 
basic_fbstringoperator+= (const value_type *s)
 
basic_fbstringoperator+= (const value_type c)
 
basic_fbstringoperator+= (std::initializer_list< value_type > il)
 
basic_fbstringappend (const basic_fbstring &str)
 
basic_fbstringappend (const basic_fbstring &str, const size_type pos, size_type n)
 
basic_fbstringappend (const value_type *s, size_type n)
 
basic_fbstringappend (const value_type *s)
 
basic_fbstringappend (size_type n, value_type c)
 
template<class InputIterator >
basic_fbstringappend (InputIterator first, InputIterator last)
 
basic_fbstringappend (std::initializer_list< value_type > il)
 
void push_back (const value_type c)
 
basic_fbstringassign (const basic_fbstring &str)
 
basic_fbstringassign (basic_fbstring &&str)
 
basic_fbstringassign (const basic_fbstring &str, const size_type pos, size_type n)
 
basic_fbstringassign (const value_type *s, const size_type n)
 
basic_fbstringassign (const value_type *s)
 
basic_fbstringassign (std::initializer_list< value_type > il)
 
template<class ItOrLength , class ItOrChar >
basic_fbstringassign (ItOrLength first_or_n, ItOrChar last_or_c)
 
basic_fbstringinsert (size_type pos1, const basic_fbstring &str)
 
basic_fbstringinsert (size_type pos1, const basic_fbstring &str, size_type pos2, size_type n)
 
basic_fbstringinsert (size_type pos, const value_type *s, size_type n)
 
basic_fbstringinsert (size_type pos, const value_type *s)
 
basic_fbstringinsert (size_type pos, size_type n, value_type c)
 
iterator insert (const_iterator p, const value_type c)
 
template<class ItOrLength , class ItOrChar >
iterator insert (const_iterator p, ItOrLength first_or_n, ItOrChar last_or_c)
 
iterator insert (const_iterator p, std::initializer_list< value_type > il)
 
basic_fbstringerase (size_type pos=0, size_type n=npos)
 
iterator erase (iterator position)
 
iterator erase (iterator first, iterator last)
 
basic_fbstringreplace (size_type pos1, size_type n1, const basic_fbstring &str)
 
basic_fbstringreplace (size_type pos1, size_type n1, const basic_fbstring &str, size_type pos2, size_type n2)
 
basic_fbstringreplace (size_type pos, size_type n1, const value_type *s)
 
template<class StrOrLength , class NumOrChar >
basic_fbstringreplace (size_type pos, size_type n1, StrOrLength s_or_n2, NumOrChar n_or_c)
 
basic_fbstringreplace (iterator i1, iterator i2, const basic_fbstring &str)
 
basic_fbstringreplace (iterator i1, iterator i2, const value_type *s)
 
template<class T1 , class T2 >
basic_fbstringreplace (iterator i1, iterator i2, T1 first_or_n_or_s, T2 last_or_c_or_n)
 
size_type copy (value_type *s, size_type n, size_type pos=0) const
 
void swap (basic_fbstring &rhs)
 
const value_typec_str () const
 
const value_typedata () const
 
allocator_type get_allocator () const
 
size_type find (const basic_fbstring &str, size_type pos=0) const
 
size_type find (const value_type *needle, size_type pos, size_type nsize) const
 
size_type find (const value_type *s, size_type pos=0) const
 
size_type find (value_type c, size_type pos=0) const
 
size_type rfind (const basic_fbstring &str, size_type pos=npos) const
 
size_type rfind (const value_type *s, size_type pos, size_type n) const
 
size_type rfind (const value_type *s, size_type pos=npos) const
 
size_type rfind (value_type c, size_type pos=npos) const
 
size_type find_first_of (const basic_fbstring &str, size_type pos=0) const
 
size_type find_first_of (const value_type *s, size_type pos, size_type n) const
 
size_type find_first_of (const value_type *s, size_type pos=0) const
 
size_type find_first_of (value_type c, size_type pos=0) const
 
size_type find_last_of (const basic_fbstring &str, size_type pos=npos) const
 
size_type find_last_of (const value_type *s, size_type pos, size_type n) const
 
size_type find_last_of (const value_type *s, size_type pos=npos) const
 
size_type find_last_of (value_type c, size_type pos=npos) const
 
size_type find_first_not_of (const basic_fbstring &str, size_type pos=0) const
 
size_type find_first_not_of (const value_type *s, size_type pos, size_type n) const
 
size_type find_first_not_of (const value_type *s, size_type pos=0) const
 
size_type find_first_not_of (value_type c, size_type pos=0) const
 
size_type find_last_not_of (const basic_fbstring &str, size_type pos=npos) const
 
size_type find_last_not_of (const value_type *s, size_type pos, size_type n) const
 
size_type find_last_not_of (const value_type *s, size_type pos=npos) const
 
size_type find_last_not_of (value_type c, size_type pos=npos) const
 
basic_fbstring substr (size_type pos=0, size_type n=npos) const &
 
basic_fbstring substr (size_type pos=0, size_type n=npos)&&
 
int compare (const basic_fbstring &str) const
 
int compare (size_type pos1, size_type n1, const basic_fbstring &str) const
 
int compare (size_type pos1, size_type n1, const value_type *s) const
 
int compare (size_type pos1, size_type n1, const value_type *s, size_type n2) const
 
int compare (size_type pos1, size_type n1, const basic_fbstring &str, size_type pos2, size_type n2) const
 
int compare (const value_type *s) const
 
template<class InputIter >
basic_fbstring< E, T, A, S > & replaceImplDiscr (iterator i1, iterator i2, InputIter b, InputIter e, std::integral_constant< int, 0 >)
 

Static Public Attributes

static constexpr size_type npos = size_type(-1)
 

Private Types

typedef std::basic_istream< value_type, traits_typeistream_type
 

Private Member Functions

bool isSane () const
 
istream_typegetlineImpl (istream_type &is, value_type delim)
 
iterator insertImplDiscr (const_iterator i, size_type n, value_type c, std::true_type)
 
template<class InputIter >
iterator insertImplDiscr (const_iterator i, InputIter b, InputIter e, std::false_type)
 
template<class FwdIterator >
iterator insertImpl (const_iterator i, FwdIterator s1, FwdIterator s2, std::forward_iterator_tag)
 
template<class InputIterator >
iterator insertImpl (const_iterator i, InputIterator b, InputIterator e, std::input_iterator_tag)
 
basic_fbstringreplaceImplDiscr (iterator i1, iterator i2, const value_type *s, size_type n, std::integral_constant< int, 2 >)
 
basic_fbstringreplaceImplDiscr (iterator i1, iterator i2, size_type n2, value_type c, std::integral_constant< int, 1 >)
 
template<class InputIter >
basic_fbstringreplaceImplDiscr (iterator i1, iterator i2, InputIter b, InputIter e, std::integral_constant< int, 0 >)
 
template<class FwdIterator >
bool replaceAliased (iterator, iterator, FwdIterator, FwdIterator, std::false_type)
 
template<class FwdIterator >
bool replaceAliased (iterator i1, iterator i2, FwdIterator s1, FwdIterator s2, std::true_type)
 
template<class FwdIterator >
void replaceImpl (iterator i1, iterator i2, FwdIterator s1, FwdIterator s2, std::forward_iterator_tag)
 
template<class InputIterator >
void replaceImpl (iterator i1, iterator i2, InputIterator b, InputIterator e, std::input_iterator_tag)
 

Static Private Member Functions

template<typename Ex , typename... Args>
static FOLLY_ALWAYS_INLINE void enforce (bool condition, Args &&...args)
 
static void procrustes (size_type &n, size_type nmax)
 
static size_type traitsLength (const value_type *s)
 

Private Attributes

Storage store_
 

Friends

istream_typegetline (istream_type &is, basic_fbstring &str, value_type delim)
 
istream_typegetline (istream_type &is, basic_fbstring &str)
 

Detailed Description

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
class folly::basic_fbstring< E, T, A, Storage >

This is the basic_string replacement. For conformity, basic_fbstring takes the same template parameters, plus the last one which is the core.

Definition at line 1070 of file FBString.h.

Member Typedef Documentation

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef A folly::basic_fbstring< E, T, A, Storage >::allocator_type

Definition at line 1102 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef const E* folly::basic_fbstring< E, T, A, Storage >::const_iterator

Definition at line 1112 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef A::const_pointer folly::basic_fbstring< E, T, A, Storage >::const_pointer

Definition at line 1109 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef A::const_reference folly::basic_fbstring< E, T, A, Storage >::const_reference

Definition at line 1107 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef std::reverse_iterator<const_iterator> folly::basic_fbstring< E, T, A, Storage >::const_reverse_iterator

Definition at line 1114 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef A::difference_type folly::basic_fbstring< E, T, A, Storage >::difference_type

Definition at line 1104 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef std::true_type folly::basic_fbstring< E, T, A, Storage >::IsRelocatable

Definition at line 1117 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef std::basic_istream<value_type, traits_type> folly::basic_fbstring< E, T, A, Storage >::istream_type
private

Definition at line 1508 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef E* folly::basic_fbstring< E, T, A, Storage >::iterator

Definition at line 1111 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef A::pointer folly::basic_fbstring< E, T, A, Storage >::pointer

Definition at line 1108 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef A::reference folly::basic_fbstring< E, T, A, Storage >::reference

Definition at line 1106 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef std::reverse_iterator<iterator> folly::basic_fbstring< E, T, A, Storage >::reverse_iterator

Definition at line 1113 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef A::size_type folly::basic_fbstring< E, T, A, Storage >::size_type

Definition at line 1103 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef T folly::basic_fbstring< E, T, A, Storage >::traits_type

Definition at line 1100 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
typedef traits_type::char_type folly::basic_fbstring< E, T, A, Storage >::value_type

Definition at line 1101 of file FBString.h.

Constructor & Destructor Documentation

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( )
inlinenoexcept

Definition at line 1143 of file FBString.h.

1143 : basic_fbstring(A()) {}
basic_fbstring() noexcept
Definition: FBString.h:1143
std::unique_ptr< int > A
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( const A )
inlineexplicitnoexcept

Definition at line 1145 of file FBString.h.

1145 {}
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( const basic_fbstring< E, T, A, Storage > &  str)
inline

Definition at line 1147 of file FBString.h.

1147 : store_(str.store_) {}
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( basic_fbstring< E, T, A, Storage > &&  goner)
inlinenoexcept

Definition at line 1150 of file FBString.h.

1151  : store_(std::move(goner.store_)) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
template<typename A2 >
folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( const std::basic_string< E, T, A2 > &  str)
inline

Definition at line 1156 of file FBString.h.

1157  : store_(str.data(), str.size()) {}
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( const basic_fbstring< E, T, A, Storage > &  str,
size_type  pos,
size_type  n = npos,
const A = A() 
)
inline

Definition at line 1160 of file FBString.h.

1164  {
1165  assign(str, pos, n);
1166  }
basic_fbstring & assign(const basic_fbstring &str)
Definition: FBString.h:1441
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
FOLLY_MALLOC_NOINLINE folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( const value_type s,
const A = A() 
)
inline

Definition at line 1169 of file FBString.h.

1170  : store_(s, traitsLength(s)) {}
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
FOLLY_MALLOC_NOINLINE folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( const value_type s,
size_type  n,
const A = A() 
)
inline

Definition at line 1173 of file FBString.h.

1174  : store_(s, n) {}
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
FOLLY_MALLOC_NOINLINE folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( size_type  n,
value_type  c,
const A = A() 
)
inline

Definition at line 1177 of file FBString.h.

1177  {
1178  auto const pData = store_.expandNoinit(n);
1179  fbstring_detail::podFill(pData, pData + n, c);
1180  }
void podFill(Pod *b, Pod *e, T c)
Definition: FBString.h:141
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
template<class InIt >
FOLLY_MALLOC_NOINLINE folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( InIt  begin,
InIt  end,
typename std::enable_if< !std::is_same< InIt, value_type * >::value, const A >::type = A() 
)
inline

Definition at line 1183 of file FBString.h.

1189  {
1190  assign(begin, end);
1191  }
basic_fbstring & assign(const basic_fbstring &str)
Definition: FBString.h:1441
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
FOLLY_MALLOC_NOINLINE folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( const value_type b,
const value_type e,
const A = A() 
)
inline

Definition at line 1195 of file FBString.h.

1196  : store_(b, size_type(e - b)) {}
char b
A::size_type size_type
Definition: FBString.h:1103
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( value_type s,
size_type  n,
size_type  c,
AcquireMallocatedString  a 
)
inline

Definition at line 1199 of file FBString.h.

1204  : store_(s, n, c, a) {}
char a
static set< string > s
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
FOLLY_MALLOC_NOINLINE folly::basic_fbstring< E, T, A, Storage >::basic_fbstring ( std::initializer_list< value_type il)
inline

Definition at line 1208 of file FBString.h.

1208  {
1209  assign(il.begin(), il.end());
1210  }
basic_fbstring & assign(const basic_fbstring &str)
Definition: FBString.h:1441
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
folly::basic_fbstring< E, T, A, Storage >::~basic_fbstring ( )
inlinenoexcept

Definition at line 1212 of file FBString.h.

1212 {}

Member Function Documentation

template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S > & folly::basic_fbstring< E, T, A, S >::append ( const basic_fbstring< E, T, A, Storage > &  str)
inline

Definition at line 1953 of file FBString.h.

References append(), folly::basic_fbstring< E, T, A, Storage >::data(), FBSTRING_ASSERT, folly::size(), and folly::basic_fbstring< E, T, A, Storage >::size().

Referenced by BENCHMARK(), proxygen::HPACKDecodeBuffer::decodeLiteral(), folly::basic_fbstring< E, T, A, Storage >::insertImpl(), folly::operator+(), folly::parseTo(), folly::basic_fbstring< E, T, A, Storage >::replaceAliased(), folly::basic_fbstring< E, T, A, Storage >::replaceImpl(), and folly::toAppend().

1954  {
1955 #ifndef NDEBUG
1956  auto desiredSize = size() + str.size();
1957 #endif
1958  append(str.data(), str.size());
1959  FBSTRING_ASSERT(size() == desiredSize);
1960  return *this;
1961 }
size_type size() const
Definition: FBString.h:1337
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
basic_fbstring & append(const basic_fbstring &str)
Definition: FBString.h:1953
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S > & folly::basic_fbstring< E, T, A, S >::append ( const basic_fbstring< E, T, A, Storage > &  str,
const size_type  pos,
size_type  n 
)
inline

Definition at line 1964 of file FBString.h.

References append(), folly::basic_fbstring< E, T, A, Storage >::data(), FOLLY_MALLOC_NOINLINE, and folly::basic_fbstring< E, T, A, Storage >::size().

1967  {
1968  const size_type sz = str.size();
1969  enforce<std::out_of_range>(pos <= sz, "");
1970  procrustes(n, sz - pos);
1971  return append(str.data() + pos, n);
1972 }
A::size_type size_type
Definition: FBString.h:1103
basic_fbstring & append(const basic_fbstring &str)
Definition: FBString.h:1953
static void procrustes(size_type &n, size_type nmax)
Definition: FBString.h:1120
template<typename E , class T , class A , class S >
FOLLY_MALLOC_NOINLINE basic_fbstring< E, T, A, S > & folly::basic_fbstring< E, T, A, S >::append ( const value_type s,
size_type  n 
)
inline

Definition at line 1976 of file FBString.h.

References data, FBSTRING_ASSERT, FBSTRING_UNLIKELY, folly::fbstring_detail::podCopy(), folly::fbstring_detail::podMove(), and folly::size().

1976  {
1977  Invariant checker(*this);
1978 
1979  if (FBSTRING_UNLIKELY(!n)) {
1980  // Unlikely but must be done
1981  return *this;
1982  }
1983  auto const oldSize = size();
1984  auto const oldData = data();
1985  auto pData = store_.expandNoinit(n, /* expGrowth = */ true);
1986 
1987  // Check for aliasing (rare). We could use "<=" here but in theory
1988  // those do not work for pointers unless the pointers point to
1989  // elements in the same array. For that reason we use
1990  // std::less_equal, which is guaranteed to offer a total order
1991  // over pointers. See discussion at http://goo.gl/Cy2ya for more
1992  // info.
1993  std::less_equal<const value_type*> le;
1994  if (FBSTRING_UNLIKELY(le(oldData, s) && !le(oldData + oldSize, s))) {
1995  FBSTRING_ASSERT(le(s + n, oldData + oldSize));
1996  // expandNoinit() could have moved the storage, restore the source.
1997  s = data() + (s - oldData);
1998  fbstring_detail::podMove(s, s + n, pData);
1999  } else {
2000  fbstring_detail::podCopy(s, s + n, pData);
2001  }
2002 
2003  FBSTRING_ASSERT(size() == oldSize + n);
2004  return *this;
2005 }
size_type size() const
Definition: FBString.h:1337
void podMove(const Pod *b, const Pod *e, Pod *d)
Definition: FBString.h:188
void podCopy(const Pod *b, const Pod *e, Pod *d)
Definition: FBString.h:174
#define FBSTRING_UNLIKELY(x)
Definition: FBString.h:75
const value_type * data() const
Definition: FBString.h:1716
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::append ( const value_type s)
inline

Definition at line 1421 of file FBString.h.

1421  {
1422  return append(s, traitsLength(s));
1423  }
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
static set< string > s
basic_fbstring & append(const basic_fbstring &str)
Definition: FBString.h:1953
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S > & folly::basic_fbstring< E, T, A, S >::append ( size_type  n,
value_type  c 
)
inline

Definition at line 2008 of file FBString.h.

References folly::fbstring_detail::podFill().

2010  {
2011  Invariant checker(*this);
2012  auto pData = store_.expandNoinit(n, /* expGrowth = */ true);
2013  fbstring_detail::podFill(pData, pData + n, c);
2014  return *this;
2015 }
void podFill(Pod *b, Pod *e, T c)
Definition: FBString.h:141
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
template<class InputIterator >
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::append ( InputIterator  first,
InputIterator  last 
)
inline

Definition at line 1428 of file FBString.h.

1428  {
1429  insert(end(), first, last);
1430  return *this;
1431  }
basic_fbstring & insert(size_type pos1, const basic_fbstring &str)
Definition: FBString.h:1470
constexpr detail::First first
Definition: Base-inl.h:2553
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::append ( std::initializer_list< value_type il)
inline

Definition at line 1433 of file FBString.h.

1433  {
1434  return append(il.begin(), il.end());
1435  }
basic_fbstring & append(const basic_fbstring &str)
Definition: FBString.h:1953
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::assign ( const basic_fbstring< E, T, A, Storage > &  str)
inline

Definition at line 1441 of file FBString.h.

Referenced by folly::errnoStr().

1441  {
1442  if (&str == this) {
1443  return *this;
1444  }
1445  return assign(str.data(), str.size());
1446  }
basic_fbstring & assign(const basic_fbstring &str)
Definition: FBString.h:1441
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::assign ( basic_fbstring< E, T, A, Storage > &&  str)
inline

Definition at line 1448 of file FBString.h.

1448  {
1449  return *this = std::move(str);
1450  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S > & folly::basic_fbstring< E, T, A, S >::assign ( const basic_fbstring< E, T, A, Storage > &  str,
const size_type  pos,
size_type  n 
)
inline

Definition at line 2018 of file FBString.h.

References folly::basic_fbstring< E, T, A, Storage >::data(), FOLLY_MALLOC_NOINLINE, and folly::basic_fbstring< E, T, A, Storage >::size().

2021  {
2022  const size_type sz = str.size();
2023  enforce<std::out_of_range>(pos <= sz, "");
2024  procrustes(n, sz - pos);
2025  return assign(str.data() + pos, n);
2026 }
A::size_type size_type
Definition: FBString.h:1103
basic_fbstring & assign(const basic_fbstring &str)
Definition: FBString.h:1441
static void procrustes(size_type &n, size_type nmax)
Definition: FBString.h:1120
template<typename E , class T , class A , class S >
FOLLY_MALLOC_NOINLINE basic_fbstring< E, T, A, S > & folly::basic_fbstring< E, T, A, S >::assign ( const value_type s,
const size_type  n 
)
inline

Definition at line 2030 of file FBString.h.

References FBSTRING_ASSERT, folly::fbstring_detail::podCopy(), folly::fbstring_detail::podMove(), resize(), and folly::size().

2030  {
2031  Invariant checker(*this);
2032 
2033  if (n == 0) {
2034  resize(0);
2035  } else if (size() >= n) {
2036  // s can alias this, we need to use podMove.
2037  fbstring_detail::podMove(s, s + n, store_.mutableData());
2038  store_.shrink(size() - n);
2039  FBSTRING_ASSERT(size() == n);
2040  } else {
2041  // If n is larger than size(), s cannot alias this string's
2042  // storage.
2043  resize(0);
2044  // Do not use exponential growth here: assign() should be tight,
2045  // to mirror the behavior of the equivalent constructor.
2046  fbstring_detail::podCopy(s, s + n, store_.expandNoinit(n));
2047  }
2048 
2049  FBSTRING_ASSERT(size() == n);
2050  return *this;
2051 }
size_type size() const
Definition: FBString.h:1337
void podMove(const Pod *b, const Pod *e, Pod *d)
Definition: FBString.h:188
void podCopy(const Pod *b, const Pod *e, Pod *d)
Definition: FBString.h:174
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
static set< string > s
void resize(size_type n, value_type c=value_type())
Definition: FBString.h:1936
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::assign ( const value_type s)
inline

Definition at line 1457 of file FBString.h.

1457  {
1458  return assign(s, traitsLength(s));
1459  }
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
basic_fbstring & assign(const basic_fbstring &str)
Definition: FBString.h:1441
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::assign ( std::initializer_list< value_type il)
inline

Definition at line 1461 of file FBString.h.

1461  {
1462  return assign(il.begin(), il.end());
1463  }
basic_fbstring & assign(const basic_fbstring &str)
Definition: FBString.h:1441
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
template<class ItOrLength , class ItOrChar >
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::assign ( ItOrLength  first_or_n,
ItOrChar  last_or_c 
)
inline

Definition at line 1466 of file FBString.h.

1466  {
1467  return replace(begin(), end(), first_or_n, last_or_c);
1468  }
basic_fbstring & replace(size_type pos1, size_type n1, const basic_fbstring &str)
Definition: FBString.h:1581
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const_reference folly::basic_fbstring< E, T, A, Storage >::at ( size_type  n) const
inline

Definition at line 1385 of file FBString.h.

1385  {
1386  enforce<std::out_of_range>(n < size(), "");
1387  return (*this)[n];
1388  }
size_type size() const
Definition: FBString.h:1337
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
reference folly::basic_fbstring< E, T, A, Storage >::at ( size_type  n)
inline

Definition at line 1390 of file FBString.h.

1390  {
1391  enforce<std::out_of_range>(n < size(), "");
1392  return (*this)[n];
1393  }
size_type size() const
Definition: FBString.h:1337
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const value_type& folly::basic_fbstring< E, T, A, Storage >::back ( ) const
inline

Definition at line 1318 of file FBString.h.

Referenced by TEST().

1318  {
1319  FBSTRING_ASSERT(!empty());
1320  // Should be begin()[size() - 1], but that branches twice
1321  return *(end() - 1);
1322  }
bool empty() const
Definition: FBString.h:1372
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
value_type& folly::basic_fbstring< E, T, A, Storage >::back ( )
inline

Definition at line 1326 of file FBString.h.

1326  {
1327  FBSTRING_ASSERT(!empty());
1328  // Should be begin()[size() - 1], but that branches twice
1329  return *(end() - 1);
1330  }
bool empty() const
Definition: FBString.h:1372
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
iterator folly::basic_fbstring< E, T, A, Storage >::begin ( )
inline

Definition at line 1265 of file FBString.h.

Referenced by TEST().

1265  {
1266  return store_.mutableData();
1267  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const_iterator folly::basic_fbstring< E, T, A, Storage >::begin ( ) const
inline

Definition at line 1269 of file FBString.h.

1269  {
1270  return store_.data();
1271  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const value_type* folly::basic_fbstring< E, T, A, Storage >::c_str ( ) const
inline

Definition at line 1712 of file FBString.h.

Referenced by TEST().

1712  {
1713  return store_.c_str();
1714  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::capacity ( ) const
inline

Definition at line 1351 of file FBString.h.

Referenced by TEST().

1351  {
1352  return store_.capacity();
1353  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const_iterator folly::basic_fbstring< E, T, A, Storage >::cbegin ( ) const
inline

Definition at line 1273 of file FBString.h.

1273  {
1274  return begin();
1275  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const_iterator folly::basic_fbstring< E, T, A, Storage >::cend ( ) const
inline

Definition at line 1285 of file FBString.h.

1285  {
1286  return end();
1287  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
void folly::basic_fbstring< E, T, A, Storage >::clear ( )
inline

Definition at line 1368 of file FBString.h.

Referenced by BENCHMARK_RELATIVE(), proxygen::HPACKDecodeBuffer::decodeLiteral(), folly::parseTo(), StringUnsplit_Gen(), folly::test::TEST(), TEST(), and TEST_F().

1368  {
1369  resize(0);
1370  }
void resize(size_type n, value_type c=value_type())
Definition: FBString.h:1936
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
int folly::basic_fbstring< E, T, A, Storage >::compare ( const basic_fbstring< E, T, A, Storage > &  str) const
inline

Definition at line 1829 of file FBString.h.

Referenced by folly::operator<(), folly::operator==(), and folly::operator>().

1829  {
1830  // FIX due to Goncalo N M de Carvalho July 18, 2005
1831  return compare(0, size(), str);
1832  }
size_type size() const
Definition: FBString.h:1337
int compare(const basic_fbstring &str) const
Definition: FBString.h:1829
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
int folly::basic_fbstring< E, T, A, Storage >::compare ( size_type  pos1,
size_type  n1,
const basic_fbstring< E, T, A, Storage > &  str 
) const
inline

Definition at line 1834 of file FBString.h.

1834  {
1835  return compare(pos1, n1, str.data(), str.size());
1836  }
int compare(const basic_fbstring &str) const
Definition: FBString.h:1829
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
int folly::basic_fbstring< E, T, A, Storage >::compare ( size_type  pos1,
size_type  n1,
const value_type s 
) const
inline

Definition at line 1838 of file FBString.h.

1838  {
1839  return compare(pos1, n1, s, traitsLength(s));
1840  }
int compare(const basic_fbstring &str) const
Definition: FBString.h:1829
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
int folly::basic_fbstring< E, T, A, Storage >::compare ( size_type  pos1,
size_type  n1,
const value_type s,
size_type  n2 
) const
inline

Definition at line 1842 of file FBString.h.

1843  {
1844  enforce<std::out_of_range>(pos1 <= size(), "");
1845  procrustes(n1, size() - pos1);
1846  // The line below fixed by Jean-Francois Bastien, 04-23-2007. Thanks!
1847  const int r = traits_type::compare(pos1 + data(), s, std::min(n1, n2));
1848  return r != 0 ? r : n1 > n2 ? 1 : n1 < n2 ? -1 : 0;
1849  }
size_type size() const
Definition: FBString.h:1337
const value_type * data() const
Definition: FBString.h:1716
LogLevel min
Definition: LogLevel.cpp:30
static set< string > s
static void procrustes(size_type &n, size_type nmax)
Definition: FBString.h:1120
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
int folly::basic_fbstring< E, T, A, Storage >::compare ( size_type  pos1,
size_type  n1,
const basic_fbstring< E, T, A, Storage > &  str,
size_type  pos2,
size_type  n2 
) const
inline

Definition at line 1851 of file FBString.h.

1856  {
1857  enforce<std::out_of_range>(pos2 <= str.size(), "");
1858  return compare(
1859  pos1, n1, str.data() + pos2, std::min(n2, str.size() - pos2));
1860  }
int compare(const basic_fbstring &str) const
Definition: FBString.h:1829
LogLevel min
Definition: LogLevel.cpp:30
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
int folly::basic_fbstring< E, T, A, Storage >::compare ( const value_type s) const
inline

Definition at line 1863 of file FBString.h.

1863  {
1864  // Could forward to compare(0, size(), s, traitsLength(s))
1865  // but that does two extra checks
1866  const size_type n1(size()), n2(traitsLength(s));
1867  const int r = traits_type::compare(data(), s, std::min(n1, n2));
1868  return r != 0 ? r : n1 > n2 ? 1 : n1 < n2 ? -1 : 0;
1869  }
size_type size() const
Definition: FBString.h:1337
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
const value_type * data() const
Definition: FBString.h:1716
LogLevel min
Definition: LogLevel.cpp:30
A::size_type size_type
Definition: FBString.h:1103
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::copy ( value_type s,
size_type  n,
size_type  pos = 0 
) const
inline

Definition at line 1698 of file FBString.h.

1698  {
1699  enforce<std::out_of_range>(pos <= size(), "");
1700  procrustes(n, size() - pos);
1701 
1702  if (n != 0) {
1703  fbstring_detail::podCopy(data() + pos, data() + pos + n, s);
1704  }
1705  return n;
1706  }
size_type size() const
Definition: FBString.h:1337
void podCopy(const Pod *b, const Pod *e, Pod *d)
Definition: FBString.h:174
const value_type * data() const
Definition: FBString.h:1716
static set< string > s
static void procrustes(size_type &n, size_type nmax)
Definition: FBString.h:1120
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const_reverse_iterator folly::basic_fbstring< E, T, A, Storage >::crbegin ( ) const
inline

Definition at line 1297 of file FBString.h.

1297  {
1298  return rbegin();
1299  }
reverse_iterator rbegin()
Definition: FBString.h:1289
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const_reverse_iterator folly::basic_fbstring< E, T, A, Storage >::crend ( ) const
inline

Definition at line 1309 of file FBString.h.

1309  {
1310  return rend();
1311  }
reverse_iterator rend()
Definition: FBString.h:1301
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
bool folly::basic_fbstring< E, T, A, Storage >::empty ( ) const
inline

Definition at line 1372 of file FBString.h.

Referenced by proxygen::HPACKContext::getIndex(), proxygen::HPACKHeader::hasValue(), TEST(), and TEST_F().

1372  {
1373  return size() == 0;
1374  }
size_type size() const
Definition: FBString.h:1337
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
iterator folly::basic_fbstring< E, T, A, Storage >::end ( )
inline

Definition at line 1277 of file FBString.h.

Referenced by TEST().

1277  {
1278  return store_.mutableData() + store_.size();
1279  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const_iterator folly::basic_fbstring< E, T, A, Storage >::end ( ) const
inline

Definition at line 1281 of file FBString.h.

1281  {
1282  return store_.data() + store_.size();
1283  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
template<typename Ex , typename... Args>
static FOLLY_ALWAYS_INLINE void folly::basic_fbstring< E, T, A, Storage >::enforce ( bool  condition,
Args &&...  args 
)
inlinestaticprivate

Definition at line 1072 of file FBString.h.

1072  {
1073  if (!condition) {
1074  throw_exception<Ex>(static_cast<Args&&>(args)...);
1075  }
1076  }
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::erase ( size_type  pos = 0,
size_type  n = npos 
)
inline

Definition at line 1555 of file FBString.h.

Referenced by folly::operator>>().

1555  {
1556  Invariant checker(*this);
1557 
1558  enforce<std::out_of_range>(pos <= length(), "");
1559  procrustes(n, length() - pos);
1560  std::copy(begin() + pos + n, end(), begin() + pos);
1561  resize(length() - n);
1562  return *this;
1563  }
constexpr std::decay< T >::type copy(T &&value) noexcept(noexcept(typename std::decay< T >::type(std::forward< T >(value))))
Definition: Utility.h:72
static void procrustes(size_type &n, size_type nmax)
Definition: FBString.h:1120
void resize(size_type n, value_type c=value_type())
Definition: FBString.h:1936
size_type length() const
Definition: FBString.h:1341
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
iterator folly::basic_fbstring< E, T, A, Storage >::erase ( iterator  position)
inline

Definition at line 1565 of file FBString.h.

1565  {
1566  const size_type pos(position - begin());
1567  enforce<std::out_of_range>(pos <= size(), "");
1568  erase(pos, 1);
1569  return begin() + pos;
1570  }
size_type size() const
Definition: FBString.h:1337
basic_fbstring & erase(size_type pos=0, size_type n=npos)
Definition: FBString.h:1555
A::size_type size_type
Definition: FBString.h:1103
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
iterator folly::basic_fbstring< E, T, A, Storage >::erase ( iterator  first,
iterator  last 
)
inline

Definition at line 1572 of file FBString.h.

1572  {
1573  const size_type pos(first - begin());
1574  erase(pos, last - first);
1575  return begin() + pos;
1576  }
basic_fbstring & erase(size_type pos=0, size_type n=npos)
Definition: FBString.h:1555
A::size_type size_type
Definition: FBString.h:1103
constexpr detail::First first
Definition: Base-inl.h:2553
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find ( const basic_fbstring< E, T, A, Storage > &  str,
size_type  pos = 0 
) const
inline

Definition at line 1724 of file FBString.h.

Referenced by proxygen::HeaderIndexingStrategy::indexHeader(), and TEST().

1724  {
1725  return find(str.data(), pos, str.length());
1726  }
size_type find(const basic_fbstring &str, size_type pos=0) const
Definition: FBString.h:1724
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S >::size_type folly::basic_fbstring< E, T, A, S >::find ( const value_type needle,
size_type  pos,
size_type  nsize 
) const
inline

Definition at line 2090 of file FBString.h.

References data, FBSTRING_ASSERT, i, folly::size(), and folly::gen::skip().

2093  {
2094  auto const size = this->size();
2095  // nsize + pos can overflow (eg pos == npos), guard against that by checking
2096  // that nsize + pos does not wrap around.
2097  if (nsize + pos > size || nsize + pos < pos) {
2098  return npos;
2099  }
2100 
2101  if (nsize == 0) {
2102  return pos;
2103  }
2104  // Don't use std::search, use a Boyer-Moore-like trick by comparing
2105  // the last characters first
2106  auto const haystack = data();
2107  auto const nsize_1 = nsize - 1;
2108  auto const lastNeedle = needle[nsize_1];
2109 
2110  // Boyer-Moore skip value for the last char in the needle. Zero is
2111  // not a valid value; skip will be computed the first time it's
2112  // needed.
2113  size_type skip = 0;
2114 
2115  const E* i = haystack + pos;
2116  auto iEnd = haystack + size - nsize_1;
2117 
2118  while (i < iEnd) {
2119  // Boyer-Moore: match the last element in the needle
2120  while (i[nsize_1] != lastNeedle) {
2121  if (++i == iEnd) {
2122  // not found
2123  return npos;
2124  }
2125  }
2126  // Here we know that the last char matches
2127  // Continue in pedestrian mode
2128  for (size_t j = 0;;) {
2129  FBSTRING_ASSERT(j < nsize);
2130  if (i[j] != needle[j]) {
2131  // Not found, we can skip
2132  // Compute the skip value lazily
2133  if (skip == 0) {
2134  skip = 1;
2135  while (skip <= nsize_1 && needle[nsize_1 - skip] != lastNeedle) {
2136  ++skip;
2137  }
2138  }
2139  i += skip;
2140  break;
2141  }
2142  // Check if done searching
2143  if (++j == nsize) {
2144  // Yay
2145  return i - haystack;
2146  }
2147  }
2148  }
2149  return npos;
2150 }
const string needle
size_type size() const
Definition: FBString.h:1337
detail::Skip skip(size_t count)
Definition: Base-inl.h:2598
const value_type * data() const
Definition: FBString.h:1716
A::size_type size_type
Definition: FBString.h:1103
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
static constexpr size_type npos
Definition: FBString.h:1116
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find ( const value_type s,
size_type  pos = 0 
) const
inline

Definition at line 1731 of file FBString.h.

1731  {
1732  return find(s, pos, traitsLength(s));
1733  }
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
size_type find(const basic_fbstring &str, size_type pos=0) const
Definition: FBString.h:1724
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find ( value_type  c,
size_type  pos = 0 
) const
inline

Definition at line 1735 of file FBString.h.

1735  {
1736  return find(&c, pos, 1);
1737  }
size_type find(const basic_fbstring &str, size_type pos=0) const
Definition: FBString.h:1724
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find_first_not_of ( const basic_fbstring< E, T, A, Storage > &  str,
size_type  pos = 0 
) const
inline

Definition at line 1783 of file FBString.h.

1784  {
1785  return find_first_not_of(str.data(), pos, str.size());
1786  }
size_type find_first_not_of(const basic_fbstring &str, size_type pos=0) const
Definition: FBString.h:1783
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S >::size_type folly::basic_fbstring< E, T, A, S >::find_first_not_of ( const value_type s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 2408 of file FBString.h.

References folly::test::begin(), folly::test::end(), and i.

2411  {
2412  if (pos < length()) {
2413  const_iterator i(begin() + pos), finish(end());
2414  for (; i != finish; ++i) {
2415  if (traits_type::find(s, n, *i) == nullptr) {
2416  return i - begin();
2417  }
2418  }
2419  }
2420  return npos;
2421 }
static set< string > s
static constexpr size_type npos
Definition: FBString.h:1116
const E * const_iterator
Definition: FBString.h:1112
size_type length() const
Definition: FBString.h:1341
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find_first_not_of ( const value_type s,
size_type  pos = 0 
) const
inline

Definition at line 1791 of file FBString.h.

1791  {
1792  return find_first_not_of(s, pos, traitsLength(s));
1793  }
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
size_type find_first_not_of(const basic_fbstring &str, size_type pos=0) const
Definition: FBString.h:1783
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find_first_not_of ( value_type  c,
size_type  pos = 0 
) const
inline

Definition at line 1795 of file FBString.h.

1795  {
1796  return find_first_not_of(&c, pos, 1);
1797  }
size_type find_first_not_of(const basic_fbstring &str, size_type pos=0) const
Definition: FBString.h:1783
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find_first_of ( const basic_fbstring< E, T, A, Storage > &  str,
size_type  pos = 0 
) const
inline

Definition at line 1753 of file FBString.h.

1753  {
1754  return find_first_of(str.data(), pos, str.length());
1755  }
size_type find_first_of(const basic_fbstring &str, size_type pos=0) const
Definition: FBString.h:1753
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S >::size_type folly::basic_fbstring< E, T, A, S >::find_first_of ( const value_type s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 2369 of file FBString.h.

References folly::test::begin(), folly::test::end(), and i.

2372  {
2373  if (pos > length() || n == 0) {
2374  return npos;
2375  }
2376  const_iterator i(begin() + pos), finish(end());
2377  for (; i != finish; ++i) {
2378  if (traits_type::find(s, n, *i) != nullptr) {
2379  return i - begin();
2380  }
2381  }
2382  return npos;
2383 }
static set< string > s
static constexpr size_type npos
Definition: FBString.h:1116
const E * const_iterator
Definition: FBString.h:1112
size_type length() const
Definition: FBString.h:1341
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find_first_of ( const value_type s,
size_type  pos = 0 
) const
inline

Definition at line 1760 of file FBString.h.

1760  {
1761  return find_first_of(s, pos, traitsLength(s));
1762  }
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
size_type find_first_of(const basic_fbstring &str, size_type pos=0) const
Definition: FBString.h:1753
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find_first_of ( value_type  c,
size_type  pos = 0 
) const
inline

Definition at line 1764 of file FBString.h.

1764  {
1765  return find_first_of(&c, pos, 1);
1766  }
size_type find_first_of(const basic_fbstring &str, size_type pos=0) const
Definition: FBString.h:1753
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find_last_not_of ( const basic_fbstring< E, T, A, Storage > &  str,
size_type  pos = npos 
) const
inline

Definition at line 1799 of file FBString.h.

1800  {
1801  return find_last_not_of(str.data(), pos, str.length());
1802  }
size_type find_last_not_of(const basic_fbstring &str, size_type pos=npos) const
Definition: FBString.h:1799
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S >::size_type folly::basic_fbstring< E, T, A, S >::find_last_not_of ( const value_type s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 2425 of file FBString.h.

References folly::test::begin(), folly::empty(), i, min, and folly::size().

2428  {
2429  if (!this->empty()) {
2430  pos = std::min(pos, size() - 1);
2431  const_iterator i(begin() + pos);
2432  for (;; --i) {
2433  if (traits_type::find(s, n, *i) == nullptr) {
2434  return i - begin();
2435  }
2436  if (i == begin()) {
2437  break;
2438  }
2439  }
2440  }
2441  return npos;
2442 }
size_type size() const
Definition: FBString.h:1337
bool empty() const
Definition: FBString.h:1372
LogLevel min
Definition: LogLevel.cpp:30
static set< string > s
static constexpr size_type npos
Definition: FBString.h:1116
const E * const_iterator
Definition: FBString.h:1112
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find_last_not_of ( const value_type s,
size_type  pos = npos 
) const
inline

Definition at line 1807 of file FBString.h.

1807  {
1808  return find_last_not_of(s, pos, traitsLength(s));
1809  }
size_type find_last_not_of(const basic_fbstring &str, size_type pos=npos) const
Definition: FBString.h:1799
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find_last_not_of ( value_type  c,
size_type  pos = npos 
) const
inline

Definition at line 1811 of file FBString.h.

1811  {
1812  return find_last_not_of(&c, pos, 1);
1813  }
size_type find_last_not_of(const basic_fbstring &str, size_type pos=npos) const
Definition: FBString.h:1799
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find_last_of ( const basic_fbstring< E, T, A, Storage > &  str,
size_type  pos = npos 
) const
inline

Definition at line 1768 of file FBString.h.

1769  {
1770  return find_last_of(str.data(), pos, str.length());
1771  }
size_type find_last_of(const basic_fbstring &str, size_type pos=npos) const
Definition: FBString.h:1768
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S >::size_type folly::basic_fbstring< E, T, A, S >::find_last_of ( const value_type s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 2387 of file FBString.h.

References folly::test::begin(), folly::empty(), i, and min.

2390  {
2391  if (!empty() && n > 0) {
2392  pos = std::min(pos, length() - 1);
2393  const_iterator i(begin() + pos);
2394  for (;; --i) {
2395  if (traits_type::find(s, n, *i) != nullptr) {
2396  return i - begin();
2397  }
2398  if (i == begin()) {
2399  break;
2400  }
2401  }
2402  }
2403  return npos;
2404 }
bool empty() const
Definition: FBString.h:1372
LogLevel min
Definition: LogLevel.cpp:30
static set< string > s
static constexpr size_type npos
Definition: FBString.h:1116
const E * const_iterator
Definition: FBString.h:1112
size_type length() const
Definition: FBString.h:1341
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find_last_of ( const value_type s,
size_type  pos = npos 
) const
inline

Definition at line 1775 of file FBString.h.

1775  {
1776  return find_last_of(s, pos, traitsLength(s));
1777  }
size_type find_last_of(const basic_fbstring &str, size_type pos=npos) const
Definition: FBString.h:1768
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::find_last_of ( value_type  c,
size_type  pos = npos 
) const
inline

Definition at line 1779 of file FBString.h.

1779  {
1780  return find_last_of(&c, pos, 1);
1781  }
size_type find_last_of(const basic_fbstring &str, size_type pos=npos) const
Definition: FBString.h:1768
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const value_type& folly::basic_fbstring< E, T, A, Storage >::front ( ) const
inline

Definition at line 1315 of file FBString.h.

Referenced by TEST().

1315  {
1316  return *begin();
1317  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
value_type& folly::basic_fbstring< E, T, A, Storage >::front ( )
inline

Definition at line 1323 of file FBString.h.

1323  {
1324  return *begin();
1325  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
allocator_type folly::basic_fbstring< E, T, A, Storage >::get_allocator ( ) const
inline

Definition at line 1720 of file FBString.h.

1720  {
1721  return allocator_type();
1722  }
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S >::istream_type & folly::basic_fbstring< E, T, A, S >::getlineImpl ( istream_type is,
value_type  delim 
)
inlineprivate

Definition at line 2056 of file FBString.h.

References FBSTRING_ASSERT, reserve(), resize(), and folly::size().

2056  {
2057  Invariant checker(*this);
2058 
2059  clear();
2060  size_t size = 0;
2061  while (true) {
2062  size_t avail = capacity() - size;
2063  // fbstring has 1 byte extra capacity for the null terminator,
2064  // and getline null-terminates the read string.
2065  is.getline(store_.expandNoinit(avail), avail + 1, delim);
2066  size += is.gcount();
2067 
2068  if (is.bad() || is.eof() || !is.fail()) {
2069  // Done by either failure, end of file, or normal read.
2070  if (!is.bad() && !is.eof()) {
2071  --size; // gcount() also accounts for the delimiter.
2072  }
2073  resize(size);
2074  break;
2075  }
2076 
2077  FBSTRING_ASSERT(size == this->size());
2078  FBSTRING_ASSERT(size == capacity());
2079  // Start at minimum allocation 63 + terminator = 64.
2080  reserve(std::max<size_t>(63, 3 * size / 2));
2081  // Clear the error so we can continue reading.
2082  is.clear();
2083  }
2084  return is;
2085 }
size_type size() const
Definition: FBString.h:1337
void reserve(size_type res_arg=0)
Definition: FBString.h:1355
size_type capacity() const
Definition: FBString.h:1351
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
void resize(size_type n, value_type c=value_type())
Definition: FBString.h:1936
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::insert ( size_type  pos1,
const basic_fbstring< E, T, A, Storage > &  str 
)
inline

Definition at line 1470 of file FBString.h.

1470  {
1471  return insert(pos1, str.data(), str.size());
1472  }
basic_fbstring & insert(size_type pos1, const basic_fbstring &str)
Definition: FBString.h:1470
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::insert ( size_type  pos1,
const basic_fbstring< E, T, A, Storage > &  str,
size_type  pos2,
size_type  n 
)
inline

Definition at line 1474 of file FBString.h.

1478  {
1479  enforce<std::out_of_range>(pos2 <= str.length(), "");
1480  procrustes(n, str.length() - pos2);
1481  return insert(pos1, str.data() + pos2, n);
1482  }
basic_fbstring & insert(size_type pos1, const basic_fbstring &str)
Definition: FBString.h:1470
static void procrustes(size_type &n, size_type nmax)
Definition: FBString.h:1120
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::insert ( size_type  pos,
const value_type s,
size_type  n 
)
inline

Definition at line 1484 of file FBString.h.

1484  {
1485  enforce<std::out_of_range>(pos <= length(), "");
1486  insert(begin() + pos, s, s + n);
1487  return *this;
1488  }
basic_fbstring & insert(size_type pos1, const basic_fbstring &str)
Definition: FBString.h:1470
static set< string > s
size_type length() const
Definition: FBString.h:1341
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::insert ( size_type  pos,
const value_type s 
)
inline

Definition at line 1490 of file FBString.h.

1490  {
1491  return insert(pos, s, traitsLength(s));
1492  }
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
basic_fbstring & insert(size_type pos1, const basic_fbstring &str)
Definition: FBString.h:1470
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::insert ( size_type  pos,
size_type  n,
value_type  c 
)
inline

Definition at line 1494 of file FBString.h.

1494  {
1495  enforce<std::out_of_range>(pos <= length(), "");
1496  insert(begin() + pos, n, c);
1497  return *this;
1498  }
basic_fbstring & insert(size_type pos1, const basic_fbstring &str)
Definition: FBString.h:1470
char c
size_type length() const
Definition: FBString.h:1341
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
iterator folly::basic_fbstring< E, T, A, Storage >::insert ( const_iterator  p,
const value_type  c 
)
inline

Definition at line 1500 of file FBString.h.

1500  {
1501  const size_type pos = p - cbegin();
1502  insert(p, 1, c);
1503  return begin() + pos;
1504  }
A::size_type size_type
Definition: FBString.h:1103
basic_fbstring & insert(size_type pos1, const basic_fbstring &str)
Definition: FBString.h:1470
const_iterator cbegin() const
Definition: FBString.h:1273
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
template<class ItOrLength , class ItOrChar >
iterator folly::basic_fbstring< E, T, A, Storage >::insert ( const_iterator  p,
ItOrLength  first_or_n,
ItOrChar  last_or_c 
)
inline

Definition at line 1546 of file FBString.h.

1546  {
1547  using Sel = bool_constant<std::numeric_limits<ItOrLength>::is_specialized>;
1548  return insertImplDiscr(p, first_or_n, last_or_c, Sel());
1549  }
iterator insertImplDiscr(const_iterator i, size_type n, value_type c, std::true_type)
Definition: FBString.h:2154
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
iterator folly::basic_fbstring< E, T, A, Storage >::insert ( const_iterator  p,
std::initializer_list< value_type il 
)
inline

Definition at line 1551 of file FBString.h.

1551  {
1552  return insert(p, il.begin(), il.end());
1553  }
basic_fbstring & insert(size_type pos1, const basic_fbstring &str)
Definition: FBString.h:1470
template<typename E , class T , class A , class S >
template<class FwdIterator >
basic_fbstring< E, T, A, S >::iterator folly::basic_fbstring< E, T, A, S >::insertImpl ( const_iterator  i,
FwdIterator  s1,
FwdIterator  s2,
std::forward_iterator_tag   
)
inlineprivate

Definition at line 2188 of file FBString.h.

References b, folly::test::begin(), folly::padded::cbegin(), folly::padded::cend(), folly::copy(), FBSTRING_ASSERT, folly::fbstring_detail::podMove(), and folly::size().

2192  {
2193  Invariant checker(*this);
2194 
2195  FBSTRING_ASSERT(i >= cbegin() && i <= cend());
2196  const size_type pos = i - cbegin();
2197  auto n = std::distance(s1, s2);
2198  FBSTRING_ASSERT(n >= 0);
2199 
2200  auto oldSize = size();
2201  store_.expandNoinit(n, /* expGrowth = */ true);
2202  auto b = begin();
2203  fbstring_detail::podMove(b + pos, b + oldSize, b + pos + n);
2204  std::copy(s1, s2, b + pos);
2205 
2206  return b + pos;
2207 }
size_type size() const
Definition: FBString.h:1337
void podMove(const Pod *b, const Pod *e, Pod *d)
Definition: FBString.h:188
char b
constexpr std::decay< T >::type copy(T &&value) noexcept(noexcept(typename std::decay< T >::type(std::forward< T >(value))))
Definition: Utility.h:72
A::size_type size_type
Definition: FBString.h:1103
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
const_iterator cend() const
Definition: FBString.h:1285
const_iterator cbegin() const
Definition: FBString.h:1273
template<typename E , class T , class A , class S >
template<class InputIterator >
basic_fbstring< E, T, A, S >::iterator folly::basic_fbstring< E, T, A, S >::insertImpl ( const_iterator  i,
InputIterator  b,
InputIterator  e,
std::input_iterator_tag   
)
inlineprivate

Definition at line 2212 of file FBString.h.

References folly::basic_fbstring< E, T, A, Storage >::append(), b, folly::test::begin(), folly::padded::cbegin(), folly::padded::cend(), folly::basic_fbstring< E, T, A, Storage >::push_back(), folly::swap(), and shell_builder::temp.

2216  {
2217  const auto pos = i - cbegin();
2219  for (; b != e; ++b) {
2220  temp.push_back(*b);
2221  }
2222  temp.append(i, cend());
2223  swap(temp);
2224  return begin() + pos;
2225 }
basic_fbstring() noexcept
Definition: FBString.h:1143
char b
void swap(basic_fbstring &rhs)
Definition: FBString.h:1708
const_iterator cend() const
Definition: FBString.h:1285
const_iterator cbegin() const
Definition: FBString.h:1273
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S >::iterator folly::basic_fbstring< E, T, A, S >::insertImplDiscr ( const_iterator  i,
size_type  n,
value_type  c,
std::true_type   
)
inlineprivate

Definition at line 2154 of file FBString.h.

References b, folly::test::begin(), folly::padded::cbegin(), folly::padded::cend(), FBSTRING_ASSERT, folly::fbstring_detail::podFill(), folly::fbstring_detail::podMove(), and folly::size().

2158  {
2159  Invariant checker(*this);
2160 
2161  FBSTRING_ASSERT(i >= cbegin() && i <= cend());
2162  const size_type pos = i - cbegin();
2163 
2164  auto oldSize = size();
2165  store_.expandNoinit(n, /* expGrowth = */ true);
2166  auto b = begin();
2167  fbstring_detail::podMove(b + pos, b + oldSize, b + pos + n);
2168  fbstring_detail::podFill(b + pos, b + pos + n, c);
2169 
2170  return b + pos;
2171 }
size_type size() const
Definition: FBString.h:1337
void podMove(const Pod *b, const Pod *e, Pod *d)
Definition: FBString.h:188
char b
A::size_type size_type
Definition: FBString.h:1103
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
const_iterator cend() const
Definition: FBString.h:1285
void podFill(Pod *b, Pod *e, T c)
Definition: FBString.h:141
const_iterator cbegin() const
Definition: FBString.h:1273
char c
template<typename E , class T , class A , class S >
template<class InputIter >
basic_fbstring< E, T, A, S >::iterator folly::basic_fbstring< E, T, A, S >::insertImplDiscr ( const_iterator  i,
InputIter  b,
InputIter  e,
std::false_type   
)
inlineprivate

Definition at line 2176 of file FBString.h.

2180  {
2181  return insertImpl(
2182  i, b, e, typename std::iterator_traits<InputIter>::iterator_category());
2183 }
char b
iterator insertImpl(const_iterator i, FwdIterator s1, FwdIterator s2, std::forward_iterator_tag)
Definition: FBString.h:2188
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
bool folly::basic_fbstring< E, T, A, Storage >::isSane ( ) const
inlineprivate

Definition at line 1078 of file FBString.h.

1078  {
1079  return begin() <= end() && empty() == (size() == 0) &&
1080  empty() == (begin() == end()) && size() <= max_size() &&
1081  capacity() <= max_size() && size() <= capacity() &&
1082  begin()[size()] == '\0';
1083  }
size_type size() const
Definition: FBString.h:1337
bool empty() const
Definition: FBString.h:1372
size_type max_size() const
Definition: FBString.h:1345
size_type capacity() const
Definition: FBString.h:1351
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::length ( ) const
inline
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::max_size ( ) const
inline

Definition at line 1345 of file FBString.h.

Referenced by folly::operator>>().

1345  {
1347  }
LogLevel max
Definition: LogLevel.cpp:31
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::operator+= ( const basic_fbstring< E, T, A, Storage > &  str)
inline

Definition at line 1396 of file FBString.h.

1396  {
1397  return append(str);
1398  }
basic_fbstring & append(const basic_fbstring &str)
Definition: FBString.h:1953
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::operator+= ( const value_type s)
inline

Definition at line 1400 of file FBString.h.

1400  {
1401  return append(s);
1402  }
static set< string > s
basic_fbstring & append(const basic_fbstring &str)
Definition: FBString.h:1953
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::operator+= ( const value_type  c)
inline

Definition at line 1404 of file FBString.h.

1404  {
1405  push_back(c);
1406  return *this;
1407  }
void push_back(const value_type c)
Definition: FBString.h:1437
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::operator+= ( std::initializer_list< value_type il)
inline

Definition at line 1409 of file FBString.h.

1409  {
1410  append(il);
1411  return *this;
1412  }
basic_fbstring & append(const basic_fbstring &str)
Definition: FBString.h:1953
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S > & folly::basic_fbstring< E, T, A, S >::operator= ( const basic_fbstring< E, T, A, Storage > &  lhs)
inline

Definition at line 1886 of file FBString.h.

References folly::basic_fbstring< E, T, A, Storage >::data(), FBSTRING_UNLIKELY, and folly::basic_fbstring< E, T, A, Storage >::size().

1887  {
1888  Invariant checker(*this);
1889 
1890  if (FBSTRING_UNLIKELY(&lhs == this)) {
1891  return *this;
1892  }
1893 
1894  return assign(lhs.data(), lhs.size());
1895 }
#define FBSTRING_UNLIKELY(x)
Definition: FBString.h:75
basic_fbstring & assign(const basic_fbstring &str)
Definition: FBString.h:1441
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S > & folly::basic_fbstring< E, T, A, S >::operator= ( basic_fbstring< E, T, A, Storage > &&  goner)
inlinenoexcept

Definition at line 1899 of file FBString.h.

References FBSTRING_UNLIKELY, folly::gen::move, type, and value.

1900  {
1901  if (FBSTRING_UNLIKELY(&goner == this)) {
1902  // Compatibility with std::basic_string<>,
1903  // C++11 21.4.2 [string.cons] / 23 requires self-move-assignment support.
1904  return *this;
1905  }
1906  // No need of this anymore
1907  this->~basic_fbstring();
1908  // Move the goner into this
1909  new (&store_) S(std::move(goner.store_));
1910  return *this;
1911 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define FBSTRING_UNLIKELY(x)
Definition: FBString.h:75
~basic_fbstring() noexcept
Definition: FBString.h:1212
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
template<typename A2 >
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::operator= ( const std::basic_string< E, T, A2 > &  rhs)
inline

Definition at line 1222 of file FBString.h.

1222  {
1223  return assign(rhs.data(), rhs.size());
1224  }
basic_fbstring & assign(const basic_fbstring &str)
Definition: FBString.h:1441
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::operator= ( const value_type s)
inline

Definition at line 1237 of file FBString.h.

1237  {
1238  return assign(s);
1239  }
basic_fbstring & assign(const basic_fbstring &str)
Definition: FBString.h:1441
static set< string > s
template<typename E, class T, class A , class S >
template<typename TP >
std::enable_if< std::is_same< typename std::decay< TP >::type, typename folly::basic_fbstring< E, T, A, S >::value_type >::value, basic_fbstring< E, T, A, S > & >::type folly::basic_fbstring< E, T, A, S >::operator= ( TP  c)
inline

Definition at line 1920 of file FBString.h.

References c, folly::empty(), folly::size(), and folly::basic_fbstring< E, T, A, Storage >::swap().

1920  {
1921  Invariant checker(*this);
1922 
1923  if (empty()) {
1924  store_.expandNoinit(1);
1925  } else if (store_.isShared()) {
1926  basic_fbstring(1, c).swap(*this);
1927  return *this;
1928  } else {
1929  store_.shrink(size() - 1);
1930  }
1931  front() = c;
1932  return *this;
1933 }
size_type size() const
Definition: FBString.h:1337
basic_fbstring() noexcept
Definition: FBString.h:1143
bool empty() const
Definition: FBString.h:1372
const value_type & front() const
Definition: FBString.h:1315
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::operator= ( std::initializer_list< value_type il)
inline

Definition at line 1260 of file FBString.h.

1260  {
1261  return assign(il.begin(), il.end());
1262  }
basic_fbstring & assign(const basic_fbstring &str)
Definition: FBString.h:1441
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const_reference folly::basic_fbstring< E, T, A, Storage >::operator[] ( size_type  pos) const
inline

Definition at line 1377 of file FBString.h.

1377  {
1378  return *(begin() + pos);
1379  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
reference folly::basic_fbstring< E, T, A, Storage >::operator[] ( size_type  pos)
inline

Definition at line 1381 of file FBString.h.

1381  {
1382  return *(begin() + pos);
1383  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
void folly::basic_fbstring< E, T, A, Storage >::pop_back ( )
inline

Definition at line 1331 of file FBString.h.

1331  {
1332  FBSTRING_ASSERT(!empty());
1333  store_.shrink(1);
1334  }
bool empty() const
Definition: FBString.h:1372
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
static void folly::basic_fbstring< E, T, A, Storage >::procrustes ( size_type n,
size_type  nmax 
)
inlinestaticprivate

Definition at line 1120 of file FBString.h.

1120  {
1121  if (n > nmax) {
1122  n = nmax;
1123  }
1124  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
void folly::basic_fbstring< E, T, A, Storage >::push_back ( const value_type  c)
inline
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
reverse_iterator folly::basic_fbstring< E, T, A, Storage >::rbegin ( )
inline

Definition at line 1289 of file FBString.h.

1289  {
1290  return reverse_iterator(end());
1291  }
std::reverse_iterator< iterator > reverse_iterator
Definition: FBString.h:1113
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const_reverse_iterator folly::basic_fbstring< E, T, A, Storage >::rbegin ( ) const
inline

Definition at line 1293 of file FBString.h.

1293  {
1294  return const_reverse_iterator(end());
1295  }
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: FBString.h:1114
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
reverse_iterator folly::basic_fbstring< E, T, A, Storage >::rend ( )
inline

Definition at line 1301 of file FBString.h.

1301  {
1302  return reverse_iterator(begin());
1303  }
std::reverse_iterator< iterator > reverse_iterator
Definition: FBString.h:1113
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
const_reverse_iterator folly::basic_fbstring< E, T, A, Storage >::rend ( ) const
inline

Definition at line 1305 of file FBString.h.

1305  {
1306  return const_reverse_iterator(begin());
1307  }
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition: FBString.h:1114
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::replace ( size_type  pos1,
size_type  n1,
const basic_fbstring< E, T, A, Storage > &  str 
)
inline

Definition at line 1581 of file FBString.h.

Referenced by TEST().

1581  {
1582  return replace(pos1, n1, str.data(), str.size());
1583  }
basic_fbstring & replace(size_type pos1, size_type n1, const basic_fbstring &str)
Definition: FBString.h:1581
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::replace ( size_type  pos1,
size_type  n1,
const basic_fbstring< E, T, A, Storage > &  str,
size_type  pos2,
size_type  n2 
)
inline

Definition at line 1587 of file FBString.h.

1592  {
1593  enforce<std::out_of_range>(pos2 <= str.length(), "");
1594  return replace(
1595  pos1, n1, str.data() + pos2, std::min(n2, str.size() - pos2));
1596  }
LogLevel min
Definition: LogLevel.cpp:30
basic_fbstring & replace(size_type pos1, size_type n1, const basic_fbstring &str)
Definition: FBString.h:1581
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::replace ( size_type  pos,
size_type  n1,
const value_type s 
)
inline

Definition at line 1599 of file FBString.h.

1599  {
1600  return replace(pos, n1, s, traitsLength(s));
1601  }
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
static set< string > s
basic_fbstring & replace(size_type pos1, size_type n1, const basic_fbstring &str)
Definition: FBString.h:1581
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
template<class StrOrLength , class NumOrChar >
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::replace ( size_type  pos,
size_type  n1,
StrOrLength  s_or_n2,
NumOrChar  n_or_c 
)
inline

Definition at line 1612 of file FBString.h.

1612  {
1613  Invariant checker(*this);
1614 
1615  enforce<std::out_of_range>(pos <= size(), "");
1616  procrustes(n1, length() - pos);
1617  const iterator b = begin() + pos;
1618  return replace(b, b + n1, s_or_n2, n_or_c);
1619  }
size_type size() const
Definition: FBString.h:1337
char b
basic_fbstring & replace(size_type pos1, size_type n1, const basic_fbstring &str)
Definition: FBString.h:1581
static void procrustes(size_type &n, size_type nmax)
Definition: FBString.h:1120
size_type length() const
Definition: FBString.h:1341
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::replace ( iterator  i1,
iterator  i2,
const basic_fbstring< E, T, A, Storage > &  str 
)
inline

Definition at line 1621 of file FBString.h.

1621  {
1622  return replace(i1, i2, str.data(), str.length());
1623  }
basic_fbstring & replace(size_type pos1, size_type n1, const basic_fbstring &str)
Definition: FBString.h:1581
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::replace ( iterator  i1,
iterator  i2,
const value_type s 
)
inline

Definition at line 1625 of file FBString.h.

1625  {
1626  return replace(i1, i2, s, traitsLength(s));
1627  }
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
static set< string > s
basic_fbstring & replace(size_type pos1, size_type n1, const basic_fbstring &str)
Definition: FBString.h:1581
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
template<class T1 , class T2 >
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::replace ( iterator  i1,
iterator  i2,
T1  first_or_n_or_s,
T2  last_or_c_or_n 
)
inline

Definition at line 1690 of file FBString.h.

1690  {
1691  constexpr bool num1 = std::numeric_limits<T1>::is_specialized,
1692  num2 = std::numeric_limits<T2>::is_specialized;
1693  using Sel =
1694  std::integral_constant<int, num1 ? (num2 ? 1 : -1) : (num2 ? 2 : 0)>;
1695  return replaceImplDiscr(i1, i2, first_or_n_or_s, last_or_c_or_n, Sel());
1696  }
basic_fbstring & replaceImplDiscr(iterator i1, iterator i2, const value_type *s, size_type n, std::integral_constant< int, 2 >)
Definition: FBString.h:2228
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
template<class FwdIterator >
bool folly::basic_fbstring< E, T, A, Storage >::replaceAliased ( iterator  ,
iterator  ,
FwdIterator  ,
FwdIterator  ,
std::false_type   
)
inlineprivate

Definition at line 1654 of file FBString.h.

1659  {
1660  return false;
1661  }
template<typename E , class T , class A , class S >
template<class FwdIterator >
bool folly::basic_fbstring< E, T, A, S >::replaceAliased ( iterator  i1,
iterator  i2,
FwdIterator  s1,
FwdIterator  s2,
std::true_type   
)
inlineprivate

Definition at line 2274 of file FBString.h.

References folly::basic_fbstring< E, T, A, Storage >::append(), folly::test::begin(), folly::test::end(), folly::basic_fbstring< E, T, A, Storage >::reserve(), folly::size(), folly::swap(), and shell_builder::temp.

2279  {
2280  std::less_equal<const value_type*> le{};
2281  const bool aliased = le(&*begin(), &*s1) && le(&*s1, &*end());
2282  if (!aliased) {
2283  return false;
2284  }
2285  // Aliased replace, copy to new string
2287  temp.reserve(size() - (i2 - i1) + std::distance(s1, s2));
2288  temp.append(begin(), i1).append(s1, s2).append(i2, end());
2289  swap(temp);
2290  return true;
2291 }
size_type size() const
Definition: FBString.h:1337
basic_fbstring() noexcept
Definition: FBString.h:1143
void swap(basic_fbstring &rhs)
Definition: FBString.h:1708
template<typename E , class T , class A , class S >
template<class FwdIterator >
void folly::basic_fbstring< E, T, A, S >::replaceImpl ( iterator  i1,
iterator  i2,
FwdIterator  s1,
FwdIterator  s2,
std::forward_iterator_tag   
)
inlineprivate

Definition at line 2295 of file FBString.h.

References folly::copy(), folly::fbstring_detail::copy_n(), FBSTRING_ASSERT, isSane(), and value.

2300  {
2301  Invariant checker(*this);
2302 
2303  // Handle aliased replace
2304  using Sel = bool_constant<
2307  if (replaceAliased(i1, i2, s1, s2, Sel())) {
2308  return;
2309  }
2310 
2311  auto const n1 = i2 - i1;
2312  FBSTRING_ASSERT(n1 >= 0);
2313  auto const n2 = std::distance(s1, s2);
2314  FBSTRING_ASSERT(n2 >= 0);
2315 
2316  if (n1 > n2) {
2317  // shrinks
2318  std::copy(s1, s2, i1);
2319  erase(i1 + n2, i2);
2320  } else {
2321  // grows
2322  s1 = fbstring_detail::copy_n(s1, n1, i1).first;
2323  insert(i2, s1, s2);
2324  }
2326 }
basic_fbstring & erase(size_type pos=0, size_type n=npos)
Definition: FBString.h:1555
constexpr std::decay< T >::type copy(T &&value) noexcept(noexcept(typename std::decay< T >::type(std::forward< T >(value))))
Definition: Utility.h:72
bool replaceAliased(iterator, iterator, FwdIterator, FwdIterator, std::false_type)
Definition: FBString.h:1654
std::integral_constant< bool, B > bool_constant
Definition: Traits.h:145
basic_fbstring & insert(size_type pos1, const basic_fbstring &str)
Definition: FBString.h:1470
static const char *const value
Definition: Conv.cpp:50
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
std::pair< InIt, OutIt > copy_n(InIt b, typename std::iterator_traits< InIt >::difference_type n, OutIt d)
Definition: FBString.h:130
bool isSane() const
Definition: FBString.h:1078
template<typename E , class T , class A , class S >
template<class InputIterator >
void folly::basic_fbstring< E, T, A, S >::replaceImpl ( iterator  i1,
iterator  i2,
InputIterator  b,
InputIterator  e,
std::input_iterator_tag   
)
inlineprivate

Definition at line 2330 of file FBString.h.

References folly::basic_fbstring< E, T, A, Storage >::append(), folly::test::begin(), folly::test::end(), folly::swap(), and shell_builder::temp.

2335  {
2336  basic_fbstring temp(begin(), i1);
2337  temp.append(b, e).append(i2, end());
2338  swap(temp);
2339 }
basic_fbstring() noexcept
Definition: FBString.h:1143
char b
void swap(basic_fbstring &rhs)
Definition: FBString.h:1708
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S > & folly::basic_fbstring< E, T, A, S >::replaceImplDiscr ( iterator  i1,
iterator  i2,
const value_type s,
size_type  n,
std::integral_constant< int, 2 >   
)
inlineprivate

Definition at line 2228 of file FBString.h.

References folly::test::begin(), folly::test::end(), FBSTRING_ASSERT, and replace().

2233  {
2234  FBSTRING_ASSERT(i1 <= i2);
2235  FBSTRING_ASSERT(begin() <= i1 && i1 <= end());
2236  FBSTRING_ASSERT(begin() <= i2 && i2 <= end());
2237  return replace(i1, i2, s, s + n);
2238 }
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
static set< string > s
basic_fbstring & replace(size_type pos1, size_type n1, const basic_fbstring &str)
Definition: FBString.h:1581
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S > & folly::basic_fbstring< E, T, A, S >::replaceImplDiscr ( iterator  i1,
iterator  i2,
size_type  n2,
value_type  c,
std::integral_constant< int, 1 >   
)
inlineprivate

Definition at line 2241 of file FBString.h.

References FBSTRING_ASSERT, and isSane().

2246  {
2247  const size_type n1 = i2 - i1;
2248  if (n1 > n2) {
2249  std::fill(i1, i1 + n2, c);
2250  erase(i1 + n2, i2);
2251  } else {
2252  std::fill(i1, i2, c);
2253  insert(i2, n2 - n1, c);
2254  }
2256  return *this;
2257 }
basic_fbstring & erase(size_type pos=0, size_type n=npos)
Definition: FBString.h:1555
A::size_type size_type
Definition: FBString.h:1103
basic_fbstring & insert(size_type pos1, const basic_fbstring &str)
Definition: FBString.h:1470
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
bool isSane() const
Definition: FBString.h:1078
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
template<class InputIter >
basic_fbstring& folly::basic_fbstring< E, T, A, Storage >::replaceImplDiscr ( iterator  i1,
iterator  i2,
InputIter  b,
InputIter  e,
std::integral_constant< int, 0 >   
)
private
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
template<class InputIter >
basic_fbstring<E, T, A, S>& folly::basic_fbstring< E, T, A, Storage >::replaceImplDiscr ( iterator  i1,
iterator  i2,
InputIter  b,
InputIter  e,
std::integral_constant< int, 0 >   
)
inline

Definition at line 2261 of file FBString.h.

2266  {
2267  using Cat = typename std::iterator_traits<InputIter>::iterator_category;
2268  replaceImpl(i1, i2, b, e, Cat());
2269  return *this;
2270 }
char b
void replaceImpl(iterator i1, iterator i2, FwdIterator s1, FwdIterator s2, std::forward_iterator_tag)
Definition: FBString.h:2295
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
void folly::basic_fbstring< E, T, A, Storage >::reserve ( size_type  res_arg = 0)
inline

Definition at line 1355 of file FBString.h.

Referenced by BENCHMARK(), folly::operator+(), folly::basic_fbstring< E, T, A, Storage >::replaceAliased(), folly::test::TEST(), and TEST().

1355  {
1356  enforce<std::length_error>(res_arg <= max_size(), "");
1357  store_.reserve(res_arg);
1358  }
size_type max_size() const
Definition: FBString.h:1345
template<typename E , class T , class A , class S >
void folly::basic_fbstring< E, T, A, S >::resize ( size_type  n,
value_type  c = value_type() 
)
inline

Definition at line 1936 of file FBString.h.

References FBSTRING_ASSERT, folly::fbstring_detail::podFill(), and folly::size().

Referenced by BENCHMARK().

1938  {
1939  Invariant checker(*this);
1940 
1941  auto size = this->size();
1942  if (n <= size) {
1943  store_.shrink(size - n);
1944  } else {
1945  auto const delta = n - size;
1946  auto pData = store_.expandNoinit(delta);
1947  fbstring_detail::podFill(pData, pData + delta, c);
1948  }
1949  FBSTRING_ASSERT(this->size() == n);
1950 }
size_type size() const
Definition: FBString.h:1337
#define FBSTRING_ASSERT(expr)
Definition: FBString.h:64
void podFill(Pod *b, Pod *e, T c)
Definition: FBString.h:141
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::rfind ( const basic_fbstring< E, T, A, Storage > &  str,
size_type  pos = npos 
) const
inline

Definition at line 1739 of file FBString.h.

1739  {
1740  return rfind(str.data(), pos, str.length());
1741  }
size_type rfind(const basic_fbstring &str, size_type pos=npos) const
Definition: FBString.h:1739
template<typename E , class T , class A , class S >
basic_fbstring< E, T, A, S >::size_type folly::basic_fbstring< E, T, A, S >::rfind ( const value_type s,
size_type  pos,
size_type  n 
) const
inline

Definition at line 2343 of file FBString.h.

References folly::test::begin(), i, and min.

2346  {
2347  if (n > length()) {
2348  return npos;
2349  }
2350  pos = std::min(pos, length() - n);
2351  if (n == 0) {
2352  return pos;
2353  }
2354 
2355  const_iterator i(begin() + pos);
2356  for (;; --i) {
2357  if (traits_type::eq(*i, *s) && traits_type::compare(&*i, s, n) == 0) {
2358  return i - begin();
2359  }
2360  if (i == begin()) {
2361  break;
2362  }
2363  }
2364  return npos;
2365 }
LogLevel min
Definition: LogLevel.cpp:30
static set< string > s
static constexpr size_type npos
Definition: FBString.h:1116
const E * const_iterator
Definition: FBString.h:1112
size_type length() const
Definition: FBString.h:1341
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::rfind ( const value_type s,
size_type  pos = npos 
) const
inline

Definition at line 1745 of file FBString.h.

1745  {
1746  return rfind(s, pos, traitsLength(s));
1747  }
static size_type traitsLength(const value_type *s)
Definition: FBString.h:1878
size_type rfind(const basic_fbstring &str, size_type pos=npos) const
Definition: FBString.h:1739
static set< string > s
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
size_type folly::basic_fbstring< E, T, A, Storage >::rfind ( value_type  c,
size_type  pos = npos 
) const
inline

Definition at line 1749 of file FBString.h.

1749  {
1750  return rfind(&c, pos, 1);
1751  }
size_type rfind(const basic_fbstring &str, size_type pos=npos) const
Definition: FBString.h:1739
char c
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
void folly::basic_fbstring< E, T, A, Storage >::shrink_to_fit ( )
inline

Definition at line 1360 of file FBString.h.

1360  {
1361  // Shrink only if slack memory is sufficiently large
1362  if (capacity() < size() * 3 / 2) {
1363  return;
1364  }
1365  basic_fbstring(cbegin(), cend()).swap(*this);
1366  }
size_type size() const
Definition: FBString.h:1337
basic_fbstring() noexcept
Definition: FBString.h:1143
size_type capacity() const
Definition: FBString.h:1351
const_iterator cend() const
Definition: FBString.h:1285
const_iterator cbegin() const
Definition: FBString.h:1273
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring folly::basic_fbstring< E, T, A, Storage >::substr ( size_type  pos = 0,
size_type  n = npos 
) const
inline

Definition at line 1815 of file FBString.h.

1815  {
1816  enforce<std::out_of_range>(pos <= size(), "");
1817  return basic_fbstring(data() + pos, std::min(n, size() - pos));
1818  }
size_type size() const
Definition: FBString.h:1337
basic_fbstring() noexcept
Definition: FBString.h:1143
const value_type * data() const
Definition: FBString.h:1716
LogLevel min
Definition: LogLevel.cpp:30
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
basic_fbstring folly::basic_fbstring< E, T, A, Storage >::substr ( size_type  pos = 0,
size_type  n = npos 
)
inline

Definition at line 1820 of file FBString.h.

1820  {
1821  enforce<std::out_of_range>(pos <= size(), "");
1822  erase(0, pos);
1823  if (n < size()) {
1824  resize(n);
1825  }
1826  return std::move(*this);
1827  }
size_type size() const
Definition: FBString.h:1337
basic_fbstring & erase(size_type pos=0, size_type n=npos)
Definition: FBString.h:1555
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void resize(size_type n, value_type c=value_type())
Definition: FBString.h:1936
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
void folly::basic_fbstring< E, T, A, Storage >::swap ( basic_fbstring< E, T, A, Storage > &  rhs)
inline

Definition at line 1708 of file FBString.h.

Referenced by folly::basic_fbstring< E, T, A, Storage >::operator=(), folly::basic_fbstring< char >::shrink_to_fit(), and folly::swap().

1708  {
1709  store_.swap(rhs.store_);
1710  }
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
template<typename E , class T , class A , class S >
FOLLY_MALLOC_NOINLINE basic_fbstring< E, T, A, S >::size_type folly::basic_fbstring< E, T, A, S >::traitsLength ( const value_type s)
inlinestaticprivate

Definition at line 1878 of file FBString.h.

1878  {
1879  return s ? traits_type::length(s)
1880  : (throw_exception<std::logic_error>(
1881  "basic_fbstring: null pointer initializer not valid"),
1882  0);
1883 }
STL namespace.
static set< string > s
FOLLY_NOINLINE FOLLY_COLD void throw_exception(Ex &&ex)
Definition: Exception.h:32

Friends And Related Function Documentation

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
istream_type& getline ( istream_type is,
basic_fbstring< E, T, A, Storage > &  str,
value_type  delim 
)
friend

Definition at line 1513 of file FBString.h.

1513  {
1514  return str.getlineImpl(is, delim);
1515  }
template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
istream_type& getline ( istream_type is,
basic_fbstring< E, T, A, Storage > &  str 
)
friend

Definition at line 1517 of file FBString.h.

1517  {
1518  return getline(is, str, '\n');
1519  }
friend istream_type & getline(istream_type &is, basic_fbstring &str, value_type delim)
Definition: FBString.h:1513

Member Data Documentation

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
constexpr basic_fbstring< E1, T, A, S >::size_type folly::basic_fbstring< E1, T, A, S >::npos = size_type(-1)
static

Definition at line 1116 of file FBString.h.

template<typename E, class T = std::char_traits<E>, class A = std::allocator<E>, class Storage = fbstring_core<E>>
Storage folly::basic_fbstring< E, T, A, Storage >::store_
private

Definition at line 1873 of file FBString.h.

Referenced by folly::basic_fbstring< char >::swap().


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