proxygen
folly::Range< Iter > Class Template Reference

#include <ScopedEventBaseThread.h>

Public Types

typedef std::size_t size_type
 
typedef Iter iterator
 
typedef Iter const_iterator
 
typedef std::remove_reference< typename std::iterator_traits< Iter >::reference >::type value_type
 
using difference_type = typename std::iterator_traits< Iter >::difference_type
 
typedef std::iterator_traits< Iter >::reference reference
 
typedef std::conditional< std::is_same< Iter, char * >::value||std::is_same< Iter, unsigned char * >::value, Range< const value_type * >, Range< Iter > >::type const_range_type
 
typedef std::char_traits< typename std::remove_const< value_type >::typetraits_type
 

Public Member Functions

constexpr Range ()
 
constexpr Range (const Range &)=default
 
constexpr Range (Range &&)=default
 
constexpr Range (Iter start, Iter end)
 
constexpr Range (Iter start, size_t size)
 
 Range (std::nullptr_t)=delete
 
constexpr Range (Iter str)
 
template<class T = Iter, typename detail::IsCharPointer< T >::const_type = 0>
 Range (const std::string &str)
 
template<class T = Iter, typename detail::IsCharPointer< T >::const_type = 0>
 Range (const std::string &str, std::string::size_type startFrom)
 
template<class T = Iter, typename detail::IsCharPointer< T >::const_type = 0>
 Range (const std::string &str, std::string::size_type startFrom, std::string::size_type size)
 
 Range (const Range &other, size_type first, size_type length=npos)
 
template<class Container , class = typename std::enable_if< std::is_same<Iter, typename Container::const_pointer>::value>::type, class = decltype( Iter(std::declval<Container const&>().data()), Iter( std::declval<Container const&>().data() + std::declval<Container const&>().size()))>
constexpr Range (Container const &container)
 
template<class Container , class = typename std::enable_if< std::is_same<Iter, typename Container::const_pointer>::value>::type, class = decltype( Iter(std::declval<Container const&>().data()), Iter( std::declval<Container const&>().data() + std::declval<Container const&>().size()))>
 Range (Container const &container, typename Container::size_type startFrom)
 
template<class Container , class = typename std::enable_if< std::is_same<Iter, typename Container::const_pointer>::value>::type, class = decltype( Iter(std::declval<Container const&>().data()), Iter( std::declval<Container const&>().data() + std::declval<Container const&>().size()))>
 Range (Container const &container, typename Container::size_type startFrom, typename Container::size_type size)
 
template<class OtherIter , typename std::enable_if< (std::is_same< Iter, const unsigned char * >::value &&(std::is_same< OtherIter, const char * >::value||std::is_same< OtherIter, char * >::value)), int >::type = 0>
 Range (const Range< OtherIter > &other)
 
template<class OtherIter , typename std::enable_if< (std::is_same< Iter, unsigned char * >::value &&std::is_same< OtherIter, char * >::value), int >::type = 0>
 Range (const Range< OtherIter > &other)
 
template<class OtherIter , typename std::enable_if< (std::is_same< Iter, const char * >::value &&(std::is_same< OtherIter, const unsigned char * >::value||std::is_same< OtherIter, unsigned char * >::value)), int >::type = 0>
 Range (const Range< OtherIter > &other)
 
template<class OtherIter , typename std::enable_if< (std::is_same< Iter, char * >::value &&std::is_same< OtherIter, unsigned char * >::value), int >::type = 0>
 Range (const Range< OtherIter > &other)
 
template<class OtherIter , typename std::enable_if< (!std::is_same< Iter, OtherIter >::value &&std::is_convertible< OtherIter, Iter >::value), int >::type = 0>
constexpr Range (const Range< OtherIter > &other)
 
template<class OtherIter , typename std::enable_if< (!std::is_same< Iter, OtherIter >::value &&!std::is_convertible< OtherIter, Iter >::value &&std::is_constructible< Iter, const OtherIter & >::value), int >::type = 0>
constexpr Range (const Range< OtherIter > &other)
 
template<class T , size_t N, typename = typename std::enable_if< std::is_convertible<const T*, Iter>::value>::type>
constexpr Range (const std::array< T, N > &array)
 
template<class T , size_t N, typename = typename std::enable_if<std::is_convertible<T*, Iter>::value>::type>
constexpr Range (std::array< T, N > &array)
 
Rangeoperator= (const Range &rhs)&=default
 
Rangeoperator= (Range &&rhs)&=default
 
template<class T = Iter, typename detail::IsCharPointer< T >::const_type = 0>
Rangeoperator= (std::string &&rhs)=delete
 
void clear ()
 
void assign (Iter start, Iter end)
 
void reset (Iter start, size_type size)
 
void reset (const std::string &str)
 
constexpr size_type size () const
 
constexpr size_type walk_size () const
 
constexpr bool empty () const
 
constexpr Iter data () const
 
constexpr Iter start () const
 
constexpr Iter begin () const
 
constexpr Iter end () const
 
constexpr Iter cbegin () const
 
constexpr Iter cend () const
 
value_typefront ()
 
value_typeback ()
 
const value_typefront () const
 
const value_typeback () const
 
template<typename Tgt , std::enable_if_t< std::is_constructible< Tgt, Iter const &, size_type >::value &&!IsConstructibleViaStringView< Tgt >::value, int > = 0>
constexpr operator Tgt () const noexcept(std::is_nothrow_constructible< Tgt, Iter const &, size_type >::value)
 
template<typename Tgt , std::enable_if_t< !std::is_constructible< Tgt, Iter const &, size_type >::value &&std::is_constructible< Tgt, Iter const &, Iter const & >::value &&!IsConstructibleViaStringView< Tgt >::value, int > = 0>
constexpr operator Tgt () const noexcept(std::is_nothrow_constructible< Tgt, Iter const &, Iter const & >::value)
 
template<typename Tgt , typename... Args>
constexpr std::enable_if_t< std::is_constructible< Tgt, Iter const &, size_type >::value, Tgt > to (Args &&...args) const noexcept(std::is_nothrow_constructible< Tgt, Iter const &, size_type, Args &&... >::value)
 
template<typename Tgt , typename... Args>
constexpr std::enable_if_t< !std::is_constructible< Tgt, Iter const &, size_type >::value &&std::is_constructible< Tgt, Iter const &, Iter const & >::value, Tgt > to (Args &&...args) const noexcept(std::is_nothrow_constructible< Tgt, Iter const &, Iter const &, Args &&... >::value)
 
std::string str () const
 
std::string toString () const
 
const_range_type castToConst () const
 
int compare (const const_range_type &o) const
 
value_typeoperator[] (size_t i)
 
const value_typeoperator[] (size_t i) const
 
value_typeat (size_t i)
 
const value_typeat (size_t i) const
 
uint32_t hash () const
 
void advance (size_type n)
 
void subtract (size_type n)
 
Range subpiece (size_type first, size_type length=npos) const
 
void uncheckedAdvance (size_type n)
 
void uncheckedSubtract (size_type n)
 
Range uncheckedSubpiece (size_type first, size_type length=npos) const
 
void pop_front ()
 
void pop_back ()
 
size_type find (const_range_type str) const
 
size_type find (const_range_type str, size_t pos) const
 
size_type find (Iter s, size_t pos, size_t n) const
 
size_type find (const Iter s) const
 
size_type find (const Iter s, size_t pos) const
 
size_type find (value_type c) const
 
size_type rfind (value_type c) const
 
size_type find (value_type c, size_t pos) const
 
size_type find_first_of (const_range_type needles) const
 
size_type find_first_of (const_range_type needles, size_t pos) const
 
size_type find_first_of (Iter needles) const
 
size_type find_first_of (Iter needles, size_t pos) const
 
size_type find_first_of (Iter needles, size_t pos, size_t n) const
 
size_type find_first_of (value_type c) const
 
size_type find_first_of (value_type c, size_t pos) const
 
bool contains (const const_range_type &other) const
 
bool contains (const value_type &other) const
 
void swap (Range &rhs)
 
bool startsWith (const const_range_type &other) const
 
bool startsWith (value_type c) const
 
template<class Comp >
bool startsWith (const const_range_type &other, Comp &&eq) const
 
bool endsWith (const const_range_type &other) const
 
bool endsWith (value_type c) const
 
template<class Comp >
bool endsWith (const const_range_type &other, Comp &&eq) const
 
template<class Comp >
bool equals (const const_range_type &other, Comp &&eq) const
 
void erase (Iter b, Iter e)
 
bool removePrefix (const const_range_type &prefix)
 
bool removePrefix (value_type prefix)
 
bool removeSuffix (const const_range_type &suffix)
 
bool removeSuffix (value_type suffix)
 
bool replaceAt (size_t pos, const_range_type replacement)
 
size_t replaceAll (const_range_type source, const_range_type dest)
 
Range split_step (value_type delimiter)
 
Range split_step (Range delimiter)
 
template<typename TProcess , typename... Args>
auto split_step (value_type delimiter, TProcess &&process, Args &&...args) -> decltype(process(std::declval< Range >(), std::forward< Args >(args)...))
 
template<typename TProcess , typename... Args>
auto split_step (Range delimiter, TProcess &&process, Args &&...args) -> decltype(process(std::declval< Range >(), std::forward< Args >(args)...))
 

Static Public Attributes

static const size_type npos = std::string::npos
 

Private Types

template<typename Target >
using IsConstructibleViaStringView = std::false_type
 

Private Attributes

Iter b_
 
Iter e_
 

Detailed Description

template<class Iter>
class folly::Range< Iter >

Range abstraction keeping a pair of iterators. We couldn't use boost's similar range abstraction because we need an API identical with the former StringPiece class, which is used by a lot of other code. This abstraction does fulfill the needs of boost's range-oriented algorithms though.

(Keep memory lifetime in mind when using this class, since it doesn't manage the data it refers to - just like an iterator wouldn't.)

Definition at line 29 of file ScopedEventBaseThread.h.

Member Typedef Documentation

template<class Iter>
typedef Iter folly::Range< Iter >::const_iterator

Definition at line 176 of file Range.h.

template<class Iter>
typedef std::conditional< std::is_same<Iter, char*>::value || std::is_same<Iter, unsigned char*>::value, Range<const value_type*>, Range<Iter> >::type folly::Range< Iter >::const_range_type

