Changed the way that errors are produced and handled.

Compile time macros control the type and verbosity of the errors to allow space and performance optimisation.
This commit is contained in:
John Wellbelove 2015-12-15 19:28:12 +00:00
parent 57b3864449
commit a048784285
50 changed files with 507 additions and 340 deletions

12
array.h
View File

@ -55,8 +55,8 @@ namespace etl
{
public:
array_exception(const char* what)
: exception(what)
array_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -69,8 +69,8 @@ namespace etl
{
public:
array_out_of_range()
: array_exception("array: out of range")
array_out_of_range(string_type file_name, numeric_type line_number)
: array_exception("array:range", file_name, line_number)
{
}
};
@ -115,7 +115,7 @@ namespace etl
//*************************************************************************
reference at(size_t i)
{
ETL_ASSERT(i < SIZE, array_out_of_range());
ETL_ASSERT(i < SIZE, ETL_ERROR(array_out_of_range));
return _buffer[i];
}
@ -126,7 +126,7 @@ namespace etl
//*************************************************************************
const_reference at(size_t i) const
{
ETL_ASSERT(i < SIZE, array_out_of_range());
ETL_ASSERT(i < SIZE, ETL_ERROR(array_out_of_range));
return _buffer[i];
}

View File

@ -137,7 +137,7 @@ namespace etl
//*************************************************************************
bitset<N>& set(const char* text)
{
if (ETL_ASSERT(text != 0, etl::bitset_nullptr()))
if (ETL_ASSERT(text != 0, ETL_ERROR(bitset_nullptr)))
{
ibitset::set(text);
}

View File

@ -53,10 +53,10 @@ namespace etl
//*************************************************************************
/// Callback class for free handler functions.
//*************************************************************************
struct free_function : public function<void, const exception&>
struct free_function : public function<void, const etl::exception&>
{
free_function(void (*p_function)(const exception&))
: function<void, const exception&>(p_function)
free_function(void (*p_function)(const etl::exception&))
: etl::function<void, const etl::exception&>(p_function)
{
}
};
@ -65,46 +65,58 @@ namespace etl
/// Callback class for member handler functions.
//*************************************************************************
template <typename TObject>
struct member_function : public function<TObject, const exception&>
struct member_function : public etl::function<TObject, const etl::exception&>
{
member_function(TObject& object, void(TObject::*p_function)(const exception&))
: function<TObject, const exception&>(object, p_function)
member_function(TObject& object, void(TObject::*p_function)(const etl::exception&))
: etl::function<TObject, const etl::exception&>(object, p_function)
{
}
};
static void set_callback(ifunction<const exception&>& f);
static void error(const exception& e);
static void set_callback(ifunction<const etl::exception&>& f);
static void error(const etl::exception& e);
private:
static ifunction<const exception&>* p_ifunction;
static ifunction<const etl::exception&>* p_ifunction;
};
//***************************************************************************
/// Asserts a coondition.
/// Versions of the macro that return a constant value of 'true' will allow the compiler to optimise away
/// any 'if' statements that it is contained within.
/// If ETL_NO_CHECKS is defined then no runtime checks are executed at all.
/// If ETL_THROW_EXCEPTIONS is defined then the error is thrown if the assert fails. The return value is always 'true'.
/// If ETL_LOG_ERRORS is defined then the error is logged if the assert fails. The return value is the value of the boolean test.
/// Otherwise 'assert' is called. The return value is always 'true'.
///\ingroup error_handler
//***************************************************************************
#if defined(ETL_NO_CHECKS)
#define ETL_ASSERT(b, e) (true) // Does nothing. Evaluates to 'true'.
#elif defined(ETL_THROW_EXCEPTIONS)
#define ETL_ASSERT(b, e) (((b) ? true : throw((e))), true) // Throws an exception if the condition fails. Evaluates to 'true'.
#elif defined (ETL_LOG_ERRORS)
#define ETL_ASSERT(b, e) (((b) ? true : etl::error_handler::error((e))), (b)) // Logs the error if the condition fails. Evaluates to the result of the condition.
#else
#if defined(NDEBUG)
#define ETL_ASSERT(b, e) (true) // Does nothing. Evaluates to 'true'.
#elif
#define ETL_ASSERT(b, e) ((assert((b))), true) // Asserts if the condition fails. Evaluates to 'true'.
#endif
#endif
}
//***************************************************************************
/// Asserts a coondition.
/// Versions of the macro that return a constant value of 'true' will allow the compiler to optimise away
/// any 'if' statements that it is contained within.
/// If ETL_NO_CHECKS is defined then no runtime checks are executed at all.
/// If ETL_THROW_EXCEPTIONS is defined then the error is thrown if the assert fails. The return value is always 'true'.
/// If ETL_LOG_ERRORS is defined then the error is logged if the assert fails. The return value is the value of the boolean test.
/// Otherwise 'assert' is called. The return value is always 'true'.
///\ingroup error_handler
//***************************************************************************
#if defined(ETL_NO_CHECKS)
#define ETL_ASSERT(b, e) (true) // Does nothing. Evaluates to 'true'.
#elif defined(ETL_THROW_EXCEPTIONS)
#define ETL_ASSERT(b, e) (((b) ? true : throw((e))), true) // Throws an exception if the condition fails. Evaluates to 'true'.
#elif defined(ETL_LOG_ERRORS)
#define ETL_ASSERT(b, e) (((b) ? true : etl::error_handler::error((e))), (b)) // Logs the error if the condition fails. Evaluates to the result of the condition.
#else
#if defined(NDEBUG)
#define ETL_ASSERT(b, e) (true) // Does nothing. Evaluates to 'true'.
#elif
#define ETL_ASSERT(b, e) ((assert((b))), true) // Asserts if the condition fails. Evaluates to 'true'.
#endif
#endif
#if defined(ETL_VERBOSE_ERRORS)
#define ETL_ERROR(e) (e(__FILE__, __LINE__)) // Make an exception with the file name and line number.
#else
#define ETL_ERROR(e) (e("", __LINE__)) // Make an exception with the line number.
#endif
#if defined(ETL_VERBOSE_ERRORS)
#define ETL_ERROR_TEXT(verbose_text, terse_text) (verbose_text) // Use the verbose text.
#else
#define ETL_ERROR_TEXT(verbose_text, terse_text) (terse_text) // Use the terse text.
#endif
#endif

View File

@ -44,28 +44,69 @@ namespace etl
{
public:
typedef const char* value_type;
typedef const char* string_type;
typedef int numeric_type;
#if defined(ETL_VERBOSE_ERRORS)
//*************************************************************************
/// Constructor.
//*************************************************************************
exception(value_type reason)
: reason(reason)
exception(string_type reason, string_type file, numeric_type line)
: reason(reason),
file(file),
line(line)
{
}
#else
//*************************************************************************
/// Constructor.
//*************************************************************************
exception(string_type reason, string_type file, numeric_type line)
: reason(reason),
line(line)
{
}
#endif
//***************************************************************************
/// Gets the reason for the exception.
/// \return const char* to the reason.
//***************************************************************************
value_type what() const
string_type what() const
{
return reason;
}
//***************************************************************************
/// Gets the file for the exception.
/// \return const char* to the file.
//***************************************************************************
string_type file_name() const
{
#if defined(ETL_VERBOSE_ERRORS)
return file;
#else
return "";
#endif
}
//***************************************************************************
/// Gets the line for the exception.
/// \return const char* to the line.
//***************************************************************************
numeric_type line_number() const
{
return line;
}
private:
value_type reason; ///< The reason for the exception.
string_type reason; ///< The reason for the exception.
#if defined(ETL_VERBOSE_ERRORS)
string_type file; ///< The file for the exception.
#endif
numeric_type line; ///< The line for the exception.
};
}

View File

