proxygen
folly::IOBuf::Iterator Class Reference

#include <IOBuf.h>

Inheritance diagram for folly::IOBuf::Iterator:
folly::detail::IteratorFacade< IOBuf::Iterator, ByteRange const, std::forward_iterator_tag >

Public Member Functions

 Iterator (const IOBuf *pos, const IOBuf *end)
 
 Iterator ()
 
 Iterator (Iterator const &rhs)
 
Iteratoroperator= (Iterator const &rhs)
 
const ByteRangedereference () const
 
bool equal (const Iterator &other) const
 
void increment ()
 
- Public Member Functions inherited from folly::detail::IteratorFacade< IOBuf::Iterator, ByteRange const, std::forward_iterator_tag >
bool operator== (IOBuf::Iteratorconst &rhs) const
 
std::enable_if< std::is_convertible< IOBuf::Iterator, D2 >::value, bool >::type operator== (D2 const &rhs) const
 
bool operator!= (IOBuf::Iteratorconst &rhs) const
 
bool operator!= (D2 const &rhs) const
 
ByteRange const & operator* () const
 
ByteRange const * operator-> () const
 
IOBuf::Iteratoroperator++ ()
 
IOBuf::Iterator operator++ (int)
 
IOBuf::Iteratoroperator-- ()
 
IOBuf::Iterator operator-- (int)
 

Private Member Functions

void setVal ()
 
void adjustForEnd ()
 

Private Attributes

const IOBufpos_ {nullptr}
 
const IOBufend_ {nullptr}
 
ByteRange val_
 

Additional Inherited Members

- Public Types inherited from folly::detail::IteratorFacade< IOBuf::Iterator, ByteRange const, std::forward_iterator_tag >
using value_type = ByteRange const
 
using reference = value_type &
 
using pointer = value_type *
 
using difference_type = ssize_t
 
using iterator_category = std::forward_iterator_tag
 

Detailed Description

Definition at line 1619 of file IOBuf.h.

Constructor & Destructor Documentation

folly::IOBuf::Iterator::Iterator ( const IOBuf pos,
const IOBuf end 
)
inlineexplicit

Definition at line 1629 of file IOBuf.h.

1629  : pos_(pos), end_(end) {
1630  // Sadly, we must return by const reference, not by value.
1631  if (pos_) {
1632  setVal();
1633  }
1634  }
Iterator end() const
Definition: IOBuf.h:1687
const IOBuf * pos_
Definition: IOBuf.h:1679
const IOBuf * end_
Definition: IOBuf.h:1680
folly::IOBuf::Iterator::Iterator ( )
inline

Definition at line 1636 of file IOBuf.h.

1636 {}
folly::IOBuf::Iterator::Iterator ( Iterator const &  rhs)
inline

Definition at line 1638 of file IOBuf.h.

1638 : Iterator(rhs.pos_, rhs.end_) {}
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649

Member Function Documentation

void folly::IOBuf::Iterator::adjustForEnd ( )
inlineprivate

Definition at line 1670 of file IOBuf.h.

References end_.

1670  {
1671  if (pos_ == end_) {
1672  pos_ = end_ = nullptr;
1673  val_ = ByteRange();
1674  } else {
1675  setVal();
1676  }
1677  }
Range< const unsigned char * > ByteRange
Definition: Range.h:1163
const IOBuf * pos_
Definition: IOBuf.h:1679
const IOBuf * end_
Definition: IOBuf.h:1680
const ByteRange& folly::IOBuf::Iterator::dereference ( ) const
inline

Definition at line 1649 of file IOBuf.h.

1649  {
1650  return val_;
1651  }
bool folly::IOBuf::Iterator::equal ( const Iterator other) const
inline

Definition at line 1653 of file IOBuf.h.

References end_, end_, and pos_.

1653  {
1654  // We must compare end_ in addition to pos_, because forward traversal
1655  // requires that if two iterators are equal (a == b) and dereferenceable,
1656  // then ++a == ++b.
1657  return pos_ == other.pos_ && end_ == other.end_;
1658  }
const IOBuf * pos_
Definition: IOBuf.h:1679
const IOBuf * end_
Definition: IOBuf.h:1680
void folly::IOBuf::Iterator::increment ( )
inline

Definition at line 1660 of file IOBuf.h.

1660  {
1661  pos_ = pos_->next();
1662  adjustForEnd();
1663  }
IOBuf * next()
Definition: IOBuf.h:600
const IOBuf * pos_
Definition: IOBuf.h:1679
Iterator& folly::IOBuf::Iterator::operator= ( Iterator const &  rhs)
inline

Definition at line 1640 of file IOBuf.h.

References end_, end_, and pos_.

1640  {
1641  pos_ = rhs.pos_;
1642  end_ = rhs.end_;
1643  if (pos_) {
1644  setVal();
1645  }
1646  return *this;
1647  }
FOLLY_PUSH_WARNING RHS rhs
Definition: Traits.h:649
const IOBuf * pos_
Definition: IOBuf.h:1679
const IOBuf * end_
Definition: IOBuf.h:1680
void folly::IOBuf::Iterator::setVal ( )
inlineprivate

Definition at line 1666 of file IOBuf.h.

1666  {
1667  val_ = ByteRange(pos_->data(), pos_->tail());
1668  }
const uint8_t * tail() const
Definition: IOBuf.h:516
const uint8_t * data() const
Definition: IOBuf.h:499
Range< const unsigned char * > ByteRange
Definition: Range.h:1163
const IOBuf * pos_
Definition: IOBuf.h:1679

Member Data Documentation

const IOBuf* folly::IOBuf::Iterator::end_ {nullptr}
private

Definition at line 1680 of file IOBuf.h.

Referenced by equal(), and operator=().

const IOBuf* folly::IOBuf::Iterator::pos_ {nullptr}
private

Definition at line 1679 of file IOBuf.h.

Referenced by equal(), and operator=().

ByteRange folly::IOBuf::Iterator::val_
private

Definition at line 1681 of file IOBuf.h.


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