For MutableStringPiece and MutableByteRange we define StringPiece and ByteRange as const_range_type (for everything else its just identity). We do that to enable operations such as find with args which are const.

Definition at line 192 of file Range.h.

template<class Iter>
using folly::Range< Iter >::difference_type = typename std::iterator_traits<Iter>::difference_type

Definition at line 179 of file Range.h.

template<class Iter>
template<typename Target >
using folly::Range< Iter >::IsConstructibleViaStringView = std::false_type
private

Definition at line 508 of file Range.h.

template<class Iter>
typedef Iter folly::Range< Iter >::iterator

Definition at line 175 of file Range.h.

template<class Iter>
typedef std::iterator_traits<Iter>::reference folly::Range< Iter >::reference

Definition at line 180 of file Range.h.

template<class Iter>
typedef std::size_t folly::Range< Iter >::size_type

Definition at line 174 of file Range.h.

template<class Iter>
typedef std::char_traits<typename std::remove_const<value_type>::type> folly::Range< Iter >::traits_type

Definition at line 195 of file Range.h.

template<class Iter>
typedef std::remove_reference< typename std::iterator_traits<Iter>::reference>::type folly::Range< Iter >::value_type

Definition at line 178 of file Range.h.

Constructor & Destructor Documentation

template<class Iter>
constexpr folly::Range< Iter >::Range ( )
inline

Definition at line 200 of file Range.h.

200 : b_(), e_() {}
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
constexpr folly::Range< Iter >::Range ( const Range< Iter > &  )
default
template<class Iter>
constexpr folly::Range< Iter >::Range ( Range< Iter > &&  )
default
template<class Iter>
constexpr folly::Range< Iter >::Range ( Iter  start,
Iter  end 
)
inline

Definition at line 207 of file Range.h.

207 : b_(start), e_(end) {}
Iter e_
Definition: Range.h:1099
constexpr Iter start() const
Definition: Range.h:449
constexpr Iter end() const
Definition: Range.h:455
Iter b_
Definition: Range.h:1099
template<class Iter>
constexpr folly::Range< Iter >::Range ( Iter  start,
size_t  size 
)
inline

Definition at line 210 of file Range.h.

210 : b_(start), e_(start + size) {}
Iter e_
Definition: Range.h:1099
constexpr size_type size() const
Definition: Range.h:431
constexpr Iter start() const
Definition: Range.h:449
Iter b_
Definition: Range.h:1099
template<class Iter>
folly::Range< Iter >::Range ( std::nullptr_t  )
delete
template<class Iter>
constexpr folly::Range< Iter >::Range ( Iter  str)
inline

Definition at line 216 of file Range.h.

217  : b_(str), e_(str + constexpr_strlen(str)) {
218  static_assert(
219  std::is_same<int, typename detail::IsCharPointer<Iter>::type>::value,
220  "This constructor is only available for character ranges");
221  }
std::string str() const
Definition: Range.h:591
Iter e_
Definition: Range.h:1099
PskType type
constexpr size_t constexpr_strlen(const Char *s)
Definition: Constexpr.h:57
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class T = Iter, typename detail::IsCharPointer< T >::const_type = 0>
folly::Range< Iter >::Range ( const std::string str)
inline

Definition at line 224 of file Range.h.

225  : b_(str.data()), e_(b_ + str.size()) {}
std::string str() const
Definition: Range.h:591
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class T = Iter, typename detail::IsCharPointer< T >::const_type = 0>
folly::Range< Iter >::Range ( const std::string str,
std::string::size_type  startFrom 
)
inline

Definition at line 228 of file Range.h.

228  {
229  if (UNLIKELY(startFrom > str.size())) {
230  throw_exception<std::out_of_range>("index out of range");
231  }
232  b_ = str.data() + startFrom;
233  e_ = str.data() + str.size();
234  }
std::string str() const
Definition: Range.h:591
Iter e_
Definition: Range.h:1099
#define UNLIKELY(x)
Definition: Likely.h:48
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class T = Iter, typename detail::IsCharPointer< T >::const_type = 0>
folly::Range< Iter >::Range ( const std::string str,
std::string::size_type  startFrom,
std::string::size_type  size 
)
inline

Definition at line 237 of file Range.h.

240  {
241  if (UNLIKELY(startFrom > str.size())) {
242  throw_exception<std::out_of_range>("index out of range");
243  }
244  b_ = str.data() + startFrom;
245  if (str.size() - startFrom < size) {
246  e_ = str.data() + str.size();
247  } else {
248  e_ = b_ + size;
249  }
250  }
std::string str() const
Definition: Range.h:591
Iter e_
Definition: Range.h:1099
constexpr size_type size() const
Definition: Range.h:431
#define UNLIKELY(x)
Definition: Likely.h:48
Iter b_
Definition: Range.h:1099
template<class Iter>
folly::Range< Iter >::Range ( const Range< Iter > &  other,
size_type  first,
size_type  length = npos 
)
inline

Definition at line 252 of file Range.h.

253  : Range(other.subpiece(first, length)) {}
constexpr Range()
Definition: Range.h:200
constexpr detail::First first
Definition: Base-inl.h:2553
template<class Iter>
template<class Container , class = typename std::enable_if< std::is_same<Iter, typename Container::const_pointer>::value>::type, class = decltype( Iter(std::declval<Container const&>().data()), Iter( std::declval<Container const&>().data() + std::declval<Container const&>().size()))>
constexpr folly::Range< Iter >::Range ( Container const &  container)
inline

Definition at line 264 of file Range.h.

265  : b_(container.data()), e_(b_ + container.size()) {}
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class Container , class = typename std::enable_if< std::is_same<Iter, typename Container::const_pointer>::value>::type, class = decltype( Iter(std::declval<Container const&>().data()), Iter( std::declval<Container const&>().data() + std::declval<Container const&>().size()))>
folly::Range< Iter >::Range ( Container const &  container,
typename Container::size_type  startFrom 
)
inline

Definition at line 276 of file Range.h.

276  {
277  auto const cdata = container.data();
278  auto const csize = container.size();
279  if (UNLIKELY(startFrom > csize)) {
280  throw_exception<std::out_of_range>("index out of range");
281  }
282  b_ = cdata + startFrom;
283  e_ = cdata + csize;
284  }
Iter e_
Definition: Range.h:1099
#define UNLIKELY(x)
Definition: Likely.h:48
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class Container , class = typename std::enable_if< std::is_same<Iter, typename Container::const_pointer>::value>::type, class = decltype( Iter(std::declval<Container const&>().data()), Iter( std::declval<Container const&>().data() + std::declval<Container const&>().size()))>
folly::Range< Iter >::Range ( Container const &  container,
typename Container::size_type  startFrom,
typename Container::size_type  size 
)
inline

Definition at line 295 of file Range.h.

298  {
299  auto const cdata = container.data();
300  auto const csize = container.size();
301  if (UNLIKELY(startFrom > csize)) {
302  throw_exception<std::out_of_range>("index out of range");
303  }
304  b_ = cdata + startFrom;
305  if (csize - startFrom < size) {
306  e_ = cdata + csize;
307  } else {
308  e_ = b_ + size;
309  }
310  }
Iter e_
Definition: Range.h:1099
constexpr size_type size() const
Definition: Range.h:431
#define UNLIKELY(x)
Definition: Likely.h:48
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class OtherIter , typename std::enable_if< (std::is_same< Iter, const unsigned char * >::value &&(std::is_same< OtherIter, const char * >::value||std::is_same< OtherIter, char * >::value)), int >::type = 0>
folly::Range< Iter >::Range ( const Range< OtherIter > &  other)
inline

Definition at line 323 of file Range.h.

324  : b_(reinterpret_cast<const unsigned char*>(other.begin())),
325  e_(reinterpret_cast<const unsigned char*>(other.end())) {}
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class OtherIter , typename std::enable_if< (std::is_same< Iter, unsigned char * >::value &&std::is_same< OtherIter, char * >::value), int >::type = 0>
folly::Range< Iter >::Range ( const Range< OtherIter > &  other)
inline

Definition at line 333 of file Range.h.

334  : b_(reinterpret_cast<unsigned char*>(other.begin())),
335  e_(reinterpret_cast<unsigned char*>(other.end())) {}
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class OtherIter , typename std::enable_if< (std::is_same< Iter, const char * >::value &&(std::is_same< OtherIter, const unsigned char * >::value||std::is_same< OtherIter, unsigned char * >::value)), int >::type = 0>
folly::Range< Iter >::Range ( const Range< OtherIter > &  other)
inlineexplicit

Definition at line 344 of file Range.h.

345  : b_(reinterpret_cast<const char*>(other.begin())),
346  e_(reinterpret_cast<const char*>(other.end())) {}
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class OtherIter , typename std::enable_if< (std::is_same< Iter, char * >::value &&std::is_same< OtherIter, unsigned char * >::value), int >::type = 0>
folly::Range< Iter >::Range ( const Range< OtherIter > &  other)
inlineexplicit

Definition at line 354 of file Range.h.

355  : b_(reinterpret_cast<char*>(other.begin())),
356  e_(reinterpret_cast<char*>(other.end())) {}
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class OtherIter , typename std::enable_if< (!std::is_same< Iter, OtherIter >::value &&std::is_convertible< OtherIter, Iter >::value), int >::type = 0>
constexpr folly::Range< Iter >::Range ( const Range< OtherIter > &  other)
inline

Definition at line 366 of file Range.h.

367  : b_(other.begin()), e_(other.end()) {}
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class OtherIter , typename std::enable_if< (!std::is_same< Iter, OtherIter >::value &&!std::is_convertible< OtherIter, Iter >::value &&std::is_constructible< Iter, const OtherIter & >::value), int >::type = 0>
constexpr folly::Range< Iter >::Range ( const Range< OtherIter > &  other)
inlineexplicit

Definition at line 378 of file Range.h.

379  : b_(other.begin()), e_(other.end()) {}
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class T , size_t N, typename = typename std::enable_if< std::is_convertible<const T*, Iter>::value>::type>
constexpr folly::Range< Iter >::Range ( const std::array< T, N > &  array)
inlineexplicit

Allow explicit construction of Range() from a std::array of a convertible type.

For instance, this allows constructing StringPiece from a std::array<char, N> or a std::array<const char, N>

