0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-10-31 10:58:54 +01:00
construct/include/ircd/buffer
2020-04-29 01:58:29 -07:00
..
buffer.h ircd::buffer: non-call copy and move. 2020-04-25 00:28:39 -07:00
buffer_base.h ircd::buffer: Add constructors which limit requested size to input buffer. 2019-12-31 11:23:20 -08:00
const_buffer.h ircd::buffer: Add constructors which limit requested size to input buffer. 2019-12-31 11:23:20 -08:00
fixed_buffer.h ircd::buffer: Split into directory. 2018-03-12 22:48:56 -07:00
mutable_buffer.h ircd::buffer: Always inline fundamental buffer template utils. 2019-05-08 05:19:04 -07:00
parse_buffer.h ircd::buffer::parse_buffer: Remove erroneous cast operator. 2019-06-22 16:58:58 -06:00
README.md ircd: Start a README.md for any directory missing one; fix conformity of existing. 2019-01-26 12:29:08 -08:00
shared_buffer.h ircd::buffer: Cleanup/simplify shared_buffer. 2019-09-03 10:07:08 -07:00
unique_buffer.h ircd::buffer: Use buffer::empty() rather than buffer::null() for bool operators. 2020-04-29 01:58:29 -07:00
window_buffer.h ircd::buffer: Add remains() to window_buffer interface. 2019-04-08 20:42:37 -07:00

Memory Buffer Tools

This is a modernization of the (char *buf, size_t buf_sz) pattern used when working with segments of RAMs. While in C99 it is possible (and recommended) for a project to create a struct buffer { char *ptr; size_t size; }; and then manually perform object semantics buffer_copy(dst, src); buffer_move(dst, src)``buffer_free(buf); etc, we create those devices using C++ language features here instead.

This suite is born out of (though not directly based on) the boost::asio buffer objects boost::asio::const_buffer and boost::asio::mutable_buffer and the two principal objects used ubiquitously throughout IRCd share the same names and general properties. We also offer conversions between them for developers working with any asio interfaces directly.

To summarize some basics about these tools:

  • Most of these interfaces are "thin" and don't own their underlying data, nor will they copy their underlying data even if their instance itself is copied.

  • We work with signed char * (and const char *) types. We do not work with void pointers because size integers always represent a count of single bytes and there is no reason to lose or confuse that information. If unsigned char * types are required by some library function an explicit cast to uint8_t * may be required especially to avoid warnings. Note that we compile this project with -fsigned-char and don't support platforms that have incompatible conversions.