proxygen
folly::io::detail::Writable< Derived > Class Template Reference

#include <Cursor.h>

Public Member Functions

template<class T >
std::enable_if< std::is_arithmetic< T >::value >::type write (T value)
 
template<class T >
void writeBE (T value)
 
template<class T >
void writeLE (T value)
 
void push (const uint8_t *buf, size_t len)
 
void push (ByteRange buf)
 
size_t pushAtMost (ByteRange buf)
 
void push (Cursor cursor, size_t len)
 
size_t pushAtMost (Cursor cursor, size_t len)
 

Detailed Description

template<class Derived>
class folly::io::detail::Writable< Derived >

Definition at line 734 of file Cursor.h.

Member Function Documentation

template<class Derived>
void folly::io::detail::Writable< Derived >::push ( ByteRange  buf)
inline

Definition at line 762 of file Cursor.h.

762  {
763  if (this->pushAtMost(buf) != buf.size()) {
764  throw_exception<std::out_of_range>("overflow");
765  }
766  }
size_t pushAtMost(ByteRange buf)
Definition: Cursor.h:768
template<class Derived>
void folly::io::detail::Writable< Derived >::push ( Cursor  cursor,
size_t  len 
)
inline

push len bytes of data from input cursor, data could be in an IOBuf chain. If input cursor contains less than len bytes, or this cursor has less than len bytes writable space, an out_of_range exception will be thrown.

Definition at line 778 of file Cursor.h.

778  {
779  if (this->pushAtMost(cursor, len) != len) {
780  throw_exception<std::out_of_range>("overflow");
781  }
782  }
size_t pushAtMost(ByteRange buf)
Definition: Cursor.h:768
template<class Derived>
size_t folly::io::detail::Writable< Derived >::pushAtMost ( ByteRange  buf)
inline

Definition at line 768 of file Cursor.h.

768  {
769  Derived* d = static_cast<Derived*>(this);
770  return d->pushAtMost(buf.data(), buf.size());
771  }
template<class Derived>
size_t folly::io::detail::Writable< Derived >::pushAtMost ( Cursor  cursor,
size_t  len 
)
inline

Definition at line 784 of file Cursor.h.

784  {
785  size_t written = 0;
786  for (;;) {
787  auto currentBuffer = cursor.peekBytes();
788  const uint8_t* crtData = currentBuffer.data();
789  size_t available = currentBuffer.size();
790  if (available == 0) {
791  // end of buffer chain
792  return written;
793  }
794  // all data is in current buffer
795  if (available >= len) {
796  this->push(crtData, len);
797  cursor.skip(len);
798  return written + len;
799  }
800 
801  // write the whole current IOBuf
802  this->push(crtData, available);
803  cursor.skip(available);
804  written += available;
805  len -= available;
806  }
807  }
void push(const uint8_t *buf, size_t len)
Definition: Cursor.h:755
template<class Derived>
template<class T >
std::enable_if<std::is_arithmetic<T>::value>::type folly::io::detail::Writable< Derived >::write ( T  value)
inline

Definition at line 737 of file Cursor.h.

Referenced by makeBuf(), proxygen::makeBuf(), TEST(), and folly::TEST().

737  {
738  const uint8_t* u8 = reinterpret_cast<const uint8_t*>(&value);
739  Derived* d = static_cast<Derived*>(this);
740  d->push(u8, sizeof(T));
741  }
folly::std T
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
template<class Derived>
template<class T >
void folly::io::detail::Writable< Derived >::writeBE ( T  value)
inline
template<class Derived>
template<class T >
void folly::io::detail::Writable< Derived >::writeLE ( T  value)
inline

Definition at line 750 of file Cursor.h.

Referenced by proxygen::SPDYCodec::generateSettings(), and TEST().

750  {
751  Derived* d = static_cast<Derived*>(this);
752  d->write(Endian::little(value));
753  }
static T little(T x)
Definition: Bits.h:263
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)

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