Definition at line 393 of file Range.h.

394  : b_{array.empty() ? nullptr : &array.at(0)},
395  e_{array.empty() ? nullptr : &array.at(0) + N} {}
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
template<class T , size_t N, typename = typename std::enable_if<std::is_convertible<T*, Iter>::value>::type>
constexpr folly::Range< Iter >::Range ( std::array< T, N > &  array)
inlineexplicit

Definition at line 401 of file Range.h.

402  : b_{array.empty() ? nullptr : &array.at(0)},
403  e_{array.empty() ? nullptr : &array.at(0) + N} {}
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099

Member Function Documentation

template<class Iter>
void folly::Range< Iter >::advance ( size_type  n)
inline

Definition at line 672 of file Range.h.

Referenced by folly::RecordIOReader::Iterator::advanceToValid(), folly::gen::detail::consumeBufferPlus(), folly::gen::detail::consumeFixedSizeChunks(), folly::io::StreamCodec::doUncompress(), folly::symbolizer::Dwarf::findAddress(), folly::symbolizer::Dwarf::findLocation(), folly::format_value::formatNumber(), folly::symbolizer::Dwarf::getAbbreviation(), folly::RecordIOReader::Iterator::increment(), folly::RecordIOReader::Iterator::Iterator(), folly::symbolizer::Dwarf::LineNumberVM::nextDefineFile(), proxygen::HTTP1xCodec::onHeaderField(), folly::compression::BitVectorEncoder< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::openList(), folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::openList(), folly::gen::StreamSplitter< Callback >::operator()(), ReadStats::parseMessage(), folly::prettyToDouble(), folly::symbolizer::Dwarf::Section::Section(), proxygen::HTTPMessage::splitNameValue(), proxygen::HTTPMessage::splitNameValuePieces(), folly::gen::detail::splitPrefix(), folly::symbolizer::Dwarf::LineNumberVM::step(), folly::stringToLogLevel(), folly::symbolizer::test::TEST(), TYPED_TEST(), folly::recordio_helpers::validateRecord(), and folly::gen::detail::FileWriter::write().

672  {
673  if (UNLIKELY(n > size())) {
674  throw_exception<std::out_of_range>("index out of range");
675  }
676  b_ += n;
677  }
constexpr size_type size() const
Definition: Range.h:431
#define UNLIKELY(x)
Definition: Likely.h:48
Iter b_
Definition: Range.h:1099
template<class Iter>
void folly::Range< Iter >::assign ( Iter  start,
Iter  end 
)
inline
template<class Iter>
value_type& folly::Range< Iter >::at ( size_t  i)
inline

Definition at line 628 of file Range.h.

Referenced by folly::bser::decodeHeader(), and folly::json_pointer::try_parse().

628  {
629  if (i >= size()) {
630  throw_exception<std::out_of_range>("index out of range");
631  }
632  return b_[i];
633  }
constexpr size_type size() const
Definition: Range.h:431
Iter b_
Definition: Range.h:1099
template<class Iter>
const value_type& folly::Range< Iter >::at ( size_t  i) const
inline

Definition at line 635 of file Range.h.

635  {
636  if (i >= size()) {
637  throw_exception<std::out_of_range>("index out of range");
638  }
639  return b_[i];
640  }
constexpr size_type size() const
Definition: Range.h:431
Iter b_
Definition: Range.h:1099
template<class Iter>
value_type& folly::Range< Iter >::back ( )
inline

Definition at line 468 of file Range.h.

Referenced by folly::gen::detail::StringResplitter::Generator< Source >::apply(), folly::rtrimWhitespace(), and proxygen::ParseURL::stripBrackets().

468  {
469  assert(b_ < e_);
470  return detail::value_before(e_);
471  }
Iter e_
Definition: Range.h:1099
std::enable_if< std::is_same< typename std::iterator_traits< Iter >::iterator_category, std::random_access_iterator_tag >::value, typename std::iterator_traits< Iter >::reference >::type value_before(Iter i)
Definition: Range.h:123
Iter b_
Definition: Range.h:1099
template<class Iter>
const value_type& folly::Range< Iter >::back ( ) const
inline

Definition at line 476 of file Range.h.

476  {
477  assert(b_ < e_);
478  return detail::value_before(e_);
479  }
Iter e_
Definition: Range.h:1099
std::enable_if< std::is_same< typename std::iterator_traits< Iter >::iterator_category, std::random_access_iterator_tag >::value, typename std::iterator_traits< Iter >::reference >::type value_before(Iter i)
Definition: Range.h:123
Iter b_
Definition: Range.h:1099
template<class Iter>
constexpr Iter folly::Range< Iter >::begin ( ) const
inline

Definition at line 452 of file Range.h.

Referenced by folly::RecordIOReader::Iterator::advanceToValid(), proxygen::base64Encode(), folly::detail::RangeEnumerator< Range >::begin(), proxygen::caseInsensitiveEqual(), folly::cEscape(), checkResplitMaxLength(), folly::gen::detail::consumeFixedSizeChunks(), folly::cUnescape(), fizz::detail::decFunc(), fizz::detail::decFuncBlocks(), folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::EliasFanoEncoderV2(), folly::json::escapeStringImpl(), folly::detail::estimatesFromDigest(), fizz::KeyDerivationImpl< Hash >::expandLabel(), folly::symbolizer::Dwarf::findLocation(), folly::recordio_helpers::findRecord(), folly::LogName::getParent(), folly::ssl::OpenSSLUtils::getTLSClientRandom(), folly::ssl::OpenSSLUtils::getTLSMasterKey(), folly::detail::TransparentRangeHash< detail::ValueTypeForTransparentConversionToRange< T >::type >::hashImpl(), folly::test::detail::hasPCREPatternMatch(), proxygen::md5Encode(), SimpleDigest< MergeSize >::merge(), folly::TDigest::merge(), proxygen::HTTP1xCodec::onHeaderField(), proxygen::HTTP1xCodec::onIngress(), folly::gen::StreamSplitter< Callback >::operator()(), EqTraits::operator()(), KeyConvertTraits::operator()(), folly::hasher< folly::Range< T * >, std::enable_if_t< std::is_integral< T >::value, void > >::operator()(), folly::MacAddress::parse(), proxygen::RFC2616::parseByteRangeSpec(), folly::CustomLogFormatter::parseFormatString(), folly::AsyncIOOp::pread(), proxygen::HTTP1xCodec::pushHeaderNameAndValue(), folly::AsyncIOOp::pwrite(), folly::qfind(), folly::qfind_first_of(), folly::MacAddress::setFromBinary(), folly::detail::splitFixed(), proxygen::HPACKHeaderName::storeAddress(), TEST(), testInvalid(), testRangeFunc(), testValid(), folly::toAppend(), folly::toLowerAscii(), folly::symbolizer::Dwarf::Path::toString(), fizz::trimBytes(), folly::tryDecodeVarint(), TYPED_TEST(), folly::Uri::Uri(), folly::uriEscape(), folly::uriUnescape(), and folly::recordio_helpers::validateRecord().

452  {
453  return b_;
454  }
Iter b_
Definition: Range.h:1099
template<class Iter>
const_range_type folly::Range< Iter >::castToConst ( ) const
inline

Definition at line 598 of file Range.h.

Referenced by fizz::test::TEST().

598  {
599  return const_range_type(*this);
600  }
std::conditional< std::is_same< Iter, char * >::value||std::is_same< Iter, unsigned char * >::value, Range< const value_type * >, Range< Iter > >::type const_range_type
Definition: Range.h:192
template<class Iter>
constexpr Iter folly::Range< Iter >::cbegin ( ) const
inline

Definition at line 458 of file Range.h.

458  {
459  return b_;
460  }
Iter b_
Definition: Range.h:1099
template<class Iter>
constexpr Iter folly::Range< Iter >::cend ( ) const
inline

Definition at line 461 of file Range.h.

461  {
462  return e_;
463  }
Iter e_
Definition: Range.h:1099
template<class Iter>
int folly::Range< Iter >::compare ( const const_range_type o) const
inline

Definition at line 602 of file Range.h.

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

602  {
603  const size_type tsize = this->size();
604  const size_type osize = o.size();
605  const size_type msize = std::min(tsize, osize);
606  int r = traits_type::compare(data(), o.data(), msize);
607  if (r == 0 && tsize != osize) {
608  // We check the signed bit of the subtraction and bit shift it
609  // to produce either 0 or 2. The subtraction yields the
610  // comparison values of either -1 or 1.
611  r = (static_cast<int>((osize - tsize) >> (CHAR_BIT * sizeof(size_t) - 1))
612  << 1) -
613  1;
614  }
615  return r;
616  }
constexpr size_type size() const
Definition: Range.h:431
LogLevel min
Definition: LogLevel.cpp:30
constexpr Iter data() const
Definition: Range.h:446
std::size_t size_type
Definition: Range.h:174
template<class Iter>
bool folly::Range< Iter >::contains ( const const_range_type other) const
inline

Determine whether the range contains the given subrange or item.

Note: Call find() directly if the index is needed.

Definition at line 812 of file Range.h.

Referenced by folly::test::TEST().

812  {
813  return find(other) != std::string::npos;
814  }
size_type find(const_range_type str) const
Definition: Range.h:721
template<class Iter>
bool folly::Range< Iter >::contains ( const value_type other) const
inline

Definition at line 816 of file Range.h.

816  {
817  return find(other) != std::string::npos;
818  }
size_type find(const_range_type str) const
Definition: Range.h:721
template<class Iter>
constexpr Iter folly::Range< Iter >::data ( ) const
inline

Definition at line 446 of file Range.h.

