26 #include "my_config.h"
28 #include "runtime.hpp"
30 #include "yassl_types.hpp"
37 void NoCheck::check(uint, uint)
52 input_buffer::input_buffer()
53 : size_(0), current_(0), buffer_(0), end_(0)
57 input_buffer::input_buffer(uint s)
58 : size_(0), current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s)
63 input_buffer::input_buffer(uint s,
const byte* t, uint len)
64 : size_(0), current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s)
70 input_buffer::~input_buffer()
72 ysArrayDelete(buffer_);
77 void input_buffer::allocate(uint s)
79 buffer_ = NEW_YS byte[s];
85 byte* input_buffer::get_buffer()
const
93 void input_buffer::add_size(uint
i)
95 check(size_ + i-1, get_capacity());
100 uint input_buffer::get_capacity()
const
102 return (uint) (end_ - buffer_);
106 uint input_buffer::get_current()
const
112 uint input_buffer::get_size()
const
118 uint input_buffer::get_remaining()
const
120 return size_ - current_;
124 void input_buffer::set_current(uint i)
134 const byte& input_buffer::operator[](uint i)
136 check(current_, size_);
137 return buffer_[current_++];
142 bool input_buffer::eof()
144 return current_ >= size_;
149 byte input_buffer::peek()
const
151 return buffer_[current_];
156 void input_buffer::assign(
const byte* t, uint s)
158 check(current_, get_capacity());
160 memcpy(&buffer_[current_], t, s);
165 void input_buffer::read(byte* dst, uint length)
167 check(current_ + length - 1, size_);
168 memcpy(dst, &buffer_[current_], length);
185 output_buffer::output_buffer()
186 : current_(0), buffer_(0), end_(0)
191 output_buffer::output_buffer(uint s)
192 : current_(0), buffer_(NEW_YS byte[s]), end_(buffer_ + s)
197 output_buffer::output_buffer(uint s,
const byte* t, uint len)
198 : current_(0), buffer_(NEW_YS byte[s]), end_(buffer_+ s)
204 output_buffer::~output_buffer()
206 ysArrayDelete(buffer_);
210 uint output_buffer::get_size()
const
216 uint output_buffer::get_capacity()
const
218 return (uint) (end_ - buffer_);
222 void output_buffer::set_current(uint c)
224 check(c, get_capacity());
230 void output_buffer::allocate(uint s)
232 buffer_ = NEW_YS byte[s]; end_ = buffer_ + s;
237 const byte* output_buffer::get_buffer()
const
245 byte& output_buffer::operator[](uint i)
247 check(current_, get_capacity());
248 return buffer_[current_++];
253 bool output_buffer::eof()
255 return current_ >= get_capacity();
259 void output_buffer::write(
const byte* t, uint s)
261 check(current_ + s - 1, get_capacity());
262 memcpy(&buffer_[current_], t, s);