proxygen
folly::gen::detail::StringResplitter::Generator< Source > Class Template Reference

#include <String-inl.h>

Inheritance diagram for folly::gen::detail::StringResplitter::Generator< Source >:
folly::gen::GenImpl< StringPiece, Generator< Source > > folly::gen::FBounded< Self >

Public Member Functions

 Generator (Source source, char delimiter, bool keepDelimiter)
 
template<class Body >
bool apply (Body &&body) const
 
- Public Member Functions inherited from folly::gen::GenImpl< StringPiece, Generator< Source > >
bool apply (Handler &&handler) const
 
void foreach (Body &&body) const
 
- Public Member Functions inherited from folly::gen::FBounded< Self >
const Self & self () const
 
Self & self ()
 

Static Public Attributes

static constexpr bool infinite = Source::infinite
 
- Static Public Attributes inherited from folly::gen::GenImpl< StringPiece, Generator< Source > >
static constexpr bool infinite
 

Private Attributes

Source source_
 
char delimiter_
 
bool keepDelimiter_
 

Additional Inherited Members

- Public Types inherited from folly::gen::GenImpl< StringPiece, Generator< Source > >
typedef StringPiece ValueType
 
typedef std::decay< StringPiece >::type StorageType
 
- Protected Member Functions inherited from folly::gen::GenImpl< StringPiece, Generator< Source > >
 GenImpl ()=default
 
 GenImpl (GenImpl &&)=default
 
 GenImpl (const GenImpl &)=default
 
GenImploperator= (GenImpl &&)=default
 
GenImploperator= (const GenImpl &)=default
 

Detailed Description

template<class Source>
class folly::gen::detail::StringResplitter::Generator< Source >

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

Constructor & Destructor Documentation

template<class Source >
folly::gen::detail::StringResplitter::Generator< Source >::Generator ( Source  source,
char  delimiter,
bool  keepDelimiter 
)
inline

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

227  : source_(std::move(source)),
228  delimiter_(delimiter),
229  keepDelimiter_(keepDelimiter) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567

Member Function Documentation

template<class Source >
template<class Body >
bool folly::gen::detail::StringResplitter::Generator< Source >::apply ( Body &&  body) const
inline

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

References folly::Range< Iter >::back(), folly::Range< Iter >::empty(), folly::Range< Iter >::pop_back(), s, and folly::gen::streamSplitter().

232  {
233  auto splitter =
234  streamSplitter(this->delimiter_, [this, &body](StringPiece s) {
235  // The stream ended with a delimiter; our contract is to swallow
236  // the final empty piece.
237  if (s.empty()) {
238  return true;
239  }
240  if (s.back() != this->delimiter_) {
241  return body(s);
242  }
243  if (!keepDelimiter_) {
244  s.pop_back(); // Remove the 1-character delimiter
245  }
246  return body(s);
247  });
248  if (!source_.apply(splitter)) {
249  return false;
250  }
251  return splitter.flush();
252  }
StreamSplitter< Callback > streamSplitter(char delimiter, Callback &&pieceCb, uint64_t capacity=0)
Definition: String.h:239
static set< string > s
Range< const char * > StringPiece

Member Data Documentation

template<class Source >
char folly::gen::detail::StringResplitter::Generator< Source >::delimiter_
private

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

template<class Source >
constexpr bool folly::gen::detail::StringResplitter::Generator< Source >::infinite = Source::infinite
static

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

template<class Source >
bool folly::gen::detail::StringResplitter::Generator< Source >::keepDelimiter_
private

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

template<class Source >
Source folly::gen::detail::StringResplitter::Generator< Source >::source_
private

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


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