Referenced by proxygen::HTTPHeaders::add(), folly::RecordIOReader::Iterator::advanceToValid(), folly::io::detail::CursorStringAppender::append(), folly::IOBufQueue::append(), folly::MemoryMapping::asRange(), folly::symbolizer::SignalSafeElfCache::Path::assign(), folly::MemoryMapping::asWritableRange(), folly::compression::BitVectorEncoder< Value, SkipValue, kSkipQuantum, kForwardQuantum >::BitVectorEncoder(), folly::bser::bserEncodeString(), fizz::CryptoUtils::clean(), folly::Subprocess::communicate(), folly::gen::detail::consumeBufferPlus(), folly::IOBuf::copyBuffer(), fizz::jni::createByteArray(), createProtectedBuf(), fizz::detail::decodeECPublicKey(), folly::ssl::OpenSSLCertUtils::derDecode(), folly::symbolizer::FDSymbolizePrinter::doPrint(), folly::symbolizer::FILESymbolizePrinter::doPrint(), folly::symbolizer::StringSymbolizePrinter::doPrint(), folly::io::StreamCodec::doUncompress(), folly::dynamic::dynamic(), fizz::detail::ecSign(), fizz::detail::ecVerify(), proxygen::Base64::encode(), proxygen::HPACKEncodeBuffer::encodeLiteral(), fizz::CryptoUtils::equal(), fizz::detail::evpDecrypt(), fizz::detail::evpEncrypt(), proxygen::HTTPHeaders::exists(), folly::symbolizer::Dwarf::findDebugInfoOffset(), proxygen::HTTPHeaders::forEachValueOfHeader(), folly::LogStreamProcessor::formatLogString(), folly::format_value::formatString(), folly::compression::BitVectorCompressedListBase< Pointer >::free(), folly::compression::EliasFanoCompressedListBase< Pointer >::free(), fizz::X25519KeyExchange::generateSharedSecret(), fizz::test::getCert(), fizz::test::getPrivateKey(), fizz::test::getPublicKey(), folly::ssl::OpenSSLHash::Digest::hash_final(), folly::ssl::OpenSSLHash::Hmac::hash_final(), folly::ssl::OpenSSLHash::Hmac::hash_init(), folly::ssl::OpenSSLHash::Digest::hash_update(), folly::ssl::OpenSSLHash::Hmac::hash_update(), folly::symbolizer::Dwarf::LineNumberVM::init(), folly::SSLContext::loadCertificateFromBufferPEM(), folly::SSLContext::loadPrivateKeyFromBufferPEM(), folly::makeConversionError(), fizz::test::MATCHER_P(), folly::mmapFileCopy(), folly::symbolizer::Dwarf::Section::next(), proxygen::RFC1867Codec::onHeadersComplete(), folly::compression::BitVectorEncoder< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::openList(), folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::openList(), folly::gen::StreamSplitter< Callback >::operator()(), proxygen::ParseURL::parse(), folly::bser::parseBser(), proxygen::GzipHeaderCodec::parseNameValues(), folly::parseTo(), fizz::CertUtils::prepareSignData(), folly::io::detail::Writable< Appender >::pushAtMost(), folly::qfind(), folly::symbolizer::Dwarf::readAbbreviation(), readCertFromData(), folly::ssl::OpenSSLCertUtils::readCertsFromBuffer(), readThread(), HPACKBufferTests::releaseData(), proxygen::HTTPHeaders::remove(), fizz::test::HandshakeTest::resetTransportsAndStartCookieHandshake(), folly::rfind(), fizz::detail::rsaPssSign(), fizz::detail::rsaPssVerify(), folly::io::test::CompressionTest::runSimpleStringTest(), folly::symbolizer::Dwarf::Section::Section(), fizz::server::SlidingBloomReplayCache::set(), folly::SocketAddress::setFromPath(), folly::setThreadName(), folly::gen::detail::splitPrefix(), proxygen::HPACKHeaderName::storeAddress(), folly::stringPieceDel(), folly::stringPieceDup(), fizz::server::SlidingBloomReplayCache::test(), TEST(), folly::io::test::TEST(), TEST_F(), fizz::server::SlidingBloomReplayCache::testAndSet(), folly::toAppend(), proxygen::HTTPHeaders::transferHeaderIfPresent(), folly::IOBuf::wrapBuffer(), folly::gen::detail::FileWriter::write(), folly::writeFileAtomic(), folly::writeFileAtomicNoThrow(), folly::ImmediateFileWriter::writeMessage(), and proxygen::compress::HeaderPiece::~HeaderPiece().

446  {
447  return b_;
448  }
Iter b_
Definition: Range.h:1099
template<class Iter>
constexpr bool folly::Range< Iter >::empty ( ) const
inline

Definition at line 443 of file Range.h.

Referenced by folly::io::addOutputBuffer(), folly::RecordIOReader::Iterator::advanceToValid(), folly::gen::detail::StringResplitter::Generator< Source >::apply(), folly::gen::detail::SplitStringSource< DelimiterType >::apply(), folly::symbolizer::SignalSafeElfCache::Path::assign(), folly::LogName::cmp(), folly::io::test::compressSome(), folly::io::StreamCodec::compressStream(), folly::gen::detail::consumeFixedSizeChunks(), proxygen::HTTPMessage::createUrl(), folly::detail::delimFront(), folly::io::StreamCodec::doCompress(), folly::io::StreamCodec::doUncompress(), fizz::HkdfImpl< Hash >::extract(), folly::symbolizer::Dwarf::findAddress(), folly::symbolizer::Dwarf::LineNumberVM::findAddress(), folly::symbolizer::Dwarf::findLocation(), fizz::tool::fizzClientCommand(), folly::FormatArg::FormatArg(), fizz::client::test::AsyncFizzClientTest::fullHandshakeSuccess(), folly::symbolizer::Dwarf::LineNumberVM::getIncludeDirectory(), folly::LogName::getParent(), proxygen::ParseURL::hasHost(), folly::initLogging(), folly::detail::internalSplit(), folly::ltrimWhitespace(), folly::makeConversionError(), folly::TDigest::merge(), folly::symbolizer::Dwarf::Section::next(), folly::symbolizer::Dwarf::LineNumberVM::nextDefineFile(), proxygen::HTTP1xCodec::onIngress(), folly::GoogleLogger< Style >::operator()(), folly::gen::StreamSplitter< Callback >::operator()(), proxygen::ParseURL::parseNonFully(), folly::symbolizer::Dwarf::Path::Path(), folly::qfind(), folly::symbolizer::Dwarf::readAbbreviation(), folly::symbolizer::Dwarf::LineNumberVM::readFileName(), folly::rfind(), folly::rtrimWhitespace(), folly::symbolizer::Dwarf::Section::Section(), folly::symbolizer::Dwarf::Path::size(), folly::io::test::StreamingCompressionTest::split(), proxygen::HTTPMessage::splitNameValue(), proxygen::ParseURL::stripBrackets(), folly::test::TEST(), TEST(), fizz::test::TEST_F(), folly::test::testVarint(), folly::symbolizer::Dwarf::Path::toBuffer(), folly::symbolizer::Dwarf::Path::toString(), folly::json_pointer::try_parse(), TYPED_TEST(), folly::io::Codec::uncompress(), folly::io::StreamCodec::uncompressStream(), folly::Uri::Uri(), and folly::gen::detail::FileWriter::write().

443  {
444  return b_ == e_;
445  }
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
constexpr Iter folly::Range< Iter >::end ( ) const
inline

Definition at line 455 of file Range.h.

Referenced by proxygen::caseInsensitiveEqual(), folly::cEscape(), checkResplitMaxLength(), folly::cUnescape(), folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::EliasFanoEncoderV2(), folly::detail::RangeEnumerator< Range >::end(), folly::json::escapeStringImpl(), folly::detail::estimatesFromDigest(), fizz::KeyDerivationImpl< Hash >::expandLabel(), folly::symbolizer::Dwarf::findLocation(), folly::recordio_helpers::findRecord(), folly::detail::TransparentRangeHash< detail::ValueTypeForTransparentConversionToRange< T >::type >::hashImpl(), folly::test::detail::hasPCREPatternMatch(), folly::symbolizer::Dwarf::LineNumberVM::init(), SimpleDigest< MergeSize >::merge(), folly::TDigest::merge(), folly::symbolizer::Dwarf::Section::next(), proxygen::HTTP1xCodec::onHeaderField(), folly::MacAddress::parse(), proxygen::RFC2616::parseByteRangeSpec(), folly::CustomLogFormatter::parseFormatString(), folly::parseTo(), folly::detail::parseToWrap(), folly::qfind(), folly::qfind_first_of(), folly::symbolizer::Dwarf::Section::Section(), folly::Range< unsigned char * >::split_step(), folly::detail::splitFixed(), proxygen::HPACKHeaderName::storeAddress(), TEST(), testRangeFunc(), folly::symbolizer::Dwarf::Path::toString(), folly::tryDecodeVarint(), TYPED_TEST(), folly::compression::EliasFanoCompressedListBase< Pointer >::upperSize(), folly::Uri::Uri(), folly::uriEscape(), and folly::uriUnescape().

455  {
456  return e_;
457  }
Iter e_
Definition: Range.h:1099
template<class Iter>
bool folly::Range< Iter >::endsWith ( const const_range_type other) const
inline

Does this Range end with another range?

Definition at line 849 of file Range.h.

Referenced by proxygen::compress::CompressionSimulator::getScheme(), ReadStats::messageReceived(), ReadStats::parseMessage(), folly::symbolizer::Dwarf::Path::size(), TEST(), and folly::symbolizer::Dwarf::Path::toBuffer().

849  {
850  return size() >= other.size() &&
851  castToConst().subpiece(size() - other.size()) == other;
852  }
constexpr size_type size() const
Definition: Range.h:431
const_range_type castToConst() const
Definition: Range.h:598
template<class Iter>
bool folly::Range< Iter >::endsWith ( value_type  c) const
inline

Definition at line 853 of file Range.h.

853  {
854  return !empty() && back() == c;
855  }
constexpr bool empty() const
Definition: Range.h:443
char c
value_type & back()
Definition: Range.h:468
template<class Iter>
template<class Comp >
bool folly::Range< Iter >::endsWith ( const const_range_type other,
Comp &&  eq 
) const
inline

Definition at line 858 of file Range.h.

858  {
859  if (size() < other.size()) {
860  return false;
861  }
862  auto const trunc = subpiece(size() - other.size());
863  return std::equal(
864  trunc.begin(), trunc.end(), other.begin(), std::forward<Comp>(eq));
865  }
constexpr size_type size() const
Definition: Range.h:431
Range subpiece(size_type first, size_type length=npos) const
Definition: Range.h:686
template<class Iter>
template<class Comp >
bool folly::Range< Iter >::equals ( const const_range_type other,
Comp &&  eq 
) const
inline

Definition at line 868 of file Range.h.

Referenced by TEST().

