mirror of
https://github.com/ETLCPP/etl.git
synced 2026-06-16 17:06:05 +08:00
Initial code
This commit is contained in:
parent
9a1705ed4c
commit
43100b2cf4
@ -2230,7 +2230,7 @@ namespace etl
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef ETL_ISTRING_REPAIR_ENABLE
|
||||
#if ETL_ISTRING_REPAIR_ENABLED
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
|
||||
@ -1,4 +1,27 @@
|
||||
///\file
|
||||
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
Copyright(c) 2022 jwellbelove
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#ifndef ETL_BYTE_INCLUDED
|
||||
#define ETL_BYTE_INCLUDED
|
||||
@ -6,7 +29,6 @@
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
|
||||
namespace etl
|
||||
{
|
||||
#if ETL_CPP11_SUPPORTED && !defined(ETL_BYTE_FORCE_CPP03_IMPLEMENTATION)
|
||||
|
||||
@ -235,4 +235,13 @@ namespace std
|
||||
|
||||
#endif // ETL_USE_INITIALIZER_LIST
|
||||
|
||||
namespace etl
|
||||
{
|
||||
namespace library_traits
|
||||
{
|
||||
static ETL_CONSTANT bool has_initializer_list = (ETL_USING_INITIALIZER_LIST == 1);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ETL_INITIALIZER_LIST_INCLUDED
|
||||
#endif // ETL_INITIALIZER_LIST_INCLUDED
|
||||
|
||||
@ -40,6 +40,9 @@ SOFTWARE.
|
||||
// Define a debug macro
|
||||
#if (defined(_DEBUG) || defined(DEBUG)) && !defined(ETL_DEBUG)
|
||||
#define ETL_DEBUG
|
||||
#define ETL_IS_DEBUG_BUILD 1
|
||||
#else
|
||||
#define ETL_IS_DEBUG_BUILD 0
|
||||
#endif
|
||||
|
||||
// Determine the bit width of the platform.
|
||||
@ -146,6 +149,7 @@ SOFTWARE.
|
||||
#define ETL_STRING_CLEAR_AFTER_USE_ENABLED 1
|
||||
#endif
|
||||
|
||||
|
||||
//*************************************
|
||||
// The macros below are dependent on the profile.
|
||||
// C++11
|
||||
@ -269,4 +273,30 @@ SOFTWARE.
|
||||
// Sort out namespaces for STL/No STL options.
|
||||
#include "private/choose_namespace.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
namespace library_traits
|
||||
{
|
||||
static ETL_CONSTANT bool using_stl = (ETL_USING_STL == 1);
|
||||
static ETL_CONSTANT bool using_stlport = (ETL_USING_STLPORT == 1);
|
||||
static ETL_CONSTANT bool using_cpp11 = (ETL_CPP11_SUPPORTED == 1);
|
||||
static ETL_CONSTANT bool using_cpp14 = (ETL_CPP14_SUPPORTED == 1);
|
||||
static ETL_CONSTANT bool using_cpp17 = (ETL_CPP17_SUPPORTED == 1);
|
||||
static ETL_CONSTANT bool using_cpp20 = (ETL_CPP20_SUPPORTED == 1);
|
||||
static ETL_CONSTANT bool has_8bit_types = (ETL_USING_8BIT_TYPES == 1);
|
||||
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_NO_NULLPTR_SUPPORT == 0);
|
||||
static ETL_CONSTANT bool has_large_char = (ETL_NO_LARGE_CHAR_SUPPORT == 0);
|
||||
static ETL_CONSTANT bool has_string_truncation_checks = (ETL_STRING_TRUNCATION_CHECKS_ENABLED == 1);
|
||||
static ETL_CONSTANT bool has_string_clear_after_use = (ETL_STRING_CLEAR_AFTER_USE_ENABLED == 1);
|
||||
static ETL_CONSTANT bool has_istring_repair = (ETL_ISTRING_REPAIR_ENABLED == 1);
|
||||
static ETL_CONSTANT bool has_ivector_repair = (ETL_IVECTOR_REPAIR_ENABLED == 1);
|
||||
static ETL_CONSTANT bool has_ideque_repair = (ETL_IDEQUE_REPAIR_ENABLED == 1);
|
||||
static ETL_CONSTANT bool is_debug_build = (ETL_IS_DEBUG_BUILD == 1);
|
||||
static ETL_CONSTANT bool has_polymorphic_messages = (ETL_HAS_POLYMORPHIC_MESSAGES == 1);
|
||||
static ETL_CONSTANT bool error_on_string_truncation = (ETL_ERROR_ON_STRING_TRUNCATION == 1);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -146,4 +146,19 @@ SOFTWARE.
|
||||
#define ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE 0
|
||||
#endif
|
||||
|
||||
namespace etl
|
||||
{
|
||||
namespace library_traits
|
||||
{
|
||||
static ETL_CONSTANT bool using_builtin_memcmp = (ETL_USING_BUILTIN_MEMCMP == 1);
|
||||
static ETL_CONSTANT bool using_builtin_memmove = (ETL_USING_BUILTIN_MEMMOVE == 1);
|
||||
static ETL_CONSTANT bool USING_BUILTIN_MEMSET = (ETL_USING_BUILTIN_MEMSET == 1);
|
||||
static ETL_CONSTANT bool USING_BUILTIN_IS_ASSIGNABLE = (ETL_USING_BUILTIN_IS_ASSIGNABLE == 1);
|
||||
static ETL_CONSTANT bool USING_BUILTIN_IS_CONSTRUCTIBLE = (ETL_USING_BUILTIN_IS_CONSTRUCTIBLE == 1);
|
||||
static ETL_CONSTANT bool USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE = (ETL_USING_BUILTIN_IS_TRIVIALLY_CONSTRUCTIBLE == 1);
|
||||
static ETL_CONSTANT bool USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE = (ETL_USING_BUILTIN_IS_TRIVIALLY_DESTRUCTIBLE == 1);
|
||||
static ETL_CONSTANT bool USING_BUILTIN_IS_TRIVIALLY_COPYABLE = (ETL_USING_BUILTIN_IS_TRIVIALLY_COPYABLE == 1);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -234,7 +234,7 @@ namespace etl
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
void repair()
|
||||
#ifdef ETL_ISTRING_REPAIR_ENABLE
|
||||
#if ETL_ISTRING_REPAIR_ENABLED
|
||||
ETL_OVERRIDE
|
||||
#endif
|
||||
{
|
||||
@ -419,7 +419,7 @@ namespace etl
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
void repair()
|
||||
#ifdef ETL_ISTRING_REPAIR_ENABLE
|
||||
#if ETL_ISTRING_REPAIR_ENABLED
|
||||
ETL_OVERRIDE
|
||||
#endif
|
||||
{
|
||||
|
||||
@ -218,7 +218,7 @@ namespace etl
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
void repair()
|
||||
#ifdef ETL_ISTRING_REPAIR_ENABLE
|
||||
#if ETL_ISTRING_REPAIR_ENABLED
|
||||
ETL_OVERRIDE
|
||||
#endif
|
||||
{
|
||||
@ -402,7 +402,7 @@ namespace etl
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
void repair()
|
||||
#ifdef ETL_ISTRING_REPAIR_ENABLE
|
||||
#if ETL_ISTRING_REPAIR_ENABLED
|
||||
ETL_OVERRIDE
|
||||
#endif
|
||||
{
|
||||
|
||||
@ -218,7 +218,7 @@ namespace etl
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
void repair()
|
||||
#ifdef ETL_ISTRING_REPAIR_ENABLE
|
||||
#if ETL_ISTRING_REPAIR_ENABLED
|
||||
ETL_OVERRIDE
|
||||
#endif
|
||||
{
|
||||
@ -402,7 +402,7 @@ namespace etl
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
void repair()
|
||||
#ifdef ETL_ISTRING_REPAIR_ENABLE
|
||||
#if ETL_ISTRING_REPAIR_ENABLED
|
||||
ETL_OVERRIDE
|
||||
#endif
|
||||
{
|
||||
|
||||
@ -217,7 +217,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
#ifdef ETL_ISTRING_REPAIR_ENABLE
|
||||
#if ETL_ISTRING_REPAIR_ENABLED
|
||||
virtual
|
||||
#endif
|
||||
void repair()
|
||||
@ -402,7 +402,7 @@ namespace etl
|
||||
/// Fix the internal pointers after a low level memory copy.
|
||||
//*************************************************************************
|
||||
void repair()
|
||||
#ifdef ETL_ISTRING_REPAIR_ENABLE
|
||||
#if ETL_ISTRING_REPAIR_ENABLED
|
||||
ETL_OVERRIDE
|
||||
#endif
|
||||
{
|
||||
|
||||
54
test/test_library_traits.cpp
Normal file
54
test/test_library_traits.cpp
Normal file
@ -0,0 +1,54 @@
|
||||
/******************************************************************************
|
||||
The MIT License(MIT)
|
||||
|
||||
Embedded Template Library.
|
||||
https://github.com/ETLCPP/etl
|
||||
https://www.etlcpp.com
|
||||
|
||||
Copyright(c) 2022 jwellbelove
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files(the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions :
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "unit_test_framework.h"
|
||||
|
||||
#include "etl/platform.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
SUITE(test_library_traits)
|
||||
{
|
||||
TEST(test_library_traits)
|
||||
{
|
||||
CHECK_EQUAL(false, etl::library_traits::error_on_string_truncation);
|
||||
CHECK_EQUAL(true, etl::library_traits::has_64bit_types);
|
||||
CHECK_EQUAL(true, etl::library_traits::has_8bit_types);
|
||||
CHECK_EQUAL(true, etl::library_traits::has_atomic);
|
||||
CHECK_EQUAL(true, etl::library_traits::has_ideque_repair);
|
||||
CHECK_EQUAL(true, etl::library_traits::has_istring_repair);
|
||||
CHECK_EQUAL(true, etl::library_traits::has_ivector_repair);
|
||||
CHECK_EQUAL(true, etl::library_traits::has_large_char);
|
||||
CHECK_EQUAL(true, etl::library_traits::has_nullptr);
|
||||
CHECK_EQUAL(false, etl::library_traits::has_polymorphic_messages);
|
||||
CHECK_EQUAL(true, etl::library_traits::has_string_clear_after_use);
|
||||
CHECK_EQUAL(true, etl::library_traits::has_string_truncation_checks);
|
||||
CHECK_EQUAL(true, etl::library_traits::is_debug_build);
|
||||
}
|
||||
};
|
||||
}
|
||||
@ -10677,6 +10677,7 @@
|
||||
<ClCompile Include="..\test_indirect_vector.cpp" />
|
||||
<ClCompile Include="..\test_indirect_vector_external_buffer.cpp" />
|
||||
<ClCompile Include="..\test_invert.cpp" />
|
||||
<ClCompile Include="..\test_library_traits.cpp" />
|
||||
<ClCompile Include="..\test_limiter.cpp" />
|
||||
<ClCompile Include="..\test_limits.cpp" />
|
||||
<ClCompile Include="..\test_list_shared_pool.cpp" />
|
||||
|
||||
@ -3116,9 +3116,6 @@
|
||||
<ClCompile Include="..\sanity-check\gamma.h.t.cpp">
|
||||
<Filter>Tests\Sanity Checks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\wstring_stream.h.t.cpp">
|
||||
<Filter>Tests\Sanity Checks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\sanity-check\variant.h.t.cpp">
|
||||
<Filter>Tests\Sanity Checks</Filter>
|
||||
</ClCompile>
|
||||
@ -3140,6 +3137,9 @@
|
||||
<ClCompile Include="..\sanity-check\wstring.h.t.cpp">
|
||||
<Filter>Tests\Sanity Checks</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_library_traits.cpp">
|
||||
<Filter>Tests\Misc</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\test_callback_timer_interrupt.cpp">
|
||||
<Filter>Tests\Callback Timers</Filter>
|
||||
</ClCompile>
|
||||
@ -3380,4 +3380,4 @@
|
||||
<Filter>Resource Files</Filter>
|
||||
</Natvis>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user