From aecaf24c22013482de84ac6567249bec5ae7c78e Mon Sep 17 00:00:00 2001 From: dufourj Date: Sun, 1 May 2005 15:37:34 +0000 Subject: DataBuffer : Rajout du type de données Socket : Non-bloquant --- 2005/i/robert/src/data/data_buffer.cc | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to '2005/i/robert/src/data/data_buffer.cc') diff --git a/2005/i/robert/src/data/data_buffer.cc b/2005/i/robert/src/data/data_buffer.cc index 4fc7c56..c0d8cef 100644 --- a/2005/i/robert/src/data/data_buffer.cc +++ b/2005/i/robert/src/data/data_buffer.cc @@ -32,24 +32,26 @@ static const unsigned min_size = 10; /// Constructeur par defaut DataBuffer::DataBuffer (void) - : size_ (min_size), headPos_ (0), tailPos_ (0) + : size_ (min_size), headPos_ (0), tailPos_ (0), type_ (NoType) { buffer_ = new uint8_t [size_]; } /// Constructeur par recopie. DataBuffer::DataBuffer (const DataBuffer &d) - : headPos_ (0) + : headPos_ (0), type_ (NoType) { unsigned sizeUse = d.tailPos_ - d.headPos_; size_ = tailPos_ = sizeUse; + type_ = d.type_; buffer_ = new uint8_t [size_]; std::memcpy (buffer_, &d.buffer_[headPos_], sizeUse); } /// Constructeur avec données. -DataBuffer::DataBuffer (uint8_t *data, unsigned size, unsigned sizeAllocated) - : size_ (sizeAllocated), headPos_ (0), tailPos_ (size) +DataBuffer::DataBuffer (uint8_t *data, unsigned size, unsigned sizeAllocated, + dataType_e type) + : size_ (sizeAllocated), headPos_ (0), tailPos_ (size), type_ (type) { if (!data || size > sizeAllocated) throw std::invalid_argument ("Paramêtres invalides"); @@ -110,7 +112,8 @@ DataBuffer::grow (const unsigned size) if (tailleLibre < size) { // On augmente de deux fois la taille - DataBuffer d (&buffer_[headPos_], tailPos_ - headPos_, 2 * size + size_); + DataBuffer d (&buffer_[headPos_], tailPos_ - headPos_, + 2 * size + size_, type_); d.swap (*this); } } @@ -123,4 +126,5 @@ DataBuffer::swap (DataBuffer &d) std::swap (size_, d.size_); std::swap (headPos_, d.headPos_); std::swap (tailPos_, d.tailPos_); + std::swap (type_, d.type_); } -- cgit v1.2.3