io: add more write wrappers
This commit is contained in:
parent
003685ce2b
commit
ba9a8f8b35
3
io.hpp
3
io.hpp
@ -82,6 +82,9 @@ namespace util {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
void write (const fd&, const T *restrict data, size_t count);
|
void write (const fd&, const T *restrict data, size_t count);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
void write (const fd&, const T &data);
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
void write (const fd&, const T *restrict first, const T *restrict last);
|
void write (const fd&, const T *restrict first, const T *restrict last);
|
||||||
|
|
||||||
|
16
io.ipp
16
io.ipp
@ -15,6 +15,22 @@ namespace util {
|
|||||||
write (_fd, first, first + sizeof (T) * count);
|
write (_fd, first, first + sizeof (T) * count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
template <typename T>
|
||||||
|
void
|
||||||
|
write (const fd &_fd, const T &data)
|
||||||
|
{
|
||||||
|
write (_fd, &data, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
inline void
|
||||||
|
write (const fd &_fd, const void *_data, size_t _bytes)
|
||||||
|
{
|
||||||
|
auto data = reinterpret_cast<const uint8_t*> (_data);
|
||||||
|
write (_fd, data, data + _bytes);
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
template <typename T>
|
template <typename T>
|
||||||
indented<T>::indented (const T &_data):
|
indented<T>::indented (const T &_data):
|
||||||
|
Loading…
Reference in New Issue
Block a user