summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/data/data_buffer.cc
diff options
context:
space:
mode:
Diffstat (limited to '2005/i/robert/src/data/data_buffer.cc')
-rw-r--r--2005/i/robert/src/data/data_buffer.cc14
1 files changed, 9 insertions, 5 deletions
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_);
}