diff --git a/etk/Exception.hpp b/etk/Exception.hpp index 62033fb..7277370 100644 --- a/etk/Exception.hpp +++ b/etk/Exception.hpp @@ -165,5 +165,17 @@ namespace etk { } }; + class RuntimeError : public etk::Exception { + public: + /** + * @brief Contructor of an generic Exception. + * @param[in] _what The explanation of the problem. + * @param[in] _function Function name to find faster the source od the problem. + */ + RuntimeError(const etk::String& _what, const char* _function = nullptr): + etk::Exception("RUNTIME-ERROR", _what, _function) { + + } + }; } } diff --git a/etk/Function.hpp b/etk/Function.hpp index 442a919..72b3801 100644 --- a/etk/Function.hpp +++ b/etk/Function.hpp @@ -36,7 +36,7 @@ namespace etk { class FunctionPrivateLambda: public FunctionPrivate { private: - ETK_TYPE_FUNCTION_FUNCTOR m_dataPointer; + mutable ETK_TYPE_FUNCTION_FUNCTOR m_dataPointer; public: FunctionPrivateLambda(ETK_TYPE_FUNCTION_FUNCTOR _functor): m_dataPointer(_functor) { diff --git a/etk/Map.hpp b/etk/Map.hpp index ef70f41..978cd00 100644 --- a/etk/Map.hpp +++ b/etk/Map.hpp @@ -244,12 +244,37 @@ namespace etk { /** * @brief Constructor of the Map table. * @param[in] _count Number of basic element in the table. + * @param[in] _ordered select an ordered map or an onordered map. */ Map(int32_t _count = 0, bool _ordered=true) : m_data(_count), m_ordered(_ordered) { // nothing to do } + /** + * @brief Move constructor + * @param[in] _obj Other Map to move + */ + Map(Map&& _obj): + m_data(0), + m_ordered(true) { + _obj.swap(*this); + } + /** + * @brief Copy constructor + * @param[in] _obj Other Map to copy + */ + Map(const Map& _obj) : + m_data(), + m_ordered(_obj.m_ordered) { + m_data.reserve(_obj.m_data.size()); + for (auto &it : _obj.m_data) { + if (it == nullptr) { + continue; + } + m_data.pushBack(new etk::Pair(it->first, it->second)); + } + } void setOrdered(bool _ordered) { m_ordered = _ordered; if (m_ordered == true) { @@ -262,6 +287,31 @@ namespace etk { ~Map() { clear(); } + /** + * @brief Swap two map + * @param[in] _obj Other Map to swap with + */ + void swap(Map& _obj) { + etk::swap(m_data, _obj.m_data); + etk::swap(m_ordered, _obj.m_ordered); + } + /** + * @brief Move operator + * @param[in] _obj Other Map to move + */ + Map& operator=(Map&& _obj) { + _obj.swap(*this); + return *this; + } + /** + * @brief Copy operator + * @param[in] _obj Other Map to copy + */ + Map& operator=(const Map& _obj) { + Map tmp(_obj); + tmp.swap(*this); + return *this; + } /** * @brief Remove all entry in the Map table. * @note It does not delete pointer if your value is a pointer type... diff --git a/etk/Pair.hpp b/etk/Pair.hpp index 8c5f538..cb3a8f4 100644 --- a/etk/Pair.hpp +++ b/etk/Pair.hpp @@ -7,6 +7,7 @@ #include #include +#include namespace etk { template diff --git a/etk/String.cpp b/etk/String.cpp index 230ec6e..6ebaf8d 100644 --- a/etk/String.cpp +++ b/etk/String.cpp @@ -580,6 +580,12 @@ bool etk::String::to() const { } return false; } + +etk::Stream& etk::operator <<(etk::Stream& _os, const etk::String& _obj) { + _os << _obj.c_str(); + return _os; +} + void etk::sort(etk::Vector &_list) { etk::Vector tmpList(_list); _list.clear(); diff --git a/etk/String.hpp b/etk/String.hpp index 29437bd..149ff50 100644 --- a/etk/String.hpp +++ b/etk/String.hpp @@ -519,6 +519,8 @@ namespace etk { inline bool operator<= (const char* _left, const String& _right) { return _right <= _left; } + //! @not_in_doc + etk::Stream& operator <<(etk::Stream& _os, const etk::String& _obj); /** * @brief Template to declare conversion from anything in etk::String * @param[in] _variable Variable to convert diff --git a/etk/Vector.hpp b/etk/Vector.hpp index 8d2d2d8..94012d8 100644 --- a/etk/Vector.hpp +++ b/etk/Vector.hpp @@ -7,6 +7,7 @@ #include //#include +#include namespace etk { class Stream; @@ -878,4 +879,18 @@ namespace etk { } return false; } + class Stream; + //! @not_in_doc + template + etk::Stream& operator <<(etk::Stream& _os, const etk::Vector& _obj) { + _os << "{"; + for (size_t iii=0; iii< _obj.size(); iii++) { + if (iii>0) { + _os << ";"; + } + _os << _obj[iii]; + } + _os << "}"; + return _os; + } } diff --git a/etk/math/Vector4D.hpp b/etk/math/Vector4D.hpp index ee0e4ad..963736d 100644 --- a/etk/math/Vector4D.hpp +++ b/etk/math/Vector4D.hpp @@ -6,6 +6,7 @@ #pragma once #include +#include extern "C" { #include diff --git a/etk/typeInfo.cpp b/etk/typeInfo.cpp index b3a0593..92cea2c 100644 --- a/etk/typeInfo.cpp +++ b/etk/typeInfo.cpp @@ -56,5 +56,5 @@ ETK_DECLARE_TYPE(etk::exception::OverflowError); ETK_DECLARE_TYPE(etk::exception::UnderflowError); ETK_DECLARE_TYPE(etk::exception::CastError); ETK_DECLARE_TYPE(etk::exception::AllocationError); - +ETK_DECLARE_TYPE(etk::exception::RuntimeError);