From 63cc38e6bd6329dfe0021adc2f8609bf7819fc49 Mon Sep 17 00:00:00 2001 From: Erwin Nindl Date: Wed, 27 Feb 2008 21:21:05 +0000 Subject: added mux to options --- buffer.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'buffer.cpp') diff --git a/buffer.cpp b/buffer.cpp index 91ad950..986c7ba 100644 --- a/buffer.cpp +++ b/buffer.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include "datatypes.h" @@ -64,6 +65,23 @@ Buffer::Buffer(u_int8_t* data, u_int32_t length, bool allow_realloc) : length_(l std::memcpy(buf_, data, length_); } +Buffer::Buffer(std::string hex_data, bool allow_realloc) : length_(hex_data.size()/2), + real_length_(length_ + Buffer::OVER_SIZE_), + allow_realloc_(allow_realloc) +{ + buf_ = new u_int8_t[real_length_]; + if(!buf_) { + length_ = 0; + real_length_ = 0; + throw std::bad_alloc(); + } + std::stringstream tmp(hex_data); + for(u_int32_t i=0;i> std::hex >> std::setw(2) >> buf_[i]; + } +} + Buffer::~Buffer() { if(buf_) -- cgit v1.2.3