15#ifndef _FASTCDR_CDRBUFFER_H_
16#define _FASTCDR_CDRBUFFER_H_
18#include "fastcdr_dll.h"
25inline uint32_t size_to_uint32(
28 #if defined(_WIN32) || !defined(FASTCDR_ARM32)
30 return static_cast<uint32_t
>(val);
62 , current_position_(&buffer_[index])
76 ptrdiff_t diff = current_position_ - buffer_;
77 buffer_ = iterator.buffer_;
78 current_position_ = buffer_ + diff;
90 ptrdiff_t diff = iterator.current_position_ - iterator.buffer_;
91 current_position_ = buffer_ + diff;
104 memcpy(current_position_, &data,
sizeof(_T));
112 template<
typename _T>
117 memcpy(&data, current_position_,
sizeof(_T));
132 memcpy(current_position_, src, size);
148 memcpy(dst, current_position_, size);
160 current_position_ += num_bytes;
167 current_position_ -= num_bytes;
179 return static_cast<size_t>(current_position_ - it.current_position_);
213 return current_position_;
219 return other_iterator.current_position_ == current_position_;
225 return !(other_iterator == *
this);
231 char* buffer_ {
nullptr};
234 char* current_position_ {
nullptr};
265 const size_t bufferSize);
272 , m_internalBuffer(true)
274 std::swap(buffer_, fbuffer.buffer_);
275 std::swap(size_, fbuffer.size_);
276 std::swap(m_internalBuffer, fbuffer.m_internalBuffer);
283 std::swap(buffer_, fbuffer.buffer_);
284 std::swap(size_, fbuffer.size_);
285 std::swap(m_internalBuffer, fbuffer.m_internalBuffer);
346 size_t min_size_inc);
357 char* buffer_ {
nullptr };
363 bool m_internalBuffer {
true };
This class implements the iterator used to go through a FastBuffer.
Definition FastBuffer.h:43
void memcopy(const void *src, const size_t size)
This function copies a buffer into the raw buffer.
Definition FastBuffer.h:126
_FastBuffer_iterator()=default
Default constructor.
void rmemcopy(void *dst, const size_t size)
This function copies from the raw buffer to a external buffer.
Definition FastBuffer.h:142
_FastBuffer_iterator(char *buffer, size_t index)
Constructor.
Definition FastBuffer.h:58
This class represents a stream of bytes that contains (or will contain) serialized data.
Definition FastBuffer.h:244
virtual ~FastBuffer()
Default destructor.
bool reserve(size_t size)
This function reserves memory for the internal raw buffer.
FastBuffer()=default
This constructor creates an internal stream and assigns it to the eprosima::fastcdr::FastBuffers obje...
FastBuffer(char *const buffer, const size_t bufferSize)
This constructor assigns the user's stream of bytes to the eprosima::fastcdr::FastBuffers object.
_FastBuffer_iterator iterator
Definition FastBuffer.h:247
bool resize(size_t min_size_inc)
This function resizes the raw buffer.
char * getBuffer() const
This function returns the stream that the eprosima::fastcdr::FastBuffers uses to serialize data.
Definition FastBuffer.h:298
size_t getBufferSize() const
This function returns the size of the allocated memory of the stream that the eprosima::fastcdr::Fast...
Definition FastBuffer.h:307
FastBuffer(FastBuffer &&fbuffer)
Move constructor.
Definition FastBuffer.h:268
iterator end()
This function returns a iterator that points to the end of the stream.
Definition FastBuffer.h:327
iterator begin()
This function returns a iterator that points to the begining of the stream.
Definition FastBuffer.h:317