mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-16 00:46:03 +08:00
Large and small character support macros
This commit is contained in:
parent
733b50e9ae
commit
63c05fb6b9
@ -43,15 +43,6 @@ SOFTWARE.
|
||||
///\ingroup string
|
||||
//*****************************************************************************
|
||||
|
||||
// Define the large character types if necessary.
|
||||
#if ETL_NO_LARGE_CHAR_SUPPORT
|
||||
#if ETL_USING_8BIT_TYPES
|
||||
typedef int8_t char8_t;
|
||||
#endif
|
||||
typedef int16_t char16_t;
|
||||
typedef int32_t char32_t;
|
||||
#endif
|
||||
|
||||
namespace etl
|
||||
{
|
||||
template<typename T> struct char_traits_types;
|
||||
|
||||
@ -271,7 +271,7 @@ namespace etl
|
||||
static ETL_CONSTEXPR signed char signaling_NaN() { return 0; }
|
||||
};
|
||||
|
||||
#if (ETL_NO_LARGE_CHAR_SUPPORT == false)
|
||||
#if ETL_USING_CHAR16_T
|
||||
//***************************************************************************
|
||||
// char16_t
|
||||
template<>
|
||||
@ -294,7 +294,9 @@ namespace etl
|
||||
static ETL_CONSTEXPR char16_t quiet_NaN() { return 0U; }
|
||||
static ETL_CONSTEXPR char16_t signaling_NaN() { return 0U; }
|
||||
};
|
||||
#endif
|
||||
|
||||
#if ETL_USING_CHAR32_T
|
||||
//***************************************************************************
|
||||
// char32_t
|
||||
template<>
|
||||
@ -317,7 +319,6 @@ namespace etl
|
||||
static ETL_CONSTEXPR char32_t quiet_NaN() { return 0U; }
|
||||
static ETL_CONSTEXPR char32_t signaling_NaN() { return 0U; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
|
||||
@ -31,13 +31,15 @@ SOFTWARE.
|
||||
#ifndef ETL_MACROS_INCLUDED
|
||||
#define ETL_MACROS_INCLUDED
|
||||
|
||||
#define ETL_CONCAT2(X, Y) X##Y
|
||||
#define ETL_CONCAT(X, Y) ETL_CONCAT2(X, Y)
|
||||
#define ETL_STRINGIFY2(X) #X
|
||||
#define ETL_STRINGIFY(X) ETL_STRINGIFY2(X)
|
||||
#define ETL_CONCAT2(X, Y) X##Y
|
||||
#define ETL_CONCAT(X, Y) ETL_CONCAT2(X, Y)
|
||||
#define ETL_STRINGIFY2(X) #X
|
||||
#define ETL_STRINGIFY(X) ETL_STRINGIFY2(X)
|
||||
#define ETL_STRING(X) ETL_STRINGIFY(X))
|
||||
#define ETL_WIDE_STRING(X) ETL_CONCAT(L, ETL_STRINGIFY(X))
|
||||
#define ETL_U16_STRING(X) ETL_CONCAT(u, ETL_STRINGIFY(X))
|
||||
#define ETL_U32_STRING(X) ETL_CONCAT(U, ETL_STRINGIFY(X))
|
||||
#define ETL_U8_STRING(X) ETL_CONCAT(u8, ETL_STRINGIFY(X))
|
||||
#define ETL_U16_STRING(X) ETL_CONCAT(u, ETL_STRINGIFY(X))
|
||||
#define ETL_U32_STRING(X) ETL_CONCAT(U, ETL_STRINGIFY(X))
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -200,14 +200,6 @@ SOFTWARE.
|
||||
#define ETL_HAS_NULLPTR 1
|
||||
#endif
|
||||
|
||||
//*************************************
|
||||
// Indicate if there are large char types.
|
||||
#if defined(ETL_NO_LARGE_CHAR_SUPPORT)
|
||||
#define ETL_HAS_LARGE_CHAR 0
|
||||
#else
|
||||
#define ETL_HAS_LARGE_CHAR 1
|
||||
#endif
|
||||
|
||||
//*************************************
|
||||
// Indicate if array_view is mutable.
|
||||
#if defined(ETL_ARRAY_VIEW_IS_MUTABLE)
|
||||
@ -221,16 +213,16 @@ SOFTWARE.
|
||||
// C++11
|
||||
#if ETL_USING_CPP11 && !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
#define ETL_CONSTEXPR constexpr
|
||||
#define ETL_CONSTANT constexpr
|
||||
#define ETL_DELETE = delete
|
||||
#define ETL_EXPLICIT explicit
|
||||
#define ETL_OVERRIDE override
|
||||
#define ETL_FINAL final
|
||||
#define ETL_NORETURN [[noreturn]]
|
||||
#define ETL_MOVE(x) etl::move(x)
|
||||
#define ETL_CONSTANT constexpr
|
||||
#define ETL_DELETE = delete
|
||||
#define ETL_EXPLICIT explicit
|
||||
#define ETL_OVERRIDE override
|
||||
#define ETL_FINAL final
|
||||
#define ETL_NORETURN [[noreturn]]
|
||||
#define ETL_MOVE(x) etl::move(x)
|
||||
|
||||
#if ETL_USING_EXCEPTIONS
|
||||
#define ETL_NOEXCEPT noexcept
|
||||
#define ETL_NOEXCEPT noexcept
|
||||
#define ETL_NOEXCEPT_EXPR(expression) noexcept(expression)
|
||||
#else
|
||||
#define ETL_NOEXCEPT
|
||||
@ -253,7 +245,7 @@ SOFTWARE.
|
||||
// C++14
|
||||
#if ETL_USING_CPP14 && !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
#define ETL_CONSTEXPR14 constexpr
|
||||
#define ETL_DEPRECATED [[deprecated]]
|
||||
#define ETL_DEPRECATED [[deprecated]]
|
||||
#define ETL_DEPRECATED_REASON(reason) [[deprecated(reason)]]
|
||||
#else
|
||||
#define ETL_CONSTEXPR14
|
||||
@ -264,12 +256,12 @@ SOFTWARE.
|
||||
//*************************************
|
||||
// C++17
|
||||
#if ETL_USING_CPP17 && !defined(ETL_FORCE_NO_ADVANCED_CPP)
|
||||
#define ETL_CONSTEXPR17 constexpr
|
||||
#define ETL_CONSTEXPR17 constexpr
|
||||
#define ETL_IF_CONSTEXPR constexpr
|
||||
#define ETL_NODISCARD [[nodiscard]]
|
||||
#define ETL_NODISCARD [[nodiscard]]
|
||||
#define ETL_MAYBE_UNUSED [[maybe_unused]]
|
||||
#define ETL_FALLTHROUGH [[fallthrough]]
|
||||
#define ETL_INLINE_VAR inline
|
||||
#define ETL_FALLTHROUGH [[fallthrough]]
|
||||
#define ETL_INLINE_VAR inline
|
||||
#else
|
||||
#define ETL_CONSTEXPR17
|
||||
#define ETL_IF_CONSTEXPR
|
||||
@ -297,6 +289,24 @@ SOFTWARE.
|
||||
#define ETL_NO_UNIQUE_ADDRESS
|
||||
#endif
|
||||
|
||||
//*************************************
|
||||
// Determine if the ETL can use char8_t type.
|
||||
#if ETL_NO_SMALL_CHAR_SUPPORT
|
||||
#define ETL_HAS_CHAR8_T 0
|
||||
#else
|
||||
#define ETL_HAS_CHAR8_T 1
|
||||
#endif
|
||||
|
||||
//*************************************
|
||||
// Determine if the ETL can use char16_t and char32_t types.
|
||||
#if ETL_NO_LARGE_CHAR_SUPPORT
|
||||
#define ETL_HAS_CHAR16_T 0
|
||||
#define ETL_HAS_CHAR32_T 0
|
||||
#else
|
||||
#define ETL_HAS_CHAR16_T 1
|
||||
#define ETL_HAS_CHAR32_T 1
|
||||
#endif
|
||||
|
||||
//*************************************
|
||||
// Determine if the ETL can use std::array
|
||||
#if !defined(ETL_HAS_STD_ARRAY)
|
||||
@ -368,7 +378,9 @@ namespace etl
|
||||
static ETL_CONSTANT bool has_64bit_types = (ETL_USING_64BIT_TYPES == 1);
|
||||
static ETL_CONSTANT bool has_atomic = (ETL_HAS_ATOMIC == 1);
|
||||
static ETL_CONSTANT bool has_nullptr = (ETL_HAS_NULLPTR == 1);
|
||||
static ETL_CONSTANT bool has_large_char = (ETL_HAS_LARGE_CHAR == 1);
|
||||
static ETL_CONSTANT bool has_char8_t = (ETL_HAS_CHAR8_T == 1);
|
||||
static ETL_CONSTANT bool has_char16_t = (ETL_HAS_CHAR16_T == 1);
|
||||
static ETL_CONSTANT bool has_char32_t = (ETL_HAS_CHAR32_T == 1);
|
||||
static ETL_CONSTANT bool has_string_truncation_checks = (ETL_HAS_STRING_TRUNCATION_CHECKS == 1);
|
||||
static ETL_CONSTANT bool has_error_on_string_truncation = (ETL_HAS_ERROR_ON_STRING_TRUNCATION == 1);
|
||||
static ETL_CONSTANT bool has_string_clear_after_use = (ETL_HAS_STRING_CLEAR_AFTER_USE == 1);
|
||||
|
||||
@ -149,8 +149,12 @@ SOFTWARE.
|
||||
#define ETL_NO_NULLPTR_SUPPORT ETL_CPP11_NOT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#if !defined(ETL_NO_SMALL_CHAR_SUPPORT)
|
||||
#define ETL_NO_SMALL_CHAR_SUPPORT ETL_CPP20_NOT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#if !defined(ETL_NO_LARGE_CHAR_SUPPORT)
|
||||
#define ETL_NO_LARGE_CHAR_SUPPORT ETL_CPP11_NOT_SUPPORTED
|
||||
#define ETL_NO_LARGE_CHAR_SUPPORT ETL_CPP11_NOT_SUPPORTED
|
||||
#endif
|
||||
|
||||
#if !defined(ETL_CPP11_TYPE_TRAITS_IS_TRIVIAL_SUPPORTED)
|
||||
|
||||
@ -42,11 +42,17 @@ SOFTWARE.
|
||||
#define ETL_VERSION_MINOR 27
|
||||
#define ETL_VERSION_PATCH 3
|
||||
|
||||
|
||||
#define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_U32 ETL_STRINGIFY(ETL_VERSION_MAJOR) U"." ETL_STRINGIFY(ETL_VERSION_MINOR) U"." ETL_STRINGIFY(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION ETL_STRING(ETL_VERSION_MAJOR) "." ETL_STRING(ETL_VERSION_MINOR) "." ETL_STRING(ETL_VERSION_PATCH)
|
||||
#define ETL_VERSION_W ETL_WIDE_STRING(ETL_VERSION_MAJOR) L"." ETL_WIDE_STRING(ETL_VERSION_MINOR) L"." ETL_WIDE_STRING(ETL_VERSION_PATCH)
|
||||
#if ETL_HAS_CHAR8_T
|
||||
#define ETL_VERSION_U8 ETL_U8_STRING(ETL_VERSION_MAJOR) u8"." ETL_U8_STRING(ETL_VERSION_MINOR) u8"." ETL_U8_STRING(ETL_VERSION_PATCH)
|
||||
#endif
|
||||
#if ETL_HAS_CHAR16_T
|
||||
#define ETL_VERSION_U16 ETL_U16_STRING(ETL_VERSION_MAJOR) u"." ETL_U16_STRING(ETL_VERSION_MINOR) u"." ETL_U16_STRING(ETL_VERSION_PATCH)
|
||||
#endif
|
||||
#if ETL_HAS_CHAR32_T
|
||||
#define ETL_VERSION_U32 ETL_U32_STRING(ETL_VERSION_MAJOR) U"." ETL_U32_STRING(ETL_VERSION_MINOR) U"." ETL_U32_STRING(ETL_VERSION_PATCH)
|
||||
#endif
|
||||
#define ETL_VERSION_VALUE ((ETL_VERSION_MAJOR * 10000) + (ETL_VERSION_MINOR * 100) + ETL_VERSION_PATCH)
|
||||
|
||||
namespace etl
|
||||
@ -57,14 +63,22 @@ namespace etl
|
||||
static ETL_CONSTANT long version_major = ETL_VERSION_MAJOR;
|
||||
static ETL_CONSTANT long version_minor = ETL_VERSION_MINOR;
|
||||
static ETL_CONSTANT long version_patch = ETL_VERSION_PATCH;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
static constexpr const char* version_string = ETL_VERSION;
|
||||
static constexpr const wchar_t* version_wstring = ETL_VERSION_W;
|
||||
#if ETL_HAS_CHAR8_T
|
||||
static constexpr const char8_t* version_u8string = ETL_VERSION_U8;
|
||||
#endif
|
||||
#if ETL_HAS_CHAR16_T
|
||||
static constexpr const char16_t* version_u16string = ETL_VERSION_U16;
|
||||
#endif
|
||||
#if ETL_HAS_CHAR32_T
|
||||
static constexpr const char32_t* version_u32string = ETL_VERSION_U32;
|
||||
#endif
|
||||
#else
|
||||
static const char* version_string = ETL_VERSION;
|
||||
static const wchar_t* version_wstring = ETL_VERSION_W;
|
||||
static const char* version_string = ETL_VERSION;
|
||||
static const wchar_t* version_wstring = ETL_VERSION_W;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,7 +61,9 @@ namespace
|
||||
CHECK_EQUAL((ETL_USING_64BIT_TYPES == 1), etl::traits::has_64bit_types);
|
||||
CHECK_EQUAL((ETL_HAS_ATOMIC == 1), etl::traits::has_atomic);
|
||||
CHECK_EQUAL((ETL_HAS_NULLPTR == 1), etl::traits::has_nullptr);
|
||||
CHECK_EQUAL((ETL_HAS_LARGE_CHAR == 1), etl::traits::has_large_char);
|
||||
CHECK_EQUAL((ETL_HAS_CHAR8_T == 1), etl::traits::has_char8_t);
|
||||
CHECK_EQUAL((ETL_HAS_CHAR16_T == 1), etl::traits::has_char16_t);
|
||||
CHECK_EQUAL((ETL_HAS_CHAR32_T == 1), etl::traits::has_char32_t);
|
||||
CHECK_EQUAL((ETL_HAS_STRING_TRUNCATION_CHECKS == 1), etl::traits::has_string_truncation_checks);
|
||||
CHECK_EQUAL((ETL_HAS_ERROR_ON_STRING_TRUNCATION == 1), etl::traits::has_error_on_string_truncation);
|
||||
CHECK_EQUAL((ETL_HAS_STRING_CLEAR_AFTER_USE == 1), etl::traits::has_string_clear_after_use);
|
||||
@ -77,6 +79,9 @@ namespace
|
||||
CHECK_EQUAL(ETL_VERSION_VALUE, etl::traits::version);
|
||||
CHECK_ARRAY_EQUAL(ETL_VERSION, etl::traits::version_string, etl::strlen(ETL_VERSION));
|
||||
CHECK_ARRAY_EQUAL(ETL_VERSION, etl::traits::version_wstring, etl::strlen(ETL_VERSION_W));
|
||||
#if ETL_HAS_CHAR8_T
|
||||
CHECK_ARRAY_EQUAL(ETL_VERSION, etl::traits::version_u8string, etl::strlen(ETL_VERSION_U8));
|
||||
#endif
|
||||
CHECK_ARRAY_EQUAL(ETL_VERSION, etl::traits::version_u16string, etl::strlen(ETL_VERSION_U16));
|
||||
CHECK_ARRAY_EQUAL(ETL_VERSION, etl::traits::version_u32string, etl::strlen(ETL_VERSION_U32));
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user