From 6baf64bbf414af41b104b83c6130b22145a4325a Mon Sep 17 00:00:00 2001 From: Joao Paulo Magalhaes Date: Fri, 12 Apr 2024 18:59:36 +0100 Subject: [PATCH 1/3] Improve doxygen comments for use in rapidyaml's docs --- cmake | 2 +- ...conv-atof-mega_bytes_per_second-double.png | 1 + ...rconv-atof-mega_bytes_per_second-float.png | 1 + ...harconv-atox-mega_bytes_per_second-i16.png | 1 + ...harconv-atox-mega_bytes_per_second-i32.png | 1 + ...harconv-atox-mega_bytes_per_second-i64.png | 1 + ...charconv-atox-mega_bytes_per_second-i8.png | 1 + ...harconv-atox-mega_bytes_per_second-u16.png | 1 + ...harconv-atox-mega_bytes_per_second-u32.png | 1 + ...harconv-atox-mega_bytes_per_second-u64.png | 1 + ...charconv-atox-mega_bytes_per_second-u8.png | 1 + ...conv-ftoa-mega_bytes_per_second-double.png | 1 + ...rconv-ftoa-mega_bytes_per_second-float.png | 1 + ...harconv-xtoa-mega_bytes_per_second-i16.png | 1 + ...harconv-xtoa-mega_bytes_per_second-i32.png | 1 + ...harconv-xtoa-mega_bytes_per_second-i64.png | 1 + ...charconv-xtoa-mega_bytes_per_second-i8.png | 1 + ...harconv-xtoa-mega_bytes_per_second-u16.png | 1 + ...harconv-xtoa-mega_bytes_per_second-u32.png | 1 + ...harconv-xtoa-mega_bytes_per_second-u64.png | 1 + ...charconv-xtoa-mega_bytes_per_second-u8.png | 1 + ...conv-atof-mega_bytes_per_second-double.png | 1 + ...rconv-atof-mega_bytes_per_second-float.png | 1 + ...harconv-atox-mega_bytes_per_second-i16.png | 1 + ...harconv-atox-mega_bytes_per_second-i32.png | 1 + ...harconv-atox-mega_bytes_per_second-i64.png | 1 + ...charconv-atox-mega_bytes_per_second-i8.png | 1 + ...harconv-atox-mega_bytes_per_second-u16.png | 1 + ...harconv-atox-mega_bytes_per_second-u32.png | 1 + ...harconv-atox-mega_bytes_per_second-u64.png | 1 + ...charconv-atox-mega_bytes_per_second-u8.png | 1 + ...conv-ftoa-mega_bytes_per_second-double.png | 1 + ...rconv-ftoa-mega_bytes_per_second-float.png | 1 + ...harconv-xtoa-mega_bytes_per_second-i16.png | 1 + ...harconv-xtoa-mega_bytes_per_second-i32.png | 1 + ...harconv-xtoa-mega_bytes_per_second-i64.png | 1 + ...charconv-xtoa-mega_bytes_per_second-i8.png | 1 + ...harconv-xtoa-mega_bytes_per_second-u16.png | 1 + ...harconv-xtoa-mega_bytes_per_second-u32.png | 1 + ...harconv-xtoa-mega_bytes_per_second-u64.png | 1 + ...charconv-xtoa-mega_bytes_per_second-u8.png | 1 + src/c4/base64.hpp | 21 +- src/c4/charconv.hpp | 428 +++++++++++++----- src/c4/dump.hpp | 11 +- src/c4/format.hpp | 311 ++++++++++--- src/c4/substr.hpp | 32 +- 46 files changed, 656 insertions(+), 189 deletions(-) create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atof-mega_bytes_per_second-double.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atof-mega_bytes_per_second-float.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i16.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i32.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i64.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i8.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u16.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u32.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u64.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u8.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-double.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-float.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i16.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i32.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i64.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i8.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u16.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u32.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u64.png create mode 120000 doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u8.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atof-mega_bytes_per_second-double.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atof-mega_bytes_per_second-float.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i16.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i32.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i64.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i8.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u16.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u32.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u64.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u8.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-double.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-float.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i16.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i32.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i64.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i8.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u16.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u32.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u64.png create mode 120000 doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u8.png diff --git a/cmake b/cmake index 9059c981..8f5ae21c 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 9059c98181f944aec83b90a677c96f3b43bd1047 +Subproject commit 8f5ae21cd187bb26f8fa5b1c5b9281a443869231 diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atof-mega_bytes_per_second-double.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atof-mega_bytes_per_second-double.png new file mode 120000 index 00000000..6a5bff55 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atof-mega_bytes_per_second-double.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-atof-mega_bytes_per_second-double.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atof-mega_bytes_per_second-float.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atof-mega_bytes_per_second-float.png new file mode 120000 index 00000000..d44cf4e9 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atof-mega_bytes_per_second-float.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-atof-mega_bytes_per_second-float.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i16.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i16.png new file mode 120000 index 00000000..4206ab86 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i16.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-atox-mega_bytes_per_second-i16.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i32.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i32.png new file mode 120000 index 00000000..860b0702 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i32.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-atox-mega_bytes_per_second-i32.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i64.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i64.png new file mode 120000 index 00000000..9844a19c --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i64.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-atox-mega_bytes_per_second-i64.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i8.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i8.png new file mode 120000 index 00000000..0c981c45 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i8.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-atox-mega_bytes_per_second-i8.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u16.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u16.png new file mode 120000 index 00000000..c0eb21b0 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u16.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-atox-mega_bytes_per_second-u16.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u32.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u32.png new file mode 120000 index 00000000..f58cbc39 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u32.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-atox-mega_bytes_per_second-u32.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u64.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u64.png new file mode 120000 index 00000000..2d251d91 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u64.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-atox-mega_bytes_per_second-u64.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u8.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u8.png new file mode 120000 index 00000000..d1292929 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u8.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-atox-mega_bytes_per_second-u8.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-double.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-double.png new file mode 120000 index 00000000..1c303310 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-double.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-ftoa-mega_bytes_per_second-double.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-float.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-float.png new file mode 120000 index 00000000..197cf98d --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-float.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-ftoa-mega_bytes_per_second-float.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i16.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i16.png new file mode 120000 index 00000000..6c3c7f4a --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i16.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-i16.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i32.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i32.png new file mode 120000 index 00000000..47cde912 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i32.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-i32.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i64.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i64.png new file mode 120000 index 00000000..45380920 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i64.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-i64.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i8.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i8.png new file mode 120000 index 00000000..547bee41 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i8.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-i8.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u16.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u16.png new file mode 120000 index 00000000..9a4cb010 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u16.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-u16.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u32.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u32.png new file mode 120000 index 00000000..a8c44487 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u32.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-u32.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u64.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u64.png new file mode 120000 index 00000000..252c5243 --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u64.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-u64.png \ No newline at end of file diff --git a/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u8.png b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u8.png new file mode 120000 index 00000000..8e27526d --- /dev/null +++ b/doc/img/linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u8.png @@ -0,0 +1 @@ +linux-x86_64-gxx12.1-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-u8.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atof-mega_bytes_per_second-double.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atof-mega_bytes_per_second-double.png new file mode 120000 index 00000000..5400639b --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atof-mega_bytes_per_second-double.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-atof-mega_bytes_per_second-double.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atof-mega_bytes_per_second-float.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atof-mega_bytes_per_second-float.png new file mode 120000 index 00000000..6ea15c73 --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atof-mega_bytes_per_second-float.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-atof-mega_bytes_per_second-float.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i16.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i16.png new file mode 120000 index 00000000..dd924cc8 --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i16.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-atox-mega_bytes_per_second-i16.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i32.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i32.png new file mode 120000 index 00000000..75eea41a --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i32.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-atox-mega_bytes_per_second-i32.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i64.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i64.png new file mode 120000 index 00000000..acad57d9 --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i64.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-atox-mega_bytes_per_second-i64.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i8.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i8.png new file mode 120000 index 00000000..1a0546dd --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i8.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-atox-mega_bytes_per_second-i8.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u16.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u16.png new file mode 120000 index 00000000..5bc01c88 --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u16.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-atox-mega_bytes_per_second-u16.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u32.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u32.png new file mode 120000 index 00000000..1929c1a7 --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u32.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-atox-mega_bytes_per_second-u32.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u64.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u64.png new file mode 120000 index 00000000..451e1f2e --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u64.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-atox-mega_bytes_per_second-u64.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u8.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u8.png new file mode 120000 index 00000000..aeabfe21 --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-u8.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-atox-mega_bytes_per_second-u8.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-double.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-double.png new file mode 120000 index 00000000..8158cc23 --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-double.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-ftoa-mega_bytes_per_second-double.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-float.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-float.png new file mode 120000 index 00000000..b27b90ed --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-ftoa-mega_bytes_per_second-float.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-ftoa-mega_bytes_per_second-float.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i16.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i16.png new file mode 120000 index 00000000..690c632b --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i16.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-i16.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i32.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i32.png new file mode 120000 index 00000000..68355379 --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i32.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-i32.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i64.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i64.png new file mode 120000 index 00000000..6f542f0f --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i64.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-i64.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i8.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i8.png new file mode 120000 index 00000000..6feb757c --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i8.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-i8.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u16.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u16.png new file mode 120000 index 00000000..19bea433 --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u16.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-u16.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u32.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u32.png new file mode 120000 index 00000000..e78fef60 --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u32.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-u32.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u64.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u64.png new file mode 120000 index 00000000..8b6b7912 --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u64.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-u64.png \ No newline at end of file diff --git a/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u8.png b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u8.png new file mode 120000 index 00000000..067e31f1 --- /dev/null +++ b/doc/img/windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-u8.png @@ -0,0 +1 @@ +windows-x86_64-vs2019-Release/c4core-bm-charconv-xtoa-mega_bytes_per_second-u8.png \ No newline at end of file diff --git a/src/c4/base64.hpp b/src/c4/base64.hpp index 9de4b9af..4456c0ce 100644 --- a/src/c4/base64.hpp +++ b/src/c4/base64.hpp @@ -11,6 +11,10 @@ namespace c4 { +/** @defgroup doc_base64 Base64 encoding/decoding + * @see https://en.wikipedia.org/wiki/Base64 + * @see https://www.base64encode.org/ + * @{ */ /** check that the given buffer is a valid base64 encoding * @see https://en.wikipedia.org/wiki/Base64 */ @@ -53,9 +57,16 @@ C4CORE_EXPORT size_t base64_encode(substr encoded, cblob data); * @see https://en.wikipedia.org/wiki/Base64 */ C4CORE_EXPORT size_t base64_decode(csubstr encoded, blob data); +/** @} */ // base64 namespace fmt { +/** @addtogroup doc_format_specifiers + * @{ */ + +/** @defgroup doc_base64_fmt Base64 + * @{ */ + template struct base64_wrapper_ { @@ -104,16 +115,22 @@ C4_ALWAYS_INLINE base64_wrapper base64(substr s) return base64_wrapper(blob(s.str, s.len)); } +/** @} */ // base64_fmt + +/** @} */ // format_specifiers + } // namespace fmt -/** write a variable in base64 format */ +/** write a variable in base64 format + * @ingroup doc_to_chars */ inline size_t to_chars(substr buf, fmt::const_base64_wrapper b) { return base64_encode(buf, b.data); } -/** read a variable in base64 format */ +/** read a variable in base64 format + * @ingroup doc_from_chars */ inline size_t from_chars(csubstr buf, fmt::base64_wrapper *b) { return base64_decode(buf, b->data); diff --git a/src/c4/charconv.hpp b/src/c4/charconv.hpp index ffb6a616..a744e730 100644 --- a/src/c4/charconv.hpp +++ b/src/c4/charconv.hpp @@ -3,39 +3,6 @@ /** @file charconv.hpp Lightweight generic type-safe wrappers for * converting individual values to/from strings. - * - * These are the main functions: - * - * @code{.cpp} - * // Convert the given value, writing into the string. - * // The resulting string will NOT be null-terminated. - * // Return the number of characters needed. - * // This function is safe to call when the string is too small - - * // no writes will occur beyond the string's last character. - * template size_t c4::to_chars(substr buf, T const& C4_RESTRICT val); - * - * - * // Convert the given value to a string using to_chars(), and - * // return the resulting string, up to and including the last - * // written character. - * template substr c4::to_chars_sub(substr buf, T const& C4_RESTRICT val); - * - * - * // Read a value from the string, which must be - * // trimmed to the value (ie, no leading/trailing whitespace). - * // return true if the conversion succeeded. - * // There is no check for overflow; the value wraps around in a way similar - * // to the standard C/C++ overflow behavior. For example, - * // from_chars("128", &val) returns true and val will be - * // set tot 0. - * template bool c4::from_chars(csubstr buf, T * C4_RESTRICT val); - * - * - * // Read the first valid sequence of characters from the string, - * // skipping leading whitespace, and convert it using from_chars(). - * // Return the number of characters read for converting. - * template size_t c4::from_chars_first(csubstr buf, T * C4_RESTRICT val); - * @endcode */ #include "c4/language.hpp" @@ -171,6 +138,50 @@ namespace c4 { +/** @defgroup doc_charconv Charconv utilities + * + * Lightweight, very fast generic type-safe wrappers for converting + * individual values to/from strings. These are the main generic + * functions: + * - @ref doc_to_chars and its alias @ref doc_xtoa + * - @ref doc_from_chars and its alias @ref doc_atox + * - @ref to_chars_sub() + * - @ref from_chars_first() + * + * And also some modest brag is in order: these functions are really + * fast: faster even than C++17 `std::to_chars()` and + * `std::to_chars()`, and many dozens of times faster than the + * iostream abominations. + * + * For example, here are some benchmark comparisons for @ref + * doc_from_chars (link leads to the main project README, where these + * results are shown more systematically). + * + * + * + *
atox,int64_t
g++12, linux Visual Studio 2019 + *
\image html linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i64.png \image html windows-x86_64-vs2019-Release-c4core-bm-charconv-atox-mega_bytes_per_second-i64.png + *
+ * + * + * + *
xtoa,int64_t
g++12, linux Visual Studio 2019 + *
\image html linux-x86_64-gxx12.1-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i64.png \image html windows-x86_64-vs2019-Release-c4core-bm-charconv-xtoa-mega_bytes_per_second-i64.png + *
+ * + * To parse floating point, c4core uses + * [fastfloat](https://github.com/fastfloat/fast_float), which is + * extremely fast, by an even larger factor: + * + * + * + *
atox,float
g++12, linux Visual Studio 2019 + *
\image html linux-x86_64-gxx12.1-Release-c4core-bm-charconv-atof-mega_bytes_per_second-float.png \image html windows-x86_64-vs2019-Release-c4core-bm-charconv-atof-mega_bytes_per_second-float.png + *
+ * + * @{ + */ + #if C4CORE_HAVE_STD_TOCHARS /** @warning Use only the symbol. Do not rely on the type or naked value of this enum. */ typedef enum : std::underlying_type::type { @@ -197,7 +208,7 @@ typedef enum : char { } RealFormat_e; #endif - +/** @cond dev */ /** in some platforms, int,unsigned int * are not any of int8_t...int64_t and * long,unsigned long are not any of uint8_t...uint64_t */ @@ -221,6 +232,7 @@ struct is_fixed_length value = value_i || value_u }; }; +/** @endcond */ //----------------------------------------------------------------------------- @@ -239,6 +251,7 @@ struct is_fixed_length # endif #endif +/** @cond dev */ namespace detail { /* python command to get the values below: @@ -398,25 +411,30 @@ template<> struct charconv_digits_<8u, false> }; } // namespace detail +// Helper macros, undefined below +#define _c4append(c) { if(C4_LIKELY(pos < buf.len)) { buf.str[pos++] = static_cast(c); } else { ++pos; } } +#define _c4appendhex(i) { if(C4_LIKELY(pos < buf.len)) { buf.str[pos++] = hexchars[i]; } else { ++pos; } } + +/** @endcond */ + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -// Helper macros, undefined below -#define _c4append(c) { if(C4_LIKELY(pos < buf.len)) { buf.str[pos++] = static_cast(c); } else { ++pos; } } -#define _c4appendhex(i) { if(C4_LIKELY(pos < buf.len)) { buf.str[pos++] = hexchars[i]; } else { ++pos; } } -/** @name digits_dec return the number of digits required to encode a - * decimal number. +/** @defgroup doc_digits Get number of digits * * @note At first sight this code may look heavily branchy and * therefore inefficient. However, measurements revealed this to be * the fastest among the alternatives. * - * @see https://github.com/biojppm/c4core/pull/77 */ -/** @{ */ + * @see https://github.com/biojppm/c4core/pull/77 + * + * @{ + */ +/** decimal digits for 8 bit integers */ template C4_CONSTEXPR14 C4_ALWAYS_INLINE auto digits_dec(T v) noexcept @@ -427,6 +445,7 @@ auto digits_dec(T v) noexcept return ((v >= 100) ? 3u : ((v >= 10) ? 2u : 1u)); } +/** decimal digits for 16 bit integers */ template C4_CONSTEXPR14 C4_ALWAYS_INLINE auto digits_dec(T v) noexcept @@ -437,6 +456,7 @@ auto digits_dec(T v) noexcept return ((v >= 10000) ? 5u : (v >= 1000) ? 4u : (v >= 100) ? 3u : (v >= 10) ? 2u : 1u); } +/** decimal digits for 32 bit integers */ template C4_CONSTEXPR14 C4_ALWAYS_INLINE auto digits_dec(T v) noexcept @@ -449,6 +469,7 @@ auto digits_dec(T v) noexcept (v >= 1000) ? 4u : (v >= 100) ? 3u : (v >= 10) ? 2u : 1u); } +/** decimal digits for 64 bit integers */ template C4_CONSTEXPR14 C4_ALWAYS_INLINE auto digits_dec(T v) noexcept @@ -496,9 +517,8 @@ auto digits_dec(T v) noexcept return (v >= 10) ? 2u : 1u; } -/** @} */ - +/** return the number of digits required to encode an hexadecimal number. */ template C4_CONSTEXPR14 C4_ALWAYS_INLINE unsigned digits_hex(T v) noexcept { @@ -507,6 +527,7 @@ C4_CONSTEXPR14 C4_ALWAYS_INLINE unsigned digits_hex(T v) noexcept return v ? 1u + (msb((typename std::make_unsigned::type)v) >> 2u) : 1u; } +/** return the number of digits required to encode a binary number. */ template C4_CONSTEXPR14 C4_ALWAYS_INLINE unsigned digits_bin(T v) noexcept { @@ -515,6 +536,7 @@ C4_CONSTEXPR14 C4_ALWAYS_INLINE unsigned digits_bin(T v) noexcept return v ? 1u + msb((typename std::make_unsigned::type)v) : 1u; } +/** return the number of digits required to encode an octal number. */ template C4_CONSTEXPR14 C4_ALWAYS_INLINE unsigned digits_oct(T v_) noexcept { @@ -545,11 +567,14 @@ C4_CONSTEXPR14 C4_ALWAYS_INLINE unsigned digits_oct(T v_) noexcept } } +/** @} */ + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +/** @cond dev */ namespace detail { C4_INLINE_CONSTEXPR const char hexchars[] = "0123456789abcdef"; C4_INLINE_CONSTEXPR const char digits0099[] = @@ -559,6 +584,7 @@ C4_INLINE_CONSTEXPR const char digits0099[] = "6061626364656667686970717273747576777879" "8081828384858687888990919293949596979899"; } // namespace detail +/** @endcond */ C4_SUPPRESS_WARNING_GCC_PUSH C4_SUPPRESS_WARNING_GCC("-Warray-bounds") // gcc has false positives here @@ -566,6 +592,16 @@ C4_SUPPRESS_WARNING_GCC("-Warray-bounds") // gcc has false positives here C4_SUPPRESS_WARNING_GCC("-Wstringop-overflow") // gcc has false positives here #endif +/** @defgroup doc_write_unchecked Write with known number of digits + * + * Writes a value without checking the buffer length with regards to + * the required number of digits to encode the value. It is the + * responsibility of the caller to ensure that the provided number of + * digits is enough to write the given value. Notwithstanding the + * name, assertions are liberally performed, so this code is safe. + * + * @{ */ + template C4_HOT C4_ALWAYS_INLINE void write_dec_unchecked(substr buf, T v, unsigned digits_v) noexcept @@ -646,6 +682,19 @@ void write_bin_unchecked(substr buf, T v, unsigned digits_v) noexcept C4_ASSERT(digits_v == 0); } +/** @} */ // write_unchecked + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +/** @defgroup doc_write Write a value + * + * Writes a value without checking the buffer length + * decimal number -- but asserting. + * + * @{ */ /** write an integer to a string in decimal format. This is the * lowest level (and the fastest) function to do this task. @@ -724,6 +773,7 @@ C4_ALWAYS_INLINE size_t write_bin(substr buf, T v) noexcept } +/** @cond dev */ namespace detail { template using NumberWriter = size_t (*)(substr, U); template writer> @@ -742,6 +792,7 @@ size_t write_num_digits(substr buf, T v, size_t num_digits) noexcept return num_digits; } } // namespace detail +/** @endcond */ /** same as c4::write_dec(), but pad with zeroes on the left @@ -780,6 +831,8 @@ C4_ALWAYS_INLINE size_t write_oct(substr buf, T val, size_t num_digits) noexcept return detail::write_num_digits>(buf, val, num_digits); } +/** @} */ // write + C4_SUPPRESS_WARNING_GCC_POP @@ -791,6 +844,10 @@ C4_SUPPRESS_WARNING_GCC_POP C4_SUPPRESS_WARNING_MSVC_PUSH C4_SUPPRESS_WARNING_MSVC(4365) // '=': conversion from 'int' to 'I', signed/unsigned mismatch +/** @defgroup doc_read Read a value + * + * @{ */ + /** read a decimal integer from a string. This is the * lowest level (and the fastest) function to do this task. * @note does not accept negative numbers @@ -911,6 +968,8 @@ C4_ALWAYS_INLINE bool read_oct(csubstr s, I *C4_RESTRICT v) noexcept return true; } +/** @} */ + C4_SUPPRESS_WARNING_MSVC_POP @@ -920,6 +979,7 @@ C4_SUPPRESS_WARNING_MSVC_POP C4_SUPPRESS_WARNING_GCC_WITH_PUSH("-Wswitch-default") +/** @cond dev */ namespace detail { inline size_t _itoa2buf(substr buf, size_t pos, csubstr val) noexcept { @@ -1032,7 +1092,12 @@ C4_NO_INLINE size_t _itoa2buf(substr buf, I radix, size_t num_digits) noexcept return pos; } } // namespace detail +/** @endcond */ + +/** @defgroup doc_itoa itoa: signed to chars + * + * @{ */ /** convert an integral signed decimal to a string. * @note the resulting string is NOT zero-terminated. @@ -1217,11 +1282,17 @@ C4_ALWAYS_INLINE size_t itoa(substr buf, T v, T radix, size_t num_digits) noexce return detail::_itoa2buf(buf, radix, num_digits); } +/** @} */ + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +/** @defgroup doc_utoa utoa: unsigned to chars + * + * @{ */ + /** convert an integral unsigned decimal to a string. * * @note the resulting string is NOT zero-terminated. @@ -1347,11 +1418,17 @@ C4_ALWAYS_INLINE size_t utoa(substr buf, T v, T radix, size_t num_digits) noexce } C4_SUPPRESS_WARNING_GCC_POP +/** @} */ + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +/** @defgroup doc_atoi atoi: chars to signed + * + * @{ */ + /** Convert a trimmed string to a signed integral value. The input * string can be formatted as decimal, binary (prefix 0b or 0B), octal * (prefix 0o or 0O) or hexadecimal (prefix 0x or 0X). Strings with @@ -1362,14 +1439,15 @@ C4_SUPPRESS_WARNING_GCC_POP * * @return true if the conversion was successful. * - * @note overflow is not detected: the return status is true even if - * the conversion would return a value outside of the type's range, in - * which case the result will wrap around the type's range. - * This is similar to native behavior. - * * @note a positive sign is not accepted. ie, the string must not * start with '+' * + * @note overflow is not detected: the return status is true even if + * the conversion would return a value outside of the type's range, in + * which case the result will wrap around the type's range. This is + * similar to native behavior. See @ref doc_overflows and @ref + * doc_overflow_checked for overflow checking utilities. + * * @see atoi_first() if the string is not trimmed to the value to read. */ template C4_NO_UBSAN_IOVRFLW @@ -1437,8 +1515,16 @@ C4_ALWAYS_INLINE size_t atoi_first(csubstr str, T * C4_RESTRICT v) return csubstr::npos; } +/** @} */ + //----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +/** @defgroup doc_atou atou: chars to unsigned + * + * @{ */ /** Convert a trimmed string to an unsigned integral value. The string can be * formatted as decimal, binary (prefix 0b or 0B), octal (prefix 0o or 0O) @@ -1449,7 +1535,9 @@ C4_ALWAYS_INLINE size_t atoi_first(csubstr str, T * C4_RESTRICT v) * * @note overflow is not detected: the return status is true even if * the conversion would return a value outside of the type's range, in - * which case the result will wrap around the type's range. + * which case the result will wrap around the type's range. See @ref + * doc_overflows and @ref doc_overflow_checked for overflow checking + * utilities. * * @note If the string has a minus character, the return status * will be false. @@ -1509,6 +1597,8 @@ C4_ALWAYS_INLINE size_t atou_first(csubstr str, T *v) } +/** @} */ + #ifdef _MSC_VER # pragma warning(pop) #elif defined(__clang__) @@ -1521,6 +1611,8 @@ C4_ALWAYS_INLINE size_t atou_first(csubstr str, T *v) //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- + +/** @cond dev */ namespace detail { inline bool check_overflow(csubstr str, csubstr limit) noexcept { @@ -1539,15 +1631,22 @@ inline bool check_overflow(csubstr str, csubstr limit) noexcept return str.len > limit.len; } } // namespace detail +/** @endcond */ + +/** @defgroup doc_overflows overflows: does a number string overflow a type + * + * @{ */ -/** Test if the following string would overflow when converted to associated - * types. +/** Test if the following string would overflow when converted to + * associated integral types; this function is dispatched with SFINAE + * to handle differently signed and unsigned types. * @return true if number will overflow, false if it fits (or doesn't parse) + * @see doc_overflow_checked for format specifiers to enforce no-overflow reads */ template auto overflows(csubstr str) noexcept - -> typename std::enable_if::value, bool>::type + -> typename std::enable_if::value, bool>::type { C4_STATIC_ASSERT(std::is_integral::value); @@ -1605,13 +1704,16 @@ auto overflows(csubstr str) noexcept } -/** Test if the following string would overflow when converted to associated - * types. +/** Test if the following string would overflow when converted to + * associated integral types; this function is dispatched with SFINAE + * to handle differently signed and unsigned types. + * * @return true if number will overflow, false if it fits (or doesn't parse) + * @see doc_overflow_checked for format specifiers to enforce no-overflow reads */ template auto overflows(csubstr str) - -> typename std::enable_if::value, bool>::type + -> typename std::enable_if::value, bool>::type { C4_STATIC_ASSERT(std::is_integral::value); if(C4_UNLIKELY(str.len == 0)) @@ -1704,11 +1806,14 @@ auto overflows(csubstr str) return detail::check_overflow(str, detail::charconv_digits::max_value_dec()); } +/** @} */ + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +/** @cond dev */ namespace detail { @@ -1933,12 +2038,17 @@ C4_ALWAYS_INLINE bool scan_rhex(csubstr s, T *C4_RESTRICT val) noexcept #endif } // namespace detail +/** @endcond */ #undef _c4appendhex #undef _c4append +/** @defgroup doc_ftoa ftoa: float32 to chars + * + * @{ */ + /** Convert a single-precision real number to string. The string will * in general be NOT null-terminated. For FTOA_FLEX, \p precision is * the number of significand digits. Otherwise \p precision is the @@ -1958,6 +2068,12 @@ C4_ALWAYS_INLINE size_t ftoa(substr str, float v, int precision=-1, RealFormat_e #endif } +/** @} */ + + +/** @defgroup doc_dtoa dtoa: float64 to chars + * + * @{ */ /** Convert a double-precision real number to string. The string will * in general be NOT null-terminated. For FTOA_FLEX, \p precision is @@ -1978,6 +2094,12 @@ C4_ALWAYS_INLINE size_t dtoa(substr str, double v, int precision=-1, RealFormat_ #endif } +/** @} */ + + +/** @defgroup doc_atof atof: chars to float32 + * + * @{ */ /** Convert a string to a single precision real number. * The input string must be trimmed to the value, ie @@ -2019,6 +2141,27 @@ C4_ALWAYS_INLINE bool atof(csubstr str, float * C4_RESTRICT v) noexcept } +/** Convert a string to a single precision real number. + * Leading whitespace is skipped until valid characters are found. + * @return the number of characters read from the string, or npos if + * conversion was not successful or if the string was empty */ +inline size_t atof_first(csubstr str, float * C4_RESTRICT v) noexcept +{ + csubstr trimmed = str.first_real_span(); + if(trimmed.len == 0) + return csubstr::npos; + if(atof(trimmed, v)) + return static_cast(trimmed.end() - str.begin()); + return csubstr::npos; +} + +/** @} */ + + +/** @defgroup doc_atod atod: chars to float64 + * + * @{ */ + /** Convert a string to a double precision real number. * The input string must be trimmed to the value, ie * no leading or trailing whitespace can be present. @@ -2058,21 +2201,6 @@ C4_ALWAYS_INLINE bool atod(csubstr str, double * C4_RESTRICT v) noexcept } -/** Convert a string to a single precision real number. - * Leading whitespace is skipped until valid characters are found. - * @return the number of characters read from the string, or npos if - * conversion was not successful or if the string was empty */ -inline size_t atof_first(csubstr str, float * C4_RESTRICT v) noexcept -{ - csubstr trimmed = str.first_real_span(); - if(trimmed.len == 0) - return csubstr::npos; - if(atof(trimmed, v)) - return static_cast(trimmed.end() - str.begin()); - return csubstr::npos; -} - - /** Convert a string to a double precision real number. * Leading whitespace is skipped until valid characters are found. * @return the number of characters read from the string, or npos if @@ -2087,12 +2215,28 @@ inline size_t atod_first(csubstr str, double * C4_RESTRICT v) noexcept return csubstr::npos; } +/** @} */ + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // generic versions +/** @cond dev */ +// on some platforms, (unsigned) int and (unsigned) long +// are not any of the fixed length types above +#define _C4_IF_NOT_FIXED_LENGTH_I(T, ty) C4_ALWAYS_INLINE typename std::enable_if::value && !is_fixed_length::value_i, ty> +#define _C4_IF_NOT_FIXED_LENGTH_U(T, ty) C4_ALWAYS_INLINE typename std::enable_if::value && !is_fixed_length::value_u, ty> +/** @endcond*/ + + +/** @defgroup doc_xtoa xtoa: generic value to chars + * + * Dispatches to the most appropriate and efficient conversion + * function + * + * @{ */ C4_ALWAYS_INLINE size_t xtoa(substr s, uint8_t v) noexcept { return write_dec(s, v); } C4_ALWAYS_INLINE size_t xtoa(substr s, uint16_t v) noexcept { return write_dec(s, v); } C4_ALWAYS_INLINE size_t xtoa(substr s, uint32_t v) noexcept { return write_dec(s, v); } @@ -2125,6 +2269,20 @@ C4_ALWAYS_INLINE size_t xtoa(substr s, int64_t v, int64_t radix, size_t num_di C4_ALWAYS_INLINE size_t xtoa(substr s, float v, int precision, RealFormat_e formatting=FTOA_FLEX) noexcept { return ftoa(s, v, precision, formatting); } C4_ALWAYS_INLINE size_t xtoa(substr s, double v, int precision, RealFormat_e formatting=FTOA_FLEX) noexcept { return dtoa(s, v, precision, formatting); } +template _C4_IF_NOT_FIXED_LENGTH_I(T, size_t)::type xtoa(substr buf, T v) noexcept { return itoa(buf, v); } +template _C4_IF_NOT_FIXED_LENGTH_U(T, size_t)::type xtoa(substr buf, T v) noexcept { return write_dec(buf, v); } +template +C4_ALWAYS_INLINE size_t xtoa(substr s, T *v) noexcept { return itoa(s, (intptr_t)v, (intptr_t)16); } + +/** @} */ + +/** @defgroup doc_atox atox: generic chars to value + * + * Dispatches to the most appropriate and efficient conversion + * function + * + * @{ */ + C4_ALWAYS_INLINE bool atox(csubstr s, uint8_t *C4_RESTRICT v) noexcept { return atou(s, v); } C4_ALWAYS_INLINE bool atox(csubstr s, uint16_t *C4_RESTRICT v) noexcept { return atou(s, v); } C4_ALWAYS_INLINE bool atox(csubstr s, uint32_t *C4_RESTRICT v) noexcept { return atou(s, v); } @@ -2136,6 +2294,35 @@ C4_ALWAYS_INLINE bool atox(csubstr s, int64_t *C4_RESTRICT v) noexcept { return C4_ALWAYS_INLINE bool atox(csubstr s, float *C4_RESTRICT v) noexcept { return atof(s, v); } C4_ALWAYS_INLINE bool atox(csubstr s, double *C4_RESTRICT v) noexcept { return atod(s, v); } +template _C4_IF_NOT_FIXED_LENGTH_I(T, bool )::type atox(csubstr buf, T *C4_RESTRICT v) noexcept { return atoi(buf, v); } +template _C4_IF_NOT_FIXED_LENGTH_U(T, bool )::type atox(csubstr buf, T *C4_RESTRICT v) noexcept { return atou(buf, v); } +template +C4_ALWAYS_INLINE bool atox(csubstr s, T **v) noexcept { intptr_t tmp; bool ret = atox(s, &tmp); if(ret) { *v = (T*)tmp; } return ret; } + +/** @} */ + + +/** @defgroup doc_to_chars to_chars: generalized chars to value + * + * Convert the given value, writing into the string. The resulting + * string will NOT be null-terminated. Return the number of + * characters needed. This function is safe to call when the string + * is too small - no writes will occur beyond the string's last + * character. + * + * Dispatches to the most appropriate and efficient conversion + * function. + * + * @see write_dec, doc_utoa, doc_itoa, doc_ftoa, doc_dtoa + * + * @warning When serializing floating point values (float or double), + * be aware that because it uses defaults, to_chars() may cause a + * truncation of the precision. To enforce a particular precision, use + * for example @ref c4::fmt::real, or call directly @ref c4::ftoa or + * @ref c4::dtoa. + * + * @{ */ + C4_ALWAYS_INLINE size_t to_chars(substr buf, uint8_t v) noexcept { return write_dec(buf, v); } C4_ALWAYS_INLINE size_t to_chars(substr buf, uint16_t v) noexcept { return write_dec(buf, v); } C4_ALWAYS_INLINE size_t to_chars(substr buf, uint32_t v) noexcept { return write_dec(buf, v); } @@ -2147,6 +2334,30 @@ C4_ALWAYS_INLINE size_t to_chars(substr buf, int64_t v) noexcept { return itoa( C4_ALWAYS_INLINE size_t to_chars(substr buf, float v) noexcept { return ftoa(buf, v); } C4_ALWAYS_INLINE size_t to_chars(substr buf, double v) noexcept { return dtoa(buf, v); } +template _C4_IF_NOT_FIXED_LENGTH_I(T, size_t)::type to_chars(substr buf, T v) noexcept { return itoa(buf, v); } +template _C4_IF_NOT_FIXED_LENGTH_U(T, size_t)::type to_chars(substr buf, T v) noexcept { return write_dec(buf, v); } +template +C4_ALWAYS_INLINE size_t to_chars(substr s, T *v) noexcept { return itoa(s, (intptr_t)v, (intptr_t)16); } + +/** @} */ + + +/** @defgroup doc_from_chars from_chars: generalized chars to value + * + * Read a value from the string, which must be trimmed to the value + * (ie, no leading/trailing whitespace). return true if the + * conversion succeeded. There is no check for overflow; the value + * wraps around in a way similar to the standard C/C++ overflow + * behavior. For example, from_chars("128", &val) returns true + * and val will be set tot 0. See @ref doc_overflows and @ref + * doc_overflow_checked for facilities enforcing no-overflow. + * + * Dispatches to the most appropriate and efficient conversion + * function + * + * @see doc_from_chars_first, atou, atoi, atof, atod + * @{ */ + C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint8_t *C4_RESTRICT v) noexcept { return atou(buf, v); } C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint16_t *C4_RESTRICT v) noexcept { return atou(buf, v); } C4_ALWAYS_INLINE bool from_chars(csubstr buf, uint32_t *C4_RESTRICT v) noexcept { return atou(buf, v); } @@ -2158,6 +2369,23 @@ C4_ALWAYS_INLINE bool from_chars(csubstr buf, int64_t *C4_RESTRICT v) noexcept C4_ALWAYS_INLINE bool from_chars(csubstr buf, float *C4_RESTRICT v) noexcept { return atof(buf, v); } C4_ALWAYS_INLINE bool from_chars(csubstr buf, double *C4_RESTRICT v) noexcept { return atod(buf, v); } +template _C4_IF_NOT_FIXED_LENGTH_I(T, bool )::type from_chars(csubstr buf, T *C4_RESTRICT v) noexcept { return atoi(buf, v); } +template _C4_IF_NOT_FIXED_LENGTH_U(T, bool )::type from_chars(csubstr buf, T *C4_RESTRICT v) noexcept { return atou(buf, v); } +template +C4_ALWAYS_INLINE bool from_chars(csubstr buf, T **v) noexcept { intptr_t tmp; bool ret = from_chars(buf, &tmp); if(ret) { *v = (T*)tmp; } return ret; } + +/** @defgroup doc_from_chars_first from_chars_first: generalized chars to value + * + * Read the first valid sequence of characters from the string, + * skipping leading whitespace, and convert it using @ref doc_from_chars . + * Return the number of characters read for converting. + * + * Dispatches to the most appropriate and efficient conversion + * function. + * + * @see atou_first, atoi_first, atof_first, atod_first + * @{ */ + C4_ALWAYS_INLINE size_t from_chars_first(csubstr buf, uint8_t *C4_RESTRICT v) noexcept { return atou_first(buf, v); } C4_ALWAYS_INLINE size_t from_chars_first(csubstr buf, uint16_t *C4_RESTRICT v) noexcept { return atou_first(buf, v); } C4_ALWAYS_INLINE size_t from_chars_first(csubstr buf, uint32_t *C4_RESTRICT v) noexcept { return atou_first(buf, v); } @@ -2169,41 +2397,17 @@ C4_ALWAYS_INLINE size_t from_chars_first(csubstr buf, int64_t *C4_RESTRICT v) n C4_ALWAYS_INLINE size_t from_chars_first(csubstr buf, float *C4_RESTRICT v) noexcept { return atof_first(buf, v); } C4_ALWAYS_INLINE size_t from_chars_first(csubstr buf, double *C4_RESTRICT v) noexcept { return atod_first(buf, v); } - -//----------------------------------------------------------------------------- -// on some platforms, (unsigned) int and (unsigned) long -// are not any of the fixed length types above - -#define _C4_IF_NOT_FIXED_LENGTH_I(T, ty) C4_ALWAYS_INLINE typename std::enable_if::value && !is_fixed_length::value_i, ty> -#define _C4_IF_NOT_FIXED_LENGTH_U(T, ty) C4_ALWAYS_INLINE typename std::enable_if::value && !is_fixed_length::value_u, ty> - -template _C4_IF_NOT_FIXED_LENGTH_I(T, size_t)::type xtoa(substr buf, T v) noexcept { return itoa(buf, v); } -template _C4_IF_NOT_FIXED_LENGTH_U(T, size_t)::type xtoa(substr buf, T v) noexcept { return write_dec(buf, v); } - -template _C4_IF_NOT_FIXED_LENGTH_I(T, bool )::type atox(csubstr buf, T *C4_RESTRICT v) noexcept { return atoi(buf, v); } -template _C4_IF_NOT_FIXED_LENGTH_U(T, bool )::type atox(csubstr buf, T *C4_RESTRICT v) noexcept { return atou(buf, v); } - -template _C4_IF_NOT_FIXED_LENGTH_I(T, size_t)::type to_chars(substr buf, T v) noexcept { return itoa(buf, v); } -template _C4_IF_NOT_FIXED_LENGTH_U(T, size_t)::type to_chars(substr buf, T v) noexcept { return write_dec(buf, v); } - -template _C4_IF_NOT_FIXED_LENGTH_I(T, bool )::type from_chars(csubstr buf, T *C4_RESTRICT v) noexcept { return atoi(buf, v); } -template _C4_IF_NOT_FIXED_LENGTH_U(T, bool )::type from_chars(csubstr buf, T *C4_RESTRICT v) noexcept { return atou(buf, v); } - template _C4_IF_NOT_FIXED_LENGTH_I(T, size_t)::type from_chars_first(csubstr buf, T *C4_RESTRICT v) noexcept { return atoi_first(buf, v); } template _C4_IF_NOT_FIXED_LENGTH_U(T, size_t)::type from_chars_first(csubstr buf, T *C4_RESTRICT v) noexcept { return atou_first(buf, v); } +template +C4_ALWAYS_INLINE size_t from_chars_first(csubstr buf, T **v) noexcept { intptr_t tmp; bool ret = from_chars_first(buf, &tmp); if(ret) { *v = (T*)tmp; } return ret; } -#undef _C4_IF_NOT_FIXED_LENGTH_I -#undef _C4_IF_NOT_FIXED_LENGTH_U - +/** @} */ -//----------------------------------------------------------------------------- -// for pointers +/** @} */ -template C4_ALWAYS_INLINE size_t xtoa(substr s, T *v) noexcept { return itoa(s, (intptr_t)v, (intptr_t)16); } -template C4_ALWAYS_INLINE bool atox(csubstr s, T **v) noexcept { intptr_t tmp; bool ret = atox(s, &tmp); if(ret) { *v = (T*)tmp; } return ret; } -template C4_ALWAYS_INLINE size_t to_chars(substr s, T *v) noexcept { return itoa(s, (intptr_t)v, (intptr_t)16); } -template C4_ALWAYS_INLINE bool from_chars(csubstr buf, T **v) noexcept { intptr_t tmp; bool ret = from_chars(buf, &tmp); if(ret) { *v = (T*)tmp; } return ret; } -template C4_ALWAYS_INLINE size_t from_chars_first(csubstr buf, T **v) noexcept { intptr_t tmp; bool ret = from_chars_first(buf, &tmp); if(ret) { *v = (T*)tmp; } return ret; } +#undef _C4_IF_NOT_FIXED_LENGTH_I +#undef _C4_IF_NOT_FIXED_LENGTH_U //----------------------------------------------------------------------------- @@ -2212,7 +2416,10 @@ template C4_ALWAYS_INLINE size_t from_chars_first(csubstr buf, T **v) /** call to_chars() and return a substr consisting of the * written portion of the input buffer. Ie, same as to_chars(), * but return a substr instead of a size_t. - * + * Convert the given value to a string using to_chars(), and + * return the resulting string, up to and including the last + * written character. + * @ingroup doc_to_chars * @see to_chars() */ template C4_ALWAYS_INLINE substr to_chars_sub(substr buf, T const& C4_RESTRICT v) noexcept @@ -2226,12 +2433,14 @@ C4_ALWAYS_INLINE substr to_chars_sub(substr buf, T const& C4_RESTRICT v) noexcep //----------------------------------------------------------------------------- // bool implementation +/** @ingroup doc_to_chars */ C4_ALWAYS_INLINE size_t to_chars(substr buf, bool v) noexcept { int val = v; return to_chars(buf, val); } +/** @ingroup doc_from_chars */ inline bool from_chars(csubstr buf, bool * C4_RESTRICT v) noexcept { if(buf == '0') @@ -2276,6 +2485,7 @@ inline bool from_chars(csubstr buf, bool * C4_RESTRICT v) noexcept return ret; } +/** @ingroup doc_from_chars_first */ inline size_t from_chars_first(csubstr buf, bool * C4_RESTRICT v) noexcept { csubstr trimmed = buf.first_non_empty_span(); @@ -2288,6 +2498,7 @@ inline size_t from_chars_first(csubstr buf, bool * C4_RESTRICT v) noexcept //----------------------------------------------------------------------------- // single-char implementation +/** @ingroup doc_to_chars */ inline size_t to_chars(substr buf, char v) noexcept { if(buf.len > 0) @@ -2299,7 +2510,9 @@ inline size_t to_chars(substr buf, char v) noexcept } /** extract a single character from a substring - * @note to extract a string instead and not just a single character, use the csubstr overload */ + * @note to extract a string instead and not just a single character, use the csubstr overload + * @ingroup doc_from_chars + * */ inline bool from_chars(csubstr buf, char * C4_RESTRICT v) noexcept { if(buf.len != 1) @@ -2309,6 +2522,7 @@ inline bool from_chars(csubstr buf, char * C4_RESTRICT v) noexcept return true; } +/** @ingroup doc_from_chars_first */ inline size_t from_chars_first(csubstr buf, char * C4_RESTRICT v) noexcept { if(buf.len < 1) @@ -2321,6 +2535,7 @@ inline size_t from_chars_first(csubstr buf, char * C4_RESTRICT v) noexcept //----------------------------------------------------------------------------- // csubstr implementation +/** @ingroup doc_to_chars */ inline size_t to_chars(substr buf, csubstr v) noexcept { C4_ASSERT(!buf.overlaps(v)); @@ -2337,12 +2552,14 @@ inline size_t to_chars(substr buf, csubstr v) noexcept return v.len; } +/** @ingroup doc_from_chars */ inline bool from_chars(csubstr buf, csubstr *C4_RESTRICT v) noexcept { *v = buf; return true; } +/** @ingroup doc_from_chars_first */ inline size_t from_chars_first(substr buf, csubstr * C4_RESTRICT v) noexcept { csubstr trimmed = buf.first_non_empty_span(); @@ -2356,6 +2573,7 @@ inline size_t from_chars_first(substr buf, csubstr * C4_RESTRICT v) noexcept //----------------------------------------------------------------------------- // substr +/** @ingroup doc_to_chars */ inline size_t to_chars(substr buf, substr v) noexcept { C4_ASSERT(!buf.overlaps(v)); @@ -2372,6 +2590,7 @@ inline size_t to_chars(substr buf, substr v) noexcept return v.len; } +/** @ingroup doc_from_chars */ inline bool from_chars(csubstr buf, substr * C4_RESTRICT v) noexcept { C4_ASSERT(!buf.overlaps(*v)); @@ -2393,6 +2612,7 @@ inline bool from_chars(csubstr buf, substr * C4_RESTRICT v) noexcept return false; } +/** @ingroup doc_from_chars_first */ inline size_t from_chars_first(csubstr buf, substr * C4_RESTRICT v) noexcept { csubstr trimmed = buf.first_non_empty_span(); @@ -2417,6 +2637,7 @@ inline size_t from_chars_first(csubstr buf, substr * C4_RESTRICT v) noexcept //----------------------------------------------------------------------------- +/** @ingroup doc_to_chars */ template inline size_t to_chars(substr buf, const char (& C4_RESTRICT v)[N]) noexcept { @@ -2424,11 +2645,14 @@ inline size_t to_chars(substr buf, const char (& C4_RESTRICT v)[N]) noexcept return to_chars(buf, sp); } +/** @ingroup doc_to_chars */ inline size_t to_chars(substr buf, const char * C4_RESTRICT v) noexcept { return to_chars(buf, to_csubstr(v)); } +/** @} */ + } // namespace c4 #ifdef _MSC_VER diff --git a/src/c4/dump.hpp b/src/c4/dump.hpp index ef23d310..c65623fb 100644 --- a/src/c4/dump.hpp +++ b/src/c4/dump.hpp @@ -367,6 +367,8 @@ C4_ALWAYS_INLINE DumpResults catsep_dump_resume(DumperFn &&dumpfn, substr buf, S //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +/// @cond dev + /** take the function pointer as a function argument */ template C4_ALWAYS_INLINE size_t format_dump(DumperFn &&dumpfn, substr buf, csubstr fmt) @@ -378,7 +380,7 @@ C4_ALWAYS_INLINE size_t format_dump(DumperFn &&dumpfn, substr buf, csubstr fmt) return 0u; } -/** take the function pointer as a function argument */ +/** take the function pointer as a template argument */ template C4_ALWAYS_INLINE size_t format_dump(substr buf, csubstr fmt) { @@ -389,9 +391,12 @@ C4_ALWAYS_INLINE size_t format_dump(substr buf, csubstr fmt) return 0u; } +/// @endcond + + /** take the function pointer as a function argument */ template -size_t format_dump(DumperFn &&dumpfn, substr buf, csubstr fmt, Arg const& C4_RESTRICT a, Args const& C4_RESTRICT ...more) +C4_NO_INLINE size_t format_dump(DumperFn &&dumpfn, substr buf, csubstr fmt, Arg const& C4_RESTRICT a, Args const& C4_RESTRICT ...more) { // we can dump without using buf // but we'll only dump if the buffer is ok @@ -414,7 +419,7 @@ size_t format_dump(DumperFn &&dumpfn, substr buf, csubstr fmt, Arg const& C4_RES /** take the function pointer as a template argument */ template -size_t format_dump(substr buf, csubstr fmt, Arg const& C4_RESTRICT a, Args const& C4_RESTRICT ...more) +C4_NO_INLINE size_t format_dump(substr buf, csubstr fmt, Arg const& C4_RESTRICT a, Args const& C4_RESTRICT ...more) { // we can dump without using buf // but we'll only dump if the buffer is ok diff --git a/src/c4/format.hpp b/src/c4/format.hpp index 322c7298..a47e9b54 100644 --- a/src/c4/format.hpp +++ b/src/c4/format.hpp @@ -21,8 +21,28 @@ # pragma GCC diagnostic ignored "-Wuseless-cast" #endif +/** @defgroup doc_format_utils Format utilities + * + * @brief Provides generic and type-safe formatting/scanning utilities + * built on top of @ref doc_to_chars() and @ref doc_from_chars, + * forwarding the arguments to these functions, which in turn use the + * @ref doc_charconv utilities. Like @ref doc_charconv, the formatting + * facilities are very efficient and many times faster than printf(). + * + * @see @ref sample::sample_formatting + * */ + +/** @defgroup doc_format_specifiers Format specifiers + * + * @brief Format specifiers are tag types and functions that are used + * together with @ref doc_to_chars and @ref doc_from_chars + * + * @ingroup doc_format_utils */ + namespace c4 { +/** @addtogroup doc_format_utils + * @{ */ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -31,6 +51,12 @@ namespace c4 { namespace fmt { +/** @addtogroup doc_format_specifiers + * @{ */ + +/** @defgroup doc_boolean_specifiers boolean specifiers + * @{ */ + /** write a variable as an alphabetic boolean, ie as either true or false * @param strict_read */ template @@ -47,9 +73,15 @@ boolalpha_ boolalpha(T const& val, bool strict_read=false) return boolalpha_(val, strict_read); } +/** @} */ + +/** @} */ + } // namespace fmt -/** write a variable as an alphabetic boolean, ie as either true or false */ +/** write a variable as an alphabetic boolean, ie as either true or + * false + * @ingroup doc_to_chars */ template inline size_t to_chars(substr buf, fmt::boolalpha_ fmt) { @@ -65,10 +97,17 @@ inline size_t to_chars(substr buf, fmt::boolalpha_ fmt) namespace fmt { +/** @addtogroup doc_format_specifiers + * @{ */ + +/** @defgroup doc_integer_specifiers Integer specifiers + * @{ */ + /** format an integral type with a custom radix */ template struct integral_ { + C4_STATIC_ASSERT(std::is_integral::value); T val; T radix; C4_ALWAYS_INLINE integral_(T val_, T radix_) : val(val_), radix(radix_) {} @@ -78,12 +117,14 @@ struct integral_ template struct integral_padded_ { + C4_STATIC_ASSERT(std::is_integral::value); T val; T radix; size_t num_digits; C4_ALWAYS_INLINE integral_padded_(T val_, T radix_, size_t nd) : val(val_), radix(radix_), num_digits(nd) {} }; + /** format an integral type with a custom radix */ template C4_ALWAYS_INLINE integral_ integral(T val, T radix=10) @@ -102,34 +143,6 @@ C4_ALWAYS_INLINE integral_ integral(std::nullptr_t, T radix=10) { return integral_(intptr_t(0), static_cast(radix)); } -/** pad the argument with zeroes on the left, with decimal radix */ -template -C4_ALWAYS_INLINE integral_padded_ zpad(T val, size_t num_digits) -{ - return integral_padded_(val, T(10), num_digits); -} -/** pad the argument with zeroes on the left */ -template -C4_ALWAYS_INLINE integral_padded_ zpad(integral_ val, size_t num_digits) -{ - return integral_padded_(val.val, val.radix, num_digits); -} -/** pad the argument with zeroes on the left */ -C4_ALWAYS_INLINE integral_padded_ zpad(std::nullptr_t, size_t num_digits) -{ - return integral_padded_(0, 16, num_digits); -} -/** pad the argument with zeroes on the left */ -template -C4_ALWAYS_INLINE integral_padded_ zpad(T const* val, size_t num_digits) -{ - return integral_padded_(reinterpret_cast(val), 16, num_digits); -} -template -C4_ALWAYS_INLINE integral_padded_ zpad(T * val, size_t num_digits) -{ - return integral_padded_(reinterpret_cast(val), 16, num_digits); -} /** format the pointer as an hexadecimal value */ @@ -210,6 +223,46 @@ inline integral_ bin(T v) return integral_(v, T(2)); } +/** @} */ // integer_specifiers + + +/** @defgroup doc_zpad Pad the number with zeroes on the left + * @{ */ + +/** pad the argument with zeroes on the left, with decimal radix */ +template +C4_ALWAYS_INLINE integral_padded_ zpad(T val, size_t num_digits) +{ + return integral_padded_(val, T(10), num_digits); +} +/** pad the argument with zeroes on the left */ +template +C4_ALWAYS_INLINE integral_padded_ zpad(integral_ val, size_t num_digits) +{ + return integral_padded_(val.val, val.radix, num_digits); +} +/** pad the argument with zeroes on the left */ +C4_ALWAYS_INLINE integral_padded_ zpad(std::nullptr_t, size_t num_digits) +{ + return integral_padded_(0, 16, num_digits); +} +/** pad the argument with zeroes on the left */ +template +C4_ALWAYS_INLINE integral_padded_ zpad(T const* val, size_t num_digits) +{ + return integral_padded_(reinterpret_cast(val), 16, num_digits); +} +template +C4_ALWAYS_INLINE integral_padded_ zpad(T * val, size_t num_digits) +{ + return integral_padded_(reinterpret_cast(val), 16, num_digits); +} + +/** @} */ // zpad + + +/** @defgroup doc_overflow_checked Check read for overflow + * @{ */ template struct overflow_checked_ @@ -224,9 +277,15 @@ C4_ALWAYS_INLINE overflow_checked_ overflow_checked(T &val) return overflow_checked_(val); } +/** @} */ // overflow_checked + +/** @} */ // format_specifiers + + } // namespace fmt -/** format an integral_ signed type */ +/** format an integer signed type + * @ingroup doc_to_chars */ template C4_ALWAYS_INLINE typename std::enable_if::value, size_t>::type @@ -234,7 +293,8 @@ to_chars(substr buf, fmt::integral_ fmt) { return itoa(buf, fmt.val, fmt.radix); } -/** format an integral_ signed type, pad with zeroes */ +/** format an integer signed type, pad with zeroes + * @ingroup doc_to_chars */ template C4_ALWAYS_INLINE typename std::enable_if::value, size_t>::type @@ -243,7 +303,8 @@ to_chars(substr buf, fmt::integral_padded_ fmt) return itoa(buf, fmt.val, fmt.radix, fmt.num_digits); } -/** format an integral_ unsigned type */ +/** format an integer unsigned type + * @ingroup doc_to_chars */ template C4_ALWAYS_INLINE typename std::enable_if::value, size_t>::type @@ -251,7 +312,8 @@ to_chars(substr buf, fmt::integral_ fmt) { return utoa(buf, fmt.val, fmt.radix); } -/** format an integral_ unsigned type, pad with zeroes */ +/** format an integer unsigned type, pad with zeroes + * @ingroup doc_to_chars */ template C4_ALWAYS_INLINE typename std::enable_if::value, size_t>::type @@ -260,6 +322,8 @@ to_chars(substr buf, fmt::integral_padded_ fmt) return utoa(buf, fmt.val, fmt.radix, fmt.num_digits); } +/** read an format an integer unsigned type + * @ingroup doc_from_chars */ template C4_ALWAYS_INLINE bool from_chars(csubstr s, fmt::overflow_checked_ wrapper) { @@ -276,6 +340,12 @@ C4_ALWAYS_INLINE bool from_chars(csubstr s, fmt::overflow_checked_ wrapper) namespace fmt { +/** @addtogroup doc_format_specifiers + * @{ */ + +/** @defgroup doc_real_specifiers Real specifiers + * @{ */ + template struct real_ { @@ -291,9 +361,15 @@ real_ real(T val, int precision, RealFormat_e fmt=FTOA_FLOAT) return real_(val, precision, fmt); } +/** @} */ // real_specifiers + +/** @} */ // format_specifiers + } // namespace fmt +/** @ingroup doc_to_chars */ inline size_t to_chars(substr buf, fmt::real_< float> fmt) { return ftoa(buf, fmt.val, fmt.precision, fmt.fmt); } +/** @ingroup doc_to_chars */ inline size_t to_chars(substr buf, fmt::real_ fmt) { return dtoa(buf, fmt.val, fmt.precision, fmt.fmt); } @@ -304,6 +380,12 @@ inline size_t to_chars(substr buf, fmt::real_ fmt) { return dtoa(buf, fm namespace fmt { +/** @addtogroup doc_format_specifiers + * @{ */ + +/** @defgroup doc_raw_binary_specifiers Raw binary data + * @{ */ + /** @see blob_ */ template struct raw_wrapper_ : public blob_ @@ -361,26 +443,35 @@ inline raw_wrapper raw(T & C4_RESTRICT data, size_t alignment=alignof(T)) return raw_wrapper(blob(data), alignment); } +/** @} */ // raw_binary_specifiers + +/** @} */ // format_specifiers + } // namespace fmt -/** write a variable in raw binary format, using memcpy */ +/** write a variable in raw binary format, using memcpy + * @ingroup doc_to_chars */ C4CORE_EXPORT size_t to_chars(substr buf, fmt::const_raw_wrapper r); -/** read a variable in raw binary format, using memcpy */ +/** read a variable in raw binary format, using memcpy + * @ingroup doc_from_chars */ C4CORE_EXPORT bool from_chars(csubstr buf, fmt::raw_wrapper *r); -/** read a variable in raw binary format, using memcpy */ +/** read a variable in raw binary format, using memcpy + * @ingroup doc_from_chars */ inline bool from_chars(csubstr buf, fmt::raw_wrapper r) { return from_chars(buf, &r); } -/** read a variable in raw binary format, using memcpy */ +/** read a variable in raw binary format, using memcpy + * @ingroup doc_from_chars_first */ inline size_t from_chars_first(csubstr buf, fmt::raw_wrapper *r) { return from_chars(buf, r); } -/** read a variable in raw binary format, using memcpy */ +/** read a variable in raw binary format, using memcpy + * @ingroup doc_from_chars_first */ inline size_t from_chars_first(csubstr buf, fmt::raw_wrapper r) { return from_chars(buf, &r); @@ -394,6 +485,12 @@ inline size_t from_chars_first(csubstr buf, fmt::raw_wrapper r) namespace fmt { +/** @addtogroup doc_format_specifiers + * @{ */ + +/** @defgroup doc_alignment_specifiers Alignment specifiers + * @{ */ + template struct left_ { @@ -426,9 +523,14 @@ right_ right(T val, size_t width, char padchar=' ') return right_(val, width, padchar); } +/** @} */ // alignment_specifiers + +/** @} */ // format_specifiers + } // namespace fmt +/** @ingroup doc_to_chars */ template size_t to_chars(substr buf, fmt::left_ const& C4_RESTRICT align) { @@ -440,6 +542,7 @@ size_t to_chars(substr buf, fmt::left_ const& C4_RESTRICT align) return align.width; } +/** @ingroup doc_to_chars */ template size_t to_chars(substr buf, fmt::right_ const& C4_RESTRICT align) { @@ -457,13 +560,16 @@ size_t to_chars(substr buf, fmt::right_ const& C4_RESTRICT align) //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -/// @cond dev +/** @defgroup doc_cat cat: concatenate arguments to string + * @{ */ + +/** @cond dev */ // terminates the variadic recursion inline size_t cat(substr /*buf*/) { return 0; } -/// @endcond +/** @endcond */ /** serialize the arguments, concatenating them to the given fixed-size buffer. @@ -491,16 +597,22 @@ substr cat_sub(substr buf, Args && ...args) return {buf.str, sz <= buf.len ? sz : buf.len}; } +/** @} */ + //----------------------------------------------------------------------------- -/// @cond dev + +/** @defgroup doc_uncat uncat: read concatenated arguments from string + * @{ */ + +/** @cond dev */ // terminates the variadic recursion inline size_t uncat(csubstr /*buf*/) { return 0; } -/// @endcond +/** @endcond */ /** deserialize the arguments from the given buffer. @@ -521,14 +633,20 @@ size_t uncat(csubstr buf, Arg & C4_RESTRICT a, Args & C4_RESTRICT ...more) return out + num; } +/** @} */ + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -namespace detail { +/** @defgroup doc_catsep catsep: cat arguments to string with separator + * @{ */ + +/** @cond dev */ +namespace detail { template C4_ALWAYS_INLINE size_t catsep_more(substr /*buf*/, Sep const& C4_RESTRICT /*sep*/) { @@ -578,13 +696,13 @@ size_t uncatsep_more(csubstr buf, Sep & C4_RESTRICT sep, Arg & C4_RESTRICT a, Ar } // namespace detail -/// @cond dev template size_t catsep(substr /*buf*/, Sep const& C4_RESTRICT /*sep*/) { return 0; } -/// @endcond +/** @endcond */ + /** serialize the arguments, concatenating them to the given fixed-size * buffer, using a separator between each argument. @@ -613,6 +731,23 @@ substr catsep_sub(substr buf, Args && ...args) return {buf.str, sz <= buf.len ? sz : buf.len}; } +/** @} */ + + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +/** @defgroup doc_uncatsep uncatsep: deserialize the separated arguments from a string + * @{ */ + +/** deserialize the arguments from the given buffer. + * + * @return the number of characters read from the buffer, or csubstr::npos + * if a conversion was not successful. + * @see c4::cat(). c4::uncat() is the inverse of c4::cat(). */ + /** deserialize the arguments from the given buffer, using a separator. * * @return the number of characters read from the buffer, or csubstr::npos @@ -632,11 +767,16 @@ size_t uncatsep(csubstr buf, Sep & C4_RESTRICT sep, Arg & C4_RESTRICT a, Args & return num; } +/** @} */ + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +/** @defgroup doc_format format: formatted string interpolation + * @{ */ + /// @cond dev // terminates the variadic recursion inline size_t format(substr buf, csubstr fmt) @@ -689,9 +829,14 @@ substr format_sub(substr buf, csubstr fmt, Args const& C4_RESTRICT ...args) return {buf.str, sz <= buf.len ? sz : buf.len}; } +/** @} */ + //----------------------------------------------------------------------------- +/** @defgroup doc_unformat unformat: formatted read from string + * @{ */ + /// @cond dev // terminates the variadic recursion inline size_t unformat(csubstr /*buf*/, csubstr fmt) @@ -726,15 +871,18 @@ size_t unformat(csubstr buf, csubstr fmt, Arg & C4_RESTRICT a, Args & C4_RESTRIC return out; } +/** @} */ + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -/** like c4::cat(), but receives a container, and resizes it as needed to contain - * the result. The container is overwritten. To append to it, use the append - * overload. - * @see c4::cat() */ +/** cat+resize: like c4::cat(), but receives a container, and resizes + * it as needed to contain the result. The container is + * overwritten. To append to it, use the append overload. + * @see c4::cat() + * @ingroup doc_cat */ template inline void catrs(CharOwningContainer * C4_RESTRICT cont, Args const& C4_RESTRICT ...args) { @@ -746,9 +894,10 @@ inline void catrs(CharOwningContainer * C4_RESTRICT cont, Args const& C4_RESTRIC goto retry; } -/** like c4::cat(), but creates and returns a new container sized as needed to contain - * the result. - * @see c4::cat() */ +/** cat+resize: like c4::cat(), but creates and returns a new + * container sized as needed to contain the result. + * @see c4::cat() + * @ingroup doc_cat */ template inline CharOwningContainer catrs(Args const& C4_RESTRICT ...args) { @@ -757,11 +906,14 @@ inline CharOwningContainer catrs(Args const& C4_RESTRICT ...args) return cont; } -/** like c4::cat(), but receives a container, and appends to it instead of - * overwriting it. The container is resized as needed to contain the result. +/** cat+resize+append: like c4::cat(), but receives a container, and + * appends to it instead of overwriting it. The container is resized + * as needed to contain the result. + * * @return the region newly appended to the original container * @see c4::cat() - * @see c4::catrs() */ + * @see c4::catrs() + * @ingroup doc_cat */ template inline csubstr catrs_append(CharOwningContainer * C4_RESTRICT cont, Args const& C4_RESTRICT ...args) { @@ -778,9 +930,12 @@ inline csubstr catrs_append(CharOwningContainer * C4_RESTRICT cont, Args const& //----------------------------------------------------------------------------- -/** like c4::catsep(), but receives a container, and resizes it as needed to contain the result. - * The container is overwritten. To append to the container use the append overload. - * @see c4::catsep() */ +/** catsep+resize: like c4::catsep(), but receives a container, and + * resizes it as needed to contain the result. The container is + * overwritten. To append to the container use the append overload. + * + * @see c4::catsep() + * @ingroup doc_catsep */ template inline void catseprs(CharOwningContainer * C4_RESTRICT cont, Sep const& C4_RESTRICT sep, Args const& C4_RESTRICT ...args) { @@ -792,8 +947,11 @@ inline void catseprs(CharOwningContainer * C4_RESTRICT cont, Sep const& C4_RESTR goto retry; } -/** like c4::catsep(), but create a new container with the result. - * @return the requested container */ +/** catsep+resize: like c4::catsep(), but create a new container with + * the result. + * + * @return the requested container + * @ingroup doc_catsep */ template inline CharOwningContainer catseprs(Sep const& C4_RESTRICT sep, Args const& C4_RESTRICT ...args) { @@ -803,10 +961,13 @@ inline CharOwningContainer catseprs(Sep const& C4_RESTRICT sep, Args const& C4_R } -/** like catsep(), but receives a container, and appends the arguments, resizing the - * container as needed to contain the result. The buffer is appended to. +/** catsep+resize+append: like catsep(), but receives a container, and + * appends the arguments, resizing the container as needed to contain + * the result. The buffer is appended to. + * * @return a csubstr of the appended part - * @ingroup formatting_functions */ + * @ingroup formatting_functions + * @ingroup doc_catsep */ template inline csubstr catseprs_append(CharOwningContainer * C4_RESTRICT cont, Sep const& C4_RESTRICT sep, Args const& C4_RESTRICT ...args) { @@ -823,10 +984,12 @@ inline csubstr catseprs_append(CharOwningContainer * C4_RESTRICT cont, Sep const //----------------------------------------------------------------------------- -/** like c4::format(), but receives a container, and resizes it as needed - * to contain the result. The container is overwritten. To append to - * the container use the append overload. - * @see c4::format() */ +/** format+resize: like c4::format(), but receives a container, and + * resizes it as needed to contain the result. The container is + * overwritten. To append to the container use the append overload. + * + * @see c4::format() + * @ingroup doc_format */ template inline void formatrs(CharOwningContainer * C4_RESTRICT cont, csubstr fmt, Args const& C4_RESTRICT ...args) { @@ -838,8 +1001,11 @@ inline void formatrs(CharOwningContainer * C4_RESTRICT cont, csubstr fmt, Args c goto retry; } -/** like c4::format(), but create a new container with the result. - * @return the requested container */ +/** format+resize: like c4::format(), but create a new container with + * the result. + * + * @return the requested container + * @ingroup doc_format */ template inline CharOwningContainer formatrs(csubstr fmt, Args const& C4_RESTRICT ...args) { @@ -848,11 +1014,12 @@ inline CharOwningContainer formatrs(csubstr fmt, Args const& C4_RESTRICT ...args return cont; } -/** like format(), but receives a container, and appends the +/** format+resize+append: like format(), but receives a container, and appends the * arguments, resizing the container as needed to contain the * result. The buffer is appended to. * @return the region newly appended to the original container - * @ingroup formatting_functions */ + * @ingroup formatting_functions + * @ingroup doc_format */ template inline csubstr formatrs_append(CharOwningContainer * C4_RESTRICT cont, csubstr fmt, Args const& C4_RESTRICT ...args) { @@ -866,6 +1033,8 @@ inline csubstr formatrs_append(CharOwningContainer * C4_RESTRICT cont, csubstr f return to_csubstr(*cont).range(pos, cont->size()); } +/** @} */ + } // namespace c4 #ifdef _MSC_VER diff --git a/src/c4/substr.hpp b/src/c4/substr.hpp index ff51b15f..7ec407e8 100644 --- a/src/c4/substr.hpp +++ b/src/c4/substr.hpp @@ -24,13 +24,15 @@ namespace c4 { +/** @defgroup doc_substr Substring: read/write string views + * @{ */ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +/** @cond dev */ namespace detail { - template static inline void _do_reverse(C *C4_RESTRICT first, C *C4_RESTRICT last) { @@ -41,19 +43,20 @@ static inline void _do_reverse(C *C4_RESTRICT first, C *C4_RESTRICT last) *first++ = tmp; } } - } // namespace detail - +/** @endcond */ //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +/** @cond dev */ // utility macros to deuglify SFINAE code; undefined after the class. // https://stackoverflow.com/questions/43051882/how-to-disable-a-class-member-funrtion-for-certain-template-types #define C4_REQUIRE_RW(ret_type) \ template \ typename std::enable_if< ! std::is_const::value, ret_type>::type +/** @endcond */ /** a non-owning string-view, consisting of a character pointer @@ -345,7 +348,7 @@ struct C4CORE_EXPORT basic_substring return basic_substring(str, num != npos ? num : len); } - /** return the last @num elements: [len-num,len[*/ + /** return the last @p num elements: [len-num,len[*/ C4_ALWAYS_INLINE C4_PURE basic_substring last(size_t num) const noexcept { C4_ASSERT(num <= len || num == npos); @@ -2109,7 +2112,7 @@ struct C4CORE_EXPORT basic_substring } /** replace @p pattern with @p repl, and write the result into - * @dst. pattern and repl don't need equal sizes. + * @p dst. pattern and repl don't need equal sizes. * * @return the required size for dst. No overflow occurs if * dst.len is smaller than the required size; this can be used to @@ -2168,10 +2171,12 @@ struct C4CORE_EXPORT basic_substring //----------------------------------------------------------------------------- -/** @name Adapter functions. to_substr() and to_csubstr() is used in - * generic code like format(), and allow adding construction of - * substrings from new types like containers. */ -/** @{ */ +/** @defgroup doc_substr_adapters substr adapters + * + * to_substr() and to_csubstr() is used in generic code like + * format(), and allow adding construction of substrings from new + * types like containers. + * @{ */ /** neutral version for use in generic code */ @@ -2211,6 +2216,9 @@ to_csubstr(U s) noexcept { csubstr ss(s); return ss; } //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- +/** @defgroup doc_substr_cmp substr comparison operators + * @{ */ + template inline bool operator== (const char (&s)[N], basic_substring const that) noexcept { return that.compare(s, N-1) == 0; } template inline bool operator!= (const char (&s)[N], basic_substring const that) noexcept { return that.compare(s, N-1) != 0; } template inline bool operator< (const char (&s)[N], basic_substring const that) noexcept { return that.compare(s, N-1) > 0; } @@ -2225,12 +2233,14 @@ template inline bool operator> (const char c, basic_substring co template inline bool operator<= (const char c, basic_substring const that) noexcept { return that.compare(c) >= 0; } template inline bool operator>= (const char c, basic_substring const that) noexcept { return that.compare(c) <= 0; } +/** @} */ + //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- -/** @define C4_SUBSTR_NO_OSTREAM_LSHIFT doctest does not deal well with +/* C4_SUBSTR_NO_OSTREAM_LSHIFT doctest does not deal well with * template operator<< * @see https://github.com/onqtam/doctest/pull/431 */ #ifndef C4_SUBSTR_NO_OSTREAM_LSHIFT @@ -2265,6 +2275,8 @@ inline OStream& operator<< (OStream& os, basic_substring s) #endif #endif // !C4_SUBSTR_NO_OSTREAM_LSHIFT +/** @} */ + } // namespace c4 From 6d26a0aa4a3bc0fcb18b14d7897c30eca876365c Mon Sep 17 00:00:00 2001 From: Joao Paulo Magalhaes Date: Fri, 12 Apr 2024 19:00:03 +0100 Subject: [PATCH 2/3] Add compiler annotation helper macros: - C4_ASSUME - C4_NODISCARD - C4_DEPRECATED - C4_UNREACHABLE_AFTER_ERR --- .github/workflows/arch.yml | 2 +- .github/workflows/benchmarks.yml | 6 +-- .github/workflows/clang.yml | 10 ++--- .github/workflows/clang_tidy.yml | 2 +- .github/workflows/codeql.yml | 2 +- .github/workflows/coverage.yml | 4 +- .github/workflows/emscripten.yml | 4 +- .github/workflows/gcc.yml | 10 ++--- .github/workflows/libcxx.yml | 2 +- .github/workflows/macosx.yml | 2 +- .github/workflows/release.yml | 8 ++-- .github/workflows/test_install.yml | 2 +- .github/workflows/windows.yml | 8 ++-- changelog/current.md | 2 +- cmake | 2 +- src/c4/language.hpp | 62 +++++++++++++++++++++++++++--- 16 files changed, 90 insertions(+), 38 deletions(-) diff --git a/.github/workflows/arch.yml b/.github/workflows/arch.yml index 67ebb32f..de5abc44 100644 --- a/.github/workflows/arch.yml +++ b/.github/workflows/arch.yml @@ -62,7 +62,7 @@ jobs: #- {std: 17, bt: Debug , arch: armv7 , distro: ubuntu20.04} #- {std: 17, bt: Release, arch: armv7 , distro: ubuntu20.04} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - name: test uses: uraimo/run-on-arch-action@v2.3.0 with: diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index acc7dd63..ce4c8913 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: # use fetch-depth to ensure all tags are fetched - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive, fetch-depth: 0}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive, fetch-depth: 0}} - name: Variables (from tag) if: contains(github.ref, 'tags/v') run: | @@ -88,7 +88,7 @@ jobs: env: {BM: ON, STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: # use fetch-depth to ensure all tags are fetched - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive, fetch-depth: 0}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive, fetch-depth: 0}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - name: Download vars.sh uses: actions/download-artifact@v3 @@ -173,7 +173,7 @@ jobs: #- {std: 11, bt: Release, arch: armv7 , distro: ubuntu18.04} #- {std: 17, bt: Release, arch: armv7 , distro: ubuntu18.04} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive, fetch-depth: 0}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive, fetch-depth: 0}} - name: Download vars.sh uses: actions/download-artifact@v3 with: {name: vars.sh, path: ./} diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index fcaadcf5..174adc67 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -43,7 +43,7 @@ jobs: - {std: 11, cxx: clang++-6.0, bt: Release, bitlinks: shared64 static32} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -85,7 +85,7 @@ jobs: - {std: 11, cxx: clang++-6.0, bt: Release, bitlinks: shared64 static32} env: {CXXFLAGS: "-fno-exceptions -fno-rtti", STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -151,7 +151,7 @@ jobs: - {std: 11, cxx: clang++-3.9, bt: Release, vg: on, img: ubuntu18.04} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -205,7 +205,7 @@ jobs: - {std: 20, cxx: clang++-16 , bt: ubsan, bitlinks: static64} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -251,7 +251,7 @@ jobs: # - {std: 20, cxx: clang++-10, bt: Release, bitlinks: shared64, os: ubuntu-20.04} # env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} # steps: -# - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} +# - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} # - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 # - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} # - {name: show info, run: source .github/setenv.sh && c4_show_info} diff --git a/.github/workflows/clang_tidy.yml b/.github/workflows/clang_tidy.yml index 51b7e495..4fccd46d 100644 --- a/.github/workflows/clang_tidy.yml +++ b/.github/workflows/clang_tidy.yml @@ -48,7 +48,7 @@ jobs: - {std: 11, cxx: clang++-16, bt: ReleaseWithDebInfo, lint: clang-tidy, bitlinks: static32} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index ca8d78bb..2adbeced 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: recursive diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 5187e029..840f4efa 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -47,7 +47,7 @@ jobs: COVERALLS_PARALLEL: true, } steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: static64-configure--------------------------------------------------- @@ -105,7 +105,7 @@ jobs: IDIR: "install/nofastfloat-${{matrix.cxx}}-cxx${{matrix.std}}", } steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: nofastfloat-configure------------------------------------------------ diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index d6d8e189..ea4d068f 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -59,13 +59,13 @@ jobs: EM_VERSION: "${{matrix.emver}}" EM_CACHE_FOLDER: 'emsdk-cache' steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - name: setup emscripten cache id: cache-system-libraries uses: actions/cache@v3 with: {path: "${{env.EM_CACHE_FOLDER}}", key: "${{env.EM_VERSION}}-${{runner.os}}"} - name: setup emscripten - uses: mymindstorm/setup-emsdk@v11 + uses: mymindstorm/setup-emsdk@v14 with: {version: "${{matrix.emver}}", actions-cache-folder: "${{env.EM_CACHE_FOLDER}}"} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: static32-configure--------------------------------------------------- diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml index 90b3fecf..bdf0a1eb 100644 --- a/.github/workflows/gcc.yml +++ b/.github/workflows/gcc.yml @@ -47,7 +47,7 @@ jobs: - {std: 11, cxx: g++-4.8, bt: Release, bitlinks: shared64 static32} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -89,7 +89,7 @@ jobs: - {std: 20, cxx: g++-10 , bt: Release, bitlinks: shared64 static32} env: {CXXFLAGS: "-fno-exceptions -fno-rtti", STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -155,7 +155,7 @@ jobs: - {std: 11, cxx: g++-4.8, bt: Release, img: ubuntu18.04} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -209,7 +209,7 @@ jobs: - {std: 20, cxx: g++-12, bt: ubsan, bitlinks: static64} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -253,7 +253,7 @@ jobs: - {std: 17, bt: Release, toolchain: cmake/Toolchain-Arm-ubuntu.cmake, cxx: arm-linux-gnueabihf-gcc, os: ubuntu-20.04} env: {TOOLCHAIN: "${{matrix.toolchain}}", STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - name: install gcc-arm-linux-gnueabihf run: | diff --git a/.github/workflows/libcxx.yml b/.github/workflows/libcxx.yml index d8ff1a84..4b948364 100644 --- a/.github/workflows/libcxx.yml +++ b/.github/workflows/libcxx.yml @@ -62,7 +62,7 @@ jobs: LINT: "${{matrix.lint}}" OS: "${{matrix.os}}" steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} diff --git a/.github/workflows/macosx.yml b/.github/workflows/macosx.yml index daefdbe2..0c428035 100644 --- a/.github/workflows/macosx.yml +++ b/.github/workflows/macosx.yml @@ -52,7 +52,7 @@ jobs: - {std: 17, cxx: xcode, xcver: 11, bt: Release, os: macos-11, bitlinks: shared64 static64} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - {name: xcode, uses: maxim-lobanov/setup-xcode@v1, with: {xcode-version: "${{matrix.xcver}}" }} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0f5a1387..a8d2f9ce 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,7 @@ jobs: runs-on: ubuntu-latest steps: # use fetch-depth to ensure all tags are fetched - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive, fetch-depth: 0}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive, fetch-depth: 0}} - name: Variables (from tag) if: contains(github.ref, 'tags/v') run: | @@ -77,7 +77,7 @@ jobs: needs: gettag runs-on: ubuntu-latest steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - name: Download vars.sh uses: actions/download-artifact@v3 with: {name: vars.sh, path: ./} @@ -121,7 +121,7 @@ jobs: - {name: Windows VS2019 zip, sfxg: win64-shared-Release.zip , sfxp: windows-vs2019.zip , gen: ZIP , mime: zip , os: windows-2019, cxx: vs2019} - {name: MacOSX sh , sfxg: apple64-shared-Release.sh, sfxp: macosx-xcode.sh , gen: STGZ , mime: x-sh , os: macos-11.0 , cxx: xcode } steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - name: Download vars.sh uses: actions/download-artifact@v3 with: {name: vars.sh, path: ./} @@ -152,7 +152,7 @@ jobs: - src - cpp steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - name: Gather artifacts - ./assets uses: actions/download-artifact@v3 with: {name: assets, path: assets} diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index 14c3e85b..d41846f4 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -82,7 +82,7 @@ jobs: IDIR: "install/${{matrix.name}}-${{matrix.bt}}" PDIR: "prefix/${{matrix.name}}-${{matrix.bt}}" steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: Install python 3.9 diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 03d13c57..9971c516 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -59,7 +59,7 @@ jobs: - {std: 20, cxx: vs2022, bt: Release, os: windows-2022, bitlinks: shared64 static32} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: shared64-configure--------------------------------------------------- @@ -101,7 +101,7 @@ jobs: # https://learn.microsoft.com/en-us/cpp/build/reference/gr-enable-run-time-type-information?view=msvc-170 env: {CXXFLAGS: "/EHa- /EHs- /EHc /EHr- /GR- /wd4530", STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: shared64-configure--------------------------------------------------- @@ -148,7 +148,7 @@ jobs: IDIR: "install_${{matrix.arch}}_${{matrix.bt}}_${{matrix.std}}" } steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: configure run: | @@ -196,7 +196,7 @@ jobs: - {std: 20, cxx: vs2022, bt: Release, os: windows-2022, bitlinks: shared64arm } env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: shared64arm-configure--------------------------------------------------- diff --git a/changelog/current.md b/changelog/current.md index 8cb92fd6..dea5240b 100644 --- a/changelog/current.md +++ b/changelog/current.md @@ -46,7 +46,7 @@ assert(to_substr((char*)ptr).len == 3); // as before - `C4_IF_RTTI(code_with_rtti, code_without_rtti)`: select statements for rtti enabled/disabled - `C4_IF_RTTI_(code_with_rtti, code_without_rtti)`: select code tokens for rtti enabled/disabled - [PR#109](https://github.com/biojppm/c4core/pull/109): Add partial support for XTENSA processors (missing implementation of `c4::aalloc()`). See [rapidyaml#358](https://github.com/biojppm/rapidyaml/issues/358). - +- Add compiler annotation helper macros: `C4_ASSUME`, `C4_NODISCARD`, `C4_DEPRECATED`, `C4_UNREACHABLE_AFTER_ERR` ### Fixes diff --git a/cmake b/cmake index 8f5ae21c..3167ab1d 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 8f5ae21cd187bb26f8fa5b1c5b9281a443869231 +Subproject commit 3167ab1d4c4d5e82832f43eea54bc5311662ea00 diff --git a/src/c4/language.hpp b/src/c4/language.hpp index 8a949050..4ad81b60 100644 --- a/src/c4/language.hpp +++ b/src/c4/language.hpp @@ -13,7 +13,7 @@ * @see http://stackoverflow.com/a/7132549/5875572 */ #ifndef C4_CPP # if defined(_MSC_VER) && !defined(__clang__) -# if _MSC_VER >= 1910 // >VS2015: VS2017, VS2019 +# if _MSC_VER >= 1910 // >VS2015: VS2017, VS2019, VS2022 # if (!defined(_MSVC_LANG)) # error _MSVC not defined # endif @@ -221,12 +221,20 @@ # define C4_FLATTEN # define C4_HOT /** @todo */ # define C4_COLD /** @todo */ +# define C4_ASSUME(...) __assume(__VA_ARGS__) # define C4_EXPECT(x, y) x /** @todo */ -# define C4_LIKELY(x) x /** @todo */ -# define C4_UNLIKELY(x) x /** @todo */ -# define C4_UNREACHABLE() /** @todo */ +# define C4_LIKELY(x) x +# define C4_UNLIKELY(x) x +# define C4_UNREACHABLE() _c4_msvc_unreachable() # define C4_ATTR_FORMAT(...) /** */ -# define C4_NORETURN /** @todo */ +# define C4_NORETURN [[noreturn]] +# if _MSC_VER >= 1700 // VS2012 +# define C4_NODISCARD _Check_return_ +# else +# define C4_NODISCARD +# endif +[[noreturn]] __forceinline void _c4_msvc_unreachable() { __assume(false); } ///< https://stackoverflow.com/questions/60802864/emulating-gccs-builtin-unreachable-in-visual-studio +# define C4_UNREACHABLE_AFTER_ERR() /* */ #else ///< @todo assuming gcc-like compiler. check it is actually so. /** for function attributes in GCC, @@ -254,8 +262,52 @@ # define C4_UNREACHABLE() __builtin_unreachable() # define C4_ATTR_FORMAT(...) //__attribute__((format (__VA_ARGS__))) ///< @see https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#Common-Function-Attributes # define C4_NORETURN __attribute__((noreturn)) +# define C4_NODISCARD __attribute__((warn_unused_result)) +# define C4_UNREACHABLE_AFTER_ERR() C4_UNREACHABLE() +// C4_ASSUME +// see https://stackoverflow.com/questions/63493968/reproducing-clangs-builtin-assume-for-gcc +// preferred option: C++ standard attribute +# ifdef __has_cpp_attribute +# if __has_cpp_attribute(assume) >= 202207L +# define C4_ASSUME(...) [[assume(__VA_ARGS__)]] +# endif +# endif +// first fallback: compiler intrinsics/attributes for assumptions +# ifndef C4_ASSUME +# if defined(__clang__) +# define C4_ASSUME(...) __builtin_assume(__VA_ARGS__) +# elif defined(__GNUC__) +# if __GNUC__ >= 13 +# define C4_ASSUME(...) __attribute__((__assume__(__VA_ARGS__))) +# endif +# endif +# endif +// second fallback: possibly evaluating uses of unreachable() +// Set this to 1 if you want to allow assumptions to possibly evaluate. +# ifndef C4_ASSUME_ALLOW_EVAL +# define C4_ASSUME_ALLOW_EVAL 0 +# endif +# if !defined(C4_ASSUME) && (C4_ASSUME_ALLOW_EVAL) +# define C4_ASSUME(...) do { if (!bool(__VA_ARGS__)) C4_UNREACHABLE(); ) while(0) +# endif +// last fallback: define macro as doing nothing +# ifndef C4_ASSUME +# define C4_ASSUME(...) +# endif +#endif + + +#if C4_CPP >= 14 +# define C4_DEPRECATED(msg) [[deprecated(msg)]] +#else +# if defined(_MSC_VER) +# define C4_DEPRECATED(msg) __declspec(deprecated(msg)) +# else // defined(__GNUC__) || defined(__clang__) +# define C4_DEPRECATED(msg) __attribute__((deprecated(msg))) +# endif #endif + #ifdef _MSC_VER # define C4_FUNC __FUNCTION__ # define C4_PRETTY_FUNC __FUNCSIG__ From f6cbf5df5ce86dec03e768a756050cc7de40899e Mon Sep 17 00:00:00 2001 From: Joao Paulo Magalhaes Date: Sat, 13 Apr 2024 17:42:04 +0100 Subject: [PATCH 3/3] update docker images, fix 18.04 because of node error with actions/checkout@v4 --- .github/docker/build_and_push.sh | 15 ++++ .github/docker/ubuntu18.04/Dockerfile | 89 ++++++++++++++++++++--- .github/docker/ubuntu18.04/c4core-install | 27 +++++++ .github/docker/ubuntu22.04/c4core-install | 21 +++--- .github/workflows/arch.yml | 2 +- .github/workflows/benchmarks.yml | 6 +- .github/workflows/clang.yml | 10 +-- .github/workflows/clang_tidy.yml | 2 +- .github/workflows/codeql.yml | 2 +- .github/workflows/coverage.yml | 4 +- .github/workflows/emscripten.yml | 2 +- .github/workflows/gcc.yml | 10 +-- .github/workflows/libcxx.yml | 2 +- .github/workflows/macosx.yml | 2 +- .github/workflows/release.yml | 8 +- .github/workflows/test_install.yml | 55 +++++++++----- .github/workflows/windows.yml | 8 +- 17 files changed, 196 insertions(+), 69 deletions(-) diff --git a/.github/docker/build_and_push.sh b/.github/docker/build_and_push.sh index ba3d65da..343dfd86 100755 --- a/.github/docker/build_and_push.sh +++ b/.github/docker/build_and_push.sh @@ -2,6 +2,19 @@ set -o pipefail +# https://stackoverflow.com/questions/44785585/how-can-i-delete-all-local-docker-images +# +# To delete all containers including its volumes use, +# +# docker rm -vf $(docker ps -aq) +# +# To delete all the images, +# +# docker rmi -f $(docker images -aq) +# +# Remember, you should remove all the containers before removing all +# the images from which those containers were created. + if [ -z "$CR_USR" ] ; then echo "error: \$CR_USR is not defined. Set it to a user name." exit 1 @@ -10,6 +23,8 @@ if [ -z "$CR_PAT" ] ; then echo "error: \$CR_PAT is not defined. Set it to a personal access token." exit 1 fi + +# see https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry#building-container-images echo $CR_PAT | docker login ghcr.io -u $CR_USR --password-stdin mydir=$(cd $(dirname $0) ; pwd) diff --git a/.github/docker/ubuntu18.04/Dockerfile b/.github/docker/ubuntu18.04/Dockerfile index bb6e88aa..bcedb73d 100644 --- a/.github/docker/ubuntu18.04/Dockerfile +++ b/.github/docker/ubuntu18.04/Dockerfile @@ -1,10 +1,12 @@ FROM ubuntu:18.04 +# to build, use the script build_and_push.sh, located above + LABEL org.opencontainers.image.source=https://github.com/biojppm/c4core LABEL org.opencontainers.image.description="C++ build testing: gcc4.8-gcc11, clang3.9-clang16, arm-eabi-none, swig" LABEL org.opencontainers.image.licenses=MIT LABEL maintainer=dev@jpmag.me -LABEL version=1.0 +LABEL version=1.1 SHELL ["/bin/bash", "-c"] RUN apt-get update \ @@ -82,6 +84,7 @@ RUN apt-get install -y \ # cmany RUN ( \ + set -xe ; \ cd /tmp ; \ git clone --recursive https://github.com/biojppm/cmany -b dev ; \ pip install cmany \ @@ -92,16 +95,78 @@ RUN ( \ RUN apt-get install -y valgrind \ && echo "valgrind done" +# helper to install compiler versions, etc ADD c4core-install /usr/bin/c4core-install -RUN \ - # Standard Cleanup on Debian images - apt-get -y clean \ - && apt-get -y autoclean \ - && apt-get -y autoremove \ - && rm -rf /var/lib/apt/lists/* \ - && rm -rf /var/cache/debconf/*-old \ - && rm -rf /usr/share/doc/* \ - && rm -rf /usr/share/man/?? \ - && rm -rf /usr/share/man/??_* \ - && echo "cleanup done" + +## actions/checkout@v4 needs a different version of nodejs: +## node 18 and 20 failed with this: +## error:node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node) +RUN cd /tmp \ + && git clone --recursive https://github.com/nodejs/node --branch v20.12.1 \ + && cd node \ + && /usr/bin/c4core-install g++-10 \ + && env CXX=g++-10 ./configure \ + && make -j `nproc` \ + && make install \ + && cd .. \ + && rm -rf node +## actions/checkout@v4 needs a different version of nodejs: +## node 18 and 20 failed with this: +## error:node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node) +## see https://tecadmin.net/how-to-install-nvm-on-ubuntu-20-04/ +## see https://stackoverflow.com/questions/25899912/how-to-install-nvm-in-docker +## /usr/local/nvm or ~/.nvm , depending +#ENV NVM_DIR /usr/local/nvm +##ENV NVM_DIR ~/.nvm +#ENV NODE_VERSION 20.12.2 +#ENV NODE_PATH $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules +#ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH +#SHELL ["/bin/bash", "--login", "-i", "-c"] # https://stackoverflow.com/questions/25899912/how-to-install-nvm-in-docker/60137919#60137919 +#RUN mkdir $NVM_DIR \ +# && curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.2/install.sh | bash \ +# && whoami \ +# && echo "NVM_DIR=$NVM_DIR" \ +# && . $NVM_DIR/nvm.sh \ +# && nvm install $NODE_VERSION \ +# && nvm alias default $NODE_VERSION \ +# && nvm use default \ +# # node 20 doesn't work because it requires glib-2.28 +# #&& set -x \ +# #&& which node \ +# #&& `which node` --version \ +# #&& node --version +# +## +## so install glibc-2.28! +## +#RUN echo "glibc-2.28" \ +# && apt install -y gawk \ +# && cd /tmp \ +# && wget -c https://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz \ +# && tar -zxf glibc-2.28.tar.gz \ +# && cd glibc-2.28 \ +# && ../configure --prefix=/opt/glibc-2.28 \ +# && make -j `nproc` \ +# && make install \ +# && cd .. \ +# && rm -fr glibc-2.28 glibc-2.28.tar.gz +## +## Patch the installed Node 20 to work with /opt/glibc-2.28 instead: +## +#RUN echo "patching node to use glibc 2.28" \ +# && apt install -y patchelf \ +# && patchelf --set-interpreter \ +# #&& /opt/glibc-2.28/lib/ld-linux-x86_64.so.2 --set-rpath /opt/glibc-2.28/lib/:/lib/aarch64-linux-gnu/:/usr/lib/aarch64-linux-gnu/ /usr/local/bin/node + + +# Standard Cleanup on Debian images +RUN apt-get -y clean \ + && apt-get -y autoclean \ + && apt-get -y autoremove \ + && rm -rf /var/lib/apt/lists/* \ + && rm -rf /var/cache/debconf/*-old \ + && rm -rf /usr/share/doc/* \ + && rm -rf /usr/share/man/?? \ + && rm -rf /usr/share/man/??_* \ + && echo "cleanup done" diff --git a/.github/docker/ubuntu18.04/c4core-install b/.github/docker/ubuntu18.04/c4core-install index a4138f18..422cfb88 100755 --- a/.github/docker/ubuntu18.04/c4core-install +++ b/.github/docker/ubuntu18.04/c4core-install @@ -19,6 +19,8 @@ case $what in $script gcc-9 $script gcc-10 $script gcc-11 + #$script gcc-12 #not available in ubuntu 18.04 + $script gcc-13 ;; clang-all) $script clang-16 @@ -116,6 +118,31 @@ case $what in apt-get install -y \ cpp-11 gcc-11 g++-11 g++-11-multilib libstdc++-11-dev lib32stdc++-11-dev ;; + #not available in ubuntu18.04 + #g++-12|gcc-12) + # apt-get update + # apt-get install -y \ + # software-properties-common + # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4 + # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 + # apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 + # apt-add-repository --yes --no-update ppa:ubuntu-toolchain-r/test + # apt-get update + # apt-get install -y \ + # cpp-12 gcc-12 g++-12 g++-12-multilib libstdc++-12-dev lib32stdc++-12-dev + # ;; + g++-13|gcc-13) + apt-get update + apt-get install -y \ + software-properties-common + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 6AF7F09730B3F0A4 + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 40976EAF437D05B5 + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 + apt-add-repository --yes --no-update ppa:ubuntu-toolchain-r/test + apt-get update + apt-get install -y \ + cpp-13 gcc-13 g++-13 g++-13-multilib libstdc++-13-dev lib32stdc++-13-dev + ;; clang++-3.9|clang-3.9) apt-get update apt-get install -y \ diff --git a/.github/docker/ubuntu22.04/c4core-install b/.github/docker/ubuntu22.04/c4core-install index 3d2847a4..27de4520 100755 --- a/.github/docker/ubuntu22.04/c4core-install +++ b/.github/docker/ubuntu22.04/c4core-install @@ -20,6 +20,7 @@ case $what in $script gcc-10 $script gcc-11 $script gcc-12 + $script gcc-13 ;; clang-all) $script clang-16 @@ -116,16 +117,16 @@ case $what in apt-get install -y \ cpp-12 gcc-12 g++-12 g++-12-multilib libstdc++-12-dev lib32stdc++-12-dev ;; - #g++-13|#gcc-13) - # apt-get update - # apt-get install -y \ - # wget \ - # software-properties-common - # apt-add-repository --yes --no-update ppa:ubuntu-toolchain-r/test - # apt-get update - # apt-get install -y \ - # cpp-13 gcc-13 g++-13 g++-13-multilib libstdc++-13-dev lib32stdc++-13-dev - # ;; + g++-13|gcc-13) + apt-get update + apt-get install -y \ + wget \ + software-properties-common + apt-add-repository --yes --no-update ppa:ubuntu-toolchain-r/test + apt-get update + apt-get install -y \ + cpp-13 gcc-13 g++-13 g++-13-multilib libstdc++-13-dev lib32stdc++-13-dev + ;; #clang++-3.9|clang-3.9) # apt-get update # apt-get install -y \ diff --git a/.github/workflows/arch.yml b/.github/workflows/arch.yml index de5abc44..67ebb32f 100644 --- a/.github/workflows/arch.yml +++ b/.github/workflows/arch.yml @@ -62,7 +62,7 @@ jobs: #- {std: 17, bt: Debug , arch: armv7 , distro: ubuntu20.04} #- {std: 17, bt: Release, arch: armv7 , distro: ubuntu20.04} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - name: test uses: uraimo/run-on-arch-action@v2.3.0 with: diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index ce4c8913..acc7dd63 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -29,7 +29,7 @@ jobs: runs-on: ubuntu-latest steps: # use fetch-depth to ensure all tags are fetched - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive, fetch-depth: 0}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive, fetch-depth: 0}} - name: Variables (from tag) if: contains(github.ref, 'tags/v') run: | @@ -88,7 +88,7 @@ jobs: env: {BM: ON, STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: # use fetch-depth to ensure all tags are fetched - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive, fetch-depth: 0}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive, fetch-depth: 0}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - name: Download vars.sh uses: actions/download-artifact@v3 @@ -173,7 +173,7 @@ jobs: #- {std: 11, bt: Release, arch: armv7 , distro: ubuntu18.04} #- {std: 17, bt: Release, arch: armv7 , distro: ubuntu18.04} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive, fetch-depth: 0}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive, fetch-depth: 0}} - name: Download vars.sh uses: actions/download-artifact@v3 with: {name: vars.sh, path: ./} diff --git a/.github/workflows/clang.yml b/.github/workflows/clang.yml index 174adc67..fcaadcf5 100644 --- a/.github/workflows/clang.yml +++ b/.github/workflows/clang.yml @@ -43,7 +43,7 @@ jobs: - {std: 11, cxx: clang++-6.0, bt: Release, bitlinks: shared64 static32} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -85,7 +85,7 @@ jobs: - {std: 11, cxx: clang++-6.0, bt: Release, bitlinks: shared64 static32} env: {CXXFLAGS: "-fno-exceptions -fno-rtti", STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -151,7 +151,7 @@ jobs: - {std: 11, cxx: clang++-3.9, bt: Release, vg: on, img: ubuntu18.04} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -205,7 +205,7 @@ jobs: - {std: 20, cxx: clang++-16 , bt: ubsan, bitlinks: static64} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -251,7 +251,7 @@ jobs: # - {std: 20, cxx: clang++-10, bt: Release, bitlinks: shared64, os: ubuntu-20.04} # env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} # steps: -# - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} +# - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} # - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 # - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} # - {name: show info, run: source .github/setenv.sh && c4_show_info} diff --git a/.github/workflows/clang_tidy.yml b/.github/workflows/clang_tidy.yml index 4fccd46d..51b7e495 100644 --- a/.github/workflows/clang_tidy.yml +++ b/.github/workflows/clang_tidy.yml @@ -48,7 +48,7 @@ jobs: - {std: 11, cxx: clang++-16, bt: ReleaseWithDebInfo, lint: clang-tidy, bitlinks: static32} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2adbeced..ca8d78bb 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -24,7 +24,7 @@ jobs: steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: submodules: recursive diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 840f4efa..5187e029 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -47,7 +47,7 @@ jobs: COVERALLS_PARALLEL: true, } steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: static64-configure--------------------------------------------------- @@ -105,7 +105,7 @@ jobs: IDIR: "install/nofastfloat-${{matrix.cxx}}-cxx${{matrix.std}}", } steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: nofastfloat-configure------------------------------------------------ diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index ea4d068f..965db224 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -59,7 +59,7 @@ jobs: EM_VERSION: "${{matrix.emver}}" EM_CACHE_FOLDER: 'emsdk-cache' steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - name: setup emscripten cache id: cache-system-libraries uses: actions/cache@v3 diff --git a/.github/workflows/gcc.yml b/.github/workflows/gcc.yml index bdf0a1eb..90b3fecf 100644 --- a/.github/workflows/gcc.yml +++ b/.github/workflows/gcc.yml @@ -47,7 +47,7 @@ jobs: - {std: 11, cxx: g++-4.8, bt: Release, bitlinks: shared64 static32} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -89,7 +89,7 @@ jobs: - {std: 20, cxx: g++-10 , bt: Release, bitlinks: shared64 static32} env: {CXXFLAGS: "-fno-exceptions -fno-rtti", STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -155,7 +155,7 @@ jobs: - {std: 11, cxx: g++-4.8, bt: Release, img: ubuntu18.04} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -209,7 +209,7 @@ jobs: - {std: 20, cxx: g++-12, bt: ubsan, bitlinks: static64} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} @@ -253,7 +253,7 @@ jobs: - {std: 17, bt: Release, toolchain: cmake/Toolchain-Arm-ubuntu.cmake, cxx: arm-linux-gnueabihf-gcc, os: ubuntu-20.04} env: {TOOLCHAIN: "${{matrix.toolchain}}", STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - name: install gcc-arm-linux-gnueabihf run: | diff --git a/.github/workflows/libcxx.yml b/.github/workflows/libcxx.yml index 4b948364..d8ff1a84 100644 --- a/.github/workflows/libcxx.yml +++ b/.github/workflows/libcxx.yml @@ -62,7 +62,7 @@ jobs: LINT: "${{matrix.lint}}" OS: "${{matrix.os}}" steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - run: git config --system --add safe.directory '*' # needed for running in the docker image. see https://github.com/actions/checkout/issues/1169 - run: c4core-install ${{matrix.cxx}} - {name: show info, run: source .github/setenv.sh && c4_show_info} diff --git a/.github/workflows/macosx.yml b/.github/workflows/macosx.yml index 0c428035..daefdbe2 100644 --- a/.github/workflows/macosx.yml +++ b/.github/workflows/macosx.yml @@ -52,7 +52,7 @@ jobs: - {std: 17, cxx: xcode, xcver: 11, bt: Release, os: macos-11, bitlinks: shared64 static64} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - {name: xcode, uses: maxim-lobanov/setup-xcode@v1, with: {xcode-version: "${{matrix.xcver}}" }} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a8d2f9ce..0f5a1387 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,7 @@ jobs: runs-on: ubuntu-latest steps: # use fetch-depth to ensure all tags are fetched - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive, fetch-depth: 0}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive, fetch-depth: 0}} - name: Variables (from tag) if: contains(github.ref, 'tags/v') run: | @@ -77,7 +77,7 @@ jobs: needs: gettag runs-on: ubuntu-latest steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - name: Download vars.sh uses: actions/download-artifact@v3 with: {name: vars.sh, path: ./} @@ -121,7 +121,7 @@ jobs: - {name: Windows VS2019 zip, sfxg: win64-shared-Release.zip , sfxp: windows-vs2019.zip , gen: ZIP , mime: zip , os: windows-2019, cxx: vs2019} - {name: MacOSX sh , sfxg: apple64-shared-Release.sh, sfxp: macosx-xcode.sh , gen: STGZ , mime: x-sh , os: macos-11.0 , cxx: xcode } steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - name: Download vars.sh uses: actions/download-artifact@v3 with: {name: vars.sh, path: ./} @@ -152,7 +152,7 @@ jobs: - src - cpp steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - name: Gather artifacts - ./assets uses: actions/download-artifact@v3 with: {name: assets, path: assets} diff --git a/.github/workflows/test_install.yml b/.github/workflows/test_install.yml index d41846f4..8b00044c 100644 --- a/.github/workflows/test_install.yml +++ b/.github/workflows/test_install.yml @@ -38,56 +38,77 @@ jobs: include: - {name: find_package/linux/Release , sdir: test/test_install , os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10" , tgt: all , bt: Release, vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } - {name: find_package/linux/Debug , sdir: test/test_install , os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10" , tgt: all , bt: Debug , vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } - - {name: find_package/linux/NoExc , sdir: test/test_install , os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Debug , vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } + - {name: find_package/linux/RelNoExc , sdir: test/test_install , os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Release, vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } + - {name: find_package/linux/DbgNoExc , sdir: test/test_install , os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Debug , vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } - {name: find_package/linux/libcxx/Release, sdir: test/test_install , os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9" , tgt: all , bt: Release, vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: "-DC4CORE_USE_LIBCXX=ON"} - {name: find_package/linux/libcxx/Debug , sdir: test/test_install , os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9" , tgt: all , bt: Debug , vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: "-DC4CORE_USE_LIBCXX=ON"} - - {name: find_package/linux/libcxx/NoExc , sdir: test/test_install , os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Debug , vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: "-DC4CORE_USE_LIBCXX=ON"} + - {name: find_package/linux/libcxx/RelNoExc,sdir: test/test_install , os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Release, vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: "-DC4CORE_USE_LIBCXX=ON"} + - {name: find_package/linux/libcxx/DbgNoExc,sdir: test/test_install , os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Debug , vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: "-DC4CORE_USE_LIBCXX=ON"} - {name: find_package/macos/Release , sdir: test/test_install , os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64" , tgt: ALL_BUILD, bt: Release, vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } - {name: find_package/macos/Debug , sdir: test/test_install , os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64" , tgt: ALL_BUILD, bt: Debug , vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } - - {name: find_package/macos/NoExc , sdir: test/test_install , os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: ALL_BUILD, bt: Debug , vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } + - {name: find_package/macos/RelNoExc , sdir: test/test_install , os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: ALL_BUILD, bt: Release, vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } + - {name: find_package/macos/DbgNoExc , sdir: test/test_install , os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: ALL_BUILD, bt: Debug , vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/lib/cmake/c4core -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } - {name: find_package/win/Release , sdir: test/test_install , os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64" , tgt: ALL_BUILD, bt: Release, vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/cmake -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } - {name: find_package/win/Debug , sdir: test/test_install , os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64" , tgt: ALL_BUILD, bt: Debug , vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/cmake -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } - - {name: find_package/win/NoExc , sdir: test/test_install , os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64 -DCMAKE_CXX_FLAGS=' /EHa- /EHs- /EHc /EHr- /GR- /wd4530'", tgt: ALL_BUILD, bt: Debug , vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/cmake -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } + - {name: find_package/win/RelNoExc , sdir: test/test_install , os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64 -DCMAKE_CXX_FLAGS=' /EHa- /EHs- /EHc /EHr- /GR- /wd4530'", tgt: ALL_BUILD, bt: Release, vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/cmake -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } + - {name: find_package/win/DbgNoExc , sdir: test/test_install , os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64 -DCMAKE_CXX_FLAGS=' /EHa- /EHs- /EHc /EHr- /GR- /wd4530'", tgt: ALL_BUILD, bt: Debug , vars: "-Dc4core_DIR=$GITHUB_WORKSPACE/$PDIR/cmake -DC4CORE_TEST_INSTALL_PACKAGE_MODE=ON", commonvars: } # - {name: find_library/linux/Release , sdir: test/test_install , os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10" , tgt: all , bt: Release, vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } - {name: find_library/linux/Debug , sdir: test/test_install , os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10" , tgt: all , bt: Debug , vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } - - {name: find_library/linux/NoExc , sdir: test/test_install , os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Debug , vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } + - {name: find_library/linux/RelNoExc , sdir: test/test_install , os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Release, vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } + - {name: find_library/linux/DbgNoExc , sdir: test/test_install , os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Debug , vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } - {name: find_library/linux/libcxx/Release, sdir: test/test_install , os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9" , tgt: all , bt: Release, vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: "-DC4CORE_USE_LIBCXX=ON"} - {name: find_library/linux/libcxx/Debug , sdir: test/test_install , os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9" , tgt: all , bt: Debug , vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: "-DC4CORE_USE_LIBCXX=ON"} - - {name: find_library/linux/libcxx/NoExc , sdir: test/test_install , os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Debug , vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: "-DC4CORE_USE_LIBCXX=ON"} + - {name: find_library/linux/libcxx/RelNoExc,sdir: test/test_install , os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Release, vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: "-DC4CORE_USE_LIBCXX=ON"} + - {name: find_library/linux/libcxx/DbgNoExc,sdir: test/test_install , os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Debug , vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: "-DC4CORE_USE_LIBCXX=ON"} - {name: find_library/macos/Release , sdir: test/test_install , os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64" , tgt: ALL_BUILD, bt: Release, vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } - {name: find_library/macos/Debug , sdir: test/test_install , os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64" , tgt: ALL_BUILD, bt: Debug , vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } - - {name: find_library/macos/NoExc , sdir: test/test_install , os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: ALL_BUILD, bt: Debug , vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } + - {name: find_library/macos/RelNoExc , sdir: test/test_install , os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: ALL_BUILD, bt: Release, vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } + - {name: find_library/macos/DbgNoExc , sdir: test/test_install , os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: ALL_BUILD, bt: Debug , vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } - {name: find_library/win/Release , sdir: test/test_install , os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64" , tgt: ALL_BUILD, bt: Release, vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } - {name: find_library/win/Debug , sdir: test/test_install , os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64" , tgt: ALL_BUILD, bt: Debug , vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } - - {name: find_library/win/NoExc , sdir: test/test_install , os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64 -DCMAKE_CXX_FLAGS=' /EHa- /EHs- /EHc /EHr- /GR- /wd4530'", tgt: ALL_BUILD, bt: Debug , vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } + - {name: find_library/win/RelNoExc , sdir: test/test_install , os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64 -DCMAKE_CXX_FLAGS=' /EHa- /EHs- /EHc /EHr- /GR- /wd4530'", tgt: ALL_BUILD, bt: Release, vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } + - {name: find_library/win/DbgNoExc , sdir: test/test_install , os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64 -DCMAKE_CXX_FLAGS=' /EHa- /EHs- /EHc /EHr- /GR- /wd4530'", tgt: ALL_BUILD, bt: Debug , vars: "-DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/$PDIR -DC4CORE_TEST_INSTALL_PACKAGE_MODE=OFF", commonvars: } # - {name: singleheader/linux/Release , sdir: test/test_singleheader, os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10" , tgt: all , bt: Release, vars: , commonvars: } - {name: singleheader/linux/Debug , sdir: test/test_singleheader, os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10" , tgt: all , bt: Debug , vars: , commonvars: } - - {name: singleheader/linux/NoExc , sdir: test/test_singleheader, os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Debug , vars: , commonvars: } + - {name: singleheader/linux/RelNoExc , sdir: test/test_singleheader, os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Release, vars: , commonvars: } + - {name: singleheader/linux/DbgNoExc , sdir: test/test_singleheader, os: ubuntu-20.04, cxx: g++-10 , gen: "-DCMAKE_CXX_COMPILER=g++-10 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Debug , vars: , commonvars: } - {name: singleheader/linux/libcxx/Release, sdir: test/test_singleheader, os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9" , tgt: all , bt: Release, vars: , commonvars: "-DC4CORE_USE_LIBCXX=ON"} - {name: singleheader/linux/libcxx/Debug , sdir: test/test_singleheader, os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9" , tgt: all , bt: Debug , vars: , commonvars: "-DC4CORE_USE_LIBCXX=ON"} - - {name: singleheader/linux/libcxx/NoExc , sdir: test/test_singleheader, os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Debug , vars: , commonvars: "-DC4CORE_USE_LIBCXX=ON"} + - {name: singleheader/linux/libcxx/RelNoExc,sdir: test/test_singleheader, os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Release, vars: , commonvars: "-DC4CORE_USE_LIBCXX=ON"} + - {name: singleheader/linux/libcxx/DbgNoExc,sdir: test/test_singleheader, os: ubuntu-20.04, cxx: clang++-9, gen: "-DCMAKE_CXX_COMPILER=clang++-9 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: all , bt: Debug , vars: , commonvars: "-DC4CORE_USE_LIBCXX=ON"} - {name: singleheader/macos/Release , sdir: test/test_singleheader, os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64" , tgt: ALL_BUILD, bt: Release, vars: , commonvars: } - {name: singleheader/macos/Debug , sdir: test/test_singleheader, os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64" , tgt: ALL_BUILD, bt: Debug , vars: , commonvars: } - - {name: singleheader/macos/NoExc , sdir: test/test_singleheader, os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: ALL_BUILD, bt: Debug , vars: , commonvars: } + - {name: singleheader/macos/RelNoExc , sdir: test/test_singleheader, os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: ALL_BUILD, bt: Release, vars: , commonvars: } + - {name: singleheader/macos/DbgNoExc , sdir: test/test_singleheader, os: macos-11.0 , cxx: xcode , gen: "-G Xcode -DCMAKE_OSX_ARCHITECTURES=x86_64 -DCMAKE_CXX_FLAGS='-fno-exceptions -fno-rtti'" , tgt: ALL_BUILD, bt: Debug , vars: , commonvars: } - {name: singleheader/win/Release , sdir: test/test_singleheader, os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64" , tgt: ALL_BUILD, bt: Release, vars: , commonvars: } - {name: singleheader/win/Debug , sdir: test/test_singleheader, os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64" , tgt: ALL_BUILD, bt: Debug , vars: , commonvars: } - - {name: singleheader/win/NoExc , sdir: test/test_singleheader, os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64 -DCMAKE_CXX_FLAGS=' /EHa- /EHs- /EHc /EHr- /GR- /wd4530'", tgt: ALL_BUILD, bt: Debug , vars: , commonvars: } + - {name: singleheader/win/RelNoExc , sdir: test/test_singleheader, os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64 -DCMAKE_CXX_FLAGS=' /EHa- /EHs- /EHc /EHr- /GR- /wd4530'", tgt: ALL_BUILD, bt: Release, vars: , commonvars: } + - {name: singleheader/win/DbgNoExc , sdir: test/test_singleheader, os: windows-2019, cxx: vs2019 , gen: "-G 'Visual Studio 16 2019' -A x64 -DCMAKE_CXX_FLAGS=' /EHa- /EHs- /EHc /EHr- /GR- /wd4530'", tgt: ALL_BUILD, bt: Debug , vars: , commonvars: } env: CXX_: "${{matrix.cxx}}" BT: "${{matrix.bt}}" OS: "${{matrix.os}}" - BDIR: "build/${{matrix.name}}-${{matrix.bt}}" - IDIR: "install/${{matrix.name}}-${{matrix.bt}}" - PDIR: "prefix/${{matrix.name}}-${{matrix.bt}}" + BDIR: "build/${{matrix.name}}" + IDIR: "install/${{matrix.name}}" + PDIR: "prefix/${{matrix.name}}" steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: Install python 3.9 uses: actions/setup-python@v4 with: { python-version: 3.9 } + - name: dirs + run: | + set -x + echo $BDIR + echo $IDIR + echo $PDIR + mkdir -p $BDIR + mkdir -p $IDIR + mkdir -p $PDIR - name: preinstall run: | if [ "${{matrix.sdir}}" == "test/test_install" ] ; then @@ -98,8 +119,6 @@ jobs: fi - name: configure run: | - mkdir -p $BDIR - mkdir -p $IDIR cmake -S ${{matrix.sdir}} -B $BDIR \ -DC4CORE_BUILD_TESTS=ON \ -DC4CORE_VALGRIND=OFF \ diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 9971c516..03d13c57 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -59,7 +59,7 @@ jobs: - {std: 20, cxx: vs2022, bt: Release, os: windows-2022, bitlinks: shared64 static32} env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: shared64-configure--------------------------------------------------- @@ -101,7 +101,7 @@ jobs: # https://learn.microsoft.com/en-us/cpp/build/reference/gr-enable-run-time-type-information?view=msvc-170 env: {CXXFLAGS: "/EHa- /EHs- /EHc /EHr- /GR- /wd4530", STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: shared64-configure--------------------------------------------------- @@ -148,7 +148,7 @@ jobs: IDIR: "install_${{matrix.arch}}_${{matrix.bt}}_${{matrix.std}}" } steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: configure run: | @@ -196,7 +196,7 @@ jobs: - {std: 20, cxx: vs2022, bt: Release, os: windows-2022, bitlinks: shared64arm } env: {STD: "${{matrix.std}}", CXX_: "${{matrix.cxx}}", BT: "${{matrix.bt}}", BITLINKS: "${{matrix.bitlinks}}", VG: "${{matrix.vg}}", SAN: "${{matrix.san}}", LINT: "${{matrix.lint}}", OS: "${{matrix.os}}"} steps: - - {name: checkout, uses: actions/checkout@v4, with: {submodules: recursive}} + - {name: checkout, uses: actions/checkout@v3, with: {submodules: recursive}} - {name: install requirements, run: source .github/reqs.sh && c4_install_test_requirements $OS} - {name: show info, run: source .github/setenv.sh && c4_show_info} - name: shared64arm-configure---------------------------------------------------