@ -51,8 +51,8 @@ namespace etl
{
public:
bitset_exception(const char* what)
: exception(what)
bitset_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -65,8 +65,8 @@ namespace etl
{
public:
bitset_nullptr()
: bitset_exception("bitset: nullptr")
bitset_nullptr(string_type file_name, numeric_type line_number)
: bitset_exception("bitset: nullptr", file_name, line_number)
{
}
};

View File

@ -491,7 +491,7 @@ namespace etl
//*************************************************************************
void assign(size_type n, const value_type& value)
{
if (ETL_ASSERT(n <= MAX_SIZE, deque_full()))
if (ETL_ASSERT(n <= MAX_SIZE, ETL_ERROR(deque_full)))
{
initialise();
@ -513,7 +513,7 @@ namespace etl
//*************************************************************************
reference at(size_t index)
{
ETL_ASSERT(index < current_size, deque_out_of_bounds());
ETL_ASSERT(index < current_size, ETL_ERROR(deque_out_of_bounds));
iterator result(_begin);
result += index;
@ -528,7 +528,7 @@ namespace etl
//*************************************************************************
const_reference at(size_t index) const
{
ETL_ASSERT(index < current_size, deque_out_of_bounds());
ETL_ASSERT(index < current_size, ETL_ERROR(deque_out_of_bounds));
iterator result(_begin);
result += index;
@ -710,7 +710,7 @@ namespace etl
{
iterator position(insert_position.index, *this, p_buffer);
if (ETL_ASSERT(!full(), deque_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(deque_full)))
{
if (insert_position == begin())
{
@ -764,7 +764,7 @@ namespace etl
{
iterator position;
if (ETL_ASSERT((current_size + n) <= MAX_SIZE, deque_full()))
if (ETL_ASSERT((current_size + n) <= MAX_SIZE, ETL_ERROR(deque_full)))
{
if (insert_position == begin())
{
@ -878,7 +878,7 @@ namespace etl
difference_type n = std::distance(range_begin, range_end);
if (ETL_ASSERT((current_size + n) <= MAX_SIZE, deque_full()))
if (ETL_ASSERT((current_size + n) <= MAX_SIZE, ETL_ERROR(deque_full)))
{
if (insert_position == begin())
{
@ -980,7 +980,7 @@ namespace etl
{
iterator position(erase_position.index, *this, p_buffer);
if (ETL_ASSERT(distance(position) <= difference_type(current_size), deque_out_of_bounds()))
if (ETL_ASSERT(distance(position) <= difference_type(current_size), ETL_ERROR(deque_out_of_bounds)))
{
if (position == _begin)
{
@ -1022,7 +1022,7 @@ namespace etl
{
iterator position(range_begin.index, *this, p_buffer);
if (ETL_ASSERT((distance(range_begin) <= difference_type(current_size)) && (distance(range_end) <= difference_type(current_size)), deque_out_of_bounds()))
if (ETL_ASSERT((distance(range_begin) <= difference_type(current_size)) && (distance(range_end) <= difference_type(current_size)), ETL_ERROR(deque_out_of_bounds)))
{
// How many to erase?
size_t length = std::distance(range_begin, range_end);
@ -1087,7 +1087,7 @@ namespace etl
//*************************************************************************
void push_back(parameter_t item)
{
if (ETL_ASSERT(!full(), deque_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(deque_full)))
{
create_element_back(item);
}
@ -1102,7 +1102,7 @@ namespace etl
{
reference r = *_end;
if (ETL_ASSERT(!full(), deque_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(deque_full)))
{
create_element_back();
}
@ -1128,7 +1128,7 @@ namespace etl
//*************************************************************************
void push_front(parameter_t item)
{
if (ETL_ASSERT(!full(), deque_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(deque_full)))
{
create_element_front(item);
}
@ -1141,7 +1141,7 @@ namespace etl
//*************************************************************************
reference push_front()
{
if (ETL_ASSERT(!full(), deque_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(deque_full)))
{
create_element_front();
}
@ -1168,7 +1168,7 @@ namespace etl
//*************************************************************************
void resize(size_t new_size, const value_type& value = value_type())
{
if (ETL_ASSERT(new_size <= MAX_SIZE, deque_out_of_bounds()))
if (ETL_ASSERT(new_size <= MAX_SIZE, ETL_ERROR(deque_out_of_bounds)))
{
// Make it smaller?
if (new_size < current_size)

View File

@ -240,7 +240,7 @@ namespace etl
{
iterator i_element = lower_bound(key);
ETL_ASSERT(i_element != end(), flat_map_out_of_bounds());
ETL_ASSERT(i_element != end(), ETL_ERROR(flat_map_out_of_bounds));
return i_element->second;
}
@ -255,7 +255,7 @@ namespace etl
{
typename buffer_t::const_iterator i_element = lower_bound(key);
ETL_ASSERT(i_element != end(), flat_map_out_of_bounds());
ETL_ASSERT(i_element != end(), ETL_ERROR(flat_map_out_of_bounds));
return i_element->second;
}
@ -273,8 +273,8 @@ namespace etl
#ifdef _DEBUG
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, flat_map_iterator());
ETL_ASSERT(count <= difference_type(capacity()), flat_map_full());
ETL_ASSERT(count >= 0, ETL_ERROR(flat_map_iterator));
ETL_ASSERT(count <= difference_type(capacity()), ETL_ERROR(flat_map_full));
#endif
clear();
@ -299,7 +299,7 @@ namespace etl
if (i_element == end())
{
// At the end.
if (ETL_ASSERT(!buffer.full(), flat_map_full()))
if (ETL_ASSERT(!buffer.full(), ETL_ERROR(flat_map_full)))
{
buffer.push_back(value);
result.first = end() - 1;
@ -320,7 +320,7 @@ namespace etl
else
{
// A new one.
if (ETL_ASSERT(!buffer.full(), flat_map_full()))
if (ETL_ASSERT(!buffer.full(), ETL_ERROR(flat_map_full)))
{
buffer.insert(i_element, value);
result.first = i_element;

View File

@ -223,7 +223,7 @@ namespace etl
{
#ifdef _DEBUG
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, flat_multimap_iterator());
ETL_ASSERT(count >= 0, ETL_ERROR(flat_multimap_iterator));
#endif
clear();
@ -245,7 +245,7 @@ namespace etl
iterator i_element = lower_bound(value.first);
if (ETL_ASSERT(!buffer.full(), flat_multimap_full()))
if (ETL_ASSERT(!buffer.full(), ETL_ERROR(flat_multimap_full)))
{
if (i_element == end())
{

View File

@ -200,7 +200,7 @@ namespace etl
#ifdef _DEBUG
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, flat_multiset_iterator());
ETL_ASSERT(count >= 0, ETL_ERROR(flat_multiset_iterator));
#endif
clear();
@ -220,7 +220,7 @@ namespace etl
{
std::pair<iterator, bool> result(end(), false);
if (ETL_ASSERT(!buffer.full(), flat_multiset_full()))
if (ETL_ASSERT(!buffer.full(), ETL_ERROR(flat_multiset_full)))
{
iterator i_element = std::lower_bound(begin(), end(), value, TKeyCompare());

View File

@ -199,7 +199,7 @@ namespace etl
{
#ifdef _DEBUG
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, flat_set_iterator());
ETL_ASSERT(count >= 0, ETL_ERROR(flat_set_iterator));
#endif
clear();
@ -219,7 +219,7 @@ namespace etl
{
std::pair<iterator, bool> result(end(), false);
if (ETL_ASSERT(!buffer.full(), flat_set_full()))
if (ETL_ASSERT(!buffer.full(), ETL_ERROR(flat_set_full)))
{
iterator i_element = std::lower_bound(begin(), end(), value, TKeyCompare());

View File

@ -363,7 +363,7 @@ namespace etl
{
#ifdef _DEBUG
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, forward_list_iterator());
ETL_ASSERT(count >= 0, ETL_ERROR(forward_list_iterator));
#endif
initialise();
@ -373,7 +373,7 @@ namespace etl
// Add all of the elements.
while (first != last)
{
if (ETL_ASSERT(!full(), forward_list_iterator()))
if (ETL_ASSERT(!full(), ETL_ERROR(forward_list_iterator)))
{
Data_Node& data_node = allocate_data_node(*first++);
join(p_last_node, &data_node);
@ -389,7 +389,7 @@ namespace etl
//*************************************************************************
void assign(size_t n, parameter_t value)
{
if (ETL_ASSERT(n <= MAX_SIZE, forward_list_full()))
if (ETL_ASSERT(n <= MAX_SIZE, ETL_ERROR(forward_list_full)))
{
initialise();
@ -412,7 +412,7 @@ namespace etl
//*************************************************************************
void push_front()
{
if (ETL_ASSERT(!full(), forward_list_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)))
{
Data_Node& data_node = allocate_data_node(T());
insert_node_after(start_node, data_node);
@ -424,7 +424,7 @@ namespace etl
//*************************************************************************
void push_front(parameter_t value)
{
if (ETL_ASSERT(!full(), forward_list_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)))
{
Data_Node& data_node = allocate_data_node(value);
insert_node_after(start_node, data_node);
@ -457,7 +457,7 @@ namespace etl
//*************************************************************************
void resize(size_t n, T value)
{
if (ETL_ASSERT(n <= MAX_SIZE, forward_list_full()))
if (ETL_ASSERT(n <= MAX_SIZE, ETL_ERROR(forward_list_full)))
{
size_t i = 0;
iterator i_node = begin();
@ -493,7 +493,7 @@ namespace etl
//*************************************************************************
iterator insert_after(iterator position, parameter_t value)
{
if (ETL_ASSERT(!full(), forward_list_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)))
{
Data_Node& data_node = allocate_data_node(value);
insert_node_after(*position.p_node, data_node);
@ -507,7 +507,7 @@ namespace etl
//*************************************************************************
void insert_after(iterator position, size_t n, parameter_t value)
{
if (ETL_ASSERT(!full(), forward_list_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(forward_list_full)))
{
for (size_t i = 0; !full() && (i < n); ++i)
{
@ -526,7 +526,7 @@ namespace etl
{
#ifdef _DEBUG
difference_type count = std::distance(first, last);
ETL_ASSERT((count + current_size) <= MAX_SIZE, forward_list_full());
ETL_ASSERT((count + current_size) <= MAX_SIZE, ETL_ERROR(forward_list_full));
#endif
while (first != last)

14
ihash.h
View File

@ -34,10 +34,14 @@ SOFTWARE.
#include <utility>
#include "exception.h"
#include "error_handler.h"
///\defgroup ihash Common data for all hash type classes.
///\ingroup hash
#undef ETL_FILE
#define ETL_FILE "19"
namespace etl
{
//***************************************************************************
@ -48,8 +52,8 @@ namespace etl
{
public:
hash_exception(const char* what)
: exception(what)
hash_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{}
};
@ -61,8 +65,8 @@ namespace etl
{
public:
hash_finalised()
: hash_exception("ihash: finalised")
hash_finalised(string_type file_name, numeric_type line_number)
: hash_exception(ETL_ERROR_TEXT("ihash:finalised", ETL_FILE"A"), file_name, line_number)
{}
};
@ -70,4 +74,6 @@ namespace etl
typedef hash_finalised hash_finalized;
}
#undef ETL_FILE
#endif

22
ilist.h
View File

@ -452,8 +452,8 @@ namespace etl
{
#ifdef _DEBUG
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, list_iterator());
ETL_ASSERT(size_t(count) <= MAX_SIZE, list_full());
ETL_ASSERT(count >= 0, ETL_ERROR(list_iterator));
ETL_ASSERT(size_t(count) <= MAX_SIZE, ETL_ERROR(list_full));
#endif
initialise();
@ -474,7 +474,7 @@ namespace etl
void assign(size_t n, parameter_t value)
{
#ifdef _DEBUG
ETL_ASSERT(n <= MAX_SIZE, list_full());
ETL_ASSERT(n <= MAX_SIZE, ETL_ERROR(list_full));
#endif
initialise();
@ -494,7 +494,7 @@ namespace etl
//*************************************************************************
void push_front()
{
if (ETL_ASSERT(!full(), list_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(list_full)))
{
Data_Node& data_node = allocate_data_node(T());
insert_node(get_head(), data_node);
@ -506,7 +506,7 @@ namespace etl
//*************************************************************************
void push_front(parameter_t value)
{
if (ETL_ASSERT(!full(), list_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(list_full)))
{
Node& data_node = allocate_data_node(value);
insert_node(get_head(), data_node);
@ -530,7 +530,7 @@ namespace etl
//*************************************************************************
void push_back()
{
if (ETL_ASSERT(!full(), list_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(list_full)))
{
Data_Node& data_node = allocate_data_node(T());
insert_node(terminal_node, data_node);
@ -542,7 +542,7 @@ namespace etl
//*************************************************************************
void push_back(parameter_t value)
{
if (ETL_ASSERT(!full(), list_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(list_full)))
{
Data_Node& data_node = allocate_data_node(value);
insert_node(terminal_node, data_node);
@ -566,7 +566,7 @@ namespace etl
//*************************************************************************
iterator insert(iterator position, const value_type& value)
{
if (ETL_ASSERT(!full(), list_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(list_full)))
{
Data_Node& data_node = allocate_data_node(value);
insert_node(*position.p_node, data_node);
@ -582,7 +582,7 @@ namespace etl
{
for (size_t i = 0; i < n; ++i)
{
if (ETL_ASSERT(!full(), list_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(list_full)))
{
// Set up the next free node and insert.
Data_Node& data_node = allocate_data_node(value);
@ -599,7 +599,7 @@ namespace etl
{
while (first != last)
{
if (ETL_ASSERT(!full(), list_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(list_full)))
{
// Set up the next free node and insert.
Data_Node& data_node = allocate_data_node(*first++);
@ -660,7 +660,7 @@ namespace etl
//*************************************************************************
void resize(size_t n, parameter_t value)
{
if (ETL_ASSERT(n <= MAX_SIZE, list_full()))
if (ETL_ASSERT(n <= MAX_SIZE, ETL_ERROR(list_full)))
{
// Smaller?
if (n < size())

28
imap.h
View File

@ -524,16 +524,7 @@ namespace etl
{
iterator i_element = find(key);
if (!i_element.p_node)
{
// Doesn't exist.
#if ETL_THROW_EXCEPTIONS
throw map_out_of_bounds();
#else
error_handler::error(map_out_of_bounds());
#endif
}
ETL_ASSERT(i_element.p_node != nullptr, ETL_ERROR(map_out_of_bounds));
return i_element->second;
}
@ -548,16 +539,7 @@ namespace etl
{
const_iterator i_element = find(key);
if (!i_element.p_node)
{
// Doesn't exist.
#if ETL_THROW_EXCEPTIONS
throw map_out_of_bounds();
#else
error_handler::error(map_out_of_bounds());
#endif
}
ETL_ASSERT(i_element.p_node != nullptr, ETL_ERROR(map_out_of_bounds));
return i_element->second;
}
@ -708,7 +690,7 @@ namespace etl
Node* inserted_node = nullptr;
bool inserted = false;
if (ETL_ASSERT(!full(), map_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(map_full)))
{
// Get next available free node
Data_Node& node = allocate_data_node(value);
@ -733,7 +715,7 @@ namespace etl
// Default to no inserted node
Node* inserted_node = nullptr;
if (ETL_ASSERT(!full(), map_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(map_full)))
{
// Get next available free node
Data_Node& node = allocate_data_node(value);
@ -757,7 +739,7 @@ namespace etl
// Default to no inserted node
Node* inserted_node = nullptr;
if (ETL_ASSERT(!full(), map_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(map_full)))
{
// Get next available free node
Data_Node& node = allocate_data_node(value);

View File

@ -655,7 +655,7 @@ namespace etl
// Default to no inserted node
Node* inserted_node = nullptr;
if (ETL_ASSERT(!full(), multimap_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(multimap_full)))
{
// Get next available free node
Data_Node& node = allocate_data_node(value);

View File

@ -636,7 +636,7 @@ namespace etl
// Default to no inserted node
Node* inserted_node = nullptr;
if (ETL_ASSERT(!full(), multiset_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(multiset_full)))
{
// Get next available free node
Data_Node& node = allocate_data_node(value);

View File

@ -53,8 +53,8 @@ namespace etl
{
public:
intrusive_forward_list_exception(const char* what)
: exception(what)
intrusive_forward_list_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -67,8 +67,8 @@ namespace etl
{
public:
intrusive_forward_list_iterator_exception()
: intrusive_forward_list_exception("intrusive_forward_list: iterator problem")
intrusive_forward_list_iterator_exception(string_type file_name, numeric_type line_number)
: intrusive_forward_list_exception("intrusive_forward_list: iterator", file_name, line_number)
{
}
};
@ -81,8 +81,8 @@ namespace etl
{
public:
intrusive_forward_list_index_exception()
: intrusive_forward_list_exception("intrusive_forward_list: index out of bounds")
intrusive_forward_list_index_exception(string_type file_name, numeric_type line_number)
: intrusive_forward_list_exception("intrusive_forward_list:bounds", file_name, line_number)
{
}
};
@ -408,7 +408,7 @@ namespace etl
{
#ifdef _DEBUG
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, intrusive_forward_list_iterator_exception());
ETL_ASSERT(count >= 0, ETL_ERROR(intrusive_forward_list_iterator_exception));
#endif
initialise();

View File

@ -71,7 +71,7 @@ namespace etl
__private_intrusive_forward_list__::intrusive_forward_list_node_base* get_next(size_t index) const
{
#ifdef _DEBUG
ETL_ASSERT(index < SIZE, intrusive_forward_list_index_exception());
ETL_ASSERT(index < SIZE, ETL_ERROR(intrusive_forward_list_index_exception));
#endif
return next[index];
}
@ -79,7 +79,7 @@ namespace etl
void set_next(size_t index, __private_intrusive_forward_list__::intrusive_forward_list_node_base* pnext)
{
#ifdef _DEBUG
ETL_ASSERT(index < SIZE, intrusive_forward_list_index_exception());
ETL_ASSERT(index < SIZE, ETL_ERROR(intrusive_forward_list_index_exception));
#endif
next[index] = pnext;
}

10
ipool.h
View File

@ -323,9 +323,9 @@ namespace etl
T* allocate()
{
#if defined(_DEBUG) || defined(DEBUG)
if (ETL_ASSERT(items_allocated < MAX_SIZE && !in_use_flags.test(next_free), pool_no_allocation()))
if (ETL_ASSERT(items_allocated < MAX_SIZE && !in_use_flags.test(next_free), ETL_ERROR(pool_no_allocation)))
#else
if (ETL_ASSERT(items_allocated < MAX_SIZE, pool_no_allocation()))
if (ETL_ASSERT(items_allocated < MAX_SIZE, ETL_ERROR(pool_no_allocation)))
#endif
{
T* result = new(&p_buffer[next_free]) T();
@ -349,9 +349,9 @@ namespace etl
T* allocate(const T& initial)
{
#if defined(_DEBUG) || defined(DEBUG)
if (ETL_ASSERT(items_allocated < MAX_SIZE && !in_use_flags.test(next_free), pool_no_allocation()))
if (ETL_ASSERT(items_allocated < MAX_SIZE && !in_use_flags.test(next_free), ETL_ERROR(pool_no_allocation)))
#else
if (ETL_ASSERT(items_allocated < MAX_SIZE, pool_no_allocation()))
if (ETL_ASSERT(items_allocated < MAX_SIZE, ETL_ERROR(pool_no_allocation)))
#endif
{
T* result = new(&p_buffer[next_free]) T(initial);
@ -386,7 +386,7 @@ namespace etl
void release(const T* const p_object)
{
// Does it belong to me?
if (ETL_ASSERT(is_in_pool(p_object), pool_object_not_in_pool()))
if (ETL_ASSERT(is_in_pool(p_object), ETL_ERROR(pool_object_not_in_pool)))
{
// Where is it in the buffer?
typename std::iterator_traits<T*>::difference_type distance = p_object - p_buffer;

View File

@ -101,7 +101,7 @@ namespace etl
//*************************************************************************
void push(parameter_t value)
{
if (ETL_ASSERT(!full(), priority_queue_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(priority_queue_full)))
{
// Put element at end
container.push_back(value);
@ -135,8 +135,8 @@ namespace etl
{
#ifdef _DEBUG
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, priority_queue_iterator());
ETL_ASSERT(static_cast<size_t>(count) <= MAX_SIZE, priority_queue_full());
ETL_ASSERT(count >= 0, ETL_ERROR(priority_queue_iterator));
ETL_ASSERT(static_cast<size_t>(count) <= MAX_SIZE, ETL_ERROR(priority_queue_full));
#endif
clear();

View File

@ -113,7 +113,7 @@ namespace etl
//*************************************************************************
void push(parameter_t value)
{
if (ETL_ASSERT(!full(), queue_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(queue_full)))
{
new(&p_buffer[in]) T(value);
in = (in == (MAX_SIZE - 1)) ? 0 : in + 1;
@ -133,7 +133,7 @@ namespace etl
{
const size_type next = in;
if (ETL_ASSERT(!full(), queue_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(queue_full)))
{
new(&p_buffer[in]) T();
in = (in == (MAX_SIZE - 1)) ? 0 : in + 1;
@ -165,7 +165,7 @@ namespace etl
//*************************************************************************
void pop()
{
if ETL_ASSERT(!empty(), etl::queue_empty())
if ETL_ASSERT(!empty(), ETL_ERROR(queue_empty))
{
p_buffer[out].~T();
out = (out == (MAX_SIZE - 1)) ? 0 : out + 1;

6
iset.h
View File

@ -632,7 +632,7 @@ namespace etl
Node* inserted_node = nullptr;
bool inserted = false;
if (ETL_ASSERT(!full(), set_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(set_full)))
{
// Get next available free node
Data_Node& node = allocate_data_node(value);
@ -657,7 +657,7 @@ namespace etl
// Default to no inserted node
Node* inserted_node = nullptr;
if (ETL_ASSERT(!full(), set_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(set_full)))
{
// Get next available free node
Data_Node& node = allocate_data_node(value);
@ -681,7 +681,7 @@ namespace etl
// Default to no inserted node
Node* inserted_node = nullptr;
if (ETL_ASSERT(!full(), set_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(set_full)))
{
// Get next available free node
Data_Node& node = allocate_data_node(value);

View File

@ -85,7 +85,7 @@ namespace etl
//*************************************************************************
void push(parameter_t value)
{
if (ETL_ASSERT(!full(), stack_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(stack_full)))
{
top_index = current_size++;
new(&p_buffer[top_index]) T(value);
@ -101,7 +101,7 @@ namespace etl
//*************************************************************************
reference push()
{
if (ETL_ASSERT(!full(), stack_full()))
if (ETL_ASSERT(!full(), ETL_ERROR(stack_full)))
{
top_index = current_size++;
new(&p_buffer[top_index]) T();

View File

@ -192,7 +192,7 @@ namespace etl
//*********************************************************************
void resize(size_t new_size)
{
if (ETL_ASSERT(new_size <= MAX_SIZE, vector_full()))
if (ETL_ASSERT(new_size <= MAX_SIZE, ETL_ERROR(vector_full)))
{
// Size up or size down?
if (new_size > current_size)
@ -224,7 +224,7 @@ namespace etl
//*********************************************************************
void resize(size_t new_size, T value)
{
if (ETL_ASSERT(new_size <= MAX_SIZE, vector_full()))
if (ETL_ASSERT(new_size <= MAX_SIZE, ETL_ERROR(vector_full)))
{
// Size up?
if (new_size > current_size)
@ -273,7 +273,7 @@ namespace etl
//*********************************************************************
reference at(size_t i)
{
ETL_ASSERT(i < current_size, vector_out_of_bounds());
ETL_ASSERT(i < current_size, ETL_ERROR(vector_out_of_bounds));
return p_buffer[i];
}
@ -285,7 +285,7 @@ namespace etl
//*********************************************************************
const_reference at(size_t i) const
{
ETL_ASSERT(i < current_size, vector_out_of_bounds());
ETL_ASSERT(i < current_size, ETL_ERROR(vector_out_of_bounds));
return p_buffer[i];
}
@ -355,8 +355,8 @@ namespace etl
{
#ifdef _DEBUG
difference_type count = std::distance(first, last);
ETL_ASSERT(count >= 0, vector_iterator());
ETL_ASSERT(static_cast<size_t>(count) <= MAX_SIZE, vector_full());
ETL_ASSERT(count >= 0, ETL_ERROR(vector_iterator));
ETL_ASSERT(static_cast<size_t>(count) <= MAX_SIZE, ETL_ERROR(vector_full));
#endif
initialise();
@ -379,7 +379,7 @@ namespace etl
{
initialise();
if (ETL_ASSERT(n <= MAX_SIZE, vector_full()))
if (ETL_ASSERT(n <= MAX_SIZE, ETL_ERROR(vector_full)))
{
while (n > 0)
{
@ -403,7 +403,7 @@ namespace etl
//*************************************************************************
void push_back()
{
if (ETL_ASSERT(current_size != MAX_SIZE, vector_full()))
if (ETL_ASSERT(current_size != MAX_SIZE, ETL_ERROR(vector_full)))
{
create_element();
}
@ -416,7 +416,7 @@ namespace etl
//*********************************************************************
void push_back(parameter_t value)
{
if (ETL_ASSERT(current_size != MAX_SIZE, vector_full()))
if (ETL_ASSERT(current_size != MAX_SIZE, ETL_ERROR(vector_full)))
{
create_element(value);
}
@ -442,7 +442,7 @@ namespace etl
//*********************************************************************
iterator insert(iterator position, parameter_t value)
{
if (ETL_ASSERT((current_size) + 1 <= MAX_SIZE, vector_full()))
if (ETL_ASSERT((current_size) + 1 <= MAX_SIZE, ETL_ERROR(vector_full)))
{
create_element(value);
@ -465,7 +465,7 @@ namespace etl
//*********************************************************************
void insert(iterator position, size_t n, parameter_t value)
{
if (ETL_ASSERT((current_size) + 1 <= MAX_SIZE, vector_full()))
if (ETL_ASSERT((current_size) + 1 <= MAX_SIZE, ETL_ERROR(vector_full)))
{
if (position == end())
{
@ -528,7 +528,7 @@ namespace etl
{
size_t count = std::distance(first, last);
if (ETL_ASSERT((current_size) + count <= MAX_SIZE, vector_full()))
if (ETL_ASSERT((current_size) + count <= MAX_SIZE, ETL_ERROR(vector_full)))
{
if (position == end())
{

View File

@ -107,7 +107,7 @@ namespace etl
{
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Incompatible type");
if (ETL_ASSERT(!is_finalised, hash_finalised()))
if (ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised)))
{
while (begin != end)
{
@ -123,7 +123,7 @@ namespace etl
//*************************************************************************
void add(uint8_t value)
{
if (ETL_ASSERT(!is_finalised, hash_finalised()))
if (ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised)))
{
hash += value;
hash += (hash << 10);

View File

@ -120,7 +120,7 @@ namespace etl
{
STATIC_ASSERT(sizeof(typename std::iterator_traits<TIterator>::value_type) == 1, "Incompatible type");
if (ETL_ASSERT(!is_finalised, hash_finalised()))
if (ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised)))
{
while (begin != end)
{
@ -146,7 +146,7 @@ namespace etl
void add(uint8_t value)
{
// We can't add to a finalised hash!
if (ETL_ASSERT(!is_finalised, hash_finalised()))
if (ETL_ASSERT(!is_finalised, ETL_ERROR(hash_finalised)))
{
block |= value << (block_fill_count * 8);

View File

@ -55,6 +55,9 @@ SOFTWARE.
#include "exception.h"
#include "error_handler.h"
#undef ETL_FILE
#define ETL_FILE "18"
namespace etl
{
//***************************************************************************
@ -65,8 +68,8 @@ namespace etl
{
public:
observer_exception(const char* what)
: exception(what)
observer_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -79,8 +82,8 @@ namespace etl
{
public:
observer_list_full()
: observer_exception("observer: list full")
observer_list_full(string_type file_name, numeric_type line_number)
: observer_exception(ETL_ERROR_TEXT("observer:full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -117,7 +120,7 @@ namespace etl
if (i_observer == observer_list.end())
{
// Is there enough room?
if (ETL_ASSERT(!observer_list.full(), etl::observer_list_full()))
if (ETL_ASSERT(!observer_list.full(), ETL_ERROR(etl::observer_list_full)))
{
// Add it.
observer_list.push_back(&observer);
@ -340,4 +343,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -72,8 +72,8 @@ namespace etl
{
public:
optional_exception(const char* what)
: exception(what)
optional_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -86,8 +86,8 @@ namespace etl
{
public:
optional_invalid()
: optional_exception("optional: invalid")
optional_invalid(string_type file_name, numeric_type line_number)
: optional_exception("optional: invalid", file_name, line_number)
{
}
};
@ -215,7 +215,7 @@ namespace etl
T* operator ->()
{
#ifdef _DEBUG
ETL_ASSERT(valid, optional_invalid());
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return storage.template get_address<T>();
@ -227,7 +227,7 @@ namespace etl
const T* operator ->() const
{
#ifdef _DEBUG
ETL_ASSERT(valid, optional_invalid());
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return storage.template get_address<T>();
@ -239,7 +239,7 @@ namespace etl
T& operator *()
{
#ifdef _DEBUG
ETL_ASSERT(valid, optional_invalid());
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return storage.template get_reference<T>();
@ -251,7 +251,7 @@ namespace etl
const T& operator *() const
{
#ifdef _DEBUG
ETL_ASSERT(valid, optional_invalid());
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return storage.template get_reference<T>();
@ -271,7 +271,7 @@ namespace etl
T& value()
{
#ifdef _DEBUG
ETL_ASSERT(valid, optional_invalid());
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return storage.template get_reference<T>();
@ -283,7 +283,7 @@ namespace etl
const T& value() const
{
#ifdef _DEBUG
ETL_ASSERT(valid, optional_invalid());
ETL_ASSERT(valid, ETL_ERROR(optional_invalid));
#endif
return storage.template get_reference<T>();

View File

@ -37,6 +37,10 @@ SOFTWARE.
#include <stddef.h>
#include "../exception.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "1"
namespace etl
{
@ -48,8 +52,8 @@ namespace etl
{
public:
deque_exception(const char* what)
: exception(what)
deque_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -62,8 +66,8 @@ namespace etl
{
public:
deque_full()
: deque_exception("deque: full")
deque_full(string_type file_name, numeric_type line_number)
: deque_exception(ETL_ERROR_TEXT("deque:full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -76,8 +80,8 @@ namespace etl
{
public:
deque_empty()
: deque_exception("deque: empty")
deque_empty(string_type file_name, numeric_type line_number)
: deque_exception(ETL_ERROR_TEXT("deque:empty", ETL_FILE"B"), file_name, line_number)
{
}
};
@ -90,8 +94,8 @@ namespace etl
{
public:
deque_out_of_bounds()
: deque_exception("deque: out of bounds")
deque_out_of_bounds(string_type file_name, numeric_type line_number)
: deque_exception(ETL_ERROR_TEXT("deque:bounds", ETL_FILE"C"), file_name, line_number)
{
}
};
@ -169,4 +173,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -40,6 +40,9 @@ SOFTWARE.
#include "../ivector.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "2"
namespace etl
{
//***************************************************************************
@ -50,8 +53,8 @@ namespace etl
{
public:
flat_map_exception(const char* what)
: exception(what)
flat_map_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -64,8 +67,8 @@ namespace etl
{
public:
flat_map_full()
: flat_map_exception("flat_map: full")
flat_map_full(string_type file_name, numeric_type line_number)
: flat_map_exception(ETL_ERROR_TEXT("flat_map: full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -78,8 +81,8 @@ namespace etl
{
public:
flat_map_out_of_bounds()
: flat_map_exception("flat_map: out of bounds")
flat_map_out_of_bounds(string_type file_name, numeric_type line_number)
: flat_map_exception(ETL_ERROR_TEXT("flat_map:bounds", ETL_FILE"B"), file_name, line_number)
{
}
};
@ -92,8 +95,8 @@ namespace etl
{
public:
flat_map_iterator()
: flat_map_exception("flat_map: iterator error")
flat_map_iterator(string_type file_name, numeric_type line_number)
: flat_map_exception(ETL_ERROR_TEXT("flat_map:iterator", ETL_FILE"C"), file_name, line_number)
{
}
};
@ -176,4 +179,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -40,6 +40,9 @@ SOFTWARE.
#include "../ivector.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "3"
namespace etl
{
//***************************************************************************
@ -50,8 +53,8 @@ namespace etl
{
public:
flat_multimap_exception(const char* what)
: exception(what)
flat_multimap_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -64,8 +67,8 @@ namespace etl
{
public:
flat_multimap_full()
: flat_multimap_exception("flat_multimap: full")
flat_multimap_full(string_type file_name, numeric_type line_number)
: flat_multimap_exception(ETL_ERROR_TEXT("flat_multimap:full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -78,8 +81,8 @@ namespace etl
{
public:
flat_multimap_out_of_bounds()
: flat_multimap_exception("flat_multimap: out of bounds")
flat_multimap_out_of_bounds(string_type file_name, numeric_type line_number)
: flat_multimap_exception(ETL_ERROR_TEXT("flat_multimap:bounds", ETL_FILE"B"), file_name, line_number)
{
}
};
@ -92,8 +95,8 @@ namespace etl
{
public:
flat_multimap_iterator()
: flat_multimap_exception("flat_multimap: iterator error")
flat_multimap_iterator(string_type file_name, numeric_type line_number)
: flat_multimap_exception(ETL_ERROR_TEXT("flat_multimap:iterator", ETL_FILE"C"), file_name, line_number)
{
}
};

View File

@ -40,6 +40,9 @@ SOFTWARE.
#include "../ivector.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "4"
namespace etl
{
//***************************************************************************
@ -50,8 +53,8 @@ namespace etl
{
public:
flat_multiset_exception(const char* what)
: exception(what)
flat_multiset_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -64,8 +67,8 @@ namespace etl
{
public:
flat_multiset_full()
: flat_multiset_exception("flat_multiset: full")
flat_multiset_full(string_type file_name, numeric_type line_number)
: flat_multiset_exception(ETL_ERROR_TEXT("flat_multiset:full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -78,8 +81,8 @@ namespace etl
{
public:
flat_multiset_out_of_bounds()
: flat_multiset_exception("flat_multiset: out of bounds")
flat_multiset_out_of_bounds(string_type file_name, numeric_type line_number)
: flat_multiset_exception(ETL_ERROR_TEXT("flat_multiset:bounds", ETL_FILE"B"), file_name, line_number)
{
}
};
@ -92,8 +95,8 @@ namespace etl
{
public:
flat_multiset_iterator()
: flat_multiset_exception("flat_multiset: iterator error")
flat_multiset_iterator(string_type file_name, numeric_type line_number)
: flat_multiset_exception(ETL_ERROR_TEXT("flat_multiset:iterator", ETL_FILE"C"), file_name, line_number)
{
}
};
@ -176,4 +179,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -40,6 +40,9 @@ SOFTWARE.
#include "../ivector.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "5"
namespace etl
{
//***************************************************************************
@ -50,8 +53,8 @@ namespace etl
{
public:
flat_set_exception(const char* what)
: exception(what)
flat_set_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -64,8 +67,8 @@ namespace etl
{
public:
flat_set_full()
: flat_set_exception("flat_set: full")
flat_set_full(string_type file_name, numeric_type line_number)
: flat_set_exception(ETL_ERROR_TEXT("flat_set:full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -78,8 +81,8 @@ namespace etl
{
public:
flat_set_out_of_bounds()
: flat_set_exception("flat_set: out of bounds")
flat_set_out_of_bounds(string_type file_name, numeric_type line_number)
: flat_set_exception(ETL_ERROR_TEXT("flat_set:bounds", ETL_FILE"B"), file_name, line_number)
{
}
};
@ -92,8 +95,8 @@ namespace etl
{
public:
flat_set_iterator()
: flat_set_exception("flat_set: iterator error")
flat_set_iterator(string_type file_name, numeric_type line_number)
: flat_set_exception(ETL_ERROR_TEXT("flat_set:iterator", ETL_FILE"C"), file_name, line_number)
{
}
};
@ -176,4 +179,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -36,6 +36,10 @@ SOFTWARE.
#include <stddef.h>
#include "../exception.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "6"
namespace etl
{
@ -47,8 +51,8 @@ namespace etl
{
public:
forward_list_exception(const char* what)
: exception(what)
forward_list_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -61,8 +65,8 @@ namespace etl
{
public:
forward_list_full()
: forward_list_exception("forward list: full")
forward_list_full(string_type file_name, numeric_type line_number)
: forward_list_exception(ETL_ERROR_TEXT("forward_list:full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -75,8 +79,8 @@ namespace etl
{
public:
forward_list_iterator()
: forward_list_exception("forward_list: iterator problem")
forward_list_iterator(string_type file_name, numeric_type line_number)
: forward_list_exception(ETL_ERROR_TEXT("forward_list:iterator", ETL_FILE"B"), file_name, line_number)
{
}
};
@ -240,4 +244,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -36,6 +36,10 @@ SOFTWARE.
#include <stddef.h>
#include "../exception.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "7"
namespace etl
{
@ -47,8 +51,8 @@ namespace etl
{
public:
list_exception(const char* what)
: exception(what)
list_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -61,8 +65,8 @@ namespace etl
{
public:
list_full()
: list_exception("list: full")
list_full(string_type file_name, numeric_type line_number)
: list_exception(ETL_ERROR_TEXT("list:full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -75,8 +79,8 @@ namespace etl
{
public:
list_iterator()
: list_exception("list: iterator problem")
list_iterator(string_type file_name, numeric_type line_number)
: list_exception(ETL_ERROR_TEXT("list:iterator", ETL_FILE"B"), file_name, line_number)
{
}
};
@ -261,4 +265,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -36,6 +36,10 @@ SOFTWARE.
#include <stddef.h>
#include "../exception.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "8"
namespace etl
{
@ -47,8 +51,8 @@ namespace etl
{
public:
map_exception(const char* what)
: exception(what)
map_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -61,8 +65,8 @@ namespace etl
{
public:
map_full()
: map_exception("map: full")
map_full(string_type file_name, numeric_type line_number)
: map_exception("map:full", file_name, line_number)
{
}
};
@ -75,8 +79,8 @@ namespace etl
{
public:
map_out_of_bounds()
: map_exception("map: out of bounds")
map_out_of_bounds(string_type file_name, numeric_type line_number)
: map_exception("map:bounds", file_name, line_number)
{
}
};
@ -89,8 +93,8 @@ namespace etl
{
public:
map_iterator()
: map_exception("map: iterator problem")
map_iterator(string_type file_name, numeric_type line_number)
: map_exception("map:iterator", file_name, line_number)
{
}
};
@ -417,4 +421,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -36,6 +36,10 @@ SOFTWARE.
#include <stddef.h>
#include "../exception.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "9"
namespace etl
{
@ -47,8 +51,8 @@ namespace etl
{
public:
multimap_exception(const char* what)
: exception(what)
multimap_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -61,8 +65,8 @@ namespace etl
{
public:
multimap_full()
: multimap_exception("multimap: full")
multimap_full(string_type file_name, numeric_type line_number)
: multimap_exception("multimap:full", file_name, line_number)
{
}
};
@ -75,8 +79,8 @@ namespace etl
{
public:
multimap_out_of_bounds()
: multimap_exception("multimap: out of bounds")
multimap_out_of_bounds(string_type file_name, numeric_type line_number)
: multimap_exception("multimap:bounds", file_name, line_number)
{
}
};
@ -89,8 +93,8 @@ namespace etl
{
public:
multimap_iterator()
: multimap_exception("multimap: iterator problem")
multimap_iterator(string_type file_name, numeric_type line_number)
: multimap_exception("multimap:iterator", file_name, line_number)
{
}
};

View File

@ -36,6 +36,10 @@ SOFTWARE.
#include <stddef.h>
#include "../exception.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "10"
namespace etl
{
@ -47,8 +51,8 @@ namespace etl
{
public:
multiset_exception(const char* what)
: exception(what)
multiset_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -61,8 +65,8 @@ namespace etl
{
public:
multiset_full()
: multiset_exception("multiset: full")
multiset_full(string_type file_name, numeric_type line_number)
: multiset_exception(ETL_ERROR_TEXT("multiset:full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -75,8 +79,8 @@ namespace etl
{
public:
multiset_out_of_bounds()
: multiset_exception("multiset: out of bounds")
multiset_out_of_bounds(string_type file_name, numeric_type line_number)
: multiset_exception(ETL_ERROR_TEXT("multiset:bounds", ETL_FILE"B"), file_name, line_number)
{
}
};
@ -89,8 +93,8 @@ namespace etl
{
public:
multiset_iterator()
: multiset_exception("multiset: iterator problem")
multiset_iterator(string_type file_name, numeric_type line_number)
: multiset_exception(ETL_ERROR_TEXT("multiset:iterator", ETL_FILE"C"), file_name, line_number)
{
}
};
@ -577,4 +581,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -38,6 +38,10 @@ SOFTWARE.
#include "../exception.h"
#include "../error_handler.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "11"
namespace etl
{
@ -49,8 +53,8 @@ namespace etl
{
public:
pool_exception(const char* what)
: exception(what)
pool_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{}
};
@ -62,8 +66,8 @@ namespace etl
{
public:
pool_no_allocation()
: pool_exception("pool: no allocation")
explicit pool_no_allocation(string_type file_name, numeric_type line_number)
: pool_exception(ETL_ERROR_TEXT("pool:allocation", ETL_FILE"A"), file_name, line_number)
{}
};
@ -75,8 +79,8 @@ namespace etl
{
public:
pool_object_not_in_pool()
: pool_exception("pool: not in pool")
pool_object_not_in_pool(string_type file_name, numeric_type line_number)
: pool_exception(ETL_ERROR_TEXT("pool:notinpool", ETL_FILE"B"), file_name, line_number)
{}
};
@ -122,5 +126,8 @@ namespace etl
const size_t MAX_SIZE; ///< The maximum number of objects that can be allocated.
};
}
#undef ETL_FILE
#endif

View File

@ -37,6 +37,10 @@ SOFTWARE.
#include <stddef.h>
#include "../exception.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "12"
namespace etl
{
@ -48,8 +52,8 @@ namespace etl
{
public:
priority_queue_exception(const char* what)
: exception(what)
priority_queue_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -62,8 +66,8 @@ namespace etl
{
public:
priority_queue_full()
: priority_queue_exception("priority_queue: full")
priority_queue_full(string_type file_name, numeric_type line_number)
: priority_queue_exception(ETL_ERROR_TEXT("priority_queue:full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -76,8 +80,8 @@ namespace etl
{
public:
priority_queue_iterator()
: priority_queue_exception("priority_queue: iterator error")
priority_queue_iterator(string_type file_name, numeric_type line_number)
: priority_queue_exception(ETL_ERROR_TEXT("priority_queue:iterator", ETL_FILE"B"), file_name, line_number)
{
}
};
@ -151,4 +155,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -37,6 +37,10 @@ SOFTWARE.
#include <stddef.h>
#include "../exception.h"
#include "../error_handler.h"
#undef ETL_FILE
#define ETL_FILE "13"
namespace etl
{
@ -48,8 +52,8 @@ namespace etl
{
public:
queue_exception(const char* what)
: exception(what)
queue_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -62,8 +66,8 @@ namespace etl
{
public:
queue_full()
: queue_exception("queue: full")
queue_full(string_type file_name, numeric_type line_number)
: queue_exception(ETL_ERROR_TEXT("queue:full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -76,8 +80,8 @@ namespace etl
{
public:
queue_empty()
: queue_exception("queue: empty")
queue_empty(string_type file_name, numeric_type line_number)
: queue_exception(ETL_ERROR_TEXT("queue:empty", ETL_FILE"B"), file_name, line_number)
{
}
};
@ -155,4 +159,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -36,6 +36,9 @@ SOFTWARE.
#include <stddef.h>
#include "../exception.h"
#include "../error_handler.h"
#define ETL_FILE "14"
namespace etl
{
@ -47,8 +50,8 @@ namespace etl
{
public:
set_exception(const char* what)
: exception(what)
set_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -61,8 +64,8 @@ namespace etl
{
public:
set_full()
: set_exception("set: full")
set_full(string_type file_name, numeric_type line_number)
: set_exception(ETL_ERROR_TEXT("set:full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -75,8 +78,8 @@ namespace etl
{
public:
set_out_of_bounds()
: set_exception("set: out of bounds")
set_out_of_bounds(string_type file_name, numeric_type line_number)
: set_exception(ETL_ERROR_TEXT("set:bounds", ETL_FILE"B"), file_name, line_number)
{
}
};
@ -89,8 +92,8 @@ namespace etl
{
public:
set_iterator()
: set_exception("set: iterator problem")
set_iterator(string_type file_name, numeric_type line_number)
: set_exception(ETL_ERROR_TEXT("set:iterator problem", ETL_FILE"C"), file_name, line_number)
{
}
};
@ -418,4 +421,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -37,6 +37,9 @@ SOFTWARE.
#include <stddef.h>
#include "../exception.h"
#include "../error_handler.h"
#define ETL_FILE "15"
namespace etl
{
@ -48,8 +51,8 @@ namespace etl
{
public:
stack_exception(const char* what)
: exception(what)
stack_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -62,8 +65,8 @@ namespace etl
{
public:
stack_full()
: stack_exception("stack: full")
stack_full(string_type file_name, numeric_type line_number)
: stack_exception(ETL_ERROR_TEXT("stack: full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -140,4 +143,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -36,6 +36,9 @@ SOFTWARE.
#include <stddef.h>
#include "../exception.h"
#include "../error_handler.h"
#define ETL_FILE "16"
namespace etl
{
@ -47,8 +50,8 @@ namespace etl
{
public:
unordered_map_exception(const char* what)
: exception(what)
unordered_map_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -61,8 +64,8 @@ namespace etl
{
public:
unordered_map_full()
: unordered_map_exception("unordered_map: full")
unordered_map_full(string_type file_name, numeric_type line_number)
: unordered_map_exception(ETL_ERROR_TEXT("unordered_map:full", ETL_FILE"A"), file_name, line_number)
{
}
};
@ -75,8 +78,8 @@ namespace etl
{
public:
unordered_map_out_of_range()
: unordered_map_exception("unordered_map: out of range")
unordered_map_out_of_range(string_type file_name, numeric_type line_number)
: unordered_map_exception(ETL_ERROR_TEXT("unordered_map:range", ETL_FILE"B"), file_name, line_number)
{}
};
@ -88,8 +91,8 @@ namespace etl
{
public:
unordered_map_iterator()
: unordered_map_exception("unordered_map: iterator problem")
unordered_map_iterator(string_type file_name, numeric_type line_number)
: unordered_map_exception("unordered_map:iterator", file_name, line_number)
{
}
};
@ -161,4 +164,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -39,6 +39,8 @@ SOFTWARE.
#include "../exception.h"
#include "../error_handler.h"
#define ETL_FILE "17"
namespace etl
{
//***************************************************************************
@ -49,8 +51,8 @@ namespace etl
{
public:
vector_exception(const char* what)
: exception(what)
vector_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -63,8 +65,8 @@ namespace etl
{
public:
vector_full()
: vector_exception("vector: full")
vector_full(string_type file_name, numeric_type line_number)
: vector_exception(ETL_ERROR_TEXT("vector:full", ETL_FILE"0"), file_name, line_number)
{
}
};
@ -77,8 +79,8 @@ namespace etl
{
public:
vector_out_of_bounds()
: vector_exception("vector: out of bounds")
vector_out_of_bounds(string_type file_name, numeric_type line_number)
: vector_exception(ETL_ERROR_TEXT("vector:bounds", ETL_FILE"1"), file_name, line_number)
{
}
};
@ -91,8 +93,8 @@ namespace etl
{
public:
vector_iterator()
: vector_exception("vector: iterator error")
vector_iterator(string_type file_name, numeric_type line_number)
: vector_exception(ETL_ERROR_TEXT("vector:iterator", ETL_FILE"2"), file_name, line_number)
{
}
};
@ -177,4 +179,6 @@ namespace etl
};
}
#undef ETL_FILE
#endif

View File

@ -26,6 +26,9 @@ SOFTWARE.
******************************************************************************/
#include <UnitTest++/UnitTest++.h>
#include <Windows.h>
#include <sstream>
#include <string>
#include "../error_handler.h"
#include "../exception.h"
@ -39,8 +42,8 @@ class test_exception : public etl::exception
{
public:
test_exception()
: exception("test_exception")
test_exception(string_type file_name, numeric_type line_number)
: exception(ETL_ERROR_TEXT("test_exception", "123"), file_name, line_number)
{
error_received = false;
}
@ -49,9 +52,19 @@ public:
//*****************************************************************************
// A free error handler function.
//*****************************************************************************
void receive_error(const etl::exception&)
void receive_error(const etl::exception& e)
{
error_received = true;
std::ostringstream oss;
oss << "Error '" << e.what() << "' in " << e.file_name() << " at line " << e.line_number() << "\n";
std::string stext = oss.str();
WCHAR text[200];
MultiByteToWideChar(0, 0, stext.c_str(), stext.size() + 1, text, 200);
LPCWSTR ltext = text;
OutputDebugString(ltext);
}
//*****************************************************************************
@ -62,9 +75,19 @@ public:
//***************************************************************************
// A member error handler function.
//***************************************************************************
void receive_error(const etl::exception&)
void receive_error(const etl::exception& e)
{
error_received = true;
std::ostringstream oss;
oss << "Error '" << e.what() << "' in " << e.file_name() << " at line " << e.line_number() << "\n";
std::string stext = oss.str();
WCHAR text[200];
MultiByteToWideChar(0, 0, stext.c_str(), stext.size() + 1, text, 200);
LPCWSTR ltext = text;
OutputDebugString(ltext);
}
};
@ -82,7 +105,7 @@ namespace
etl::error_handler::set_callback(error_callback);
// Log an error.
etl::error_handler::error(test_exception());
etl::error_handler::error(ETL_ERROR(test_exception));
CHECK(error_received);
}
@ -100,7 +123,7 @@ namespace
etl::error_handler::set_callback(error_callback);
// Log an error.
etl::error_handler::error(test_exception());
etl::error_handler::error(ETL_ERROR(test_exception));
CHECK(error_received);
}

View File

@ -37,15 +37,21 @@ namespace
//*************************************************************************
TEST(test_constructor)
{
etl::exception e("An exception");
etl::exception e("An exception", "Some file", 123);
std::string what(e.what());
std::string file(e.file_name());
int line(e.line_number());
CHECK_EQUAL(std::string("An exception"), std::string(e.what()));
CHECK_EQUAL(std::string("Some file"), std::string(e.file_name()));
CHECK_EQUAL(123, e.line_number());
}
//*************************************************************************
TEST(test_exception)
{
etl::exception e("An exception");
etl::exception e("An exception", "Some file", 123);
try
{
@ -53,7 +59,13 @@ namespace
}
catch (etl::exception& c)
{
std::string what(c.what());
std::string file(c.file_name());
int line(c.line_number());
CHECK_EQUAL(std::string("An exception"), std::string(c.what()));
CHECK_EQUAL(std::string("Some file"), std::string(c.file_name()));
CHECK_EQUAL(123, c.line_number());
}
}
};

View File

@ -53,7 +53,7 @@
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_THROW_EXCEPTIONS;PLATFORM_WINDOWS;COMPILER_MICROSOFT;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_LIB;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;ETL_THROW_EXCEPTIONS;PLATFORM_WINDOWS;COMPILER_MICROSOFT;ETL_VERBOSE_ERRORS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../../../unittest-cpp</AdditionalIncludeDirectories>
<UndefinePreprocessorDefinitions>
</UndefinePreprocessorDefinitions>
@ -329,8 +329,6 @@
</ItemGroup>
<ItemGroup>
<None Include="..\..\Doxyfile" />
<None Include="ClassDiagram.cd" />
<None Include="ClassDiagram1.cd" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -718,7 +718,5 @@
<None Include="..\..\Doxyfile">
<Filter>Header Files</Filter>
</None>
<None Include="ClassDiagram.cd" />
<None Include="ClassDiagram1.cd" />
</ItemGroup>
</Project>

View File

@ -73,8 +73,8 @@ namespace etl
class variant_exception : public exception
{
public:
variant_exception(const char* what)
: exception(what)
variant_exception(string_type what, string_type file_name, numeric_type line_number)
: exception(what, file_name, line_number)
{
}
};
@ -86,8 +86,8 @@ namespace etl
class variant_incorrect_type_exception : public variant_exception
{
public:
variant_incorrect_type_exception()
: variant_exception("variant: unsupported type")
variant_incorrect_type_exception(string_type file_name, numeric_type line_number)
: variant_exception("variant: unsupported type", file_name, line_number)
{
}
};
@ -99,8 +99,8 @@ namespace etl
class variant_invalid_type_id_exception : public variant_exception
{
public:
variant_invalid_type_id_exception()
: variant_exception("variant: invalid type id")
variant_invalid_type_id_exception(string_type file_name, numeric_type line_number)
: variant_exception("variant: invalid type id", file_name, line_number)
{
}
};
@ -444,7 +444,7 @@ namespace etl
case 6: return reinterpret_cast<U7&>(*p_data);
case 7: return reinterpret_cast<U8&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -463,7 +463,7 @@ namespace etl
case 6: return reinterpret_cast<const U7&>(*p_data);
case 7: return reinterpret_cast<const U8&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -490,7 +490,7 @@ namespace etl
case 5: return reinterpret_cast<U6&>(*p_data);
case 6: return reinterpret_cast<U7&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -508,7 +508,7 @@ namespace etl
case 5: return reinterpret_cast<const U6&>(*p_data);
case 6: return reinterpret_cast<const U7&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -534,7 +534,7 @@ namespace etl
case 4: return reinterpret_cast<U5&>(*p_data);
case 5: return reinterpret_cast<U6&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -551,7 +551,7 @@ namespace etl
case 4: return reinterpret_cast<const U5&>(*p_data);
case 5: return reinterpret_cast<const U6&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -576,7 +576,7 @@ namespace etl
case 3: return reinterpret_cast<U4&>(*p_data);
case 4: return reinterpret_cast<U5&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -592,7 +592,7 @@ namespace etl
case 3: return reinterpret_cast<const U4&>(*p_data);
case 4: return reinterpret_cast<const U5&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -616,7 +616,7 @@ namespace etl
case 2: return reinterpret_cast<U3&>(*p_data);
case 3: return reinterpret_cast<U4&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -631,7 +631,7 @@ namespace etl
case 2: return reinterpret_cast<const U3&>(*p_data);
case 3: return reinterpret_cast<const U4&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -654,7 +654,7 @@ namespace etl
case 1: return reinterpret_cast<U2&>(*p_data);
case 2: return reinterpret_cast<U3&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -668,7 +668,7 @@ namespace etl
case 1: return reinterpret_cast<const U2&>(*p_data);
case 2: return reinterpret_cast<const U3&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -690,7 +690,7 @@ namespace etl
case 0: return reinterpret_cast<U1&>(*p_data);
case 1: return reinterpret_cast<U2&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -703,7 +703,7 @@ namespace etl
case 0: return reinterpret_cast<const U1&>(*p_data);
case 1: return reinterpret_cast<const U2&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -724,7 +724,7 @@ namespace etl
{
case 0: return reinterpret_cast<U1&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -736,7 +736,7 @@ namespace etl
{
case 0: return reinterpret_cast<const U1&>(*p_data);
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
return reinterpret_cast<TBase&>(*p_data);
break;
}
@ -825,7 +825,7 @@ namespace etl
case 6: is_same_type = type_id == Type_Id_Lookup<U7>::type_id; break;
case 7: is_same_type = type_id == Type_Id_Lookup<U8>::type_id; break;
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
break;
}
@ -849,7 +849,7 @@ namespace etl
case 6: reader.read(static_cast<T7&>(data)); break;
case 7: reader.read(static_cast<T8&>(data)); break;
default:
ETL_ASSERT(false, variant_invalid_type_id_exception());
ETL_ASSERT(false, ETL_ERROR(variant_invalid_type_id_exception));
break;
}
}
@ -890,7 +890,7 @@ namespace etl
T& get()
{
STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
ETL_ASSERT(is_type<T>(), variant_incorrect_type_exception());
ETL_ASSERT(is_type<T>(), ETL_ERROR(variant_incorrect_type_exception));
return static_cast<T&>(data);
}
@ -904,7 +904,7 @@ namespace etl
const T& get() const
{
STATIC_ASSERT(Type_Is_Supported<T>::value, "Unsupported type");
ETL_ASSERT(is_type<T>(), variant_incorrect_type_exception());
ETL_ASSERT(is_type<T>(), ETL_ERROR(variant_incorrect_type_exception));
return static_cast<const T&>(data);
}