2018-05-21 13:17:07 +00:00
|
|
|
#ifndef LLARP_BUFFER_HPP
|
|
|
|
#define LLARP_BUFFER_HPP
|
|
|
|
|
|
|
|
#include <llarp/buffer.h>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
2018-05-22 15:54:19 +00:00
|
|
|
template < typename T >
|
|
|
|
llarp_buffer_t
|
|
|
|
StackBuffer(T& stack)
|
2018-05-21 13:17:07 +00:00
|
|
|
{
|
|
|
|
llarp_buffer_t buff;
|
2018-06-06 12:46:26 +00:00
|
|
|
buff.base = &stack[0];
|
2018-05-22 15:54:19 +00:00
|
|
|
buff.cur = buff.base;
|
|
|
|
buff.sz = sizeof(stack);
|
2018-05-21 13:17:07 +00:00
|
|
|
return buff;
|
|
|
|
}
|
|
|
|
|
2018-05-22 15:54:19 +00:00
|
|
|
/** initialize llarp_buffer_t from container */
|
|
|
|
template < typename T >
|
|
|
|
llarp_buffer_t
|
|
|
|
Buffer(T& t)
|
|
|
|
{
|
|
|
|
llarp_buffer_t buff;
|
|
|
|
buff.base = &t[0];
|
|
|
|
buff.cur = buff.base;
|
|
|
|
buff.sz = t.size();
|
|
|
|
return buff;
|
|
|
|
}
|
2018-07-22 23:14:29 +00:00
|
|
|
|
|
|
|
template < typename T >
|
|
|
|
llarp_buffer_t
|
|
|
|
ConstBuffer(const T& t)
|
|
|
|
{
|
|
|
|
llarp_buffer_t buff;
|
|
|
|
buff.base = (byte_t*)&t[0];
|
|
|
|
buff.cur = buff.base;
|
|
|
|
buff.sz = t.size();
|
|
|
|
return buff;
|
|
|
|
}
|
|
|
|
|
2018-07-09 03:34:29 +00:00
|
|
|
} // namespace llarp
|
2018-05-21 13:17:07 +00:00
|
|
|
|
|
|
|
#endif
|