31 static size_t uleb128_size(uint64_t value);
32 static size_t sleb128_size(int64_t value);
33 using pos_type = std::streampos;
34 using off_type = std::streamoff;
37 endian_swap_(endian_swap)
39 void reserve(
size_t size) {
46 return write(sp.data(), sp.size());
52 raw_.insert(std::end(raw_), count, value);
53 current_pos_ += count;
57 const uint64_t stack_val = value;
58 return write(
reinterpret_cast<const uint8_t*
>(&stack_val), size);
61 return write(other.raw());
64 template<class T, typename = typename std::enable_if<std::is_standard_layout<T>::value && std::is_trivial<T>::value>::type>
66 const auto pos =
static_cast<size_t>(tellp());
67 if (raw_.size() < (pos +
sizeof(T))) {
68 raw_.resize(pos +
sizeof(T));
70 memcpy(raw_.data() + pos, &t,
sizeof(T));
71 current_pos_ +=
sizeof(T);
83 template<
typename T,
size_t size>
85 static_assert(std::numeric_limits<T>::is_integer,
"Requires integer type");
95 for (
const T& e : elements) {
117 size_t size()
const {
122 pos_type tellp()
const {
131 vector_iostream& seekp(vector_iostream::off_type p, std::ios_base::seekdir dir);
133 const std::vector<uint8_t>& raw()
const {
137 std::vector<uint8_t>& raw() {
141 void set_endian_swap(
bool swap) {
146 pos_type current_pos_ = 0;
147 std::vector<uint8_t> raw_;
148 bool endian_swap_ =
false;