868  {
869  return size() == other.size() &&
870  std::equal(begin(), end(), other.begin(), std::forward<Comp>(eq));
871  }
constexpr size_type size() const
Definition: Range.h:431
constexpr Iter end() const
Definition: Range.h:455
constexpr Iter begin() const
Definition: Range.h:452
template<class Iter>
void folly::Range< Iter >::erase ( Iter  b,
Iter  e 
)
inline

Remove the items in [b, e), as long as this subrange is at the beginning or end of the Range.

Required for boost::algorithm::trim()

Definition at line 879 of file Range.h.

Referenced by TEST().

879  {
880  if (b == b_) {
881  b_ = e;
882  } else if (e == e_) {
883  e_ = b;
884  } else {
885  throw_exception<std::out_of_range>("index out of range");
886  }
887  }
char b
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
size_type folly::Range< Iter >::find ( const_range_type  str,
size_t  pos 
) const
inline

Definition at line 725 of file Range.h.

725  {
726  if (pos > size()) {
727  return std::string::npos;
728  }
729  size_t ret = qfind(castToConst().subpiece(pos), str);
730  return ret == npos ? ret : ret + pos;
731  }
std::string str() const
Definition: Range.h:591
constexpr size_type size() const
Definition: Range.h:431
Range subpiece(size_type first, size_type length=npos) const
Definition: Range.h:686
const_range_type castToConst() const
Definition: Range.h:598
size_t qfind(const Range< Iter > &haystack, const Range< Iter > &needle, Comp eq=Comp())
Definition: Range.h:1292
static const size_type npos
Definition: Range.h:197
template<class Iter>
size_type folly::Range< Iter >::find ( Iter  s,
size_t  pos,
size_t  n 
) const
inline

Definition at line 733 of file Range.h.

733  {
734  if (pos > size()) {
735  return std::string::npos;
736  }
737  auto forFinding = castToConst();
738  size_t ret = qfind(
739  pos ? forFinding.subpiece(pos) : forFinding, const_range_type(s, n));
740  return ret == npos ? ret : ret + pos;
741  }
constexpr size_type size() const
Definition: Range.h:431
std::conditional< std::is_same< Iter, char * >::value||std::is_same< Iter, unsigned char * >::value, Range< const value_type * >, Range< Iter > >::type const_range_type
Definition: Range.h:192
const_range_type castToConst() const
Definition: Range.h:598
size_t qfind(const Range< Iter > &haystack, const Range< Iter > &needle, Comp eq=Comp())
Definition: Range.h:1292
static const size_type npos
Definition: Range.h:197
static set< string > s
template<class Iter>
size_type folly::Range< Iter >::find ( const Iter  s) const
inline

Definition at line 744 of file Range.h.

744  {
745  return qfind(castToConst(), const_range_type(s));
746  }
std::conditional< std::is_same< Iter, char * >::value||std::is_same< Iter, unsigned char * >::value, Range< const value_type * >, Range< Iter > >::type const_range_type
Definition: Range.h:192
const_range_type castToConst() const
Definition: Range.h:598
size_t qfind(const Range< Iter > &haystack, const Range< Iter > &needle, Comp eq=Comp())
Definition: Range.h:1292
static set< string > s
template<class Iter>
size_type folly::Range< Iter >::find ( const Iter  s,
size_t  pos 
) const
inline

Definition at line 749 of file Range.h.

749  {
750  if (pos > size()) {
751  return std::string::npos;
752  }
754  return ret == npos ? ret : ret + pos;
755  }
constexpr size_type size() const
Definition: Range.h:431
std::conditional< std::is_same< Iter, char * >::value||std::is_same< Iter, unsigned char * >::value, Range< const value_type * >, Range< Iter > >::type const_range_type
Definition: Range.h:192
Range subpiece(size_type first, size_type length=npos) const
Definition: Range.h:686
const_range_type castToConst() const
Definition: Range.h:598
size_t qfind(const Range< Iter > &haystack, const Range< Iter > &needle, Comp eq=Comp())
Definition: Range.h:1292
static const size_type npos
Definition: Range.h:197
std::size_t size_type
Definition: Range.h:174
static set< string > s
template<class Iter>
size_type folly::Range< Iter >::find ( value_type  c) const
inline

Definition at line 757 of file Range.h.

757  {
758  return qfind(castToConst(), c);
759  }
const_range_type castToConst() const
Definition: Range.h:598
size_t qfind(const Range< Iter > &haystack, const Range< Iter > &needle, Comp eq=Comp())
Definition: Range.h:1292
char c
template<class Iter>
size_type folly::Range< Iter >::find ( value_type  c,
size_t  pos 
) const
inline

Definition at line 765 of file Range.h.

765  {
766  if (pos > size()) {
767  return std::string::npos;
768  }
769  size_type ret = qfind(castToConst().subpiece(pos), c);
770  return ret == npos ? ret : ret + pos;
771  }
constexpr size_type size() const
Definition: Range.h:431
Range subpiece(size_type first, size_type length=npos) const
Definition: Range.h:686
const_range_type castToConst() const
Definition: Range.h:598
size_t qfind(const Range< Iter > &haystack, const Range< Iter > &needle, Comp eq=Comp())
Definition: Range.h:1292
static const size_type npos
Definition: Range.h:197
std::size_t size_type
Definition: Range.h:174
char c
template<class Iter>
size_type folly::Range< Iter >::find_first_of ( const_range_type  needles) const
inline

Definition at line 773 of file Range.h.

Referenced by BENCHMARK(), and folly::gen::detail::splitPrefix().

773  {
774  return qfind_first_of(castToConst(), needles);
775  }
size_t qfind_first_of(const Range< Iter > &haystack, const Range< Iter > &needle)
Definition: Range.h:1466
const_range_type castToConst() const
Definition: Range.h:598
template<class Iter>
size_type folly::Range< Iter >::find_first_of ( const_range_type  needles,
size_t  pos 
) const
inline

Definition at line 777 of file Range.h.

777  {
778  if (pos > size()) {
779  return std::string::npos;
780  }
781  size_type ret = qfind_first_of(castToConst().subpiece(pos), needles);
782  return ret == npos ? ret : ret + pos;
783  }
constexpr size_type size() const
Definition: Range.h:431
size_t qfind_first_of(const Range< Iter > &haystack, const Range< Iter > &needle)
Definition: Range.h:1466
Range subpiece(size_type first, size_type length=npos) const
Definition: Range.h:686
const_range_type castToConst() const
Definition: Range.h:598
static const size_type npos
Definition: Range.h:197
std::size_t size_type
Definition: Range.h:174
template<class Iter>
size_type folly::Range< Iter >::find_first_of ( Iter  needles) const
inline

Definition at line 786 of file Range.h.

786  {
787  return find_first_of(const_range_type(needles));
788  }
size_type find_first_of(const_range_type needles) const
Definition: Range.h:773
std::conditional< std::is_same< Iter, char * >::value||std::is_same< Iter, unsigned char * >::value, Range< const value_type * >, Range< Iter > >::type const_range_type
Definition: Range.h:192
template<class Iter>
size_type folly::Range< Iter >::find_first_of ( Iter  needles,
size_t  pos 
) const
inline

Definition at line 791 of file Range.h.

791  {
792  return find_first_of(const_range_type(needles), pos);
793  }
size_type find_first_of(const_range_type needles) const
Definition: Range.h:773
std::conditional< std::is_same< Iter, char * >::value||std::is_same< Iter, unsigned char * >::value, Range< const value_type * >, Range< Iter > >::type const_range_type
Definition: Range.h:192
template<class Iter>
size_type folly::Range< Iter >::find_first_of ( Iter  needles,
size_t  pos,
size_t  n 
) const
inline

Definition at line 795 of file Range.h.

795  {
796  return find_first_of(const_range_type(needles, n), pos);
797  }
size_type find_first_of(const_range_type needles) const
Definition: Range.h:773
std::conditional< std::is_same< Iter, char * >::value||std::is_same< Iter, unsigned char * >::value, Range< const value_type * >, Range< Iter > >::type const_range_type
Definition: Range.h:192
template<class Iter>
size_type folly::Range< Iter >::find_first_of ( value_type  c) const
inline

Definition at line 799 of file Range.h.

799  {
800  return find(c);
801  }
size_type find(const_range_type str) const
Definition: Range.h:721
char c
template<class Iter>
size_type folly::Range< Iter >::find_first_of ( value_type  c,
size_t  pos 
) const
inline

Definition at line 803 of file Range.h.

803  {
804  return find(c, pos);
805  }
size_type find(const_range_type str) const
Definition: Range.h:721
char c
template<class Iter>
value_type& folly::Range< Iter >::front ( )
inline

Definition at line 464 of file Range.h.

Referenced by folly::LogName::cmp(), folly::ltrimWhitespace(), folly::prettyToDouble(), and proxygen::ParseURL::stripBrackets().

464  {
465  assert(b_ < e_);
466  return *b_;
467  }
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
const value_type& folly::Range< Iter >::front ( ) const
inline

Definition at line 472 of file Range.h.

472  {
473  assert(b_ < e_);
474  return *b_;
475  }
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
uint32_t folly::Range< Iter >::hash ( ) const
inline

Definition at line 662 of file Range.h.

Referenced by fizz::Exporter::getEkm().

662  {
663  // Taken from fbi/nstring.h:
664  // Quick and dirty bernstein hash...fine for short ascii strings
665  uint32_t hash = 5381;
666  for (size_t ix = 0; ix < size(); ix++) {
667  hash = ((hash << 5) + hash) + b_[ix];
668  }
669  return hash;
670  }
constexpr size_type size() const
Definition: Range.h:431
uint32_t hash() const
Definition: Range.h:662
Iter b_
Definition: Range.h:1099
template<class Iter>
template<typename Tgt , std::enable_if_t< std::is_constructible< Tgt, Iter const &, size_type >::value &&!IsConstructibleViaStringView< Tgt >::value, int > = 0>
constexpr folly::Range< Iter >::operator Tgt ( ) const
inlineexplicitnoexcept

explicit operator conversion to any compatible type

A compatible type is one which is constructible with an iterator and a size (preferred), or a pair of iterators (fallback), passed by const-ref.

Participates in overload resolution precisely when the target type is compatible. This allows std::is_constructible compile-time checks to work.

Definition at line 525 of file Range.h.

