Changed to stddef.h

Added error_hander support
This commit is contained in:
jwellbelove 2014-12-08 20:13:24 +00:00
parent 80791c1e11
commit e0dd8eae1a
3 changed files with 60 additions and 24 deletions

View File

@ -29,7 +29,7 @@ SOFTWARE.
#ifndef __ETL_LIST__
#define __ETL_LIST__
#include <cstddef>
#include <stddef.h>
#include "iforward_list.h"
#include "container.h"
@ -66,7 +66,7 @@ namespace etl
//*************************************************************************
/// Default constructor.
//*************************************************************************
inline forward_list()
forward_list()
: iforward_list<T>(&node_pool[0], MAX_SIZE)
{
}
@ -74,7 +74,7 @@ namespace etl
//*************************************************************************
/// Construct from size and value.
//*************************************************************************
inline explicit forward_list(size_t initialSize, typename iforward_list<T>::parameter_t value = T())
explicit forward_list(size_t initialSize, typename iforward_list<T>::parameter_t value = T())
: iforward_list<T>(&node_pool[0], MAX_SIZE)
{
iforward_list<T>::assign(initialSize, value);

View File

@ -33,12 +33,11 @@ SOFTWARE.
#ifndef __ETL_LIST_BASE__
#define __ETL_LIST_BASE__
#include <cstddef>
#include <stddef.h>
#include "exception.h"
namespace etl
{
#ifdef ETL_USE_EXCEPTIONS
//***************************************************************************
/// Exception for the forward_list.
///\ingroup forward_list
@ -62,7 +61,7 @@ namespace etl
public:
forward_list_full()
: forward_list_exception("List full")
: forward_list_exception("forward list: full")
{
}
};
@ -76,11 +75,10 @@ namespace etl
public:
forward_list_iterator()
: forward_list_exception("Iterator problem")
: forward_list_exception("forward_list: iterator problem")
{
}
};
#endif
//***************************************************************************
/// The base class for all forward_lists.
@ -124,6 +122,15 @@ namespace etl
return count == MAX_SIZE;
}
//*************************************************************************
/// Returns the remaining capacity.
///\return The remaining capacity.
//*************************************************************************
size_t available() const
{
return max_size() - size();
}
protected:
//*************************************************************************

View File

@ -37,7 +37,7 @@ SOFTWARE.
#include <iterator>
#include <algorithm>
#include <functional>
#include <cstddef>
#include <stddef.h>
#include "nullptr.h"
#include "forward_list_base.h"
@ -374,8 +374,8 @@ namespace etl
//*************************************************************************
/// Assigns a range of values to the forward_list.
/// If ETL_USE_EXCEPTIONS is defined throws etl::forward_list_full if the forward_list does not have enough free space.
/// If ETL_USE_EXCEPTIONS & _DEBUG are defined throws forward_list_iterator if the iterators are reversed.
/// If ETL_THROW_EXCEPTIONS is defined throws etl::forward_list_full if the forward_list does not have enough free space.
/// If ETL_THROW_EXCEPTIONS & _DEBUG are defined throws forward_list_iterator if the iterators are reversed.
//*************************************************************************
template <typename TIterator>
void assign(TIterator first, TIterator last)
@ -398,11 +398,15 @@ namespace etl
join(data_node, end_node);
p_last_node = &data_node;
}
#ifdef ETL_USE_EXCEPTIONS
else
#ifdef ETL_THROW_EXCEPTIONS
{
throw forward_list_full();
}
#else
{
error_handler::error(forward_list_full());
}
#endif
}
@ -440,11 +444,15 @@ namespace etl
join(data_node, end_node);
p_last_node = &data_node;
}
#ifdef ETL_USE_EXCEPTIONS
else
#ifdef ETL_THROW_EXCEPTIONS
{
throw forward_list_full();
}
#else
{
error_handler::error(forward_list_full());
}
#endif
}
@ -470,11 +478,15 @@ namespace etl
insert_node(get_head(), data_node);
}
#ifdef ETL_USE_EXCEPTIONS
else
#ifdef ETL_THROW_EXCEPTIONS
{
throw forward_list_full();
}
#else
{
error_handler::error(forward_list_full());
}
#endif
}
@ -490,11 +502,15 @@ namespace etl
insert_node_after(get_head(), data_node);
}
#ifdef ETL_USE_EXCEPTIONS
else
#ifdef ETL_THROW_EXCEPTIONS
{
throw forward_list_full();
}
#else
{
error_handler::error(forward_list_full());
}
#endif
}
@ -519,7 +535,7 @@ namespace etl
//*************************************************************************
/// Resizes the forward_list.
/// If ETL_USE_EXCEPTIONS is defined, will throw an etl::forward_list_full
/// If ETL_THROW_EXCEPTIONS is defined, will throw an etl::forward_list_full
/// if <b>n</b> is larger than the maximum size.
//*************************************************************************
void resize(size_t n, T value)
@ -550,11 +566,15 @@ namespace etl
}
}
}
#if ETL_USE_EXCEPTIONS
else
#ifdef ETL_THROW_EXCEPTIONS
{
throw forward_list_full();
}
#else
{
error_handler::error(forward_list_full());
}
#endif
}
@ -600,14 +620,15 @@ namespace etl
return iterator(data_node);
}
#if ETL_USE_EXCEPTIONS
else
#ifdef ETL_THROW_EXCEPTIONS
{
throw forward_list_full();
return end();
}
#else
{
error_handler::error(forward_list_full());
return end();
}
#endif
@ -629,11 +650,15 @@ namespace etl
insert_node(*position.p_node, data_node);
}
}
#if ETL_USE_EXCEPTIONS
else
#ifdef ETL_THROW_EXCEPTIONS
{
throw forward_list_full();
}
#else
{
error_handler::error(forward_list_full());
}
#endif
}
@ -655,11 +680,15 @@ namespace etl
++first;
++position;
}
#if ETL_USE_EXCEPTIONS
else
#ifdef ETL_THROW_EXCEPTIONS
{
throw forward_list_full();
}
#else
{
error_handler::error(forward_list_full());
}
#endif
}
}
@ -944,7 +973,7 @@ namespace etl
//*************************************************************************
/// Downcast a Node* to a Data_Node*
//*************************************************************************
inline static Data_Node* data_cast(Node* p_node)
static Data_Node* data_cast(Node* p_node)
{
return static_cast<Data_Node*>(p_node);
}
@ -952,7 +981,7 @@ namespace etl
//*************************************************************************
/// Downcast a Node& to a Data_Node&
//*************************************************************************
inline static Data_Node& data_cast(Node& node)
static Data_Node& data_cast(Node& node)
{
return static_cast<Data_Node&>(node);
}
@ -960,7 +989,7 @@ namespace etl
//*************************************************************************
/// Downcast a const Node* to a const Data_Node*
//*************************************************************************
inline static const Data_Node* data_cast(const Node* p_node)
static const Data_Node* data_cast(const Node* p_node)
{
return static_cast<const Data_Node*>(p_node);
}
@ -968,7 +997,7 @@ namespace etl
//*************************************************************************
/// Downcast a const Node& to a const Data_Node&
//*************************************************************************
inline static const Data_Node& data_cast(const Node& node)
static const Data_Node& data_cast(const Node& node)
{
return static_cast<const Data_Node&>(node);
}