proxygen
folly::gen::detail Namespace Reference

Classes

class  Append
 
class  Batch
 
class  Chain
 
class  ChunkedRangeSource
 
class  ClosableMPMCQueue
 
class  Collect
 
class  CollectTemplate
 
class  Composed
 
class  Composer
 
class  Concat
 
class  Contains
 
class  CopiedSource
 
class  Count
 
class  Cycle
 
class  Dereference
 
class  Distinct
 
class  Empty
 
struct  FBounded
 
class  FileReader
 
class  FileWriter
 
class  Filter
 
class  First
 
class  FoldLeft
 
struct  GeneratorBuilder
 
class  GroupBy
 
class  GroupByAdjacent
 
class  GuardImpl
 
class  Indirect
 
class  InfiniteImpl
 
class  Interleave
 
class  IsEmpty
 
class  IStreamByLine
 
class  Map
 
class  MergeTuples
 
class  Min
 
class  Order
 
class  Parallel
 
class  PMap
 
class  RangeConcat
 
class  RangeImpl
 
class  RangeSource
 
class  RangeWithStepImpl
 
class  Reduce
 
class  ReferencedSource
 
class  Sample
 
class  SeqImpl
 
class  Sequence
 
class  SeqWithStepImpl
 
class  SingleCopy
 
class  SingleReference
 
class  Skip
 
class  SplitStringSource
 
class  SplitTo
 
class  Stride
 
class  StringResplitter
 
class  Sub
 
class  Sum
 
class  Take
 
class  TypeAssertion
 
class  Unsplit
 
class  UnsplitBuffer
 
class  Until
 
class  Unwrap
 
class  UnwrapOr
 
struct  ValueTypeOfRange
 
class  Visit
 
class  Window
 
class  Yield
 
class  Zip
 

Functions

template<class T >
T && operator| (Optional< T > &&opt, UnwrapOr< T > &&fallback)
 
template<class T >
Toperator| (Optional< T > &opt, UnwrapOr< T > &fallback)
 
template<class T >
const Toperator| (const Optional< T > &opt, const UnwrapOr< T > &fallback)
 
template<class T , class U , class R = typename std::enable_if< !std::is_same<T, U>::value, typename std::common_type<T, U>::type>::type>
operator| (Optional< T > &&opt, UnwrapOr< U > &&fallback)
 
template<class T , class U , class R = typename std::enable_if< !std::is_same<T, U>::value, typename std::common_type<T, U>::type>::type>
operator| (const Optional< T > &opt, UnwrapOr< U > &&fallback)
 
template<class T , class U , class R = typename std::enable_if< !std::is_same<T, U>::value, typename std::common_type<T, U>::type>::type>
operator| (Optional< T > &&opt, const UnwrapOr< U > &fallback)
 
template<class T , class U , class R = typename std::enable_if< !std::is_same<T, U>::value, typename std::common_type<T, U>::type>::type>
operator| (const Optional< T > &opt, const UnwrapOr< U > &fallback)
 
template<class T >
T && operator| (Optional< T > &&opt, const Unwrap &)
 
template<class T >
Toperator| (Optional< T > &opt, const Unwrap &)
 
template<class T >
const Toperator| (const Optional< T > &opt, const Unwrap &)
 
template<class... Types1, class... Types2>
auto add_to_tuple (std::tuple< Types1... > t1, std::tuple< Types2... > t2) -> std::tuple< Types1..., Types2... >
 
template<class... Types1, class Type2 >
auto add_to_tuple (std::tuple< Types1... > t1, Type2 &&t2) -> decltype(std::tuple_cat(std::move(t1), std::make_tuple(std::forward< Type2 >(t2))))
 
template<class Type1 , class... Types2>
auto add_to_tuple (Type1 &&t1, std::tuple< Types2... > t2) -> decltype(std::tuple_cat(std::make_tuple(std::forward< Type1 >(t1)), std::move(t2)))
 
template<class Type1 , class Type2 >
auto add_to_tuple (Type1 &&t1, Type2 &&t2) -> decltype(std::make_tuple(std::forward< Type1 >(t1), std::forward< Type2 >(t2)))
 
auto byLineImpl (File file, char delim, bool keepDelimiter)
 
size_t splitPrefix (StringPiece &in, StringPiece &prefix, char delimiter)
 
size_t splitPrefix (StringPiece &in, StringPiece &prefix, StringPiece delimiter)
 