526  {
527  return Tgt(b_, walk_size());
528  }
constexpr size_type walk_size() const
Definition: Range.h:440
Iter b_
Definition: Range.h:1099
template<class Iter>
template<typename Tgt , std::enable_if_t< !std::is_constructible< Tgt, Iter const &, size_type >::value &&std::is_constructible< Tgt, Iter const &, Iter const & >::value &&!IsConstructibleViaStringView< Tgt >::value, int > = 0>
constexpr folly::Range< Iter >::operator Tgt ( ) const
inlineexplicitnoexcept

Definition at line 536 of file Range.h.

537  {
538  return Tgt(b_, e_);
539  }
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
Range& folly::Range< Iter >::operator= ( const Range< Iter > &  rhs)
default
template<class Iter>
Range& folly::Range< Iter >::operator= ( Range< Iter > &&  rhs)
default
template<class Iter>
template<class T = Iter, typename detail::IsCharPointer< T >::const_type = 0>
Range& folly::Range< Iter >::operator= ( std::string &&  rhs)
delete
template<class Iter>
value_type& folly::Range< Iter >::operator[] ( size_t  i)
inline

Definition at line 618 of file Range.h.

618  {
619  assert(i < size());
620  return b_[i];
621  }
constexpr size_type size() const
Definition: Range.h:431
Iter b_
Definition: Range.h:1099
template<class Iter>
const value_type& folly::Range< Iter >::operator[] ( size_t  i) const
inline

Definition at line 623 of file Range.h.

623  {
624  assert(i < size());
625  return b_[i];
626  }
constexpr size_type size() const
Definition: Range.h:431
Iter b_
Definition: Range.h:1099
template<class Iter>
void folly::Range< Iter >::pop_back ( )
inline

Definition at line 715 of file Range.h.

Referenced by folly::gen::detail::StringResplitter::Generator< Source >::apply(), folly::rtrimWhitespace(), and TYPED_TEST().

715  {
716  assert(b_ < e_);
717  --e_;
718  }
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
void folly::Range< Iter >::pop_front ( )
inline

Definition at line 710 of file Range.h.

Referenced by folly::ltrimWhitespace().

710  {
711  assert(b_ < e_);
712  ++b_;
713  }
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
bool folly::Range< Iter >::removePrefix ( const const_range_type prefix)
inline

Remove the given prefix and return true if the range starts with the given prefix; return false otherwise.

Definition at line 893 of file Range.h.

Referenced by my::parseTo(), folly::symbolizer::Dwarf::Section::Section(), folly::gen::detail::splitPrefix(), and TEST().

893  {
894  return startsWith(prefix) && (b_ += prefix.size(), true);
895  }
bool prefix(Cursor &c, uint32_t expected)
bool startsWith(const const_range_type &other) const
Definition: Range.h:828
Iter b_
Definition: Range.h:1099
template<class Iter>
bool folly::Range< Iter >::removePrefix ( value_type  prefix)
inline

Definition at line 896 of file Range.h.

896  {
897  return startsWith(prefix) && (++b_, true);
898  }
bool prefix(Cursor &c, uint32_t expected)
bool startsWith(const const_range_type &other) const
Definition: Range.h:828
Iter b_
Definition: Range.h:1099
template<class Iter>
bool folly::Range< Iter >::removeSuffix ( const const_range_type suffix)
inline

Remove the given suffix and return true if the range ends with the given suffix; return false otherwise.

Definition at line 904 of file Range.h.

Referenced by folly::symbolizer::Dwarf::Section::Section(), and TEST().

904  {
905  return endsWith(suffix) && (e_ -= suffix.size(), true);
906  }
Iter e_
Definition: Range.h:1099
const char * suffix
Definition: String.cpp:272
bool endsWith(const const_range_type &other) const
Definition: Range.h:849
template<class Iter>
bool folly::Range< Iter >::removeSuffix ( value_type  suffix)
inline

Definition at line 907 of file Range.h.

907  {
908  return endsWith(suffix) && (--e_, true);
909  }
Iter e_
Definition: Range.h:1099
const char * suffix
Definition: String.cpp:272
bool endsWith(const const_range_type &other) const
Definition: Range.h:849
template<class Iter>
size_t folly::Range< Iter >::replaceAll ( const_range_type  source,
const_range_type  dest 
)
inline

Replaces all occurences of 'source' with 'dest'. Returns number of replacements made. Source and dest have to have the same length. Throws if the lengths are different. If 'source' is a pattern that is overlapping with itself, we perform sequential replacement: "aaaaaaa".replaceAll("aa", "ba") –> "bababaa"

Example use:

char in[] = "buffer"; auto msp = MutablesStringPiece(input); EXPECT_EQ(msp.replaceAll("ff","tt"), 1); EXPECT_EQ(msp, "butter");

Definition at line 949 of file Range.h.

949  {
950  if (source.size() != dest.size()) {
951  throw_exception<std::invalid_argument>(
952  "replacement must have the same size as source");
953  }
954 
955  if (dest.empty()) {
956  return 0;
957  }
958 
959  size_t pos = 0;
960  size_t num_replaced = 0;
961  size_type found = std::string::npos;
962  while ((found = find(source, pos)) != std::string::npos) {
963  replaceAt(found, dest);
964  pos += source.size();
965  ++num_replaced;
966  }
967 
968  return num_replaced;
969  }
bool replaceAt(size_t pos, const_range_type replacement)
Definition: Range.h:925
size_type find(const_range_type str) const
Definition: Range.h:721
dest
Definition: upload.py:394
std::size_t size_type
Definition: Range.h:174
template<class Iter>
bool folly::Range< Iter >::replaceAt ( size_t  pos,
const_range_type  replacement 
)
inline

Replaces the content of the range, starting at position 'pos', with contents of 'replacement'. Entire 'replacement' must fit into the range. Returns false if 'replacements' does not fit. Example use:

char in[] = "buffer"; auto msp = MutablesStringPiece(input); EXPECT_TRUE(msp.replaceAt(2, "tt")); EXPECT_EQ(msp, "butter");

// not enough space EXPECT_FALSE(msp.replace(msp.size() - 1, "rr")); EXPECT_EQ(msp, "butter"); // unchanged

Definition at line 925 of file Range.h.

925  {
926  if (size() < pos + replacement.size()) {
927  return false;
928  }
929 
930  std::copy(replacement.begin(), replacement.end(), begin() + pos);
931 
932  return true;
933  }
constexpr size_type size() const
Definition: Range.h:431
constexpr std::decay< T >::type copy(T &&value) noexcept(noexcept(typename std::decay< T >::type(std::forward< T >(value))))
Definition: Utility.h:72
constexpr Iter begin() const
Definition: Range.h:452
template<class Iter>
void folly::Range< Iter >::reset ( const std::string str)
inline

Definition at line 427 of file Range.h.

427  {
428  reset(str.data(), str.size());
429  }
std::string str() const
Definition: Range.h:591
void reset(Iter start, size_type size)
Definition: Range.h:421
template<class Iter>
size_type folly::Range< Iter >::rfind ( value_type  c) const
inline

Definition at line 761 of file Range.h.

Referenced by folly::LogMessage::getFileBaseName(), LoggerTest::pathBasename(), and folly::symbolizer::test::TEST().

761  {
762  return folly::rfind(castToConst(), c);
763  }
size_t rfind(const Range< Iter > &haystack, const typename Range< Iter >::value_type &needle)
Definition: Range.h:1404
const_range_type castToConst() const
Definition: Range.h:598
char c
template<class Iter>
constexpr size_type folly::Range< Iter >::size ( ) const
inline

Definition at line 431 of file Range.h.

