|
The idea of demos is
explained here;
a menu at top column right indexes actual topic specific demos.
Here we demo iovecs.
problem
Suppose you want to write code manipulating iovec vectors of the sort passed to readv() and writev() system calls. If you try man readv you might see something like this: ssize_t readv(int d, const struct iovec *iov, int n);
On my Mac powerbook, the sys/uio.h system header defines iovec as below, which also matches what I see on Linux. (But my Mac's man page for readv() mistakenly says iov_base is char*.) struct iovec {
void* iov_base; /* Base address. */
size_t iov_len; /* Length. */
};
Wil can't really avoid using this iovec type even though he has a nearly identical yv type defined with lots of convenient methods lacking in iovec. In practice, APIs for interacting with the outside world prefer using arrays of iovec to express discontiguous scatter gather buffers for i/o. In many cases, trying to use yv isn't practical. So an ordered pair (iovec* iov, int len) often acts like a defacto standard type meaning vector of iovecs, and direct support for this is useful. So þ defines yiovecvp to represent this iovec vector pair most conveniently. Type y+iovec+v+p means thorn iovec vector pointer, which acts like an iterator over iovecs while preserving direct access to the original (iovec* iov, int len) pair. (Note all þ iterators end in p because they act semantically like pointers. If an STL collection class named foo has an iterator named foo::iterator, in þ the iterator's name is foop with no :: inside because it's not a nested class. Appending v to the end of iovec means a vector of iovecs, and appending p means an interator over that vector. But yiovecvp is really just a wrapper for (iovec* iov, int len) plus methods, to work with other types editing iovec format.) |
A submenu for demos appears below, letting you
go to the page on a topic written as a demo (as the
demos page defines it).
menu
Choose one of these demos for sample code and related docs, developed together to motivate þ C++ code for this purpose. menu: | iovecs « Þ | asserts |
stub
Most of this page is a stub since the page has only been started and not completed. |