From 21ecdd5055984088a0c8b4647cb9393549b3959f Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sat, 18 Jun 2016 07:10:12 +0100 Subject: [PATCH] Added definitions for large character types if not already supported. Fixed compile error. --- src/char_traits.h | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/char_traits.h b/src/char_traits.h index 72b74bb5..e9523e03 100644 --- a/src/char_traits.h +++ b/src/char_traits.h @@ -31,8 +31,11 @@ SOFTWARE. #ifndef __ETL_CHAR_TRAITS__ #define __ETL_CHAR_TRAITS__ +#include + +#include "platform.h" #include "stdint.h" -#include "algorithms.h" +#include "algorithm.h" //***************************************************************************** ///\defgroup char_traits char_traits @@ -40,6 +43,12 @@ SOFTWARE. ///\ingroup string //***************************************************************************** +// Define the large character types if necessary. +#ifdef NO_LARGE_CHAR_SUPPORT +typedef int16_t char16_t; +typedef int32_t char32_t; +#endif + namespace etl { template struct char_traits_types; @@ -81,11 +90,17 @@ namespace etl }; //*************************************************************************** - /// Specialisation for char. + /// Character traits for any character type. //*************************************************************************** template struct char_traits : public char_traits_types { + typedef typename char_traits_types::char_type char_type; + typedef typename char_traits_types::int_type int_type; + typedef typename char_traits_types::off_type off_type; + typedef typename char_traits_types::pos_type pos_type; + typedef typename char_traits_types::state_type state_type; + //************************************************************************* static bool eq(char_type a, char_type b) { @@ -99,7 +114,7 @@ namespace etl } //************************************************************************* - static size_t length(const char* str) + static size_t length(const char_type* str) { size_t count = 0; @@ -134,7 +149,7 @@ namespace etl //************************************************************************* static char_type* move(char_type* dest, const char_type* src, size_t count) { - if ((dest < src) || (dest > (src + count)) + if ((dest < src) || (dest > (src + count))) { etl::copy_n(src, src + count, dest); }