Referenced by proxygen::HTTPHeaders::add(), folly::RecordIOReader::Iterator::advanceToValid(), folly::io::detail::CursorStringAppender::append(), folly::IOBufQueue::append(), folly::MemoryMapping::asRange(), folly::symbolizer::SignalSafeElfCache::Path::assign(), folly::MemoryMapping::asWritableRange(), folly::detail::atDelim(), folly::backslashify(), proxygen::base64Encode(), BENCHMARK(), folly::compression::BitVectorEncoder< Value, SkipValue, kSkipQuantum, kForwardQuantum >::BitVectorEncoder(), folly::bser::bserEncodeString(), folly::LogName::canonicalize(), proxygen::caseInsensitiveEqual(), folly::cEscape(), folly::ssl::OpenSSLHash::check_out_size(), folly::ssl::OpenSSLHash::check_out_size_throw(), fizz::CryptoUtils::clean(), clibAtoiMeasure(), folly::Subprocess::communicate(), folly::io::Codec::compress(), folly::io::StreamCodec::compressStream(), folly::gen::detail::consumeFixedSizeChunks(), folly::IOBuf::copyBuffer(), fizz::jni::createByteArray(), createProtectedBuf(), proxygen::HTTPMessage::createUrl(), folly::cUnescape(), fizz::detail::decFunc(), fizz::detail::decFuncBlocks(), fizz::detail::decodeECPublicKey(), folly::detail::delimSize(), folly::ssl::OpenSSLCertUtils::derDecode(), fizz::KeyDerivationImpl< Hash >::deriveSecret(), folly::io::StreamCodec::doCompress(), folly::symbolizer::FDSymbolizePrinter::doPrint(), folly::symbolizer::FILESymbolizePrinter::doPrint(), folly::symbolizer::StringSymbolizePrinter::doPrint(), folly::io::StreamCodec::doUncompress(), folly::dynamic::dynamic(), fizz::detail::ecSign(), fizz::detail::ecVerify(), proxygen::Base64::encode(), proxygen::huffman::HuffTree::encode(), fizz::encodeHkdfLabel(), proxygen::HPACKEncodeBuffer::encodeLiteral(), fizz::CryptoUtils::equal(), folly::detail::estimatesFromDigest(), folly::estimateSpaceNeeded(), fizz::detail::evpDecrypt(), proxygen::HTTPHeaders::exists(), fizz::HkdfImpl< Hash >::expand(), folly::symbolizer::test::expect(), follyAtoiMeasure(), proxygen::HTTPHeaders::forEachValueOfHeader(), folly::LogStreamProcessor::formatLogString(), folly::CustomLogFormatter::formatMessage(), folly::format_value::formatString(), folly::IPAddressV4::fromBinary(), folly::IPAddressV6::fromBinary(), fizz::X25519KeyExchange::generateSharedSecret(), fizz::test::getCert(), proxygen::huffman::HuffTree::getEncodeSize(), folly::symbolizer::SignalSafeElfCache::getFile(), folly::LogName::getParent(), fizz::test::getPrivateKey(), fizz::test::getPublicKey(), folly::symbolizer::Dwarf::getStringFromStringSection(), folly::ssl::OpenSSLUtils::getTLSClientRandom(), folly::ssl::OpenSSLUtils::getTLSMasterKey(), handwrittenAtoiMeasure(), fizz::Sha< T >::hash(), folly::LogName::hash(), folly::ssl::OpenSSLHash::Hmac::hash_init(), folly::ssl::OpenSSLHash::Digest::hash_update(), folly::ssl::OpenSSLHash::Hmac::hash_update(), folly::detail::TransparentRangeHash< detail::ValueTypeForTransparentConversionToRange< T >::type >::hashImpl(), fizz::Sha< T >::hmac(), folly::symbolizer::Dwarf::LineNumberVM::init(), folly::detail::internalSplit(), folly::RecordIOReader::Iterator::Iterator(), lexicalCastMeasure(), folly::SSLContext::loadCertificateFromBufferPEM(), folly::SSLContext::loadPrivateKeyFromBufferPEM(), folly::makeConversionError(), fizz::test::MATCHER_P(), proxygen::md5Encode(), SimpleDigest< MergeSize >::merge(), folly::TDigest::merge(), folly::mmapFileCopy(), folly::symbolizer::Dwarf::Section::next(), proxygen::HTTP1xCodec::onHeaderField(), proxygen::RFC1867Codec::onHeadersComplete(), proxygen::HTTP1xCodec::onIngress(), folly::gen::StreamSplitter< Callback >::operator()(), EqTraits::operator()(), KeyConvertTraits::operator()(), folly::hasher< folly::Range< T * >, std::enable_if_t< std::is_integral< T >::value, void > >::operator()(), folly::operator<<(), folly::operator==(), proxygen::ParseURL::parse(), folly::bser::parseBser(), folly::CustomLogFormatter::parseFormatString(), ReadStats::parseMessage(), proxygen::GzipHeaderCodec::parseNameValues(), folly::parseTo(), folly::AsyncIOOp::pread(), fizz::CertUtils::prepareSignData(), folly::prettyToDouble(), folly::PriorityLifoSemMPMCQueue< T, kBehavior >::PriorityLifoSemMPMCQueue(), folly::io::detail::Writable< Appender >::push(), folly::io::detail::Writable< Appender >::pushAtMost(), proxygen::HTTP1xCodec::pushHeaderNameAndValue(), folly::AsyncIOOp::pwrite(), folly::qfind(), readCertFromData(), folly::ssl::OpenSSLCertUtils::readCertsFromBuffer(), proxygen::HTTPHeaders::remove(), folly::rfind(), fizz::detail::rsaPssSign(), fizz::detail::rsaPssVerify(), folly::run(), folly::symbolizer::Dwarf::Section::Section(), fizz::server::SlidingBloomReplayCache::set(), folly::MacAddress::setFromBinary(), folly::SocketAddress::setFromPath(), folly::setThreadName(), folly::symbolizer::Dwarf::Path::size(), folly::io::test::StreamingCompressionTest::split(), folly::Range< unsigned char * >::split_step(), proxygen::HTTPMessage::splitNameValue(), folly::gen::detail::splitPrefix(), proxygen::HPACKHeaderName::storeAddress(), folly::stringPieceDel(), folly::stringPieceDup(), folly::stringToLogLevel(), proxygen::ParseURL::stripBrackets(), folly::json::stripComments(), fizz::server::SlidingBloomReplayCache::test(), folly::TEST(), TEST(), TEST_F(), fizz::testing::TEST_P(), folly::io::test::TEST_P(), fizz::server::SlidingBloomReplayCache::testAndSet(), testRangeFunc(), folly::test::testVarint(), folly::toAppend(), folly::toLowerAscii(), proxygen::HTTPHeaders::transferHeaderIfPresent(), fizz::transformBufferBlocks(), fizz::trimBytes(), folly::io::Codec::uncompress(), folly::io::StreamCodec::uncompressStream(), folly::detail::SlowFingerprint< BITS >::update(), folly::uriEscape(), folly::uriUnescape(), proxygen::CodecUtil::validateHeaderName(), folly::recordio_helpers::validateRecord(), folly::IOBuf::wrapBuffer(), folly::gen::detail::FileWriter::write(), folly::writeFileAtomic(), folly::writeFileAtomicNoThrow(), folly::ImmediateFileWriter::writeMessage(), and fizz::XOR().

431  {
432  // It would be nice to assert(b_ <= e_) here. This can be achieved even
433  // in a C++11 compatible constexpr function:
434  // http://ericniebler.com/2014/09/27/assert-and-constexpr-in-cxx11/
435  // Unfortunately current gcc versions have a bug causing it to reject
436  // this check in a constexpr function:
437  // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71448
438  return size_type(e_ - b_);
439  }
Iter e_
Definition: Range.h:1099
std::size_t size_type
Definition: Range.h:174
Iter b_
Definition: Range.h:1099
template<class Iter>
Range folly::Range< Iter >::split_step ( value_type  delimiter)
inline

Splits this Range [b, e) in the position i dictated by the next occurence of delimiter.

Returns a new Range [b, i) and adjusts this range to start right after the delimiter's position. This range will be empty if the delimiter is not found. If called on an empty Range, both this and the returned Range will be empty.

Example:

folly::StringPiece s("sample string for split_next"); auto p = s.split_step(' ');

// prints "string for split_next" cout << s << endl;

// prints "sample" cout << p << endl;

Example 2:

void tokenize(StringPiece s, char delimiter) { while (!s.empty()) { cout << s.split_step(delimiter); } }

Author
: Marcelo Juchem marce.nosp@m.lo@f.nosp@m.b.com

Definition at line 1001 of file Range.h.

Referenced by TEST().

1001  {
1002  auto i = std::find(b_, e_, delimiter);
1003  Range result(b_, i);
1004 
1005  b_ = i == e_ ? e_ : std::next(i);
1006 
1007  return result;
1008  }
Iter e_
Definition: Range.h:1099
constexpr Range()
Definition: Range.h:200
Iter b_
Definition: Range.h:1099
def next(obj)
Definition: ast.py:58
template<class Iter>
Range folly::Range< Iter >::split_step ( Range< Iter >  delimiter)
inline

Definition at line 1010 of file Range.h.

1010  {
1011  auto i = find(delimiter);
1012  Range result(b_, i == std::string::npos ? size() : i);
1013 
1014  b_ = result.end() == e_
1015  ? e_
1016  : std::next(
1017  result.end(),
1018  typename std::iterator_traits<Iter>::difference_type(
1019  delimiter.size()));
1020 
1021  return result;
1022  }
Iter e_
Definition: Range.h:1099
size_type find(const_range_type str) const
Definition: Range.h:721
constexpr size_type size() const
Definition: Range.h:431
constexpr Range()
Definition: Range.h:200
Iter b_
Definition: Range.h:1099
def next(obj)
Definition: ast.py:58
template<class Iter>
template<typename TProcess , typename... Args>
auto folly::Range< Iter >::split_step ( value_type  delimiter,
TProcess &&  process,
Args &&...  args 
) -> decltype(process(std::declval<Range>(), std::forward<Args>(args)...))
inline

Convenience method that calls split_step() and passes the result to a functor, returning whatever the functor does. Any additional arguments args passed to this function are perfectly forwarded to the functor.

Say you have a functor with this signature:

Foo fn(Range r) { }

split_step()'s return type will be Foo. It works just like:

auto result = fn(myRange.split_step(' '));

A functor returning void is also supported.

Example:

