From 054857e7bd8da2725e871e3c2bf28f628386b42c Mon Sep 17 00:00:00 2001 From: David Dight Date: Sun, 15 Sep 2024 06:52:03 +1000 Subject: [PATCH 01/49] pre-rel 1.2a --- utests/edgetests.cpp | 85 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/utests/edgetests.cpp b/utests/edgetests.cpp index 0e7f1ab..b59f3e3 100644 --- a/utests/edgetests.cpp +++ b/utests/edgetests.cpp @@ -80,6 +80,82 @@ namespace test::util [[nodiscard]] constexpr size_t countOf() { return FIX8::conjure_enum::count(); } } +enum class numbers +{ + blah_0, blah_1, blah_2, blah_3, blah_4, + blah_5, blah_6, blah_7, blah_8, blah_9, + blah_10, blah_11, blah_12, blah_13, blah_14, + blah_15, blah_16, blah_17, blah_18, blah_19, + blah_20, blah_21, blah_22, blah_23, blah_24, + blah_25, blah_26, blah_27, blah_28, blah_29, + blah_30, blah_31, blah_32, blah_33, blah_34, + blah_35, blah_36, blah_37, blah_38, blah_39, + blah_40, blah_41, blah_42, blah_43, blah_44, + blah_45, blah_46, blah_47, blah_48, blah_49, + blah_50, blah_51, blah_52, blah_53, blah_54, + blah_55, blah_56, blah_57, blah_58, blah_59, + blah_60, blah_61, blah_62, blah_63, blah_64, + blah_65, blah_66, blah_67, blah_68, blah_69, + blah_70, blah_71, blah_72, blah_73, blah_74, + blah_75, blah_76, blah_77, blah_78, blah_79, + blah_80, blah_81, blah_82, blah_83, blah_84, + blah_85, blah_86, blah_87, blah_88, blah_89, + blah_90, blah_91, blah_92, blah_93, blah_94, + blah_95, blah_96, blah_97, blah_98, blah_99, + blah_100, blah_101, blah_102, blah_103, blah_104, + blah_105, blah_106, blah_107, blah_108, blah_109, + blah_110, blah_111, blah_112, blah_113, blah_114, + blah_115, blah_116, blah_117, blah_118, blah_119, + blah_120, blah_121, blah_122, blah_123, blah_124, + blah_125, blah_126, blah_127, blah_128, blah_129, + blah_130, blah_131, blah_132, blah_133, blah_134, + blah_135, blah_136, blah_137, blah_138, blah_139, + blah_140, blah_141, blah_142, blah_143, blah_144, + blah_145, blah_146, blah_147, blah_148, blah_149, + blah_150, blah_151, blah_152, blah_153, blah_154, + blah_155, blah_156, blah_157, blah_158, blah_159, + blah_160, blah_161, blah_162, blah_163, blah_164, + blah_165, blah_166, blah_167, blah_168, blah_169, + blah_170, blah_171, blah_172, blah_173, blah_174, + blah_175, blah_176, blah_177, blah_178, blah_179, + blah_180, blah_181, blah_182, blah_183, blah_184, + blah_185, blah_186, blah_187, blah_188, blah_189, + blah_190, blah_191, blah_192, blah_193, blah_194, + blah_195, blah_196, blah_197, blah_198, blah_199, + blah_200, blah_201, blah_202, blah_203, blah_204, + blah_205, blah_206, blah_207, blah_208, blah_209, + blah_210, blah_211, blah_212, blah_213, blah_214, + blah_215, blah_216, blah_217, blah_218, blah_219, + blah_220, blah_221, blah_222, blah_223, blah_224, + blah_225, blah_226, blah_227, blah_228, blah_229, + blah_230, blah_231, blah_232, blah_233, blah_234, + blah_235, blah_236, blah_237, blah_238, blah_239, + blah_240, blah_241, blah_242, blah_243, blah_244, + blah_245, blah_246, blah_247, blah_248, blah_249, + blah_250, blah_251, blah_252, blah_253, blah_254, + blah_255, blah_256, blah_257, blah_258, blah_259, + blah_260, blah_261, blah_262, blah_263, blah_264, + blah_265, blah_266, blah_267, blah_268, blah_269, + blah_270, blah_271, blah_272, blah_273, blah_274, + blah_275, blah_276, blah_277, blah_278, blah_279, + blah_280, blah_281, blah_282, blah_283, blah_284, + blah_285, blah_286, blah_287, blah_288, blah_289, + blah_290, blah_291, blah_292, blah_293, blah_294, + blah_295, blah_296, blah_297, blah_298, blah_299, + blah_300, blah_301, blah_302, blah_303, blah_304, + blah_305, blah_306, blah_307, blah_308, blah_309, + blah_310, blah_311, blah_312, blah_313, blah_314, + blah_315, blah_316, blah_317, blah_318, blah_319, + blah_320, blah_321, blah_322, blah_323, blah_324, + blah_325, blah_326, blah_327, blah_328, blah_329, + blah_330, blah_331, blah_332, blah_333, blah_334, + blah_335, blah_336, blah_337, blah_338, blah_339, + blah_340, blah_341, blah_342, blah_343, blah_344, + blah_345, blah_346, blah_347, blah_348, blah_349, + blah_350, blah_351, blah_352, blah_353, blah_354, + ce_first=blah_0,ce_last=blah_354 +}; + //----------------------------------------------------------------------------------------- using namespace FIX8; @@ -271,3 +347,12 @@ TEST_CASE("nested type") REQUIRE(conjure_type::as_string_view() == "TEST::TEST1::foo"); } +//----------------------------------------------------------------------------------------- +TEST_CASE("enum limits") +{ + REQUIRE(conjure_enum::get_enum_min_value() == conjure_enum::get_actual_enum_min_value()); + REQUIRE(conjure_enum::get_enum_max_value() == conjure_enum::get_actual_enum_max_value()); + REQUIRE(conjure_enum::get_enum_min_value() == 0); + REQUIRE(conjure_enum::get_enum_max_value() == 354); +} + From 7d1c49ae45d08aeca95837f92c0224381f637e26 Mon Sep 17 00:00:00 2001 From: David Dight Date: Tue, 15 Oct 2024 07:39:19 +1100 Subject: [PATCH 02/49] updated --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3c32ebe..c958169 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ template static constexpr std::string_view enum_to_string(); ``` Returns a `std::string_view` or empty if not found. Optionally passing `true` will remove scope in result if present. -`noscope` option ![](assets/notminimalred.svg). +![](assets/notminimalred.svg). ```c++ auto name { conjure_enum::enum_to_string(component::path) }; auto name_trim { conjure_enum::enum_to_string(component::path, true) }; // optionally remove scope in result @@ -1650,12 +1650,14 @@ The following are the default settings: These definitions set the minimum and maximum enum values that are supported. You can adjust them to suit your requirements but for most use cases the defaults are sufficient. > [!TIP] > You can reduce compile times in some circumstances by narrowing the range of `FIX8_CONJURE_ENUM_MIN_VALUE` and `FIX8_CONJURE_ENUM_MAX_VALUE`. For example -> if your enums are only within the range of say `0-16` you can set `FIX8_CONJURE_ENUM_MIN_VALUE` and `FIX8_CONJURE_ENUM_MAX_VALUE` to `0` and `16` respectively. If the range is _too_ narrow -> `conjure_enum` will **ignore enum values outside your range**. +> if your enums are only within the range of say `0-16` you can set `FIX8_CONJURE_ENUM_MIN_VALUE` and `FIX8_CONJURE_ENUM_MAX_VALUE` to `0` and `16` respectively. > [!TIP] > If you wish to set ranges on a per enum basis, use `enum_range` (see below). +> [!WARNING] +> If the range is _too_ narrow `conjure_enum` will **ignore enum values outside your specified range**. + ### ii. using `enum_range` You can specialise this class to override the defaults and set your own range on a per enum basis. ```c++ From 441df989bf3ea6ac398f979a8db4be9905c18987 Mon Sep 17 00:00:00 2001 From: David Dight Date: Mon, 21 Oct 2024 12:13:08 +1100 Subject: [PATCH 03/49] upped compiler versions --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index c958169..1e2ea06 100644 --- a/README.md +++ b/README.md @@ -596,8 +596,8 @@ template // specialisa requires (std::invocable && I > 0) static constexpr void dispatch(T ev, const std::array, I>& disp, C *obj, Args&&... args); ``` -With a given enum, search and call user supplied invocable. A typical use case would be where you want to demux a complex event, allowing you to easily declare predefined invocable actions -for different enum values. +With a given enum, search and call user supplied invocable. So for example, if you want to demux a complex event predicated on an enum, you can easily declare predefined invocable actions +for different enum values and then use `dispatch` to test and execute those actions. - Where invocable returns a value, return this value or a user supplied "not found" value. - Where invocable is void, call user supplied invocable or "not found" invocable (last in supplied array). @@ -2049,8 +2049,8 @@ From a compilation performance perspective, `conjure_enum` roughly matches the p | Compiler | Version(s) | Notes | Unsupported | | :--- | :--- | :--- | ---: | | [gcc](https://gcc.gnu.org/projects/cxx-status.html) | `11`, `12`, `13`, `14`| `std::format` not complete in `11`, `12` | `<= 10` | -| [clang](https://clang.llvm.org/cxx_status.html) | `15`, `16`, `17`, `18`| Catch2 needs `cxx_std_20` in `15` | `<= 14` | -| [msvc](https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance) | `16`, `17` | Visual Studio 2019,2022, latest `17.11.3`| `<= 16.9`| +| [clang](https://clang.llvm.org/cxx_status.html) | `15`, `16`, `17`, `18`, `19`| Catch2 needs `cxx_std_20` in `15` | `<= 14` | +| [msvc](https://learn.microsoft.com/en-us/cpp/overview/visual-cpp-language-conformance) | `16`, `17` | Visual Studio 2019,2022, latest `17.11.5`| `<= 16.9`| | [xcode](https://developer.apple.com/support/xcode/) | `15` | Apple Xcode Clang 15.0.0 (LLVM 16), some issues with `constexpr`, workarounds| `<= 14`| # 11. Compiler issues From ead7f179872aa66e8c659448b4958f21e225a9e6 Mon Sep 17 00:00:00 2001 From: David Dight Date: Sat, 2 Nov 2024 07:40:51 +1100 Subject: [PATCH 04/49] interface include --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7377db2..fc66681 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,6 +88,9 @@ foreach(x srcloctest example statictest cbenchmark) endif() endforeach() +add_library(conjure_enum INTERFACE) +target_include_directories(conjure_enum INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) + if(BUILD_UNITTESTS) include(FetchContent) FetchContent_Declare(Catch2 From cd2d6081929aac012d4530ec889f292bc41d1894 Mon Sep 17 00:00:00 2001 From: David Dight Date: Sat, 2 Nov 2024 09:44:49 +1100 Subject: [PATCH 05/49] interface prop --- CMakeLists.txt | 9 +++++---- README.md | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fc66681..8b61c8a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,9 +31,9 @@ cmake_minimum_required (VERSION 3.20) project (conjure_enum LANGUAGES CXX - HOMEPAGE_URL https://github.com/fix8mt/conjure_enum + HOMEPAGE_URL https://github.com/fix8mt/${PROJECT_NAME} DESCRIPTION "Lightweight C++20 enum and typename reflection" - VERSION 1.1.0) + VERSION 1.1.2) message("${CMAKE_PROJECT_NAME} version ${CMAKE_PROJECT_VERSION}") @@ -88,8 +88,9 @@ foreach(x srcloctest example statictest cbenchmark) endif() endforeach() -add_library(conjure_enum INTERFACE) -target_include_directories(conjure_enum INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) +# make include visible to inheriting projects +add_library(${PROJECT_NAME} INTERFACE) +target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) if(BUILD_UNITTESTS) include(FetchContent) diff --git a/README.md b/README.md index 1e2ea06..38183b8 100644 --- a/README.md +++ b/README.md @@ -1553,7 +1553,7 @@ message(STATUS "Downloading conjure_enum...") include(FetchContent) FetchContent_Declare(conjure_enum GIT_REPOSITORY https://github.com/fix8mt/conjure_enum.git) FetchContent_MakeAvailable(conjure_enum) -target_include_directories(myproj PRIVATE ${conjure_enum_SOURCE_DIR}/include) +target_link_libraries(myproj PRIVATE conjure_enum) ``` ## d) Reporting issues From ebadf8b0368f870854ebcb238dcc12f55c1e098e Mon Sep 17 00:00:00 2001 From: David Dight Date: Sat, 2 Nov 2024 09:48:06 +1100 Subject: [PATCH 06/49] interface prop --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b61c8a..928c3a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ project (conjure_enum DESCRIPTION "Lightweight C++20 enum and typename reflection" VERSION 1.1.2) -message("${CMAKE_PROJECT_NAME} version ${CMAKE_PROJECT_VERSION}") +message("-- ${CMAKE_PROJECT_NAME} version ${CMAKE_PROJECT_VERSION}") # to disable strip: # cmake -DBUILD_STRIP_EXE=false .. From 838b40444390bdc1f1dcfea686f246cd586d7ca3 Mon Sep 17 00:00:00 2001 From: David Dight Date: Wed, 4 Dec 2024 11:05:54 +1100 Subject: [PATCH 07/49] doc update; cmake updates --- CMakeLists.txt | 45 +++++++++++++++++++++------------------------ README.md | 5 +++++ 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 928c3a9..f4595df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,26 +37,26 @@ project (conjure_enum message("-- ${CMAKE_PROJECT_NAME} version ${CMAKE_PROJECT_VERSION}") -# to disable strip: -# cmake -DBUILD_STRIP_EXE=false .. -option(BUILD_STRIP_EXE "enable stripping of non-unittest executables" true) -message("-- Build: strip exes ${BUILD_STRIP_EXE}") - -# to disable warnings: -# cmake -DBUILD_ALL_WARNINGS=false .. -option(BUILD_ALL_WARNINGS "enable building with all warnings" true) -message("-- Build: with all warnings ${BUILD_ALL_WARNINGS}") - -# to disable building unit tests: -# cmake -DBUILD_UNITTESTS=false .. -option(BUILD_UNITTESTS "enable building unit tests" true) -message("-- Build: unit tests ${BUILD_UNITTESTS}") +# to disable/enable an option +# cmake -DOPTION= .. +set(CUSTOM_OPTIONS + "BUILD_UNITTESTS|enable building unit tests|true" + "BUILD_STRIP_EXE|enable stripping of non-unittest executables|true" + "BUILD_ALL_WARNINGS|enable building with all warnings|true" + "BUILD_CLANG_PROFILER|enable clang build profiler|false" +) +foreach(x ${CUSTOM_OPTIONS}) + string(REPLACE "|" ";" part ${x}) + list(GET part 0 opt_name) + list(GET part 1 opt_description) + list(GET part 2 opt_default) + if(NOT DEFINED ${opt_name}) + set(${opt_name} ${opt_default}) + endif() + option(${opt_name} "${opt_description}" ${${opt_name}}) + message("-- Build: ${opt_description}: ${${opt_name}}") +endforeach() -# to enable clang build profiler: -# cmake -DBUILD_CLANG_PROFILER=true .. -# see examples/cbenchmark.sh -option(BUILD_CLANG_PROFILER "enable clang build profiler" false) -message("-- Build: clang profiler ${BUILD_CLANG_PROFILER}") if(BUILD_CLANG_PROFILER) if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") add_compile_options(-ftime-trace) @@ -78,7 +78,7 @@ function(build loc x) $<$>:-Wall -Wextra -Wpedantic>) endif() get_target_property(cppstd ${x} CXX_STANDARD) - message("-- adding ${x}.cpp CXX_STANDARD: C++${cppstd} (${CMAKE_CXX_COMPILER_ID})") + message("-- adding ${x}.cpp (C++${cppstd}) (${CMAKE_CXX_COMPILER_ID})") endfunction() foreach(x srcloctest example statictest cbenchmark) @@ -94,10 +94,7 @@ target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} if(BUILD_UNITTESTS) include(FetchContent) - FetchContent_Declare(Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_SHALLOW ON - GIT_TAG devel) + FetchContent_Declare(Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_SHALLOW ON GIT_TAG devel) FetchContent_MakeAvailable(Catch2) list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras) target_compile_features(Catch2 PRIVATE cxx_std_20) diff --git a/README.md b/README.md index 38183b8..99d0c92 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,11 @@ component::path path numbers::two ``` + +> [!TIP] +> For scoped enums, this method will return the fully qualified enum name (with the class prefix). If you want +> just the unscoped lookup use `unscoped_string_to_enum`. + ### Aliases Because all methods in `conjure_enum` are defined _within_ a `class` instead of individual template functions in a `namespace`, you can reduce your typing with standard aliases: From 9f52ded3db36bc73b7d5941405deefa42039f80d Mon Sep 17 00:00:00 2001 From: David Dight Date: Wed, 4 Dec 2024 11:08:20 +1100 Subject: [PATCH 08/49] doc update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 99d0c92..41e3602 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ numbers::two > [!TIP] > For scoped enums, this method will return the fully qualified enum name (with the class prefix). If you want -> just the unscoped lookup use `unscoped_string_to_enum`. +> to retuen the unscoped enum specify `true` ### Aliases Because all methods in `conjure_enum` are defined _within_ a `class` instead of individual template functions in a `namespace`, you can reduce your From 64232f33ef37e854b94fad5975976b8d9bc3ccc9 Mon Sep 17 00:00:00 2001 From: David Dight Date: Wed, 4 Dec 2024 11:08:42 +1100 Subject: [PATCH 09/49] doc update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 41e3602..12ea7a0 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ numbers::two > [!TIP] > For scoped enums, this method will return the fully qualified enum name (with the class prefix). If you want -> to retuen the unscoped enum specify `true` +> to return the unscoped enum specify `true` ### Aliases Because all methods in `conjure_enum` are defined _within_ a `class` instead of individual template functions in a `namespace`, you can reduce your From 0da970a96a3a7ccdad17f90bdcbc19f2f2d0ec0d Mon Sep 17 00:00:00 2001 From: David Dight Date: Thu, 30 Jan 2025 09:56:32 +1100 Subject: [PATCH 10/49] updated build --- CMakeLists.txt | 44 +++++--------------------- README.md | 4 +-- cmake/buildutils.cmake | 72 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 38 deletions(-) create mode 100644 cmake/buildutils.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index f4595df..c1b21a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,56 +29,30 @@ # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # ---------------------------------------------------------------------------------------- cmake_minimum_required (VERSION 3.20) +include(cmake/buildutils.cmake) project (conjure_enum LANGUAGES CXX HOMEPAGE_URL https://github.com/fix8mt/${PROJECT_NAME} DESCRIPTION "Lightweight C++20 enum and typename reflection" - VERSION 1.1.2) + VERSION 1.1.3) -message("-- ${CMAKE_PROJECT_NAME} version ${CMAKE_PROJECT_VERSION}") - -# to disable/enable an option -# cmake -DOPTION= .. -set(CUSTOM_OPTIONS - "BUILD_UNITTESTS|enable building unit tests|true" - "BUILD_STRIP_EXE|enable stripping of non-unittest executables|true" - "BUILD_ALL_WARNINGS|enable building with all warnings|true" - "BUILD_CLANG_PROFILER|enable clang build profiler|false" -) -foreach(x ${CUSTOM_OPTIONS}) - string(REPLACE "|" ";" part ${x}) - list(GET part 0 opt_name) - list(GET part 1 opt_description) - list(GET part 2 opt_default) - if(NOT DEFINED ${opt_name}) - set(${opt_name} ${opt_default}) - endif() - option(${opt_name} "${opt_description}" ${${opt_name}}) - message("-- Build: ${opt_description}: ${${opt_name}}") -endforeach() - -if(BUILD_CLANG_PROFILER) - if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_compile_options(-ftime-trace) - else() - message(WARNING "BUILD_CLANG_PROFILER only available with Clang") - endif() -endif() +fix8_setbuildtype(FIX8 Release) +fix8_addoption("BUILD_UNITTESTS|enable building unit tests|true") +fix8_addoption("BUILD_STRIP_EXE|enable stripping of non-unittest executables|true") +fix8_addoption("BUILD_ALL_WARNINGS|enable building with all warnings|true") +fix8_addoption("BUILD_CLANG_PROFILER|enable clang build profiler|false") function(build loc x) add_executable(${x} ${loc}/${x}.cpp) if(NOT ${x} STREQUAL srcloctest) add_dependencies(${x} srcloctest) # srcloctest should be built even if errors with conjure_enum endif() - set_target_properties(${x} PROPERTIES CXX_STANDARD 20 CXX_STANDARD_REQUIRED true) target_include_directories(${x} PRIVATE include) if(BUILD_ALL_WARNINGS) target_compile_options(${x} PRIVATE $<$:/W4> $<$>:-Wall -Wextra -Wpedantic>) endif() - get_target_property(cppstd ${x} CXX_STANDARD) - message("-- adding ${x}.cpp (C++${cppstd}) (${CMAKE_CXX_COMPILER_ID})") endfunction() foreach(x srcloctest example statictest cbenchmark) @@ -93,9 +67,7 @@ add_library(${PROJECT_NAME} INTERFACE) target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include) if(BUILD_UNITTESTS) - include(FetchContent) - FetchContent_Declare(Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git GIT_SHALLOW ON GIT_TAG devel) - FetchContent_MakeAvailable(Catch2) + fix8_fetch(Catch2 catchorg/Catch2 devel) list(APPEND CMAKE_MODULE_PATH ${catch2_SOURCE_DIR}/extras) target_compile_features(Catch2 PRIVATE cxx_std_20) include(Catch) diff --git a/README.md b/README.md index 12ea7a0..57c95c4 100644 --- a/README.md +++ b/README.md @@ -1431,8 +1431,8 @@ static consteval const char* FIX8::conjure_type::tpeek() [with T = test] --- # 6. `fixed_string` -`fixed_string` is a specialisation of `std::array` that provides statics storage for an ASCII zero (asciiz) string. The purpose of this class is to allow the -creation of `constexpr` strings with specfic storage, adding a trailing `0`. It is used by `conjure_enum` to store all strings. API is described below. +`fixed_string` is a specialisation of `std::array` that provides static storage for an ASCII zero (asciiz) string. The purpose of this class is to allow the +creation of `constexpr` strings with specfic storage whilst adding a trailing `0`. It is used by `conjure_enum` to store all strings. API is described below. ## a) Creating a `fixed_string` ```c++ diff --git a/cmake/buildutils.cmake b/cmake/buildutils.cmake new file mode 100644 index 0000000..910cd9d --- /dev/null +++ b/cmake/buildutils.cmake @@ -0,0 +1,72 @@ +# ---------------------------------------------------------------------------------------- +# SPDX-License-Identifier: MIT +# SPDX-FileCopyrightText: Copyright (C) 2024 Fix8 Market Technologies Pty Ltd +# SPDX-FileType: SOURCE +# +# cmake utils +# Copyright (C) 2024 Fix8 Market Technologies Pty Ltd +# by David L. Dight +# see https://github.com/fix8mt/uri +# +# Licensed under the MIT License . +# +# 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 (including the next paragraph) +# 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. +# ---------------------------------------------------------------------------------------- +# cmake build utils +# min cmake version 3.20 (Mar 24, 2021) +# ---------------------------------------------------------------------------------------- +function(fix8_setbuildtype define_prefix default_type) + if(NOT "${CMAKE_BUILD_TYPE}" STREQUAL "") + if (${CMAKE_BUILD_TYPE} STREQUAL "Debug") + add_compile_definitions(${define_prefix}_DEBUG_BUILD) + elseif(${CMAKE_BUILD_TYPE} STREQUAL "RelWithDebInfo") + add_compile_definitions(${define_prefix}_RELWITHDEBINFO_BUILD) + elseif(${CMAKE_BUILD_TYPE} STREQUAL "MinSizeRel") + add_compile_definitions(${define_prefix}_MINSIZEREL_BUILD) + elseif(${default_type} STREQUAL "Release") + add_compile_definitions(${define_prefix}_RELEASE_BUILD) + else() + message(FATAL_ERROR "Unsupported build type ${default_type}") + endif() + message("-- ${CMAKE_PROJECT_NAME} version ${CMAKE_PROJECT_VERSION}, build type ${CMAKE_BUILD_TYPE}") + else() + set_property(CACHE CMAKE_BUILD_TYPE PROPERTY VALUE ${default_type}) + fix8_setbuildtype(${define_prefix} ${default_type}) + endif() +endfunction() + +# ---------------------------------------------------------------------------------------- +macro(fix8_addoption option_string) + string(REPLACE "|" ";" part ${option_string}) + list(GET part 0 opt_name) + list(GET part 1 opt_description) + list(GET part 2 opt_default) + if(NOT DEFINED ${opt_name}) + set(${opt_name} ${opt_default}) + endif() + option(${opt_name} "${opt_description}" ${${opt_name}}) + message("-- Build: ${opt_description}: ${${opt_name}}") +endmacro() + +# ---------------------------------------------------------------------------------------- +macro(fix8_fetch modname parturl tag) + include(FetchContent) + message(STATUS "Downloading ${modname}...") + FetchContent_Declare(${modname} GIT_REPOSITORY https://github.com/${parturl}.git GIT_SHALLOW ON GIT_TAG ${tag}) + FetchContent_MakeAvailable(${modname}) +endmacro() From a02aec01910e25d8a65f64b5b72077b09387eec0 Mon Sep 17 00:00:00 2001 From: David Dight Date: Tue, 4 Feb 2025 11:39:39 +1100 Subject: [PATCH 11/49] #20 possible fix --- include/fix8/conjure_enum.hpp | 1 + include/fix8/conjure_enum_ext.hpp | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/include/fix8/conjure_enum.hpp b/include/fix8/conjure_enum.hpp index 264c24b..cb612c8 100644 --- a/include/fix8/conjure_enum.hpp +++ b/include/fix8/conjure_enum.hpp @@ -63,6 +63,7 @@ #include #if not defined FIX8_CONJURE_ENUM_MINIMAL # include +# include #endif //----------------------------------------------------------------------------------------- diff --git a/include/fix8/conjure_enum_ext.hpp b/include/fix8/conjure_enum_ext.hpp index 154052a..d8c6220 100644 --- a/include/fix8/conjure_enum_ext.hpp +++ b/include/fix8/conjure_enum_ext.hpp @@ -237,9 +237,6 @@ struct iterator_adaptor constexpr auto end() noexcept { return conjure_enum::entries.cend(); } }; -//----------------------------------------------------------------------------------------- -#include - //----------------------------------------------------------------------------------------- // ostream& operator<< for any enum; add the following before using: // using ostream_enum_operator::operator<<; From ac45cc420d6113f5829d4628a43596039f68c8c9 Mon Sep 17 00:00:00 2001 From: David Dight Date: Thu, 6 Feb 2025 21:02:59 +1100 Subject: [PATCH 12/49] updated cr --- CMakeLists.txt | 2 +- README.md | 2 +- SECURITY.md | 2 +- cmake/buildutils.cmake | 2 +- examples/cbenchmark.cpp | 2 +- examples/example.cpp | 2 +- examples/srcloctest.cpp | 2 +- examples/statictest.cpp | 2 +- include/fix8/conjure_enum.hpp | 2 +- include/fix8/conjure_enum_bitset.hpp | 2 +- include/fix8/conjure_enum_ext.hpp | 2 +- include/fix8/conjure_type.hpp | 2 +- reference/source_location.md | 2 +- utests/edgetests.cpp | 2 +- utests/unittests.cpp | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c1b21a7..435ff13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # ----------------------------------------------------------------------------------------- # SPDX-License-Identifier: MIT -# SPDX-FileCopyrightText: Copyright (C) 2024 Fix8 Market Technologies Pty Ltd +# SPDX-FileCopyrightText: Copyright (C) 2024-25 Fix8 Market Technologies Pty Ltd # SPDX-FileType: SOURCE # # conjure_enum (header only) diff --git a/README.md b/README.md index 57c95c4..46ab1fc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@