25 #include "cheetah/psrdada/detail/RawBytesWriter.h" 26 #include "panda/Log.h" 34 template <
typename DataType,
typename Iterator>
35 Iterator& RawBytesWriter::write(Iterator& begin, Iterator
const& end)
37 std::size_t span = std::distance(begin, end);
41 std::size_t remaining_elements = remaining_bytes() /
sizeof(DataType);
43 if (span > remaining_elements)
45 PANDA_LOG_DEBUG <<
"Writing "<< remaining_elements <<
" elements of size " 46 <<
sizeof(DataType) <<
" bytes";
47 std::copy(begin, begin + remaining_elements, (DataType*) _write_ptr);
48 _write_ptr += remaining_elements*
sizeof(DataType);
49 begin += remaining_elements;
55 PANDA_LOG_DEBUG <<
"Writing "<< span <<
" elements of size " <<
sizeof(DataType) <<
" bytes";
56 std::copy(begin, end, (DataType*)_write_ptr);
57 _write_ptr += span *
sizeof(DataType);
char * ptr() const
Get a raw pointer to the start of the buffer.
std::size_t total_bytes() const
Get the total number of bytes in the buffer.
Some limits and constants for FLDO.
std::size_t used_bytes() const
Get the number of currently used bytes in the buffer.