void do_some_parsing(folly::StringPiece s) { auto version = s.split_step(' ', [&](folly::StringPiece x) { if (x.empty()) { throw std::invalid_argument("empty string"); } return std::strtoull(x.begin(), x.end(), 16); });

// ... }

struct Foo { void parse(folly::StringPiece s) { s.split_step(' ', parse_field, bar, 10); s.split_step('', parse_field, baz, 20);

auto const kludge = [](folly::StringPiece x, int &out, int def) { if (x == "null") { out = 0; } else { parse_field(x, out, def); } };

s.split_step('', kludge, gaz); s.split_step(' ', kludge, foo); }

private: int bar; int baz; int gaz; int foo;

static parse_field(folly::StringPiece s, int &out, int def) { try { out = folly::to<int>(s); } catch (std::exception const &) { value = def; } } };

Author
: Marcelo Juchem marce.nosp@m.lo@f.nosp@m.b.com

Definition at line 1087 of file Range.h.

1088  {
1089  return process(split_step(delimiter), std::forward<Args>(args)...);
1090  }
Range split_step(value_type delimiter)
Definition: Range.h:1001
template<class Iter>
template<typename TProcess , typename... Args>
auto folly::Range< Iter >::split_step ( Range< Iter >  delimiter,
TProcess &&  process,
Args &&...  args 
) -> decltype(process(std::declval<Range>(), std::forward<Args>(args)...))
inline

Definition at line 1093 of file Range.h.

1094  {
1095  return process(split_step(delimiter), std::forward<Args>(args)...);
1096  }
Range split_step(value_type delimiter)
Definition: Range.h:1001
template<class Iter>
constexpr Iter folly::Range< Iter >::start ( ) const
inline
template<class Iter>
bool folly::Range< Iter >::startsWith ( const const_range_type other) const
inline

Does this Range start with another range?

Definition at line 828 of file Range.h.

Referenced by folly::getXlogCategoryNameForFile(), proxygen::HeaderDecodeInfo::onHeader(), proxygen::RFC2616::parseByteRangeSpec(), folly::parseLogConfig(), ReadStats::parseMessage(), folly::prettyToDouble(), folly::symbolizer::Dwarf::Section::Section(), and TEST().

828  {
829  return size() >= other.size() &&
830  castToConst().subpiece(0, other.size()) == other;
831  }
constexpr size_type size() const
Definition: Range.h:431
const_range_type castToConst() const
Definition: Range.h:598
template<class Iter>
bool folly::Range< Iter >::startsWith ( value_type  c) const
inline

Definition at line 832 of file Range.h.

832  {
833  return !empty() && front() == c;
834  }
constexpr bool empty() const
Definition: Range.h:443
value_type & front()
Definition: Range.h:464
char c
template<class Iter>
template<class Comp >
bool folly::Range< Iter >::startsWith ( const const_range_type other,
Comp &&  eq 
) const
inline

Definition at line 837 of file Range.h.

837  {
838  if (size() < other.size()) {
839  return false;
840  }
841  auto const trunc = subpiece(0, other.size());
842  return std::equal(
843  trunc.begin(), trunc.end(), other.begin(), std::forward<Comp>(eq));
844  }
constexpr size_type size() const
Definition: Range.h:431
Range subpiece(size_type first, size_type length=npos) const
Definition: Range.h:686
template<class Iter>
std::string folly::Range< Iter >::str ( ) const
inline

Definition at line 591 of file Range.h.

Referenced by folly::FunctionScheduler::addFunctionConsistentDelay(), folly::FunctionScheduler::addFunctionOnce(), folly::FunctionScheduler::addFunctionUniformDistribution(), wangle::LoadShedConfiguration::addWhitelistAddr(), folly::AsyncFileWriter::AsyncFileWriter(), BENCHMARK(), BENCHMARK_RELATIVE(), proxygen::HTTPMessage::createUrl(), folly::NestedCommandLineApp::doRun(), example::ExampleObject::ExampleObject(), folly::symbolizer::test::expect(), folly::settings::Snapshot::getAsString(), folly::symbolizer::ElfCache::getFile(), fizz::Factory::getHkdfPrefix(), proxygen::compress::CompressionSimulator::getScheme(), folly::settings::getSettingsMeta(), proxygen::ParseURL::hostAndPort(), proxygen::ParseURL::hostIsIPAddress(), folly::ImmediateFileWriter::ImmediateFileWriter(), folly::LogHandlerConfig::LogHandlerConfig(), my::makeConversionError(), folly::NestedCommandLineApp::NestedCommandLineApp(), proxygen::RFC1867Codec::onHeadersComplete(), StubLogger::operator()(), proxygen::ParseURL::parse(), proxygen::SPDYCodec::parseHeaders(), proxygen::ParseURL::parseNonFully(), LoggerTest::pathBasename(), folly::PrintTo(), folly::FileHandlerFactory::WriterFactory::processOption(), folly::StreamHandlerFactory::WriterFactory::processOption(), folly::settings::Snapshot::resetToDefault(), proxygen::HTTPRequestVerifier::setAuthority(), folly::settings::detail::SettingCore< T >::setFromString(), folly::settings::Snapshot::setFromString(), proxygen::HTTPMessage::setMethod(), folly::NamedThreadFactory::setNamePrefix(), proxygen::HTTPRequestVerifier::setPath(), folly::setThreadName(), folly::FunctionScheduler::setThreadName(), proxygen::HTTPMessage::setURL(), proxygen::HTTPMessage::splitNameValue(), folly::symbolizer::test::TEST(), fizz::testing::TEST(), folly::test::TEST(), TEST(), fizz::test::TEST_F(), fizz::testing::TEST_P(), folly::TestLogHandlerFactory::TestLogHandlerFactory(), folly::test::WriteFileAtomic::tmpPath(), folly::IPAddressV4::toLong(), ReadStats::trailingData(), folly::LoggerDB::unregisterHandlerFactory(), proxygen::URL::URL(), folly::writeFileAtomic(), folly::AsyncFileWriter::writeMessage(), and folly::FunctionScheduler::~FunctionScheduler().

591  {
592  return to<std::string>();
593  }
template<class Iter>
Range folly::Range< Iter >::subpiece ( size_type  first,
size_type  length = npos 
) const
inline

Definition at line 686 of file Range.h.

Referenced by BENCHMARK(), clibAtoiMeasure(), follyAtoiMeasure(), folly::format_value::formatNumber(), folly::experimental::EnvironmentState::fromCurrentEnvironment(), getContainingDirectory(), folly::LogMessage::getFileBaseName(), folly::getLinuxVersion(), handwrittenAtoiMeasure(), folly::detail::internalSplit(), lexicalCastMeasure(), Lines_Gen(), ReadStats::messageReceived(), folly::compression::BitVectorEncoder< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::openList(), folly::compression::EliasFanoEncoderV2< Value, SkipValue, kSkipQuantum, kForwardQuantum >::Layout::openList(), proxygen::ParseURL::parse(), ReadStats::parseMessage(), proxygen::ParseURL::parseNonFully(), LoggerTest::pathBasename(), folly::setThreadName(), folly::io::test::StreamingCompressionTest::split(), proxygen::HTTPMessage::splitNameValue(), proxygen::ParseURL::stripBrackets(), folly::json::stripComments(), TEST(), and proxygen::validateScheme().

686  {
687  if (UNLIKELY(first > size())) {
688  throw_exception<std::out_of_range>("index out of range");
689  }
690 
691  return Range(b_ + first, std::min(length, size() - first));
692  }
constexpr size_type size() const
Definition: Range.h:431
LogLevel min
Definition: LogLevel.cpp:30
constexpr Range()
Definition: Range.h:200
#define UNLIKELY(x)
Definition: Likely.h:48
Iter b_
Definition: Range.h:1099
constexpr detail::First first
Definition: Base-inl.h:2553
template<class Iter>
void folly::Range< Iter >::subtract ( size_type  n)
inline

Definition at line 679 of file Range.h.

Referenced by folly::gen::detail::SplitStringSource< DelimiterType >::apply(), ReadStats::parseMessage(), and TEST().

679  {
680  if (UNLIKELY(n > size())) {
681  throw_exception<std::out_of_range>("index out of range");
682  }
683  e_ -= n;
684  }
Iter e_
Definition: Range.h:1099
constexpr size_type size() const
Definition: Range.h:431
#define UNLIKELY(x)
Definition: Likely.h:48
template<class Iter>
void folly::Range< Iter >::swap ( Range< Iter > &  rhs)
inline

Definition at line 820 of file Range.h.

Referenced by folly::swap().

820  {
821  std::swap(b_, rhs.b_);
822  std::swap(e_, rhs.e_);
823  }
Iter e_
Definition: Range.h:1099
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
void swap(Range< Iter > &lhs, Range< Iter > &rhs)
Definition: Range.h:1106
Iter b_
Definition: Range.h:1099
template<class Iter>
template<typename Tgt , typename... Args>
constexpr std::enable_if_t< std::is_constructible<Tgt, Iter const&, size_type>::value, Tgt> folly::Range< Iter >::to ( Args &&...  args) const
inlinenoexcept

explicit non-operator conversion to any compatible type

A compatible type is one which is constructible with an iterator and a size (preferred), or a pair of iterators (fallback), passed by const-ref.

Participates in overload resolution precisely when the target type is compatible. This allows is_invocable compile-time checks to work.

Provided in addition to the explicit operator conversion to permit passing additional arguments to the target type constructor. A canonical example of an additional argument might be an allocator, where the target type is some specialization of std::vector or std::basic_string in a context which requires a non-default-constructed allocator.

Definition at line 574 of file Range.h.

576  {
577  return Tgt(b_, walk_size(), static_cast<Args&&>(args)...);
578  }
constexpr size_type walk_size() const
Definition: Range.h:440
Iter b_
Definition: Range.h:1099
template<class Iter>
template<typename Tgt , typename... Args>
constexpr std::enable_if_t< !std::is_constructible<Tgt, Iter const&, size_type>::value && std::is_constructible<Tgt, Iter const&, Iter const&>::value, Tgt> folly::Range< Iter >::to ( Args &&...  args) const
inlinenoexcept

Definition at line 584 of file Range.h.

586  {
587  return Tgt(b_, e_, static_cast<Args&&>(args)...);
588  }
Iter e_
Definition: Range.h:1099
Iter b_
Definition: Range.h:1099
template<class Iter>
std::string folly::Range< Iter >::toString ( ) const
inline

Definition at line 594 of file Range.h.

Referenced by folly::FormatValue< dynamic >::format(), and folly::experimental::EnvironmentState::fromCurrentEnvironment().

594  {
595  return to<std::string>();
596  }
template<class Iter>
void folly::Range< Iter >::uncheckedAdvance ( size_type  n)
inline

Definition at line 695 of file Range.h.

Referenced by folly::LogName::cmp(), folly::io::StreamCodec::doUncompress(), folly::io::test::StreamingCompressionTest::split(), and folly::tryDecodeVarint().

695  {
696  assert(n <= size());
697  b_ += n;
698  }
constexpr size_type size() const
Definition: Range.h:431
Iter b_
Definition: Range.h:1099
template<class Iter>
Range folly::Range< Iter >::uncheckedSubpiece ( size_type  first,
size_type  length = npos 
) const
inline

Definition at line 705 of file Range.h.

705  {
706  assert(first <= size());
707  return Range(b_ + first, std::min(length, size() - first));
708  }
constexpr size_type size() const
Definition: Range.h:431
LogLevel min
Definition: LogLevel.cpp:30
constexpr Range()
Definition: Range.h:200
Iter b_
Definition: Range.h:1099
constexpr detail::First first
Definition: Base-inl.h:2553
template<class Iter>
void folly::Range< Iter >::uncheckedSubtract ( size_type  n)
inline

Definition at line 700 of file Range.h.

700  {
701  assert(n <= size());
702  e_ -= n;
703  }
Iter e_
Definition: Range.h:1099
constexpr size_type size() const
Definition: Range.h:431
template<class Iter>
constexpr size_type folly::Range< Iter >::walk_size ( ) const
inline

Definition at line 440 of file Range.h.

440  {
441  return size_type(std::distance(b_, e_));
442  }
Iter e_
Definition: Range.h:1099
std::size_t size_type
Definition: Range.h:174
Iter b_
Definition: Range.h:1099

Member Data Documentation

template<class Iter>
Iter folly::Range< Iter >::b_
private

Definition at line 1099 of file Range.h.

Referenced by folly::Range< unsigned char * >::swap().

template<class Iter>
Iter folly::Range< Iter >::e_
private

Definition at line 1099 of file Range.h.

Referenced by folly::Range< unsigned char * >::swap().

template<class Iter>
const Range< Iter >::size_type folly::Range< Iter >::npos = std::string::npos
static

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