Sponge
CS144's user-space TCP library
Public Member Functions | Private Attributes | List of all members
BufferViewList Class Reference

A non-owning temporary view (similar to std::string_view) of a discontiguous string. More...

#include <buffer.hh>

Public Member Functions

std::vector< iovec > as_iovecs () const
 Convert to a vector of iovec structures. More...
 
void remove_prefix (size_t n)
 Discard the first n bytes of the string (does not require a copy or move) More...
 
size_t size () const
 Size of the string. More...
 
Constructors
 BufferViewList (const std::string &str)
 Construct from a std::string. More...
 
 BufferViewList (const char *s)
 Construct from a C string (must be NULL-terminated) More...
 
 BufferViewList (const BufferList &buffers)
 Construct from a BufferList. More...
 
 BufferViewList (std::string_view str)
 Construct from a std::string_view. More...
 

Private Attributes

std::deque< std::string_view > _views {}
 

Detailed Description

A non-owning temporary view (similar to std::string_view) of a discontiguous string.

Definition at line 97 of file buffer.hh.

Constructor & Destructor Documentation

◆ BufferViewList() [1/4]

BufferViewList::BufferViewList ( const std::string str)
inline

Construct from a std::string.

Definition at line 105 of file buffer.hh.

◆ BufferViewList() [2/4]

BufferViewList::BufferViewList ( const char *  s)
inline

Construct from a C string (must be NULL-terminated)

Definition at line 108 of file buffer.hh.

◆ BufferViewList() [3/4]

BufferViewList::BufferViewList ( const BufferList buffers)

Construct from a BufferList.

Definition at line 67 of file buffer.cc.

◆ BufferViewList() [4/4]

BufferViewList::BufferViewList ( std::string_view  str)
inline

Construct from a std::string_view.

Definition at line 114 of file buffer.hh.

Member Function Documentation

◆ as_iovecs()

vector< iovec > BufferViewList::as_iovecs ( ) const

Convert to a vector of iovec structures.

Note
used for system calls that write discontiguous buffers, e.g. writev(2) and sendmsg(2)

Definition at line 97 of file buffer.cc.

◆ remove_prefix()

void BufferViewList::remove_prefix ( size_t  n)

Discard the first n bytes of the string (does not require a copy or move)

Definition at line 73 of file buffer.cc.

◆ size()

size_t BufferViewList::size ( ) const

Size of the string.

Definition at line 89 of file buffer.cc.

Member Data Documentation

◆ _views

std::deque<std::string_view> BufferViewList::_views {}
private

Definition at line 98 of file buffer.hh.


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