proxygen
|
#include <Cursor.h>
Public Member Functions | |
Appender (IOBuf *buf, std::size_t growth) | |
uint8_t * | writableData () |
size_t | length () const |
void | append (size_t n) |
void | ensure (std::size_t n) |
size_t | pushAtMost (const uint8_t *buf, size_t len) |
void | printf (FOLLY_PRINTF_FORMAT const char *fmt,...) FOLLY_PRINTF_FORMAT_ATTR(2 |
void void | vprintf (const char *fmt, va_list ap) |
void | operator() (StringPiece sp) |
Public Member Functions inherited from folly::io::detail::Writable< Appender > | |
std::enable_if< std::is_arithmetic< T >::value >::type | write (T value) |
void | writeBE (T value) |
void | writeLE (T value) |
void | push (const uint8_t *buf, size_t len) |
void | push (ByteRange buf) |
void | push (Cursor cursor, size_t len) |
size_t | pushAtMost (ByteRange buf) |
size_t | pushAtMost (Cursor cursor, size_t len) |
Private Member Functions | |
bool | tryGrowChain () |
Private Attributes | |
IOBuf * | buffer_ |
IOBuf * | crtBuf_ |
std::size_t | growth_ |
Append to the end of a buffer chain, growing the chain (by allocating new buffers) in increments of at least growth bytes every time. Won't grow (and push() and ensure() will throw) if growth == 0.
TODO(tudorb): add a flavor of Appender that reallocates one IOBuf instead of chaining.
|
inline |
|
inline |
Mark n bytes (must be <= length()) as appended, as per the IOBuf::append() method.
Definition at line 986 of file Cursor.h.
References folly::io::detail::CursorBase< Derived, BufType >::crtBuf_.
Referenced by vprintf().
|
inline |
Ensure at least n contiguous bytes available to write. Postcondition: length() >= n.
Definition at line 994 of file Cursor.h.
References folly::io::detail::CursorBase< Derived, BufType >::buffer_, folly::IOBuf::create(), folly::io::detail::CursorBase< Derived, BufType >::crtBuf_, folly::io::detail::CursorBase< Derived, BufType >::length(), LIKELY, and max.
Referenced by vprintf().
|
inline |
Definition at line 978 of file Cursor.h.
References folly::io::detail::CursorBase< Derived, BufType >::crtBuf_.
Referenced by vprintf().
|
inline |
Definition at line 1080 of file Cursor.h.
void folly::io::Appender::printf | ( | FOLLY_PRINTF_FORMAT const char * | fmt, |
... | |||
) |
|
inline |
Definition at line 1011 of file Cursor.h.
References append(), FOLLY_PRINTF_FORMAT, FOLLY_PRINTF_FORMAT_ATTR, folly::io::detail::CursorBase< Derived, BufType >::length(), LIKELY, and UNLIKELY.
|
inlineprivate |
Definition at line 1085 of file Cursor.h.
References folly::io::detail::CursorBase< Derived, BufType >::buffer_, folly::IOBuf::create(), and folly::io::detail::CursorBase< Derived, BufType >::crtBuf_.
void folly::io::Appender::vprintf | ( | const char * | fmt, |
va_list | ap | ||
) |
Definition at line 33 of file Cursor.cpp.
References append(), ensure(), length(), SCOPE_EXIT, and writableData().
Referenced by printf().
|
inline |
Definition at line 974 of file Cursor.h.
References folly::io::detail::CursorBase< Derived, BufType >::crtBuf_.
Referenced by vprintf().