mirror of
https://github.com/ETLCPP/etl.git
synced 2026-04-30 19:09:10 +08:00
Merge remote-tracking branch 'origin/feature/bit_stream' into development
# Conflicts: # include/etl/profiles/armv6.h # include/etl/profiles/armv6_no_stl.h # include/etl/version.h # support/Release notes.txt # test/vs2017/etl.vcxproj.filters
This commit is contained in:
parent
c26b94867f
commit
aee76d67e8
@ -344,8 +344,8 @@ namespace etl
|
||||
|
||||
ETL_ASSERT((NBITS <= std::numeric_limits<TReturn>::digits), ETL_ERROR(binary_out_of_range));
|
||||
|
||||
TReturn mask = TReturn(1U) << (NBITS - 1);
|
||||
value = value & ((1U << NBITS) - 1);
|
||||
TReturn mask = TReturn(1) << (NBITS - 1);
|
||||
value = value & static_cast<TValue>((TReturn(1) << NBITS) - 1);
|
||||
|
||||
return TReturn((value ^ mask) - mask);
|
||||
}
|
||||
@ -364,8 +364,8 @@ namespace etl
|
||||
|
||||
ETL_ASSERT((NBITS <= std::numeric_limits<TReturn>::digits), ETL_ERROR(binary_out_of_range));
|
||||
|
||||
TReturn mask = TReturn(1U) << (NBITS - 1);
|
||||
value = (value >> SHIFT) & ((1U << NBITS) - 1);
|
||||
TReturn mask = TReturn(1) << (NBITS - 1);
|
||||
value = (value >> SHIFT) & static_cast<TValue>((TReturn(1) << NBITS) - 1);
|
||||
|
||||
return TReturn((value ^ mask) - mask);
|
||||
}
|
||||
|
||||
529
include/etl/bit_stream.h
Normal file
529
include/etl/bit_stream.h
Normal file
@ -0,0 +1,529 @@
|
||||
#ifndef ETL_BIT_STREAM_INCLUDED
|
||||
#define ETL_BIT_STREAM_INCLUDED
|
||||
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "etl/platform.h"
|
||||
#include "etl/type_traits.h"
|
||||
#include "etl/nullptr.h"
|
||||
#include "etl/endianness.h"
|
||||
#include "etl/integral_limits.h"
|
||||
#include "etl/binary.h"
|
||||
|
||||
#include "etl/stl/algorithm.h"
|
||||
#include "etl/stl/iterator.h"
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
//***************************************************************************
|
||||
/// Encodes and decodes bitstreams.
|
||||
/// Data must be stored in the stream in network order.
|
||||
//***************************************************************************
|
||||
class bit_stream
|
||||
{
|
||||
public:
|
||||
|
||||
typedef const unsigned char* const_iterator;
|
||||
|
||||
//***************************************************************************
|
||||
/// Default constructor.
|
||||
//***************************************************************************
|
||||
bit_stream()
|
||||
: pdata(nullptr),
|
||||
length(0U)
|
||||
{
|
||||
restart();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Construct from range.
|
||||
//***************************************************************************
|
||||
bit_stream(char* begin_, char* end_)
|
||||
: pdata(reinterpret_cast<unsigned char*>(begin_)),
|
||||
length(std::distance(begin_, end_))
|
||||
{
|
||||
restart();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Construct from range.
|
||||
//***************************************************************************
|
||||
bit_stream(unsigned char* begin_, unsigned char* end_)
|
||||
: pdata(begin_),
|
||||
length(std::distance(begin_, end_))
|
||||
{
|
||||
restart();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Construct from begin and length.
|
||||
//***************************************************************************
|
||||
bit_stream(char* begin_, size_t length_)
|
||||
: pdata(reinterpret_cast<unsigned char*>(begin_)),
|
||||
length(length_)
|
||||
{
|
||||
restart();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Construct from begin and length.
|
||||
//***************************************************************************
|
||||
bit_stream(unsigned char* begin_, size_t length_)
|
||||
: pdata(begin_),
|
||||
length(length_)
|
||||
{
|
||||
restart();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Construct from begin and length.
|
||||
//***************************************************************************
|
||||
void set_stream(char* begin_, size_t length_)
|
||||
{
|
||||
pdata = reinterpret_cast<unsigned char*>(begin_);
|
||||
length = length_;
|
||||
restart();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Construct from begin and length.
|
||||
//***************************************************************************
|
||||
void set_stream(unsigned char* begin_, size_t length_)
|
||||
{
|
||||
pdata = begin_;
|
||||
length = length_;
|
||||
restart();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Construct from range.
|
||||
//***************************************************************************
|
||||
void set_stream(char* begin_, char* end_)
|
||||
{
|
||||
set_stream(begin_, std::distance(begin_, end_));
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Construct from range.
|
||||
//***************************************************************************
|
||||
void set_stream(unsigned char* begin_, unsigned char* end_)
|
||||
{
|
||||
set_stream(begin_, std::distance(begin_, end_));
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Sets the indexes back to the beginning of the stream.
|
||||
//***************************************************************************
|
||||
void restart()
|
||||
{
|
||||
bits_in_byte = 8;
|
||||
byte_index = 0U;
|
||||
bits_remaining = CHAR_BIT * length;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Returns <b>true</b> if the bitsteam indexes have reached the end.
|
||||
//***************************************************************************
|
||||
bool at_end() const
|
||||
{
|
||||
return (bits_remaining == 0U);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Puts a boolean to the stream
|
||||
//***************************************************************************
|
||||
bool put(bool value)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
if (pdata != nullptr)
|
||||
{
|
||||
if (bits_remaining > 0)
|
||||
{
|
||||
unsigned char chunk = value ? 1 : 0;
|
||||
put_integral(uint32_t(chunk), 1);
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// For integral types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_integral<T>::value, bool>::type
|
||||
put(T value, uint_least8_t width = CHAR_BIT * sizeof(T))
|
||||
{
|
||||
return put_integral(static_cast<uint32_t>(value), width);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// For 64bit integral types
|
||||
//***************************************************************************
|
||||
bool put(int64_t value, uint_least8_t width = CHAR_BIT * sizeof(int64_t))
|
||||
{
|
||||
return put_integral(uint64_t(value), width);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// For 64bit integral types
|
||||
//***************************************************************************
|
||||
bool put(uint64_t value, uint_least8_t width = CHAR_BIT * sizeof(uint64_t))
|
||||
{
|
||||
return put_integral(value, width);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// For floating point types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_floating_point<T>::value, bool>::type
|
||||
put(T value)
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
unsigned char data[sizeof(T)];
|
||||
to_bytes(value, data);
|
||||
|
||||
for (size_t i = 0; i < sizeof(T); ++i)
|
||||
{
|
||||
if (!put_integral(uint32_t(data[i]), CHAR_BIT))
|
||||
{
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// For bool types
|
||||
//***************************************************************************
|
||||
bool get(bool& value)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
if (pdata != nullptr)
|
||||
{
|
||||
// Do we have enough bits?
|
||||
if (bits_remaining > 0)
|
||||
{
|
||||
value = get_bit();
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// For integral types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_integral<T>::value, bool>::type
|
||||
get(T& value, uint_least8_t width = CHAR_BIT * sizeof(T))
|
||||
{
|
||||
bool success = false;
|
||||
uint_least8_t bits = width;
|
||||
|
||||
if (pdata != nullptr)
|
||||
{
|
||||
// Do we have enough bits?
|
||||
if (bits_remaining >= width)
|
||||
{
|
||||
value = 0;
|
||||
|
||||
// Get the bits from the stream.
|
||||
while (width != 0)
|
||||
{
|
||||
unsigned char mask_width = static_cast<unsigned char>(std::min(width, bits_in_byte));
|
||||
unsigned char chunk = get_chunk(mask_width);
|
||||
|
||||
width -= mask_width;
|
||||
value |= static_cast<T>(chunk) << width;
|
||||
}
|
||||
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Sign extend if signed type and not already full bit width.
|
||||
if (etl::is_signed<T>::value && (bits != (CHAR_BIT * sizeof(T))))
|
||||
{
|
||||
typedef typename etl::make_signed<T>::type ST;
|
||||
value = etl::sign_extend<ST, ST>(value, bits);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// For floating point types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_floating_point<T>::value, bool>::type
|
||||
get(T& value)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
if (pdata != nullptr)
|
||||
{
|
||||
uint_least8_t width = CHAR_BIT * sizeof(T);
|
||||
|
||||
// Do we have enough bits?
|
||||
if (bits_remaining >= width)
|
||||
{
|
||||
// Temporary storage.
|
||||
unsigned char data[sizeof(T)];
|
||||
|
||||
for (size_t i = 0; i < sizeof(T); ++i)
|
||||
{
|
||||
get(data[i], CHAR_BIT);
|
||||
}
|
||||
|
||||
from_bytes(data, value);
|
||||
|
||||
bits_remaining -= width;
|
||||
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Returns the number of bytes used in the stream.
|
||||
//***************************************************************************
|
||||
size_t size() const
|
||||
{
|
||||
size_t s = byte_index;
|
||||
|
||||
// Current byte is used?
|
||||
if (bits_in_byte != CHAR_BIT)
|
||||
{
|
||||
++s;
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Returns the number of bits used in the stream.
|
||||
//***************************************************************************
|
||||
size_t bits() const
|
||||
{
|
||||
return (length * CHAR_BIT) - bits_remaining;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Returns start of the stream.
|
||||
//***************************************************************************
|
||||
const_iterator begin() const
|
||||
{
|
||||
return pdata;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Returns end of the stream.
|
||||
//***************************************************************************
|
||||
const_iterator end() const
|
||||
{
|
||||
return pdata + size();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
//***************************************************************************
|
||||
/// For unsigned integral types
|
||||
//***************************************************************************
|
||||
bool put_integral(uint32_t value, uint_least8_t width)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
if (pdata != nullptr)
|
||||
{
|
||||
// Do we have enough bits?
|
||||
if (bits_remaining >= width)
|
||||
{
|
||||
// Send the bits to the stream.
|
||||
while (width != 0)
|
||||
{
|
||||
unsigned char mask_width = static_cast<unsigned char>(std::min(width, bits_in_byte));
|
||||
width -= mask_width;
|
||||
uint32_t mask = ((uint32_t(1U) << mask_width) - 1U) << width;
|
||||
|
||||
// Move chunk to lowest char bits.
|
||||
// Chunks are never larger than one char.
|
||||
uint32_t chunk = ((value & mask) >> width) << (bits_in_byte - mask_width);
|
||||
|
||||
put_chunk(static_cast<unsigned char>(chunk), mask_width);
|
||||
}
|
||||
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// For unsigned integral types. 64bit
|
||||
//***************************************************************************
|
||||
bool put_integral(uint64_t value, uint_least8_t width)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
if (pdata != nullptr)
|
||||
{
|
||||
// Do we have enough bits?
|
||||
if (bits_remaining >= width)
|
||||
{
|
||||
// Send the bits to the stream.
|
||||
while (width != 0)
|
||||
{
|
||||
unsigned char mask_width = static_cast<unsigned char>(std::min(width, bits_in_byte));
|
||||
width -= mask_width;
|
||||
uint64_t mask = ((uint64_t(1U) << mask_width) - 1U) << width;
|
||||
|
||||
// Move chunk to lowest char bits.
|
||||
// Chunks are never larger than one char.
|
||||
uint64_t chunk = ((value & mask) >> width) << (bits_in_byte - mask_width);
|
||||
|
||||
put_chunk(static_cast<unsigned char>(chunk), mask_width);
|
||||
}
|
||||
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Put a data chunk to the stream
|
||||
//***************************************************************************
|
||||
void put_chunk(unsigned char chunk, unsigned char width)
|
||||
{
|
||||
// Clear if new byte.
|
||||
if (bits_in_byte == 8)
|
||||
{
|
||||
pdata[byte_index] = 0U;
|
||||
}
|
||||
|
||||
pdata[byte_index] |= chunk;
|
||||
step(width);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Get a data chunk from the stream
|
||||
//***************************************************************************
|
||||
unsigned char get_chunk(unsigned char width)
|
||||
{
|
||||
unsigned char value = pdata[byte_index];
|
||||
|
||||
value >>= (bits_in_byte - width);
|
||||
|
||||
unsigned char mask;
|
||||
|
||||
if (width == CHAR_BIT)
|
||||
{
|
||||
mask = etl::integral_limits<unsigned char>::max;
|
||||
}
|
||||
else
|
||||
{
|
||||
mask = (1U << width) - 1;
|
||||
}
|
||||
|
||||
value &= mask;
|
||||
|
||||
step(width);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Get a bool from the stream
|
||||
//***************************************************************************
|
||||
bool get_bit()
|
||||
{
|
||||
bool result = (pdata[byte_index] & (1 << (bits_in_byte - 1))) != 0;
|
||||
|
||||
step(1U);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Helper function for floating point types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
void from_bytes(const unsigned char* data, T& value)
|
||||
{
|
||||
unsigned char temp[sizeof(T)];
|
||||
|
||||
// Network to host.
|
||||
if (etl::endianness::value() == etl::endian::little)
|
||||
{
|
||||
std::reverse_copy(data, data + sizeof(T), temp);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::copy(data, data + sizeof(T), temp);
|
||||
}
|
||||
|
||||
value = *reinterpret_cast<T*>(temp);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Helper function for floating point types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
void to_bytes(T value, unsigned char* data)
|
||||
{
|
||||
unsigned char* pf = reinterpret_cast<unsigned char*>(&value);
|
||||
|
||||
// Host to network.
|
||||
if (etl::endianness::value() == etl::endian::little)
|
||||
{
|
||||
std::reverse_copy(pf, pf + sizeof(T), data);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::copy(pf, pf + sizeof(T), data);
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Step the specified number of bits along the stream.
|
||||
/// The width will never be larger than 'bits_in_byte'.
|
||||
//***************************************************************************
|
||||
void step(unsigned char width)
|
||||
{
|
||||
bits_in_byte -= width;
|
||||
|
||||
if (bits_in_byte == 0)
|
||||
{
|
||||
++byte_index;
|
||||
bits_in_byte = 8;
|
||||
}
|
||||
|
||||
bits_remaining -= width;
|
||||
}
|
||||
|
||||
unsigned char *pdata; ///< The start of the bitstream buffer.
|
||||
size_t length; ///< The length, in unsigned char, of the bitstream buffer.
|
||||
unsigned char bits_in_byte; ///< The number of available bits in the current char.
|
||||
size_t byte_index; ///< The index of the char in the bitstream buffer.
|
||||
size_t bits_remaining; ///< The number of bits still available in the bitstream buffer.
|
||||
};
|
||||
}
|
||||
|
||||
#include "private/minmax_pop.h"
|
||||
|
||||
#endif
|
||||
@ -35,6 +35,7 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
#include "enum_type.h"
|
||||
#include "binary.h"
|
||||
|
||||
///\defgroup endian endian
|
||||
/// Constants & utilities for endianess
|
||||
@ -101,6 +102,96 @@ namespace etl
|
||||
return (u.ui16[0] == 0x5678) ? etl::endian::little : etl::endian::big;
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
inline uint8_t ntoh(const uint8_t network)
|
||||
{
|
||||
return network;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
inline uint16_t ntoh(const uint16_t network)
|
||||
{
|
||||
if (endianness::value() == endian::little)
|
||||
{
|
||||
return etl::reverse_bytes(network);
|
||||
}
|
||||
else
|
||||
{
|
||||
return network;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
inline uint32_t ntoh(const uint32_t network)
|
||||
{
|
||||
if (endianness::value() == endian::little)
|
||||
{
|
||||
return etl::reverse_bytes(network);
|
||||
}
|
||||
else
|
||||
{
|
||||
return network;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
inline uint64_t ntoh(const uint64_t network)
|
||||
{
|
||||
if (endianness::value() == endian::little)
|
||||
{
|
||||
return etl::reverse_bytes(network);
|
||||
}
|
||||
else
|
||||
{
|
||||
return network;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
inline uint8_t hton(const uint8_t host)
|
||||
{
|
||||
return host;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
inline uint16_t hton(const uint16_t host)
|
||||
{
|
||||
if (endianness::value() == endian::little)
|
||||
{
|
||||
return etl::reverse_bytes(host);
|
||||
}
|
||||
else
|
||||
{
|
||||
return host;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
inline uint32_t hton(const uint32_t host)
|
||||
{
|
||||
if (endianness::value() == endian::little)
|
||||
{
|
||||
return etl::reverse_bytes(host);
|
||||
}
|
||||
else
|
||||
{
|
||||
return host;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
inline uint64_t hton(const uint64_t host)
|
||||
{
|
||||
if (endianness::value() == endian::little)
|
||||
{
|
||||
return etl::reverse_bytes(host);
|
||||
}
|
||||
else
|
||||
{
|
||||
return host;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -37,7 +37,7 @@ SOFTWARE.
|
||||
|
||||
#define ETL_TARGET_DEVICE_ARM
|
||||
#define ETL_TARGET_OS_NONE
|
||||
#define ETL_COMPILER_ARM6
|
||||
#define ETL_COMPILER_CLANG
|
||||
#define ETL_CPP11_SUPPORTED 1
|
||||
#define ETL_CPP14_SUPPORTED 0
|
||||
#define ETL_CPP17_SUPPORTED 0
|
||||
|
||||
@ -37,7 +37,7 @@ SOFTWARE.
|
||||
|
||||
#define ETL_TARGET_DEVICE_ARM
|
||||
#define ETL_TARGET_OS_NONE
|
||||
#define ETL_COMPILER_ARM6
|
||||
#define ETL_COMPILER_CLANG
|
||||
#define ETL_CPP11_SUPPORTED 1
|
||||
#define ETL_CPP14_SUPPORTED 0
|
||||
#define ETL_CPP17_SUPPORTED 0
|
||||
|
||||
@ -376,8 +376,6 @@ namespace etl
|
||||
{
|
||||
ETL_ASSERT(task_list.size() > 0, ETL_ERROR(etl::scheduler_no_tasks_exception));
|
||||
|
||||
const size_t task_list_size = task_list.size();
|
||||
|
||||
scheduler_running = true;
|
||||
|
||||
while (!scheduler_exit)
|
||||
|
||||
@ -772,7 +772,6 @@ namespace etl
|
||||
ETL_ASSERT(!full(), ETL_ERROR(unordered_map_full));
|
||||
|
||||
const key_type& key = key_value_pair.first;
|
||||
const mapped_type& mapped = key_value_pair.second;
|
||||
|
||||
// Get the hash index.
|
||||
size_t index = get_bucket_index(key);
|
||||
|
||||
@ -663,7 +663,6 @@ namespace etl
|
||||
ETL_ASSERT(!full(), ETL_ERROR(unordered_multimap_full));
|
||||
|
||||
const key_type& key = key_value_pair.first;
|
||||
const mapped_type& mapped = key_value_pair.second;
|
||||
|
||||
// Get the hash index.
|
||||
size_t index = get_bucket_index(key);
|
||||
|
||||
@ -37,13 +37,13 @@ SOFTWARE.
|
||||
/// Definitions of the ETL version
|
||||
///\ingroup utilities
|
||||
|
||||
#define ETL_VERSION "12.1.1"
|
||||
#define ETL_VERSION_W L"12.1.1"
|
||||
#define ETL_VERSION_U16 u"12.1.1"
|
||||
#define ETL_VERSION_U32 U"12.1.1"
|
||||
#define ETL_VERSION_MAJOR 12
|
||||
#define ETL_VERSION_MINOR 1
|
||||
#define ETL_VERSION_PATCH 1
|
||||
#define ETL_VERSION "13.0.0"
|
||||
#define ETL_VERSION_W L"13.0.0"
|
||||
#define ETL_VERSION_U16 u"13.0.0"
|
||||
#define ETL_VERSION_U32 U"13.0.0"
|
||||
#define ETL_VERSION_MAJOR 13
|
||||
#define ETL_VERSION_MINOR 0
|
||||
#define ETL_VERSION_PATCH 0
|
||||
#define ETL_VERSION_VALUE ((ETL_VERSION_MAJOR * 10000) + (ETL_VERSION_MINOR * 100) + ETL_VERSION_PATCH)
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,3 +1,7 @@
|
||||
===============================================================================
|
||||
13.0.0
|
||||
Added bit stream serialiser/deserialiser
|
||||
|
||||
===============================================================================
|
||||
12.1.1
|
||||
Added random_pcg Permuted Congruential Generator
|
||||
|
||||
@ -156,6 +156,7 @@
|
||||
<Unit filename="../../include/etl/atomic/atomic_std.h" />
|
||||
<Unit filename="../../include/etl/basic_string.h" />
|
||||
<Unit filename="../../include/etl/binary.h" />
|
||||
<Unit filename="../../include/etl/bit_stream.h" />
|
||||
<Unit filename="../../include/etl/bitset.h" />
|
||||
<Unit filename="../../include/etl/bloom_filter.h" />
|
||||
<Unit filename="../../include/etl/c/ecl_timer.h" />
|
||||
@ -348,6 +349,7 @@
|
||||
<Unit filename="../test_atomic_gcc_sync.cpp" />
|
||||
<Unit filename="../test_atomic_std.cpp" />
|
||||
<Unit filename="../test_binary.cpp" />
|
||||
<Unit filename="../test_bit_stream.cpp" />
|
||||
<Unit filename="../test_bitset.cpp" />
|
||||
<Unit filename="../test_bloom_filter.cpp" />
|
||||
<Unit filename="../test_bsd_checksum.cpp" />
|
||||
@ -388,6 +390,7 @@
|
||||
<Unit filename="../test_jenkins.cpp" />
|
||||
<Unit filename="../test_largest.cpp" />
|
||||
<Unit filename="../test_list.cpp" />
|
||||
<Unit filename="../test_list_shared_pool.cpp" />
|
||||
<Unit filename="../test_map.cpp" />
|
||||
<Unit filename="../test_maths.cpp" />
|
||||
<Unit filename="../test_memory.cpp" />
|
||||
|
||||
1081
test/test_bit_stream.cpp
Normal file
1081
test/test_bit_stream.cpp
Normal file
File diff suppressed because it is too large
Load Diff
@ -104,7 +104,7 @@ namespace
|
||||
{
|
||||
DataNDC data;
|
||||
|
||||
CHECK_EQUAL(data.max_size(), 0);
|
||||
CHECK_EQUAL(data.max_size(), 0U);
|
||||
CHECK(data.has_shared_pool());
|
||||
}
|
||||
|
||||
@ -403,7 +403,7 @@ namespace
|
||||
CHECK_EQUAL(0U, data1.size());
|
||||
CHECK_EQUAL(half_data.size(), data2.size());
|
||||
|
||||
bool are_equal = std::equal(data2.begin(), data2.end(), half_data.begin());
|
||||
are_equal = std::equal(data2.begin(), data2.end(), half_data.begin());
|
||||
CHECK(are_equal);
|
||||
|
||||
// Do it again to check that clear() didn't screw up the internals.
|
||||
@ -696,7 +696,7 @@ namespace
|
||||
compare_data2.push_front(ItemNDC("7"));
|
||||
compare_data2.push_front(ItemNDC("8"));
|
||||
compare_data2.push_front(ItemNDC("9"));
|
||||
|
||||
|
||||
CHECK_NO_THROW(data1.push_front(ItemNDC("0")));
|
||||
CHECK_NO_THROW(data1.push_front(ItemNDC("1")));
|
||||
CHECK_NO_THROW(data1.push_front(ItemNDC("2")));
|
||||
|
||||
@ -220,6 +220,8 @@ namespace
|
||||
|
||||
IDataNDC* pidata = pdata;
|
||||
delete pidata;
|
||||
|
||||
CHECK_EQUAL(current_count, NDC::get_instance_count());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -492,6 +494,8 @@ namespace
|
||||
bool isEqual = Check_Equal(data.begin(),
|
||||
data.end(),
|
||||
compare_data.begin());
|
||||
|
||||
CHECK(isEqual);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -178,6 +178,8 @@ namespace
|
||||
|
||||
IDataNDC* pidata = pdata;
|
||||
delete pidata;
|
||||
|
||||
CHECK_EQUAL(current_count, NDC::get_instance_count());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -164,6 +164,8 @@ namespace
|
||||
|
||||
IDataNDC* pidata = pdata;
|
||||
delete pidata;
|
||||
|
||||
CHECK_EQUAL(current_count, NDC::get_instance_count());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -176,6 +176,8 @@ namespace
|
||||
|
||||
IDataNDC* pidata = pdata;
|
||||
delete pidata;
|
||||
|
||||
CHECK_EQUAL(current_count, NDC::get_instance_count());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -806,7 +806,6 @@ namespace
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_range)
|
||||
{
|
||||
const size_t INITIAL_SIZE = 5;
|
||||
const value_t INITIAL_VALUE = STR('A');
|
||||
|
||||
for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset)
|
||||
{
|
||||
|
||||
@ -805,7 +805,6 @@ namespace
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_range)
|
||||
{
|
||||
const size_t INITIAL_SIZE = 5;
|
||||
const value_t INITIAL_VALUE = STR('A');
|
||||
|
||||
for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset)
|
||||
{
|
||||
|
||||
@ -803,7 +803,6 @@ namespace
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_range)
|
||||
{
|
||||
const size_t INITIAL_SIZE = 5;
|
||||
const value_t INITIAL_VALUE = STR('A');
|
||||
|
||||
for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset)
|
||||
{
|
||||
|
||||
@ -805,7 +805,6 @@ namespace
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_range)
|
||||
{
|
||||
const size_t INITIAL_SIZE = 5;
|
||||
const value_t INITIAL_VALUE = STR('A');
|
||||
|
||||
for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset)
|
||||
{
|
||||
|
||||
@ -462,6 +462,7 @@ namespace
|
||||
CHECK((std::is_same<etl::make_signed<volatile int>::type, std::make_signed<volatile int>::type>::value));
|
||||
CHECK((std::is_same<etl::make_signed<const int>::type, std::make_signed<const int>::type>::value));
|
||||
CHECK((std::is_same<etl::make_signed<const volatile int>::type, std::make_signed<const volatile int>::type>::value));
|
||||
CHECK((std::is_same<etl::make_signed<size_t>::type, std::make_signed<size_t>::type>::value));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -487,6 +488,7 @@ namespace
|
||||
CHECK((std::is_same<etl::make_unsigned<volatile int>::type, std::make_unsigned<volatile int>::type>::value));
|
||||
CHECK((std::is_same<etl::make_unsigned<const int>::type, std::make_unsigned<const int>::type>::value));
|
||||
CHECK((std::is_same<etl::make_unsigned<const volatile int>::type, std::make_unsigned<const volatile int>::type>::value));
|
||||
CHECK((std::is_same<etl::make_unsigned<size_t>::type, std::make_unsigned<size_t>::type>::value));
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -125,7 +125,7 @@ namespace
|
||||
DC M17 = DC("R");
|
||||
DC M18 = DC("S");
|
||||
DC M19 = DC("T");
|
||||
|
||||
|
||||
const char* K0 = "FF"; // 0
|
||||
const char* K1 = "FG"; // 1
|
||||
const char* K2 = "FH"; // 2
|
||||
@ -240,6 +240,8 @@ namespace
|
||||
|
||||
IDataNDC* pidata = pdata;
|
||||
delete pidata;
|
||||
|
||||
CHECK_EQUAL(current_count, NDC::get_instance_count());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -508,7 +510,7 @@ namespace
|
||||
|
||||
DataNDC::iterator idata_end = data.begin();
|
||||
std::advance(idata_end, 5);
|
||||
|
||||
|
||||
data.erase(idata, idata_end);
|
||||
|
||||
CHECK_EQUAL(initial_data.size() - 3, data.size());
|
||||
|
||||
@ -217,6 +217,8 @@ namespace
|
||||
|
||||
IDataNDC* pidata = pdata;
|
||||
delete pidata;
|
||||
|
||||
CHECK_EQUAL(current_count, NDC::get_instance_count());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
|
||||
@ -151,6 +151,8 @@ namespace
|
||||
|
||||
IDataNDC* pidata = pdata;
|
||||
delete pidata;
|
||||
|
||||
CHECK_EQUAL(current_count, NDC::get_instance_count());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -397,7 +399,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(data.size(), size_t(0));
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_count_key)
|
||||
{
|
||||
@ -474,7 +476,7 @@ namespace
|
||||
CHECK_EQUAL(std::distance(result.first, result.second), 1);
|
||||
CHECK_EQUAL(*result.first, N2);
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_equal)
|
||||
{
|
||||
|
||||
@ -143,6 +143,8 @@ namespace
|
||||
|
||||
IDataNDC* pidata = pdata;
|
||||
delete pidata;
|
||||
|
||||
CHECK_EQUAL(current_count, NDC::get_instance_count());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -377,7 +379,7 @@ namespace
|
||||
|
||||
CHECK_EQUAL(data.size(), size_t(0));
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_count_key)
|
||||
{
|
||||
|
||||
@ -593,7 +593,6 @@ namespace
|
||||
{
|
||||
const size_t INITIAL_SIZE = SIZE;
|
||||
const int INITIAL_VALUE = 1;
|
||||
const int UNINITIALISED_VALUE = -1;
|
||||
|
||||
Data data(INITIAL_SIZE, INITIAL_VALUE);
|
||||
|
||||
@ -667,7 +666,6 @@ namespace
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_range)
|
||||
{
|
||||
const size_t INITIAL_SIZE = 5;
|
||||
const int INITIAL_VALUE = 1;
|
||||
|
||||
for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset)
|
||||
{
|
||||
|
||||
@ -1198,7 +1198,6 @@ namespace
|
||||
TEST_FIXTURE(SetupFixture, test_insert_position_range)
|
||||
{
|
||||
const size_t INITIAL_SIZE = 5;
|
||||
const int INITIAL_VALUE = 1;
|
||||
|
||||
for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset)
|
||||
{
|
||||
@ -1222,7 +1221,6 @@ namespace
|
||||
TEST_FIXTURE(SetupFixture, test_const_insert_position_range)
|
||||
{
|
||||
const size_t INITIAL_SIZE = 5;
|
||||
const int INITIAL_VALUE = 1;
|
||||
|
||||
for (size_t offset = 0; offset <= INITIAL_SIZE; ++offset)
|
||||
{
|
||||
@ -1266,7 +1264,7 @@ namespace
|
||||
|
||||
CHECK_THROW(data.insert(data.begin() + offset, initial_data.begin(), initial_data.end()), etl::vector_full);
|
||||
}
|
||||
|
||||
|
||||
//*************************************************************************
|
||||
TEST_FIXTURE(SetupFixture, test_const_insert_position_range_excess)
|
||||
{
|
||||
|
||||
@ -362,6 +362,7 @@
|
||||
<ClInclude Include="..\..\include\etl\atomic\atomic_gcc_sync.h" />
|
||||
<ClInclude Include="..\..\include\etl\atomic\atomic_llvm_sync.h" />
|
||||
<ClInclude Include="..\..\include\etl\atomic\atomic_std.h" />
|
||||
<ClInclude Include="..\..\include\etl\bit_stream.h" />
|
||||
<ClInclude Include="..\..\include\etl\callback_timer.h" />
|
||||
<ClInclude Include="..\..\include\etl\combinations.h" />
|
||||
<ClInclude Include="..\..\include\etl\compare.h" />
|
||||
@ -387,6 +388,9 @@
|
||||
<ClInclude Include="..\..\include\etl\mutex\mutex_std.h" />
|
||||
<ClInclude Include="..\..\include\etl\packet.h" />
|
||||
<ClInclude Include="..\..\include\etl\permutations.h" />
|
||||
<ClInclude Include="..\..\include\etl\private\ivectorpointer.h" />
|
||||
<ClInclude Include="..\..\include\etl\private\minmax_pop.h" />
|
||||
<ClInclude Include="..\..\include\etl\private\minmax_push.h" />
|
||||
<ClInclude Include="..\..\include\etl\profiles\arduino_arm.h" />
|
||||
<ClInclude Include="..\..\include\etl\profiles\armv5.h" />
|
||||
<ClInclude Include="..\..\include\etl\profiles\armv5_no_stl.h" />
|
||||
@ -570,6 +574,7 @@
|
||||
<ClCompile Include="..\murmurhash3.cpp" />
|
||||
<ClCompile Include="..\test_algorithm.cpp" />
|
||||
<ClCompile Include="..\test_alignment.cpp" />
|
||||
<ClCompile Include="..\test_bit_stream.cpp" />
|
||||
<ClCompile Include="..\test_list_shared_pool.cpp" />
|
||||
<ClCompile Include="..\test_no_stl_algorithm.cpp" />
|
||||
<ClCompile Include="..\test_array.cpp">
|
||||
|
||||
@ -693,6 +693,18 @@
|
||||
<ClInclude Include="..\..\include\etl\atomic\atomic_llvm_sync.h">
|
||||
<Filter>ETL\Utilities\Atomic</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\bit_stream.h">
|
||||
<Filter>ETL\Utilities</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\private\ivectorpointer.h">
|
||||
<Filter>ETL\Private</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\private\minmax_pop.h">
|
||||
<Filter>ETL\Private</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\private\minmax_push.h">
|
||||
<Filter>ETL\Private</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\include\etl\state_chart.h">
|
||||
<Filter>ETL\Frameworks</Filter>
|
||||
</ClInclude>
|
||||
@ -1142,6 +1154,9 @@
|
||||
<ClCompile Include="..\test_no_stl_iterator.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_bit_stream.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_state_chart.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user