proxygen
folly::gen::detail::SplitStringSource< DelimiterType > Class Template Reference

#include <String-inl.h>

Inheritance diagram for folly::gen::detail::SplitStringSource< DelimiterType >:
folly::gen::GenImpl< StringPiece, SplitStringSource< DelimiterType > > folly::gen::FBounded< Self >

Public Member Functions

 SplitStringSource (const StringPiece source, DelimiterType delimiter)
 
template<class Body >
bool apply (Body &&body) const
 
- Public Member Functions inherited from folly::gen::GenImpl< StringPiece, SplitStringSource< DelimiterType > >
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 ()
 

Private Attributes

StringPiece source_
 
DelimiterType delimiter_
 

Additional Inherited Members

- Public Types inherited from folly::gen::GenImpl< StringPiece, SplitStringSource< DelimiterType > >
typedef StringPiece ValueType
 
typedef std::decay< StringPiece >::type StorageType
 
- Static Public Attributes inherited from folly::gen::GenImpl< StringPiece, SplitStringSource< DelimiterType > >
static constexpr bool infinite
 
- Protected Member Functions inherited from folly::gen::GenImpl< StringPiece, SplitStringSource< DelimiterType > >
 GenImpl ()=default
 
 GenImpl (GenImpl &&)=default
 
 GenImpl (const GenImpl &)=default
 
GenImploperator= (GenImpl &&)=default
 
GenImploperator= (const GenImpl &)=default
 

Detailed Description

template<class DelimiterType = char>
class folly::gen::detail::SplitStringSource< DelimiterType >

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

Constructor & Destructor Documentation

template<class DelimiterType = char>
folly::gen::detail::SplitStringSource< DelimiterType >::SplitStringSource ( const StringPiece  source,
DelimiterType  delimiter 
)
inline

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

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

Member Function Documentation

template<class DelimiterType = char>
template<class Body >
bool folly::gen::detail::SplitStringSource< DelimiterType >::apply ( Body &&  body) const
inline

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

References folly::Range< Iter >::empty(), prefix(), folly::gen::detail::splitPrefix(), and folly::Range< Iter >::subtract().

279  {
280  StringPiece rest(source_);
282  while (size_t delim_len = splitPrefix(rest, prefix, this->delimiter_)) {
283  prefix.subtract(delim_len); // Remove the delimiter
284  if (!body(prefix)) {
285  return false;
286  }
287  }
288  if (!rest.empty()) {
289  if (!body(rest)) {
290  return false;
291  }
292  }
293  return true;
294  }
bool prefix(Cursor &c, uint32_t expected)
size_t splitPrefix(StringPiece &in, StringPiece &prefix, char delimiter)
Definition: String-inl.h:38
Range< const char * > StringPiece

Member Data Documentation

template<class DelimiterType = char>
DelimiterType folly::gen::detail::SplitStringSource< DelimiterType >::delimiter_
private

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

template<class DelimiterType = char>
StringPiece folly::gen::detail::SplitStringSource< DelimiterType >::source_
private

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


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