size_t splitPrefix (StringPiece &in, StringPiece &prefix, MixedNewlines)
 
const char * ch (const unsigned char *p)
 
template<class Callback >
bool consumeFixedSizeChunks (Callback &cb, StringPiece &s, uint64_t maxLength)
 
template<class Callback >
bool consumeBufferPlus (Callback &cb, IOBuf &buf, StringPiece &s, uint64_t n)
 
template<class Target , class = void>
Target passthrough (Target target)
 

Function Documentation

template<class... Types1, class... Types2>
auto folly::gen::detail::add_to_tuple ( std::tuple< Types1... >  t1,
std::tuple< Types2... >  t2 
) -> std::tuple<Types1..., Types2...>

Definition at line 153 of file Combine-inl.h.

References folly::gen::move.

Referenced by folly::gen::detail::MergeTuples::operator()().

154  {
155  return std::tuple_cat(std::move(t1), std::move(t2));
156 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class... Types1, class Type2 >
auto folly::gen::detail::add_to_tuple ( std::tuple< Types1... >  t1,
Type2 &&  t2 
) -> decltype( std::tuple_cat(std::move(t1), std::make_tuple(std::forward<Type2>(t2))))

Definition at line 159 of file Combine-inl.h.

References std::tr1::make_tuple(), and folly::gen::move.

160  {
161  return std::tuple_cat(
162  std::move(t1), std::make_tuple(std::forward<Type2>(t2)));
163 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
tuple make_tuple()
Definition: gtest-tuple.h:675
template<class Type1 , class... Types2>
auto folly::gen::detail::add_to_tuple ( Type1 &&  t1,
std::tuple< Types2... >  t2 
) -> decltype( std::tuple_cat(std::make_tuple(std::forward<Type1>(t1)), std::move(t2)))

Definition at line 166 of file Combine-inl.h.

References std::tr1::make_tuple(), and folly::gen::move.

167  {
168  return std::tuple_cat(
169  std::make_tuple(std::forward<Type1>(t1)), std::move(t2));
170 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
tuple make_tuple()
Definition: gtest-tuple.h:675
template<class Type1 , class Type2 >
auto folly::gen::detail::add_to_tuple ( Type1 &&  t1,
Type2 &&  t2 
) -> decltype( std::make_tuple(std::forward<Type1>(t1), std::forward<Type2>(t2)))

Definition at line 173 of file Combine-inl.h.

References std::tr1::make_tuple().

174  {
175  return std::make_tuple(std::forward<Type1>(t1), std::forward<Type2>(t2));
176 }
tuple make_tuple()
Definition: gtest-tuple.h:675
auto folly::gen::detail::byLineImpl ( File  file,
char  delim,
bool  keepDelimiter 
)
inline

Definition at line 121 of file File-inl.h.

References folly::gen::fromFile(), folly::gen::move, and folly::gen::resplit().

Referenced by folly::gen::byLine(), and folly::gen::byLineFull().

121  {
122  // clang-format off
123  return fromFile(std::move(file))
124  | eachAs<StringPiece>()
125  | resplit(delim, keepDelimiter);
126  // clang-format on
127 }
S resplit(char delimiter, bool keepDelimiter=false)
Definition: String.h:56
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
S fromFile(File file, size_t bufferSize=4096)
Definition: File.h:38
const char* folly::gen::detail::ch ( const unsigned char *  p)
inline

Definition at line 91 of file String-inl.h.

Referenced by consumeBufferPlus(), and folly::gen::StreamSplitter< Callback >::flush().

91  {
92  return reinterpret_cast<const char*>(p);
93 }
template<class Callback >
bool folly::gen::detail::consumeBufferPlus ( Callback &  cb,
IOBuf buf,
StringPiece s,
uint64_t  n 
)

Definition at line 113 of file String-inl.h.

References folly::Range< Iter >::advance(), folly::IOBuf::append(), ch(), folly::IOBuf::clear(), folly::Range< Iter >::data(), folly::IOBuf::data(), folly::IOBuf::length(), folly::IOBuf::reserve(), and folly::IOBuf::writableTail().

Referenced by folly::gen::StreamSplitter< Callback >::operator()().

113  {
114  buf.reserve(0, n);
115  memcpy(buf.writableTail(), s.data(), n);
116  buf.append(n);
117  s.advance(n);
118  if (!cb(StringPiece(detail::ch(buf.data()), buf.length()))) {
119  return false;
120  }
121  buf.clear();
122  return true;
123 }
auto ch
static set< string > s
Range< const char * > StringPiece
template<class Callback >
bool folly::gen::detail::consumeFixedSizeChunks ( Callback &  cb,
StringPiece s,
uint64_t  maxLength 
)

Definition at line 97 of file String-inl.h.

References folly::Range< Iter >::advance(), folly::Range< Iter >::begin(), folly::Range< Iter >::empty(), and folly::Range< Iter >::size().

Referenced by folly::gen::StreamSplitter< Callback >::operator()().

97  {
98  while (!s.empty()) {
99  auto num_to_add = s.size();
100  if (maxLength) {
101  num_to_add = std::min<uint64_t>(num_to_add, maxLength);
102  }
103  if (!cb(StringPiece(s.begin(), num_to_add))) {
104  return false;
105  }
106  s.advance(num_to_add);
107  }
108  return true;
109 }
static set< string > s
Range< const char * > StringPiece
template<class T >
T&& folly::gen::detail::operator| ( Optional< T > &&  opt,
UnwrapOr< T > &&  fallback 
)

Definition at line 2380 of file Base-inl.h.

References folly::gen::move, and T.

2380  {
2381  if (T* p = opt.get_pointer()) {
2382  return std::move(*p);
2383  }
2384  return std::move(fallback.value());
2385 }
#define T(v)
Definition: http_parser.c:233
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class T >
T& folly::gen::detail::operator| ( Optional< T > &  opt,
UnwrapOr< T > &  fallback 
)

Definition at line 2388 of file Base-inl.h.

References folly::Optional< Value >::get_pointer(), T, and folly::gen::detail::UnwrapOr< T >::value().

2388  {
2389  if (T* p = opt.get_pointer()) {
2390  return *p;
2391  }
2392  return fallback.value();
2393 }
#define T(v)
Definition: http_parser.c:233
template<class T >
const T& folly::gen::detail::operator| ( const Optional< T > &  opt,
const UnwrapOr< T > &  fallback 
)

Definition at line 2396 of file Base-inl.h.

References folly::Optional< Value >::get_pointer(), T, type, value, and folly::gen::detail::UnwrapOr< T >::value().

2396  {
2397  if (const T* p = opt.get_pointer()) {
2398  return *p;
2399  }
2400  return fallback.value();
2401 }
#define T(v)
Definition: http_parser.c:233
template<class T , class U , class R = typename std::enable_if< !std::is_same<T, U>::value, typename std::common_type<T, U>::type>::type>
R folly::gen::detail::operator| ( Optional< T > &&  opt,
UnwrapOr< U > &&  fallback 
)

Definition at line 2410 of file Base-inl.h.

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

2410  {
2411  if (T* p = opt.get_pointer()) {
2412  return std::move(*p);
2413  }
2414  return std::move(fallback.value());
2415 }
#define T(v)
Definition: http_parser.c:233
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class T , class U , class R = typename std::enable_if< !std::is_same<T, U>::value, typename std::common_type<T, U>::type>::type>
R folly::gen::detail::operator| ( const Optional< T > &  opt,
UnwrapOr< U > &&  fallback 
)

Definition at line 2423 of file Base-inl.h.

References folly::Optional< Value >::get_pointer(), folly::gen::move, T, type, and value.

2423  {
2424  if (const T* p = opt.get_pointer()) {
2425  return *p;
2426  }
2427  return std::move(fallback.value());
2428 }
#define T(v)
Definition: http_parser.c:233
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class T , class U , class R = typename std::enable_if< !std::is_same<T, U>::value, typename std::common_type<T, U>::type>::type>
R folly::gen::detail::operator| ( Optional< T > &&  opt,
const UnwrapOr< U > &  fallback 
)

Definition at line 2436 of file Base-inl.h.

References folly::gen::move, T, type, value, and folly::gen::detail::UnwrapOr< T >::value().

2436  {
2437  if (T* p = opt.get_pointer()) {
2438  return std::move(*p);
2439  }
2440  return fallback.value();
2441 }
#define T(v)
Definition: http_parser.c:233
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class T , class U , class R = typename std::enable_if< !std::is_same<T, U>::value, typename std::common_type<T, U>::type>::type>
R folly::gen::detail::operator| ( const Optional< T > &  opt,
const UnwrapOr< U > &  fallback 
)

Definition at line 2449 of file Base-inl.h.

References folly::Optional< Value >::get_pointer(), and folly::gen::detail::UnwrapOr< T >::value().

2449  {
2450  if (const T* p = opt.get_pointer()) {
2451  return *p;
2452  }
2453  return fallback.value();
2454 }
#define T(v)
Definition: http_parser.c:233
template<class T >
T&& folly::gen::detail::operator| ( Optional< T > &&  opt,
const Unwrap  
)

Definition at line 2465 of file Base-inl.h.

References folly::gen::move.

2465  {
2466  return std::move(opt.value());
2467 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class T >
T& folly::gen::detail::operator| ( Optional< T > &  opt,
const Unwrap  
)

Definition at line 2470 of file Base-inl.h.

References folly::Optional< Value >::value().

2470  {
2471  return opt.value();
2472 }
template<class T >
const T& folly::gen::detail::operator| ( const Optional< T > &  opt,
const Unwrap  
)

Definition at line 2475 of file Base-inl.h.

References folly::Optional< Value >::value().

2475  {
2476  return opt.value();
2477 }
template<class Target , class = void>
Target folly::gen::detail::passthrough ( Target  target)
inline

Hack for static for-like constructs

Definition at line 356 of file String-inl.h.

References folly::Delimiter, and FOLLY_PUSH_WARNING.

Referenced by BENCHMARK().

356  {
357  return target;
358 }
size_t folly::gen::detail::splitPrefix ( StringPiece in,
StringPiece prefix,
char  delimiter 
)
inline

Finds the first occurrence of delimiter in "in", advances "in" past the delimiter. Populates "prefix" with the consumed bytes, including the delimiter.

Returns the number of trailing bytes of "prefix" that make up the delimiter, or 0 if the delimiter was not found.

Definition at line 38 of file String-inl.h.

References folly::Range< Iter >::advance(), folly::Range< Iter >::assign(), folly::Range< Iter >::clear(), folly::Range< Iter >::data(), folly::Range< Iter >::find(), and folly::Range< const char * >::npos.

Referenced by folly::gen::detail::SplitStringSource< DelimiterType >::apply(), and folly::gen::StreamSplitter< Callback >::operator()().

38  {
39  size_t found = in.find(delimiter);
40  if (found != StringPiece::npos) {
41  ++found;
42  prefix.assign(in.data(), in.data() + found);
43  in.advance(found);
44  return 1;
45  }
46  prefix.clear();
47  return 0;
48 }
bool prefix(Cursor &c, uint32_t expected)
size_t folly::gen::detail::splitPrefix ( StringPiece in,
StringPiece prefix,
StringPiece  delimiter 
)
inline

As above, but supports multibyte delimiters.

Definition at line 54 of file String-inl.h.

References folly::Range< Iter >::advance(), folly::Range< Iter >::assign(), folly::Range< Iter >::clear(), folly::Range< Iter >::data(), folly::Range< Iter >::find(), folly::Range< const char * >::npos, and folly::Range< Iter >::size().

54  {
55  auto found = in.find(delimiter);
56  if (found != StringPiece::npos) {
57  found += delimiter.size();
58  prefix.assign(in.data(), in.data() + found);
59  in.advance(found);
60  return delimiter.size();
61  }
62  prefix.clear();
63  return 0;
64 }
bool prefix(Cursor &c, uint32_t expected)
size_t folly::gen::detail::splitPrefix ( StringPiece in,
StringPiece prefix,
MixedNewlines   
)
inline

As above, but splits by any of the EOL terms: ,
, or
.

Definition at line 69 of file String-inl.h.

References folly::Range< Iter >::advance(), folly::Range< Iter >::assign(), folly::Range< Iter >::clear(), folly::Range< Iter >::data(), folly::Range< Iter >::find_first_of(), and folly::Range< Iter >::removePrefix().

69  {
70  const auto kCRLF = "\r\n";
71  const size_t kLenCRLF = 2;
72 
73  auto p = in.find_first_of(kCRLF);
74  if (p != std::string::npos) {
75  const auto in_start = in.data();
76  size_t delim_len = 1;
77  in.advance(p);
78  // Either remove an MS-DOS CR-LF 2-byte newline, or eat 1 byte at a time.
79  if (in.removePrefix(kCRLF)) {
80  delim_len = kLenCRLF;
81  } else {
82  in.advance(delim_len);
83  }
84  prefix.assign(in_start, in.data());
85  return delim_len;
86  }
87  prefix.clear();
88  return 0;
89 }
bool prefix(Cursor &c, uint32_t expected)