mirror of
https://github.com/ETLCPP/etl.git
synced 2026-05-01 03:19:10 +08:00
Compare commits
674 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e4d41ca57 | ||
|
|
912e22f238 | ||
|
|
1a6762d6c3 | ||
|
|
ee04aa76c5 | ||
|
|
3cd03fcb7f | ||
|
|
654e222bd9 | ||
|
|
a1ad13364e | ||
|
|
22ee76914d | ||
|
|
e2bed92814 | ||
|
|
576b03f38d | ||
|
|
f7e1384a70 | ||
|
|
e61589ebf2 | ||
|
|
823f2493b4 | ||
|
|
982adecca4 | ||
|
|
2059c5b657 | ||
|
|
bd6e55b12e | ||
|
|
5a7674b637 | ||
|
|
2e74b07dff | ||
|
|
f5128a39fe | ||
|
|
01066b86ae | ||
|
|
aeb8e4f734 | ||
|
|
c7571660bd | ||
|
|
6a1585b317 | ||
|
|
9fba468dc2 | ||
|
|
bd1def8b41 | ||
|
|
27d284713a | ||
|
|
1405bf65de | ||
|
|
09dd40d4dd | ||
|
|
c536a39f0a | ||
|
|
9b394b8677 | ||
|
|
9d2c73793d | ||
|
|
1ce3deb0f7 | ||
|
|
ea397ec2dd | ||
|
|
a483eb90c4 | ||
|
|
c970fa9bad | ||
|
|
d17c0297ec | ||
|
|
3c2a4d48a9 | ||
|
|
3d564d68b9 | ||
|
|
e4dfb6c045 | ||
|
|
95c9cabc10 | ||
|
|
3638d89f8b | ||
|
|
03ca3c817e | ||
|
|
b83cef5668 | ||
|
|
2c2ce9a39f | ||
|
|
f718c54396 | ||
|
|
12cdbc0da0 | ||
|
|
ab03ea114f | ||
|
|
2f242e37f2 | ||
|
|
31b87b5419 | ||
|
|
add42b6c87 | ||
|
|
2f6a3e04aa | ||
|
|
d5fc8d0cd1 | ||
|
|
7fdea7f7ae | ||
|
|
e7107b24f1 | ||
|
|
66e3d83a81 | ||
|
|
bd15e42440 | ||
|
|
0b5621e809 | ||
|
|
fa3ac74558 | ||
|
|
325908b1b9 | ||
|
|
29ad4b327e | ||
|
|
3639850b6b | ||
|
|
89284de733 | ||
|
|
ad6e027b08 | ||
|
|
78d8b82afb | ||
|
|
a0c98662ca | ||
|
|
237d83c107 | ||
|
|
8a61985ac8 | ||
|
|
d3affac417 | ||
|
|
0a56d40bdd | ||
|
|
54a1c82c98 | ||
|
|
4a8c167a31 | ||
|
|
521df8ee19 | ||
|
|
8ce59792fd | ||
|
|
67ecc8e11e | ||
|
|
7329efc7df | ||
|
|
4ad6126ec5 | ||
|
|
f96510bd79 | ||
|
|
a8ebe338f8 | ||
|
|
7bac1d02f7 | ||
|
|
25c9235cbc | ||
|
|
6ed9ca3f1d | ||
|
|
7ee7f10f58 | ||
|
|
70e4850a0b | ||
|
|
089f65cce1 | ||
|
|
810a106bdf | ||
|
|
7ef01fcaed | ||
|
|
e439963258 | ||
|
|
37aba58965 | ||
|
|
7a8944224b | ||
|
|
58b5bf5190 | ||
|
|
55da732fc8 | ||
|
|
1d47e1b731 | ||
|
|
52e57bc8b6 | ||
|
|
56dce4a3aa | ||
|
|
9ebcf41e63 | ||
|
|
992348b4bb | ||
|
|
226117b972 | ||
|
|
2ba5e93d01 | ||
|
|
25b88e509b | ||
|
|
1b244ec4c0 | ||
|
|
bfbb7259e1 | ||
|
|
dc0f62cc3f | ||
|
|
13c90eb8f2 | ||
|
|
4cf97675bd | ||
|
|
45b352a059 | ||
|
|
43972b416e | ||
|
|
f25e6b9d07 | ||
|
|
81c8e351ff | ||
|
|
fe1f19ce4d | ||
|
|
10fd81c2be | ||
|
|
2a79845dd5 | ||
|
|
82f168c96e | ||
|
|
6cec4a3971 | ||
|
|
ca6bbd50d0 | ||
|
|
1e2b69bc95 | ||
|
|
2e54c01c69 | ||
|
|
fc7c80bb97 | ||
|
|
a4c2272ad6 | ||
|
|
58619ec675 | ||
|
|
3826e2ab2e | ||
|
|
e80623bc1a | ||
|
|
75eb6680d6 | ||
|
|
353c36c393 | ||
|
|
d8d4187176 | ||
|
|
17e6167317 | ||
|
|
012bbea249 | ||
|
|
8b0fd64289 | ||
|
|
dbaffa9169 | ||
|
|
a843650649 | ||
|
|
d419bbf16f | ||
|
|
24421edd29 | ||
|
|
45e5668782 | ||
|
|
2a727b12b4 | ||
|
|
86fea52f5c | ||
|
|
21a1f58299 | ||
|
|
b51968d6dd | ||
|
|
a3c8f80216 | ||
|
|
570a7adaa3 | ||
|
|
db89cc8920 | ||
|
|
15b96484d5 | ||
|
|
491c648d3e | ||
|
|
53a9cde9a4 | ||
|
|
f0372eaeaa | ||
|
|
a7fe6bc6b0 | ||
|
|
0ad0cec342 | ||
|
|
ff03b2807d | ||
|
|
fa8f07ab80 | ||
|
|
eb1216146c | ||
|
|
a4ee9d01aa | ||
|
|
fed1274324 | ||
|
|
21f68eb7b9 | ||
|
|
bde8747be8 | ||
|
|
a61980660f | ||
|
|
a4e4527669 | ||
|
|
a669d1f46e | ||
|
|
1243099471 | ||
|
|
746761124c | ||
|
|
69b741adb8 | ||
|
|
d7dc1281ae | ||
|
|
49d7fa80bc | ||
|
|
947e89a6e9 | ||
|
|
8320b35d47 | ||
|
|
92e33bb974 | ||
|
|
c67c617d8c | ||
|
|
1c0d7a87de | ||
|
|
61796bee8f | ||
|
|
682b1e7011 | ||
|
|
9757860241 | ||
|
|
af1caa88fd | ||
|
|
c600605734 | ||
|
|
f9dc1caa94 | ||
|
|
b82bf3b79d | ||
|
|
01a0b63919 | ||
|
|
2862b3b247 | ||
|
|
2cae496620 | ||
|
|
fcd50486ce | ||
|
|
2c78c3d151 | ||
|
|
1b1145ea4e | ||
|
|
142dff245c | ||
|
|
a1744add1f | ||
|
|
55503e0b97 | ||
|
|
c92dbc2fce | ||
|
|
3b1ca75ba2 | ||
|
|
3780070bcf | ||
|
|
226caa30b5 | ||
|
|
0644f9827b | ||
|
|
e9c2577d8e | ||
|
|
cdd1de4b56 | ||
|
|
14ce8a93fb | ||
|
|
3206ac9feb | ||
|
|
6d6ecc9fb5 | ||
|
|
09555434f6 | ||
|
|
f8ee5f450b | ||
|
|
5b99aa50b3 | ||
|
|
0c3dafa09e | ||
|
|
16389b3eea | ||
|
|
4f70ed5329 | ||
|
|
af8ec168c4 | ||
|
|
46a937fc34 | ||
|
|
94d960748d | ||
|
|
16b7183eb8 | ||
|
|
62c654c749 | ||
|
|
819d813a12 | ||
|
|
339f5abf0f | ||
|
|
342e43e28b | ||
|
|
96e3229933 | ||
|
|
c798bd337b | ||
|
|
c8fa20620e | ||
|
|
922cfde453 | ||
|
|
6b3e776eb5 | ||
|
|
62d3fa12f1 | ||
|
|
84f037b616 | ||
|
|
d98c3ac903 | ||
|
|
8c90eb8ba8 | ||
|
|
f548cfc602 | ||
|
|
fc951ff9e2 | ||
|
|
a948ffe686 | ||
|
|
e85d29b1dd | ||
|
|
b2a4b4410c | ||
|
|
8d2f91de9f | ||
|
|
702dda4373 | ||
|
|
1f1e2c54c3 | ||
|
|
054fca0e25 | ||
|
|
1ac82dc83e | ||
|
|
552e0f8b90 | ||
|
|
269f3ffdfd | ||
|
|
520b4a9f46 | ||
|
|
0d792ef13b | ||
|
|
3c36e696f5 | ||
|
|
636ed523bd | ||
|
|
8918cab50a | ||
|
|
33f7bbc43d | ||
|
|
6f11b19cfa | ||
|
|
cb2b3fe6f4 | ||
|
|
d884719098 | ||
|
|
8f3db74be8 | ||
|
|
558c04b0a0 | ||
|
|
0744ee6989 | ||
|
|
6ebd24578b | ||
|
|
9eb17369c4 | ||
|
|
338d0a4cf5 | ||
|
|
868eaa2b79 | ||
|
|
133d065bf1 | ||
|
|
1039327148 | ||
|
|
31b658ba81 | ||
|
|
57c50fce89 | ||
|
|
3525c63b54 | ||
|
|
743ed78223 | ||
|
|
1128414d21 | ||
|
|
1f15e86ebf | ||
|
|
f5f76165ef | ||
|
|
7fd0360664 | ||
|
|
3c64940e90 | ||
|
|
34abed35b0 | ||
|
|
ea73cde70b | ||
|
|
ee820f0742 | ||
|
|
cb25fdfff5 | ||
|
|
79afa52c1e | ||
|
|
81a643b9b5 | ||
|
|
79b41c85af | ||
|
|
efd5c57419 | ||
|
|
a6f4c0b4d1 | ||
|
|
14e3b9d11e | ||
|
|
78f04ad298 | ||
|
|
e5dd953c8b | ||
|
|
2f535d385f | ||
|
|
43d3f0e89c | ||
|
|
b6e78b7c9c | ||
|
|
bb24ea2164 | ||
|
|
a025d0cc68 | ||
|
|
817f2ab99e | ||
|
|
4b8ab3eeda | ||
|
|
c7d2682659 | ||
|
|
02b0de1ae9 | ||
|
|
e0e7155d63 | ||
|
|
4147216231 | ||
|
|
23d78d5dc7 | ||
|
|
30ccdea629 | ||
|
|
532c9737b7 | ||
|
|
399899bbe2 | ||
|
|
3f7b18e3c2 | ||
|
|
85678586c4 | ||
|
|
07894526e0 | ||
|
|
047071211c | ||
|
|
11c509bb44 | ||
|
|
b328d06746 | ||
|
|
115e0e91a2 | ||
|
|
6ab05a5d7e | ||
|
|
fa10567482 | ||
|
|
d14f7a66a9 | ||
|
|
07734033d3 | ||
|
|
1ea45ff28e | ||
|
|
99a33535d3 | ||
|
|
d2e0b07791 | ||
|
|
a25f195637 | ||
|
|
d456c78589 | ||
|
|
9c3e786509 | ||
|
|
ad1679ff93 | ||
|
|
9e0121125f | ||
|
|
32a2e78d79 | ||
|
|
a2415cc30f | ||
|
|
f2c33a4466 | ||
|
|
da5e42a4bc | ||
|
|
8dff499500 | ||
|
|
947f9e523b | ||
|
|
21d7ebe879 | ||
|
|
793bafa1b4 | ||
|
|
c13d01319e | ||
|
|
df6b0b20c8 | ||
|
|
abc2735504 | ||
|
|
da32625f10 | ||
|
|
5b76824c61 | ||
|
|
f9982a6fde | ||
|
|
05731c2786 | ||
|
|
86b9e0903f | ||
|
|
85fc48302d | ||
|
|
421edaf165 | ||
|
|
2c170118ff | ||
|
|
d21b0a27f0 | ||
|
|
ed718a97e9 | ||
|
|
24e603b27d | ||
|
|
e1126aafd2 | ||
|
|
27a19f5c52 | ||
|
|
d0feb3d175 | ||
|
|
b90bcaaaab | ||
|
|
0323dabeff | ||
|
|
2bf512dd42 | ||
|
|
b38feb17b5 | ||
|
|
44e7516278 | ||
|
|
077590838b | ||
|
|
15cbb12e4b | ||
|
|
bcf7a95bb6 | ||
|
|
a9265b1a71 | ||
|
|
f7cdf1bc3f | ||
|
|
07bf063daa | ||
|
|
018c7ce849 | ||
|
|
4cbc601a69 | ||
|
|
813e26e3b4 | ||
|
|
4cf522ed46 | ||
|
|
69c3f74b0f | ||
|
|
5ac8070a8c | ||
|
|
972aedd944 | ||
|
|
fbb92f85fc | ||
|
|
5face0d8f2 | ||
|
|
1b5ff74a3d | ||
|
|
081b693e0b | ||
|
|
3295cb30ca | ||
|
|
e88a74362b | ||
|
|
cc62f212ab | ||
|
|
62b5a4a6ae | ||
|
|
1da478fa60 | ||
|
|
bc78ebb72e | ||
|
|
16060ee0ae | ||
|
|
191d4fb0f0 | ||
|
|
cabfa28401 | ||
|
|
9f7e4abd42 | ||
|
|
f5bdca7216 | ||
|
|
8ed8a47c55 | ||
|
|
88e2aaeec0 | ||
|
|
a21b96396e | ||
|
|
e4117e9eb4 | ||
|
|
c80939759c | ||
|
|
df6d3b8f02 | ||
|
|
5177f69994 | ||
|
|
7a2c918b1e | ||
|
|
294720937f | ||
|
|
9028cf09b3 | ||
|
|
f9cf20d79a | ||
|
|
18caa159ac | ||
|
|
c2e7e8aca9 | ||
|
|
54ba9a8aea | ||
|
|
5c91f8b573 | ||
|
|
9a9a96f5c5 | ||
|
|
fd7edc937d | ||
|
|
4165448282 | ||
|
|
95ff22821c | ||
|
|
5dfdea7115 | ||
|
|
59ec7855c1 | ||
|
|
bc027139e2 | ||
|
|
042a62154e | ||
|
|
b5e065e1c8 | ||
|
|
193b6ba3e8 | ||
|
|
ea91dabee5 | ||
|
|
df30de2877 | ||
|
|
91aa52988b | ||
|
|
14c9e9d48e | ||
|
|
5f70befa4a | ||
|
|
73cf38cc57 | ||
|
|
96201f7919 | ||
|
|
96f494aeae | ||
|
|
603c977733 | ||
|
|
db57df1e41 | ||
|
|
476c965a1f | ||
|
|
999c210d28 | ||
|
|
5add8a94a7 | ||
|
|
02853e5bb6 | ||
|
|
d6d78eb8bd | ||
|
|
75606fc079 | ||
|
|
73243883ce | ||
|
|
ac7b268c32 | ||
|
|
7301617708 | ||
|
|
0d0e290474 | ||
|
|
2fa82d579e | ||
|
|
d27adeb510 | ||
|
|
ea61ff7770 | ||
|
|
0326edef42 | ||
|
|
363d2e8ab5 | ||
|
|
97cd7e90dc | ||
|
|
1b65c4ec91 | ||
|
|
92f07a66fc | ||
|
|
0536abe826 | ||
|
|
228d789a6c | ||
|
|
ce1c0e504b | ||
|
|
b85b071a3e | ||
|
|
8c29238116 | ||
|
|
4bdb55cfe6 | ||
|
|
8dc10b7a37 | ||
|
|
c2143f5d6c | ||
|
|
99432a8e71 | ||
|
|
1216ab2247 | ||
|
|
dffb611036 | ||
|
|
57e52ba217 | ||
|
|
90f933ff69 | ||
|
|
475e6dd878 | ||
|
|
eea7fe227d | ||
|
|
f835daec50 | ||
|
|
ebd2edde8f | ||
|
|
0676f8345f | ||
|
|
9db992256f | ||
|
|
ece4b711f5 | ||
|
|
33302790ba | ||
|
|
aea6e7da8b | ||
|
|
dffbd1e1ef | ||
|
|
c52b6d0673 | ||
|
|
e2a07c98bf | ||
|
|
e760e62dcd | ||
|
|
515dcf4bf6 | ||
|
|
efdfee8333 | ||
|
|
bb628aa25d | ||
|
|
b5ea03133d | ||
|
|
73ae8f4d85 | ||
|
|
2d1af2dfb6 | ||
|
|
0deb855676 | ||
|
|
958c331d49 | ||
|
|
76d0a78463 | ||
|
|
51675a6ce7 | ||
|
|
119d381570 | ||
|
|
d92eb4d3ff | ||
|
|
3837e36d71 | ||
|
|
c93440dadb | ||
|
|
18f50d01c4 | ||
|
|
89c479ef15 | ||
|
|
18a7e79c56 | ||
|
|
7c2804c1a9 | ||
|
|
bfe4f62574 | ||
|
|
0081cfa794 | ||
|
|
0ca68938ff | ||
|
|
5f8b7f7120 | ||
|
|
f801b9a093 | ||
|
|
e3dac1e33e | ||
|
|
cde5bcff69 | ||
|
|
2a970134da | ||
|
|
6b7bfb8633 | ||
|
|
4d5cb98d29 | ||
|
|
fb6c42ec78 | ||
|
|
5f37af3f83 | ||
|
|
44ec1e4f25 | ||
|
|
ac1d2c82d1 | ||
|
|
0a5fcef331 | ||
|
|
3a25d5934a | ||
|
|
3bc87f1045 | ||
|
|
2d22dfe236 | ||
|
|
877ef005ea | ||
|
|
28d90aa80c | ||
|
|
f6fd44a096 | ||
|
|
63d7470685 | ||
|
|
450948933f | ||
|
|
037029ea84 | ||
|
|
ae8aff5ed8 | ||
|
|
2edde546c4 | ||
|
|
1963593159 | ||
|
|
94f7d9956d | ||
|
|
d7585508da | ||
|
|
109ba9350d | ||
|
|
08ed69bac7 | ||
|
|
20f5c0402e | ||
|
|
9c046b710c | ||
|
|
f67ae46be6 | ||
|
|
efae99252b | ||
|
|
5312f5eddd | ||
|
|
2a32826b86 | ||
|
|
3553f5db22 | ||
|
|
8c49e67702 | ||
|
|
2d470d20f5 | ||
|
|
1af74206d2 | ||
|
|
534fcc6ebe | ||
|
|
e449a09b3e | ||
|
|
ca5f5394f7 | ||
|
|
87f121222f | ||
|
|
f973d31ad1 | ||
|
|
85b15552ba | ||
|
|
b734df629b | ||
|
|
4beadd18f4 | ||
|
|
8f94ef619a | ||
|
|
5c24ae2f0d | ||
|
|
3e95e772c3 | ||
|
|
310cc6e501 | ||
|
|
86f76933c1 | ||
|
|
ddfd3fa443 | ||
|
|
5c52fd19cc | ||
|
|
ff1e4296bc | ||
|
|
2de4057021 | ||
|
|
2ae0a422cd | ||
|
|
0fc2cfeff3 | ||
|
|
5d694e7aa8 | ||
|
|
1d4dbc8976 | ||
|
|
7504646301 | ||
|
|
51a4d0e8da | ||
|
|
e67066b788 | ||
|
|
2cd28ce7c5 | ||
|
|
5a2aeb683e | ||
|
|
fa25b8cd5e | ||
|
|
5fc7e33228 | ||
|
|
43385fea63 | ||
|
|
e60f68bad8 | ||
|
|
c26e2de7ec | ||
|
|
833e352dcb | ||
|
|
b7de57fbf1 | ||
|
|
05e45117ea | ||
|
|
b77698810f | ||
|
|
5df08645da | ||
|
|
7858d66884 | ||
|
|
5d7573e513 | ||
|
|
42677dd9ee | ||
|
|
5c5e5df788 | ||
|
|
f07b7e75fc | ||
|
|
2c904baf80 | ||
|
|
0e6e961039 | ||
|
|
7f53572b53 | ||
|
|
8de211acd9 | ||
|
|
13fa2801a3 | ||
|
|
d7875adf9e | ||
|
|
481e29896a | ||
|
|
4979c8a20b | ||
|
|
be5a6e2951 | ||
|
|
73e354c3be | ||
|
|
8e02bb3059 | ||
|
|
dffd86544c | ||
|
|
400f438958 | ||
|
|
69f34515e0 | ||
|
|
e4620be180 | ||
|
|
fa77f58247 | ||
|
|
1a430f4029 | ||
|
|
7f7127a6ab | ||
|
|
ea09c5ee8d | ||
|
|
3da8b20dfe | ||
|
|
94e18bee81 | ||
|
|
3dce945223 | ||
|
|
3888b623e7 | ||
|
|
dc6f028b99 | ||
|
|
7535d9b63a | ||
|
|
99e3ebd3d5 | ||
|
|
bb496e6262 | ||
|
|
9b3d8dc96e | ||
|
|
67dfd5c0dd | ||
|
|
89647c14f2 | ||
|
|
9026ef8933 | ||
|
|
28da1fa3ef | ||
|
|
72e71a8cb6 | ||
|
|
f2d9ec18a4 | ||
|
|
2c3eee4c58 | ||
|
|
cb6b384f88 | ||
|
|
5807337721 | ||
|
|
feeb0d480a | ||
|
|
3c783e2de7 | ||
|
|
3784991dd2 | ||
|
|
5f73295392 | ||
|
|
79f93b797b | ||
|
|
39469d29dc | ||
|
|
f6b969eeba | ||
|
|
3db20a4e91 | ||
|
|
a94d0ce986 | ||
|
|
52cd92d31a | ||
|
|
3ec2db51c8 | ||
|
|
8591569eb5 | ||
|
|
de13fb8afe | ||
|
|
4808919caf | ||
|
|
6530c9625f | ||
|
|
4d10d47f5e | ||
|
|
697cd0a5aa | ||
|
|
4dee5e81cd | ||
|
|
ae43011468 | ||
|
|
799280f615 | ||
|
|
9fdc1e1326 | ||
|
|
51040d1a28 | ||
|
|
0f408a43ba | ||
|
|
64eb9742f0 | ||
|
|
e84be139c5 | ||
|
|
d458811c26 | ||
|
|
185557db59 | ||
|
|
62ffe81c1f | ||
|
|
bcf00d008e | ||
|
|
eb6df0ec82 | ||
|
|
609dc3dc2d | ||
|
|
a2efcd2fe7 | ||
|
|
16a61050ca | ||
|
|
9832157fc4 | ||
|
|
ad9a17b6db | ||
|
|
293c7dfcfc | ||
|
|
a037af120b | ||
|
|
964e53974a | ||
|
|
8441069b71 | ||
|
|
8659091ff3 | ||
|
|
130859c3b7 | ||
|
|
400d6d7da0 | ||
|
|
e4977a8218 | ||
|
|
be5537ec0a | ||
|
|
7889d44db6 | ||
|
|
a85e517196 | ||
|
|
933da4dcb4 | ||
|
|
59eab34162 | ||
|
|
2ff1ed1a12 | ||
|
|
3e9f4a99ed | ||
|
|
2085295358 | ||
|
|
896a2e43b7 | ||
|
|
b56394a84f | ||
|
|
1433fb8f25 | ||
|
|
78d3c45cfd | ||
|
|
ccb37a12a3 | ||
|
|
e2f2a39a97 | ||
|
|
ea89cf79bc | ||
|
|
a1367fc05f | ||
|
|
cd273e777d | ||
|
|
fe6fd35174 | ||
|
|
6a1211c854 | ||
|
|
bf8e924308 | ||
|
|
0f9a845050 | ||
|
|
acad52a9a4 | ||
|
|
276415dc19 | ||
|
|
c5b63faca3 | ||
|
|
aa085ca65b | ||
|
|
228de00dc7 | ||
|
|
f39922dddc | ||
|
|
155050b816 | ||
|
|
f178cde02d | ||
|
|
31caeec248 | ||
|
|
8fb4090e75 | ||
|
|
0428118553 | ||
|
|
896baaa076 | ||
|
|
f21b54ff3e | ||
|
|
a5b15136d7 | ||
|
|
690ad2f082 | ||
|
|
f653279948 | ||
|
|
1cb75ff072 | ||
|
|
ddcc975cec | ||
|
|
e87e24557f | ||
|
|
15ba2b71cb | ||
|
|
9c91688a5f | ||
|
|
045535caff | ||
|
|
d913bda0ea | ||
|
|
ffc4666fe9 | ||
|
|
083439f60b | ||
|
|
cb6d924dad | ||
|
|
e8a5673f7a | ||
|
|
09acfca5a6 | ||
|
|
f2ec53a344 | ||
|
|
eed23ffedf | ||
|
|
4cd2a6ed6e | ||
|
|
ffc17160da | ||
|
|
2d3a80e2b7 | ||
|
|
0abd618271 | ||
|
|
e0ef2da603 | ||
|
|
65bae7e264 | ||
|
|
7f86d07628 |
215
.clang-format
215
.clang-format
@ -1,51 +1,184 @@
|
||||
---
|
||||
#------------------------------------
|
||||
# Configuration for clang-format v12
|
||||
#------------------------------------
|
||||
BasedOnStyle: LLVM
|
||||
Standard: Auto # let the formatter accept any C++ standard
|
||||
|
||||
Language: Cpp
|
||||
# =============================================================================
|
||||
# Indentation
|
||||
# =============================================================================
|
||||
TabWidth: 2
|
||||
ContinuationIndentWidth: 2
|
||||
ConstructorInitializerIndentWidth: 2
|
||||
NamespaceIndentation: All # everything inside namespace is indented
|
||||
IndentCaseLabels: true # case labels at switch-body indent level
|
||||
IndentCaseBlocks: true # indent block inside case label
|
||||
IndentExternBlock: Indent
|
||||
IndentWrappedFunctionNames: true # keep function name at same indent as return type
|
||||
IndentPPDirectives: BeforeHash # nested #if / #include get indented before the #
|
||||
PPIndentWidth: 2
|
||||
|
||||
SortIncludes: true
|
||||
# =============================================================================
|
||||
# Braces & line-break style
|
||||
# =============================================================================
|
||||
BreakBeforeBraces: Allman
|
||||
BreakConstructorInitializers: BeforeComma # colon on new line, commas lead
|
||||
BreakInheritanceList: BeforeComma
|
||||
BreakBeforeBinaryOperators: NonAssignment
|
||||
BreakStringLiterals: false
|
||||
AlwaysBreakTemplateDeclarations: Yes # template <…> always on its own line
|
||||
BreakAfterAttributes: Always
|
||||
|
||||
BasedOnStyle: Chromium
|
||||
# =============================================================================
|
||||
# Short statements
|
||||
# =============================================================================
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortFunctionsOnASingleLine: Empty # only empty bodies: void f() {}
|
||||
AllowShortCaseLabelsOnASingleLine: true # case X: stmt; break; on one line
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
AllowShortLambdasOnASingleLine: Inline
|
||||
|
||||
BinPackParameters: false
|
||||
BitFieldColonSpacing: Both
|
||||
# =============================================================================
|
||||
# Empty lines
|
||||
# =============================================================================
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
EmptyLineBeforeAccessModifier: Always # blank line before public:/private:/protected:
|
||||
EmptyLineAfterAccessModifier: Always # blank line after public:/private:/protected:
|
||||
InsertNewlineAtEOF: true
|
||||
|
||||
BreakBeforeBraces: Allman
|
||||
BreakConstructorInitializers: BeforeComma
|
||||
# =============================================================================
|
||||
# Spacing
|
||||
# =============================================================================
|
||||
SpacesInAngles: Leave # preserve C++03 "> >" vs C++11 ">>"
|
||||
SpacesInContainerLiterals: false
|
||||
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
|
||||
ConstructorInitializerIndentWidth: '2'
|
||||
|
||||
NamespaceIndentation: All
|
||||
IndentPPDirectives: BeforeHash
|
||||
PointerAlignment: Left
|
||||
ColumnLimit: '0'
|
||||
ContinuationIndentWidth: '2'
|
||||
UseTab: Never
|
||||
TabWidth: '2'
|
||||
IndentWidth: '2'
|
||||
AccessModifierOffset : '-2'
|
||||
IndentCaseLabels: false
|
||||
Cpp11BracedListStyle: 'true'
|
||||
AlignAfterOpenBracket: Align
|
||||
# =============================================================================
|
||||
# Alignment
|
||||
# =============================================================================
|
||||
PointerAlignment: Left # T* ptr, const T& ref
|
||||
ReferenceAlignment: Left
|
||||
AlignConsecutiveAssignments: true
|
||||
AlignConsecutiveDeclarations: true
|
||||
AlignConsecutiveBitFields: true
|
||||
AlignConsecutiveMacros: true # align macro bodies
|
||||
|
||||
#------------------------------------
|
||||
# Configurations not supported by clang-format v12
|
||||
#------------------------------------
|
||||
# BreakInheritanceList: AfterComma
|
||||
# EmptyLineBeforeAccessModifier: Always
|
||||
# EmptyLineAfterAccessModifier: Always
|
||||
# ReferenceAlignment: Left
|
||||
# =============================================================================
|
||||
# Line length and wrapping
|
||||
# =============================================================================
|
||||
ColumnLimit: 150
|
||||
ReflowComments: true # preserve hand-formatted comment rulers
|
||||
AlignEscapedNewlines: Left
|
||||
|
||||
...
|
||||
# =============================================================================
|
||||
# Includes
|
||||
# =============================================================================
|
||||
IncludeCategories:
|
||||
- Regex: '^(<|")(.*/)?platform\.h(>|")$'
|
||||
Priority: -1
|
||||
- Regex: 'private'
|
||||
Priority: 1
|
||||
- Regex: '.*'
|
||||
Priority: 0
|
||||
|
||||
# =============================================================================
|
||||
# Arguments, parameters and constructor initialisers
|
||||
# =============================================================================
|
||||
PackConstructorInitializers: Never # each initialiser on its own line
|
||||
|
||||
# =============================================================================
|
||||
# Namespaces and using declarations
|
||||
# =============================================================================
|
||||
SortUsingDeclarations: Lexicographic
|
||||
|
||||
# =============================================================================
|
||||
# Macro-aware formatting
|
||||
# =============================================================================
|
||||
# ETL-specific macros that should be treated as statement-level constructs
|
||||
StatementMacros:
|
||||
- ETL_DECLARE_DEBUG_COUNT
|
||||
- ETL_INCREMENT_DEBUG_COUNT
|
||||
- ETL_DECREMENT_DEBUG_COUNT
|
||||
- ETL_ADD_DEBUG_COUNT
|
||||
- ETL_STATIC_ASSERT
|
||||
- ETL_ASSERT
|
||||
- ETL_ASSERT_OR_RETURN
|
||||
- ETL_ASSERT_OR_RETURN_VALUE
|
||||
- ETL_ASSERT_FAIL
|
||||
- ETL_ASSERT_FAIL_AND_RETURN
|
||||
- ETL_ASSERT_FAIL_AND_RETURN_VALUE
|
||||
- ETL_MOVE
|
||||
- ETL_ENUM_CLASS
|
||||
- ETL_ENUM_CLASS_TYPE
|
||||
- ETL_IF_CONSTEXPR
|
||||
|
||||
# Macros that behave like attributes or specifiers.
|
||||
AttributeMacros:
|
||||
- ETL_NORETURN
|
||||
- ETL_FINAL
|
||||
- ETL_OVERRIDE
|
||||
- ETL_EXPLICIT
|
||||
- ETL_DELETE
|
||||
- ETL_CONSTANT
|
||||
- ETL_CONSTEXPR
|
||||
- ETL_CONSTEXPR11
|
||||
- ETL_CONSTEXPR14
|
||||
- ETL_CONSTEXPR17
|
||||
- ETL_CONSTEXPR20
|
||||
- ETL_CONSTEXPR23
|
||||
- ETL_CONSTEVAL
|
||||
- ETL_NODISCARD
|
||||
- ETL_NORETURN
|
||||
- ETL_DEPRECATED
|
||||
- ETL_DEPRECATED_REASON
|
||||
- ETL_LIKELY
|
||||
- ETL_UNLIKELY
|
||||
- ETL_FALLTHROUGH
|
||||
- ETL_MAYBE_UNUSED
|
||||
- ETL_INLINE_VAR
|
||||
- ETL_ASSUME
|
||||
- ETL_LVALUE_REF_QUALIFIER
|
||||
- ETL_RVALUE_REF_QUALIFIER
|
||||
- ETL_NOEXCEPT
|
||||
- ETL_NOEXCEPT_EXPR
|
||||
- ETL_NOEXCEPT_IF
|
||||
- ETL_NOEXCEPT_FROM
|
||||
|
||||
Macros:
|
||||
- ETL_NORETURN=[[noreturn]]
|
||||
- ETL_FINAL=final
|
||||
- ETL_OVERRIDE=override
|
||||
- ETL_EXPLICIT=explicit
|
||||
- ETL_DELETE=delete
|
||||
- ETL_CONSTANT=const
|
||||
- ETL_CONSTEXPR=constexpr
|
||||
- ETL_CONSTEXPR11=constexpr
|
||||
- ETL_CONSTEXPR14=constexpr
|
||||
- ETL_CONSTEXPR17=constexpr
|
||||
- ETL_CONSTEXPR20=constexpr
|
||||
- ETL_CONSTEXPR23=constexpr
|
||||
- ETL_CONSTEVAL=consteval
|
||||
- ETL_NODISCARD=[[nodiscard]]
|
||||
- ETL_NORETURN=[[noreturn]]
|
||||
- ETL_DEPRECATED=[[deprecated]]
|
||||
# - ETL_DEPRECATED_REASON=[[deprecated(%0)]] # Hangs with clang-format 18
|
||||
- ETL_LIKELY=[[likely]]
|
||||
- ETL_UNLIKELY=[[unlikely]]
|
||||
- ETL_FALLTHROUGH=[[fallthrough]]
|
||||
- ETL_MAYBE_UNUSED=[[maybe_unused]]
|
||||
- ETL_INLINE_VAR=inline
|
||||
- ETL_ASSUME=[[assume(&0)]]
|
||||
- ETL_LVALUE_REF_QUALIFIER=&
|
||||
- ETL_RVALUE_REF_QUALIFIER=&&
|
||||
- ETL_NOEXCEPT=noexcept
|
||||
# - ETL_NOEXCEPT_EXPR=noexcept(&0)) # Hangs with clang-format 18
|
||||
# - ETL_NOEXCEPT_IF=noexcept(&0) # Hangs with clang-format 18
|
||||
# - ETL_NOEXCEPT_FROM=noexcept(&0) # Hangs with clang-format 18
|
||||
|
||||
# Macros that behave like type names
|
||||
TypenameMacros:
|
||||
- ETL_OR_STD
|
||||
|
||||
# Do not reformat these macros — they contain DSL-like content
|
||||
WhitespaceSensitiveMacros:
|
||||
- ETL_ERROR_TEXT
|
||||
- ETL_DECLARE_ENUM_TYPE
|
||||
- ETL_ENUM_TYPE
|
||||
- ETL_END_ENUM_TYPE
|
||||
|
||||
200
.coderabbit.yaml
Normal file
200
.coderabbit.yaml
Normal file
@ -0,0 +1,200 @@
|
||||
language: "en-GB"
|
||||
early_access: false
|
||||
|
||||
reviews:
|
||||
profile: "chill"
|
||||
request_changes_workflow: false
|
||||
high_level_summary: false
|
||||
high_level_summary_in_walkthrough: false
|
||||
poem: false
|
||||
review_status: false
|
||||
collapse_walkthrough: false
|
||||
changed_files_summary: false
|
||||
sequence_diagrams: false
|
||||
estimate_code_review_effort: false
|
||||
assess_linked_issues: false
|
||||
related_issues: false
|
||||
related_prs: false
|
||||
suggested_labels: false
|
||||
suggested_reviewers: false
|
||||
auto_review:
|
||||
enabled: true
|
||||
drafts: false
|
||||
path_instructions:
|
||||
- path: "include/etl/*.h"
|
||||
instructions: |
|
||||
Review the C++ code in these directories. The code must not use
|
||||
STL containers but must instead rely on Embedded Template Library
|
||||
(ETL) for data structures and algorithms.
|
||||
|
||||
When answering questions, provide accurate and concise information based on the ETL documentation and codebase. If you don't know the answer, just say "I don't know". Do not make up answers.
|
||||
When providing code examples, ensure they are relevant to the ETL and follow its conventions.
|
||||
Always be polite and professional in your responses.
|
||||
|
||||
Header files should start with the ETL's standard MIT comment block.
|
||||
|
||||
Header files should have include guards in the format '#ifndef ETL_<FILENAME>>_INCLUDED #define ETL_<FILENAME>_INCLUDED #endif'
|
||||
|
||||
Headers should be organized in the following order
|
||||
- The first header include should be '#include "platform.h"'
|
||||
- Headers from the ETL
|
||||
- Headers from the path 'private/**'
|
||||
- C++ standard library headers
|
||||
- C standard library headers
|
||||
|
||||
Pay extra attention to the following
|
||||
- Buffer overflows
|
||||
- Memory leaks
|
||||
- Undefined behavior
|
||||
|
||||
Check that the following conventions are used
|
||||
- Variable names should be in `snake_case`
|
||||
- Macro constants should be `ALL_CAPS_WITH_UNDERSCORES`
|
||||
- Macro constants should be prefixed with 'ETL_'
|
||||
- Function, class, and type names should be `snake_case`
|
||||
- enum members should be `Caps_Snake_Case`
|
||||
|
||||
Please keep your outputs short and to the point, unless otherwise asked
|
||||
- Keep your responses short, describe small issues in a few sentences
|
||||
- Don't output tips, analysis chains or anything else with a collapsible view
|
||||
- Don't output `comment summaries` or `fix prompts for AIs`
|
||||
- If the highlighted issue is complex, don't suggest a solution
|
||||
- Don't use emojis
|
||||
|
||||
- path: "include/etl/atomic/*.h"
|
||||
instructions: |
|
||||
Review the C++ code in these directories. The code must not use
|
||||
STL containers but must instead rely on Embedded Template Library
|
||||
(ETL) for data structures and algorithms.
|
||||
|
||||
When answering questions, provide accurate and concise information based on the ETL documentation and codebase. If you don't know the answer, just say "I don't know". Do not make up answers.
|
||||
When providing code examples, ensure they are relevant to the ETL and follow its conventions.
|
||||
Always be polite and professional in your responses.
|
||||
|
||||
Header files should start with the ETL's standard MIT comment block.
|
||||
|
||||
Header files are allowed to not have include guards
|
||||
|
||||
Headers should be organized in the following order
|
||||
- Headers from the ETL
|
||||
- Headers from the path 'private/**'
|
||||
- C++ standard library headers
|
||||
- C standard library headers
|
||||
|
||||
Pay extra attention to the following
|
||||
- Buffer overflows
|
||||
- Memory leaks
|
||||
- Undefined behavior
|
||||
|
||||
Check that the following conventions are used
|
||||
- Variable names should be in `snake_case`
|
||||
- Macro constants should be `ALL_CAPS_WITH_UNDERSCORES`
|
||||
- Macro constants should be prefixed with 'ETL_'
|
||||
- Function, class, and type names should be `snake_case`
|
||||
- enum members should be `Caps_Snake_Case`
|
||||
|
||||
Please keep your outputs short and to the point, unless otherwise asked
|
||||
- Keep your responses short, describe small issues in a few sentences
|
||||
- Don't output tips, analysis chains or anything else with a collapsible view
|
||||
- Don't output `comment summaries` or `fix prompts for AIs`
|
||||
- If the highlighted issue is complex, don't suggest a solution
|
||||
- Don't use emojis
|
||||
|
||||
- path: "include/etl/atomic/*.h"
|
||||
instructions: |
|
||||
Review the C++ code in these directories. The code must not use
|
||||
STL containers but must instead rely on Embedded Template Library
|
||||
(ETL) for data structures and algorithms.
|
||||
|
||||
When answering questions, provide accurate and concise information based on the ETL documentation and codebase. If you don't know the answer, just say "I don't know". Do not make up answers.
|
||||
When providing code examples, ensure they are relevant to the ETL and follow its conventions.
|
||||
Always be polite and professional in your responses.
|
||||
|
||||
Header files should start with the ETL's standard MIT comment block.
|
||||
|
||||
Header files are allowed to not have include guards
|
||||
|
||||
Headers should be organized in the following order
|
||||
- Headers from the ETL
|
||||
- Headers from the path 'private/**'
|
||||
- C++ standard library headers
|
||||
- C standard library headers
|
||||
|
||||
Pay extra attention to the following
|
||||
- Buffer overflows
|
||||
- Memory leaks
|
||||
- Undefined behavior
|
||||
|
||||
Check that the following conventions are used
|
||||
- Variable names should be in `snake_case`
|
||||
- Macro constants should be `ALL_CAPS_WITH_UNDERSCORES`
|
||||
- Macro constants should be prefixed with 'ETL_'
|
||||
- Function, class, and type names should be `snake_case`
|
||||
- enum members should be `Caps_Snake_Case`
|
||||
|
||||
Please keep your outputs short and to the point, unless otherwise asked
|
||||
- Keep your responses short, describe small issues in a few sentences
|
||||
- Don't output tips, analysis chains or anything else with a collapsible view
|
||||
- Don't output `comment summaries` or `fix prompts for AIs`
|
||||
- If the highlighted issue is complex, don't suggest a solution
|
||||
- Don't use emojis
|
||||
|
||||
- path: "include/etl/mutex/*.h"
|
||||
instructions: |
|
||||
Review the C++ code in these directories. The code must not use
|
||||
STL containers but must instead rely on Embedded Template Library
|
||||
(ETL) for data structures and algorithms.
|
||||
|
||||
When answering questions, provide accurate and concise information based on the ETL documentation and codebase. If you don't know the answer, just say "I don't know". Do not make up answers.
|
||||
When providing code examples, ensure they are relevant to the ETL and follow its conventions.
|
||||
Always be polite and professional in your responses.
|
||||
|
||||
Header files should start with the ETL's standard MIT comment block.
|
||||
|
||||
Header files are allowed to not have include guards
|
||||
|
||||
Headers should be organized in the following order
|
||||
- Headers from the ETL
|
||||
- Headers from the path 'private/**'
|
||||
- C++ standard library headers
|
||||
- C standard library headers
|
||||
|
||||
Pay extra attention to the following
|
||||
- Buffer overflows
|
||||
- Memory leaks
|
||||
- Undefined behavior
|
||||
|
||||
Check that the following conventions are used
|
||||
- Variable names should be in `snake_case`
|
||||
- Macro constants should be `ALL_CAPS_WITH_UNDERSCORES`
|
||||
- Macro constants should be prefixed with 'ETL_'
|
||||
- Function, class, and type names should be `snake_case`
|
||||
- enum members should be `Caps_Snake_Case`
|
||||
|
||||
Please keep your outputs short and to the point, unless otherwise asked
|
||||
- Keep your responses short, describe small issues in a few sentences
|
||||
- Don't output tips, analysis chains or anything else with a collapsible view
|
||||
- Don't output `comment summaries` or `fix prompts for AIs`
|
||||
- If the highlighted issue is complex, don't suggest a solution
|
||||
- Don't use emojis
|
||||
|
||||
- path: "include/etl/deprecated/*.h"
|
||||
instructions: |
|
||||
Ingnore files in this directory
|
||||
|
||||
- path: "include/etl/experimental/*.h"
|
||||
instructions: |
|
||||
Ingnore files in this directory
|
||||
|
||||
- path: "include/etl/generators/*.h"
|
||||
instructions: |
|
||||
Ingnore files in this directory
|
||||
|
||||
- path: "include/etl/profiles/*.h"
|
||||
instructions: |
|
||||
Ingnore files in this directory
|
||||
|
||||
chat:
|
||||
art: false
|
||||
auto_reply: true
|
||||
|
||||
@ -1,18 +1,61 @@
|
||||
ARG BASE_IMAGE_NAME="clang:latest"
|
||||
ARG BASE_IMAGE_NAME="mcr.microsoft.com/devcontainers/cpp:2@sha256:a5eb5a1e9109af88bf82ebb0f71903608a68144851ed1e4b852e31b251ac59c6"
|
||||
|
||||
FROM ${BASE_IMAGE_NAME}
|
||||
|
||||
ARG REINSTALL_CMAKE_VERSION_FROM_SOURCE="3.31.7"
|
||||
ARG DEBIAN_SNAPSHOT="20260223T000000Z"
|
||||
|
||||
# Optionally install the cmake for vcpkg
|
||||
COPY ./reinstall-cmake.sh /tmp/
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
&& apt-get -y install --no-install-recommends \
|
||||
git \
|
||||
wget
|
||||
ENV LANG=C.UTF-8 \
|
||||
LC_ALL=C.UTF-8 \
|
||||
TZ=UTC
|
||||
|
||||
RUN if [ "${REINSTALL_CMAKE_VERSION_FROM_SOURCE}" != "none" ]; then \
|
||||
chmod +x /tmp/reinstall-cmake.sh && /tmp/reinstall-cmake.sh ${REINSTALL_CMAKE_VERSION_FROM_SOURCE}; \
|
||||
RUN set -eux \
|
||||
&& export DEBIAN_FRONTEND=noninteractive \
|
||||
&& if [[ "${DEBIAN_SNAPSHOT}" != "none" ]]; then \
|
||||
snapshot_main="http://snapshot.debian.org/archive/debian/${DEBIAN_SNAPSHOT}"; \
|
||||
snapshot_security="http://snapshot.debian.org/archive/debian-security/${DEBIAN_SNAPSHOT}"; \
|
||||
if [[ -f /etc/apt/sources.list.d/debian.sources ]]; then \
|
||||
sed -ri "s|^URIs: https?://deb.debian.org/debian$|URIs: ${snapshot_main}|g" /etc/apt/sources.list.d/debian.sources; \
|
||||
sed -ri "s|^URIs: https?://deb.debian.org/debian-security$|URIs: ${snapshot_security}|g" /etc/apt/sources.list.d/debian.sources; \
|
||||
elif [[ -f /etc/apt/sources.list ]] || compgen -G "/etc/apt/sources.list.d/*.list" > /dev/null; then \
|
||||
for list_file in /etc/apt/sources.list /etc/apt/sources.list.d/*.list; do \
|
||||
[[ -f "${list_file}" ]] || continue; \
|
||||
sed -ri "s|https?://deb.debian.org/debian|${snapshot_main}|g" "${list_file}"; \
|
||||
sed -ri "s|https?://security.debian.org/debian-security|${snapshot_security}|g" "${list_file}"; \
|
||||
sed -ri "s|https?://deb.debian.org/debian-security|${snapshot_security}|g" "${list_file}"; \
|
||||
done; \
|
||||
else \
|
||||
echo "ERROR: DEBIAN_SNAPSHOT='${DEBIAN_SNAPSHOT}' is set, but no supported apt source files were found."; \
|
||||
echo "Expected /etc/apt/sources.list.d/debian.sources or one or more .list files under /etc/apt/."; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
printf 'Acquire::Check-Valid-Until "false";\n' > /etc/apt/apt.conf.d/99snapshot; \
|
||||
fi \
|
||||
&& rm -f /tmp/reinstall-cmake.sh
|
||||
&& apt-get update \
|
||||
&& apt-get -y install --no-install-recommends \
|
||||
python3-full \
|
||||
python3-pip \
|
||||
git \
|
||||
wget \
|
||||
cmake \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& if pip help install | grep -q '\-\-break-system-packages'; then \
|
||||
pip install --no-cache-dir --break-system-packages cogapp; \
|
||||
else \
|
||||
pip install --no-cache-dir cogapp; \
|
||||
fi
|
||||
|
||||
RUN set -eux \
|
||||
&& echo "Pip version: " \
|
||||
&& pip --version \
|
||||
&& echo "Cogapp version: " \
|
||||
&& pip show cogapp \
|
||||
&& echo "Git version: " \
|
||||
&& git --version \
|
||||
&& echo "Wget version: " \
|
||||
&& wget --version \
|
||||
&& echo "Cmake version: " \
|
||||
&& cmake --version \
|
||||
&& echo "Make version: " \
|
||||
&& make --version
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:10"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:10",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:11"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:11",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:12"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:12",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:13"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:13",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:14"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:14",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:15"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:15",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:16"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:16",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:17"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:17",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:18-bullseye"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:18-bullseye",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:19-bullseye"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:19-bullseye",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:20-bullseye"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:20-bullseye",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
13
.devcontainer/clang21/devcontainer.json
Normal file
13
.devcontainer/clang21/devcontainer.json
Normal file
@ -0,0 +1,13 @@
|
||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
|
||||
{
|
||||
"name": "Clang 21",
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:21-bullseye",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:7"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:7",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:8"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:8",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:9"
|
||||
"BASE_IMAGE_NAME": "silkeh/clang:9",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "./Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "mcr.microsoft.com/devcontainers/cpp:debian-12"
|
||||
"BASE_IMAGE_NAME": "mcr.microsoft.com/devcontainers/cpp:2@sha256:a5eb5a1e9109af88bf82ebb0f71903608a68144851ed1e4b852e31b251ac59c6",
|
||||
"DEBIAN_SNAPSHOT": "20260223T000000Z"
|
||||
},
|
||||
"context": "./context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "gcc:9"
|
||||
"BASE_IMAGE_NAME": "gcc:9",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "gcc:10"
|
||||
"BASE_IMAGE_NAME": "gcc:10",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "gcc:11"
|
||||
"BASE_IMAGE_NAME": "gcc:11",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "gcc:12"
|
||||
"BASE_IMAGE_NAME": "gcc:12",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "gcc:13"
|
||||
"BASE_IMAGE_NAME": "gcc:13",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "gcc:14"
|
||||
"BASE_IMAGE_NAME": "gcc:14",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
@ -5,7 +5,8 @@
|
||||
"build": {
|
||||
"dockerfile": "../Dockerfile",
|
||||
"args": {
|
||||
"BASE_IMAGE_NAME": "gcc:15"
|
||||
"BASE_IMAGE_NAME": "gcc:15",
|
||||
"DEBIAN_SNAPSHOT": "none"
|
||||
},
|
||||
"context": "../context"
|
||||
}
|
||||
|
||||
40
.devcontainer/s390x/Dockerfile
Normal file
40
.devcontainer/s390x/Dockerfile
Normal file
@ -0,0 +1,40 @@
|
||||
# s390x Big-Endian Test Environment for ETL
|
||||
# Uses QEMU user-mode emulation to run s390x binaries on x64 host
|
||||
FROM debian:trixie
|
||||
|
||||
# Avoid prompts from apt
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# Install QEMU user-mode emulation and s390x cross-compilation tools
|
||||
RUN dpkg --add-architecture s390x && \
|
||||
apt-get update && apt-get install -y --no-install-recommends\
|
||||
qemu-user-static \
|
||||
qemu-user \
|
||||
binfmt-support \
|
||||
gcc-s390x-linux-gnu \
|
||||
g++-s390x-linux-gnu \
|
||||
cmake \
|
||||
make \
|
||||
ninja-build \
|
||||
git \
|
||||
wget \
|
||||
file \
|
||||
libc6:s390x \
|
||||
libstdc++6:s390x \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /workspaces/etl
|
||||
|
||||
# Verify QEMU and cross-compilation setup
|
||||
RUN echo "=== Host Architecture ===" && \
|
||||
uname -m && \
|
||||
echo "" && \
|
||||
echo "=== s390x Cross Compiler ===" && \
|
||||
s390x-linux-gnu-gcc --version && \
|
||||
echo "" && \
|
||||
echo "=== QEMU s390x ===" && \
|
||||
qemu-s390x-static --version | head -n1
|
||||
|
||||
# Default command
|
||||
CMD ["/bin/bash"]
|
||||
29
.devcontainer/s390x/devcontainer.json
Normal file
29
.devcontainer/s390x/devcontainer.json
Normal file
@ -0,0 +1,29 @@
|
||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
|
||||
{
|
||||
"name": "s390x Big Endian (Debian)",
|
||||
"build": {
|
||||
"dockerfile": "./Dockerfile",
|
||||
"context": "."
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"ms-vscode.cpptools",
|
||||
"ms-vscode.cmake-tools"
|
||||
],
|
||||
"settings": {
|
||||
"cmake.sourceDirectory": "${workspaceFolder}/test",
|
||||
"cmake.configureArgs": [
|
||||
"-DCMAKE_TOOLCHAIN_FILE=${workspaceFolder}/.devcontainer/s390x/toolchain-s390x.cmake",
|
||||
"-DBUILD_TESTS=ON",
|
||||
"-DNO_STL=OFF",
|
||||
"-DETL_CXX_STANDARD=17"
|
||||
],
|
||||
"cmake.buildDirectory": "${workspaceFolder}/build-s390x",
|
||||
"cmake.generator": "Ninja"
|
||||
}
|
||||
}
|
||||
},
|
||||
"remoteUser": "root"
|
||||
}
|
||||
21
.devcontainer/s390x/toolchain-s390x.cmake
Normal file
21
.devcontainer/s390x/toolchain-s390x.cmake
Normal file
@ -0,0 +1,21 @@
|
||||
# CMake toolchain file for s390x cross-compilation
|
||||
set(CMAKE_SYSTEM_NAME Linux)
|
||||
set(CMAKE_SYSTEM_PROCESSOR s390x)
|
||||
|
||||
# Specify the cross compiler
|
||||
set(CMAKE_C_COMPILER s390x-linux-gnu-gcc)
|
||||
set(CMAKE_CXX_COMPILER s390x-linux-gnu-g++)
|
||||
set(CMAKE_AR s390x-linux-gnu-ar)
|
||||
set(CMAKE_RANLIB s390x-linux-gnu-ranlib)
|
||||
set(CMAKE_STRIP s390x-linux-gnu-strip)
|
||||
|
||||
# Search for programs in the build host directories
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
|
||||
# For libraries and headers in the target directories
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
# Set QEMU for running tests
|
||||
set(CMAKE_CROSSCOMPILING_EMULATOR /usr/bin/qemu-s390x-static CACHE FILEPATH "Path to the emulator for cross-compiled binaries")
|
||||
7
.github/workflows/clang-c++11.yml
vendored
7
.github/workflows/clang-c++11.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
|
||||
@ -27,7 +28,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp11-linux-no-stl:
|
||||
name: Clang C++11 Linux - No STL
|
||||
@ -49,4 +50,4 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
7
.github/workflows/clang-c++14.yml
vendored
7
.github/workflows/clang-c++14.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
|
||||
@ -27,7 +28,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp14-linux-no-stl:
|
||||
name: Clang C++14 Linux - No STL
|
||||
@ -49,4 +50,4 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
7
.github/workflows/clang-c++17.yml
vendored
7
.github/workflows/clang-c++17.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
|
||||
@ -27,7 +28,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp17-linux-no-stl:
|
||||
name: Clang C++17 Linux - No STL
|
||||
@ -49,4 +50,4 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
25
.github/workflows/clang-c++20.yml
vendored
25
.github/workflows/clang-c++20.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
|
||||
@ -34,7 +35,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp20-linux-stl-force-cpp03:
|
||||
name: Clang C++20 Linux - STL - Force C++03
|
||||
@ -63,7 +64,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp20-linux-no-stl-force-cpp03:
|
||||
name: Clang C++20 Linux - No STL - Force C++03
|
||||
@ -92,14 +93,14 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp20-osx-stl:
|
||||
name: Clang C++20 OSX - STL
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-13]
|
||||
os: [macos-15]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -114,14 +115,14 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp20-osx-no-stl:
|
||||
name: Clang C++20 OSX - No STL
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-13]
|
||||
os: [macos-15]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -136,14 +137,14 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp20-osx-stl-force-cpp03:
|
||||
name: Clang C++20 OSX - STL - Force C++03
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-13]
|
||||
os: [macos-15]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -158,14 +159,14 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp20-osx-no-stl-force-cpp03:
|
||||
name: Clang C++20 OSX - No STL - Force C++03
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-13]
|
||||
os: [macos-15]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -180,5 +181,5 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
|
||||
25
.github/workflows/clang-c++23.yml
vendored
25
.github/workflows/clang-c++23.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
|
||||
@ -34,7 +35,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp23-linux-stl-force-cpp03:
|
||||
name: Clang C++23 Linux - STL - Force C++03
|
||||
@ -63,7 +64,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp2-linux-no-stl-force-cpp03:
|
||||
name: Clang C++23 Linux - No STL - Force C++03
|
||||
@ -92,14 +93,14 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp23-osx-stl:
|
||||
name: Clang C++23 OSX - STL
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-13]
|
||||
os: [macos-15]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -114,14 +115,14 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp23-osx-no-stl:
|
||||
name: Clang C++23 OSX - No STL
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-13]
|
||||
os: [macos-15]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -136,14 +137,14 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp23-osx-stl-force-cpp03:
|
||||
name: Clang C++23 OSX - STL - Force C++03
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-13]
|
||||
os: [macos-15]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -158,14 +159,14 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-clang-cpp23-osx-no-stl-force-cpp03:
|
||||
name: Clang C++23 OSX - No STL - Force C++03
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-13]
|
||||
os: [macos-15]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
@ -180,5 +181,5 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
|
||||
43
.github/workflows/clang-format.yaml
vendored
Normal file
43
.github/workflows/clang-format.yaml
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
name: clang-format
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
name: clang-format
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Install clang-format and git
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends git clang-format
|
||||
clang-format --version
|
||||
|
||||
- name: Run clang-format on added/changed files
|
||||
run: |
|
||||
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
||||
BEFORE="origin/${{ github.base_ref }}"
|
||||
elif [ "${{ github.event_name }}" = "push" ]; then
|
||||
BEFORE="${{ github.event.before }}"
|
||||
else
|
||||
echo "Unsupported event: ${{ github.event_name }}"
|
||||
echo "This is likely a bug in the workflow configuration. Please report it to the maintainers."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
git diff --name-only -z --diff-filter=AMCR "$BEFORE"..HEAD -- \
|
||||
'*.c' '*.cc' '*.cxx' '*.cpp' \
|
||||
'*.h' '*.hh' '*.hpp' '*.hxx' \
|
||||
'*.ipp' '*.inl' \
|
||||
':(exclude)include/etl/generators/*' \
|
||||
':(exclude)include/etl/private/*_cpp03.h' \
|
||||
| xargs -0 --no-run-if-empty clang-format --Werror -n --style=file
|
||||
21
.github/workflows/clang-format_update.yaml
vendored
Normal file
21
.github/workflows/clang-format_update.yaml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
name: clang-format-update
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
clang-format:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install clang-format
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends clang-format
|
||||
clang-format --version
|
||||
|
||||
- name: Run clang-format
|
||||
run: |
|
||||
find . \( -name '*.cpp' -o -name '*.h' -o -name '*.c' \) | xargs clang-format --dry-run --Werror
|
||||
3
.github/workflows/clang-syntax-checks.yml
vendored
3
.github/workflows/clang-syntax-checks.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
build-clang-cpp03-linux-STL:
|
||||
|
||||
72
.github/workflows/coverage.yml
vendored
Normal file
72
.github/workflows/coverage.yml
vendored
Normal file
@ -0,0 +1,72 @@
|
||||
name: coverage
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
# Allow only one concurrent deployment to GitHub Pages
|
||||
concurrency:
|
||||
group: coverage-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
# Grant GITHUB_TOKEN the minimum permissions needed at the workflow level
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
|
||||
coverage:
|
||||
name: Generate Coverage Report
|
||||
runs-on: ubuntu-24.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y lcov llvm gcc g++ clang cmake
|
||||
|
||||
- name: Build, test, and collect coverage
|
||||
run: |
|
||||
cd test
|
||||
./run-coverage.sh
|
||||
|
||||
- name: Upload coverage report artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: coverage-report
|
||||
path: test/build-coverage/coverage/
|
||||
retention-days: 30
|
||||
|
||||
- name: Upload Pages artifact
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: test/build-coverage/coverage/
|
||||
|
||||
deploy-pages:
|
||||
name: Deploy to GitHub Pages
|
||||
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
|
||||
needs: coverage
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
permissions:
|
||||
pages: write
|
||||
id-token: write
|
||||
|
||||
environment:
|
||||
name: github-pages
|
||||
url: ${{ steps.deployment.outputs.page_url }}
|
||||
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
|
||||
# GitHub Repository settings
|
||||
# -> Settings -> Pages
|
||||
# -> Source: gh actions
|
||||
7
.github/workflows/gcc-c++11.yml
vendored
7
.github/workflows/gcc-c++11.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
|
||||
@ -28,7 +29,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-gcc-cpp11-linux-no-stl:
|
||||
name: GCC C++11 Linux - No STL
|
||||
@ -51,4 +52,4 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
7
.github/workflows/gcc-c++14.yml
vendored
7
.github/workflows/gcc-c++14.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
|
||||
@ -27,7 +28,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-gcc-cpp14-linux-no-stl:
|
||||
name: GCC C++14 Linux - No STL
|
||||
@ -49,4 +50,4 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
7
.github/workflows/gcc-c++17.yml
vendored
7
.github/workflows/gcc-c++17.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
|
||||
@ -27,7 +28,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-gcc-cpp17-linux-no-stl:
|
||||
name: GCC C++17 Linux - No STL
|
||||
@ -49,4 +50,4 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
11
.github/workflows/gcc-c++20.yml
vendored
11
.github/workflows/gcc-c++20.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
|
||||
@ -27,7 +28,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-gcc-cpp20-linux-no-stl:
|
||||
name: GCC C++20 Linux - No STL
|
||||
@ -49,7 +50,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-gcc-cpp20-linux-stl-force-cpp03:
|
||||
name: GCC C++20 Linux - STL - Force C++03
|
||||
@ -71,7 +72,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-gcc-cpp20-linux-no-stl-force-cpp03:
|
||||
name: GCC C++20 Linux - No STL - Force C++03
|
||||
@ -93,4 +94,4 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
11
.github/workflows/gcc-c++23.yml
vendored
11
.github/workflows/gcc-c++23.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
|
||||
@ -27,7 +28,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-gcc-cpp23-linux-no-stl:
|
||||
name: GCC C++23 Linux - No STL
|
||||
@ -49,7 +50,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-gcc-cpp23-linux-stl-force-cpp03:
|
||||
name: GCC C++23 Linux - STL - Force C++03
|
||||
@ -71,7 +72,7 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
|
||||
build-gcc-cpp23-linux-no-stl-force-cpp03:
|
||||
name: GCC C++23 Linux - No STL - Force C++03
|
||||
@ -93,4 +94,4 @@ jobs:
|
||||
make -j $(getconf _NPROCESSORS_ONLN)
|
||||
|
||||
- name: Run tests
|
||||
run: ./test/etl_tests
|
||||
run: ./test/etl_tests -v
|
||||
3
.github/workflows/gcc-syntax-checks.yml
vendored
3
.github/workflows/gcc-syntax-checks.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
build-gcc-cpp03-linux-STL:
|
||||
|
||||
25
.github/workflows/generator.yml
vendored
Normal file
25
.github/workflows/generator.yml
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
name: generator checks
|
||||
on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
generator-run:
|
||||
name: Header Generator
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Generate
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y python3-cogapp
|
||||
cd include/etl/generators && bash generate.bat
|
||||
|
||||
- name: Check Generated Headers For Changes
|
||||
run: |
|
||||
git diff --exit-code
|
||||
13
.github/workflows/msvc.yml
vendored
13
.github/workflows/msvc.yml
vendored
@ -3,7 +3,8 @@ on:
|
||||
push:
|
||||
branches: [ master, development, pull-request/* ]
|
||||
pull_request:
|
||||
branches: [ master, pull-request/* ]
|
||||
branches: [ master, development, pull-request/* ]
|
||||
types: [opened, synchronize, reopened]
|
||||
|
||||
jobs:
|
||||
build-windows-msvc-stl:
|
||||
@ -21,12 +22,12 @@ jobs:
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=20 ./
|
||||
cmake -G "Visual Studio 17 2022" -AWin32 -DBUILD_TESTS=ON -DNO_STL=OFF -DETL_USE_TYPE_TRAITS_BUILTINS=OFF -DETL_USER_DEFINED_TYPE_TRAITS=OFF -DETL_FORCE_TEST_CPP03_IMPLEMENTATION=OFF -DETL_CXX_STANDARD=17 ./
|
||||
MSBuild.exe -version
|
||||
MSBuild.exe .\etl.sln
|
||||
|
||||
- name: Run tests
|
||||
run: test/Debug/etl_tests.exe
|
||||
run: test/Debug/etl_tests.exe -v
|
||||
|
||||
build-windows-msvc-no-stl:
|
||||
name: Windows - No STL
|
||||
@ -47,7 +48,7 @@ jobs:
|
||||
MSBuild.exe .\etl.sln
|
||||
|
||||
- name: Run tests
|
||||
run: test/Debug/etl_tests.exe
|
||||
run: test/Debug/etl_tests.exe -v
|
||||
|
||||
build-windows-msvc-stl-force-cpp03:
|
||||
name: Windows - STL - Force C++03
|
||||
@ -69,7 +70,7 @@ jobs:
|
||||
MSBuild.exe .\etl.sln
|
||||
|
||||
- name: Run tests
|
||||
run: test/Debug/etl_tests.exe
|
||||
run: test/Debug/etl_tests.exe -v
|
||||
|
||||
build-windows-msvc-no-stl-force-cpp03:
|
||||
name: Windows - No STL - Force C++03
|
||||
@ -91,5 +92,5 @@ jobs:
|
||||
MSBuild.exe .\etl.sln
|
||||
|
||||
- name: Run tests
|
||||
run: test/Debug/etl_tests.exe
|
||||
run: test/Debug/etl_tests.exe -v
|
||||
|
||||
|
||||
26
.github/workflows/platformio-update.yml
vendored
Normal file
26
.github/workflows/platformio-update.yml
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
name: Publish ETL to PlatformIO
|
||||
|
||||
on:
|
||||
release:
|
||||
types: [published] # Trigger only when a GitHub release is published
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: "3.x"
|
||||
|
||||
- name: Install PlatformIO
|
||||
run: pip install platformio
|
||||
|
||||
- name: Publish to PlatformIO Registry
|
||||
run: pio package publish --owner etlcpp --non-interactive
|
||||
env:
|
||||
PLATFORMIO_AUTH_TOKEN: ${{ secrets.PLATFORMIO_TOKEN }}
|
||||
19
.gitignore
vendored
19
.gitignore
vendored
@ -3,6 +3,8 @@
|
||||
## Personal
|
||||
#################
|
||||
docs/html
|
||||
hugo/public
|
||||
hugo/.hugo_build.lock
|
||||
include/etl/html/
|
||||
include/etl/latex/
|
||||
test/vs2013/Debug
|
||||
@ -400,3 +402,20 @@ test/vs2022/Debug MSVC C++20 - Forve C++03 - No virtual messages
|
||||
test/reflog.txt
|
||||
test/etl_error_handler/assert_function/build-make
|
||||
test/syntax_check/bgcc
|
||||
test/vs2022/Debug MSVC C++23
|
||||
test/vs2022/Debug MSVC C++23 - No STL
|
||||
.vs
|
||||
examples/UniquePtrWithPool/CMakeFiles
|
||||
examples/UniquePtrWithPool/cmake_install.cmake
|
||||
examples/UniquePtrWithPool/Makefile
|
||||
examples/UniquePtrWithPool/CMakeCache.txt
|
||||
examples/UniquePtrWithPool/UniquePtrWithPool
|
||||
test/vs2022/Debug Clang C++20 - Optimised -O2
|
||||
include/etl/header_file_list.txt
|
||||
temp
|
||||
test/syntax_check/build-make
|
||||
hugo/public
|
||||
hugo/resources
|
||||
hugo/.hugo_build.lock
|
||||
docs/*.html
|
||||
test/build-coverage
|
||||
|
||||
45
.treefmt.toml
Normal file
45
.treefmt.toml
Normal file
@ -0,0 +1,45 @@
|
||||
[global]
|
||||
excludes = [
|
||||
"**/Doxyfile",
|
||||
"**/Makefile",
|
||||
"*.*-format",
|
||||
"*.S",
|
||||
"*.cmm",
|
||||
"*.css",
|
||||
"*.dld",
|
||||
"*.gdb",
|
||||
"*.gif",
|
||||
"*.gitignore",
|
||||
"*.html",
|
||||
"*.ini",
|
||||
"*.josh",
|
||||
"*.json",
|
||||
"*.md",
|
||||
"*.png",
|
||||
"*.puml",
|
||||
"*.py",
|
||||
"*.rb",
|
||||
"*.rst",
|
||||
"*.s",
|
||||
"*.sh",
|
||||
"*.spec",
|
||||
"*.toml",
|
||||
"*.txt",
|
||||
"*.yaml",
|
||||
"*.yml",
|
||||
"docker/**",
|
||||
"temp/**",
|
||||
"scripts/clang-format-wrapper",
|
||||
"include/etl/generators/**",
|
||||
"include/etl/private/*_cpp03.h",
|
||||
"subprojects/**",
|
||||
"test/UnitTest++/**",
|
||||
"test/Deprecated/**",
|
||||
"test/Performance/**",
|
||||
"test/temp/**"
|
||||
]
|
||||
|
||||
[formatter.cpp]
|
||||
command = "scripts/clang-format-wrapper"
|
||||
options = [ "-i", "--style=file" ]
|
||||
includes = [ "*.c", "*.cc", "*.cpp", "*.h", "*.hh", "*.hpp" ]
|
||||
@ -1,13 +1,17 @@
|
||||
# How to contribute
|
||||
|
||||
If your are considering creating a pull request, please observe the following:
|
||||
Thanks for considering a contribution! Here’s what you need to know before opening a pull request:
|
||||
|
||||
- If you are adding or modifying a feature, add *new* unit tests that test that feature.
|
||||
- If you are fixing a bug, add a unit test that *fails* before the bug fix is implemented.
|
||||
- Do not initiate a pull request until all of the units tests pass.
|
||||
- Branches should be based on the branch `master`.
|
||||
- Do not initiate a pull request until all of the units tests pass. See below for information on project files and test scripts.
|
||||
- Branches should be based on the branch `master`. If `development` has pending updates, I’ll rebase the PR against it before pulling..
|
||||
- For formatting help, you can use clang-format, or the convenience wrapper treefmt. See also [docs/source-formatting.md](docs/source-formatting.md)
|
||||
|
||||
There is a project file for VS2022 for C++14, 17, 20, and bash scripts that run the tests for C++11, 14, 17, 20 under Linux with GCC and Clang.
|
||||
There is a project file for VS2022 for C++14, 17, 20, 23, and bash scripts that run the tests for C++11, 14, 17, 20, 23 under Linux with GCC and Clang.
|
||||
There are syntax-only check bash scripts that cover C++03, 11, 14, 17, 20, 23 under Linux with GCC and Clang.
|
||||
|
||||
If you are thinking of adding a new feature then raise this on the GitHub Issues page for discussion as the maintainers and user of the ETL may have questions or suggestions.
|
||||
It is possible that the maintainer of the ETL or another contributor is already working on the same or a related feature.
|
||||
It is possible that the maintainer of the ETL or another contributor is already working on the same or a related feature.
|
||||
|
||||
Take a look through our current issues and see if anything sparks your interest!
|
||||
|
||||
12
Converting header guards.txt
Normal file
12
Converting header guards.txt
Normal file
@ -0,0 +1,12 @@
|
||||
How to convert the ETL header beween #include guards and #pragma once.
|
||||
|
||||
Install
|
||||
python3 -m pip install guardonce
|
||||
|
||||
Navigate to etl/scripts
|
||||
|
||||
Change from #include guard to #pragma once
|
||||
./convert_headers_to_use_once.bat
|
||||
|
||||
Change from #pragma once to #include guard
|
||||
./convert_headers_to_use_guards.bat
|
||||
192
README.md
192
README.md
@ -1,16 +1,14 @@
|
||||
Embedded Template Library (ETL)
|
||||
-------------------------
|
||||
#  Embedded Template Library (ETL)
|
||||
|
||||

|
||||
[](https://img.shields.io/github/release-date/jwellbelove/etl?color=%231182c3)
|
||||
[](https://en.wikipedia.org/wiki/C%2B%2B#Standardization)
|
||||
[](https://en.wikipedia.org/wiki/C%2B%2B#Standardization)
|
||||
[](https://opensource.org/licenses/MIT)
|
||||

|
||||

|
||||

|
||||
|
||||

|
||||
[](https://ci.appveyor.com/project/jwellbelove/etl/branch/master)
|
||||

|
||||
|
||||

|
||||

|
||||
@ -34,47 +32,87 @@ Embedded Template Library (ETL)
|
||||
|
||||
## Motivation
|
||||
|
||||
C++ is a great language to use for embedded applications and templates are a powerful aspect. The standard library can offer a great deal of well tested functionality, but there are some parts of the standard library that do not fit well with deterministic behaviour and limited resource requirements. These limitations usually preclude the use of dynamically allocated memory and containers with open ended sizes.
|
||||
C++ is a powerful language for embedded systems development, with templates offering a great deal of flexibility and type safety. While the C++ Standard Library provides a wealth of well-tested functionality, it’s often not well suited to environments with strict deterministic behavior and limited resources.
|
||||
|
||||
What is needed is a template library where the user can declare the size, or maximum size of any object upfront. Most embedded compilers do not currently support the standard beyond C++ 03, therefore excluding the programmer from using the enhanced features of the later library.
|
||||
In many embedded applications, dynamic memory allocation is discouraged or outright prohibited, making standard STL containers and many other components impractical or unusable.
|
||||
|
||||
This is what the ETL attempts to achieve.
|
||||
What’s needed is a template library specifically designed for embedded systems — one that allows developers to define fixed or maximum sizes for containers and other objects at compile time. Additionally, since many embedded toolchains still lack full support for standards beyond C++03, it's valuable to have access to a library that backports select features from later versions of the C++ Standard Library.
|
||||
|
||||
## Summary
|
||||
## About the ETL
|
||||
|
||||
The ETL is not designed to completely replace the STL, but complement it.
|
||||
Its design objective covers three areas.
|
||||
The Embedded Template Library (ETL) is not intended as a full replacement for the C++ Standard Template Library (STL), but rather as a complementary solution tailored specifically for embedded systems.
|
||||
|
||||
- Create a set of containers where the size or maximum size is determined at compile time. These containers are direct equivalents of those supplied in the STL.
|
||||
- Be compatible with C++ 03 but implement as many of the C++ 11/14/17/20/23 additions as possible.
|
||||
- Add other useful components that are not present in the standard library.
|
||||
Its design goals include:
|
||||
|
||||
The embedded template library has been designed for lower resource embedded applications.
|
||||
It contains a set of containers, algorithms and utilities, some of which emulate parts of the STL.
|
||||
There is no dynamic memory allocation. The library makes no use of the heap. All of the containers have a fixed capacity allowing all memory allocation to be determined at compile time.
|
||||
The library is intended for any compiler that supports C++98/03/11/14/17/20/23.
|
||||
- Providing a set of containers with fixed or maximum sizes defined at compile-time.
|
||||
|
||||
## Main features
|
||||
- Offering APIs that closely resemble those of the STL, enabling familiar and consistent usage.
|
||||
|
||||
- Cross platform. This library is not specific to any processor type.
|
||||
- No dynamic memory allocation
|
||||
- No RTTI required
|
||||
- Very little use of virtual functions. They are used only when they are absolutely necessary for the required functionality
|
||||
- A set of fixed capacity containers. (array, bitset, deque, forward_list, list, queue, stack, vector, map, set, etc.)
|
||||
- As the storage for all of the container types is allocated as a contiguous block, they are extremely cache friendly
|
||||
- Templated compile time constants
|
||||
- Templated design pattern base classes (Visitor, Observer)
|
||||
- Reverse engineered C++ 0x11 features (type traits, algorithms, containers etc.)
|
||||
- Type-safe enumerations
|
||||
- Type-safe typedefs
|
||||
- 8, 16, 32 & 64 bit CRC calculations
|
||||
- Checksums & hash functions
|
||||
- Variants (a type that can store many types in a type-safe interface)
|
||||
- Choice of asserts, exceptions, error handler or no checks on errors
|
||||
- Unit tested (currently over 9400 tests), using VS2022, GCC 12, Clang 14.
|
||||
- Many utilities for template support.
|
||||
- Easy to read and documented source.
|
||||
- Free support via email, GitHub and Slack
|
||||
- Maintaining compatibility with C++98 while implementing many features introduced in later standards
|
||||
(C++11/14/17/20/23) where possible.
|
||||
|
||||
- Ensuring deterministic behavior, which is critical in real-time and resource-constrained environments.
|
||||
|
||||
- Introducing additional components and utilities useful in embedded contexts but absent from the STL.
|
||||
|
||||
The ETL avoids dynamic memory allocation entirely; the heap is never used. All non-intrusive containers have a fixed capacity, allowing memory requirements to be fully determined at compile-time. This makes the ETL ideal for lower-resource embedded applications where predictability, performance, and memory control are essential.
|
||||
|
||||
The library is compatible with any compiler that supports C++03 or later.
|
||||
|
||||
Help on integrating the ETL with your project may be found here.
|
||||
|
||||
|
||||
## Key features of the ETL
|
||||
|
||||
- Actively Maintained: Developed and maintained on GitHub since 2014.
|
||||
|
||||
- Open Source: MIT licensed.
|
||||
|
||||
- No STL Dependency: Designed to operate independently of the C++ Standard Template Library.
|
||||
|
||||
- No Dynamic Memory Allocation: All storage is allocated either at compile-time or on the stack; heap usage is entirely avoided.
|
||||
|
||||
- RTTI and Virtual Functions: No runtime type information (RTTI) is required. Virtual functions are used sparingly and only when strictly necessary.
|
||||
|
||||
- Header-Only Library: All functionality is provided via header files; No separate compilation needed.
|
||||
|
||||
- Fixed-Capacity Containers: Offers STL-like containers with fixed or maximum capacity, plus additional non-standard container types.
|
||||
|
||||
- Cache Efficiency: Containers use contiguous memory layouts for optimal cache performance.
|
||||
|
||||
- Compact Codebase: Shared base classes (based on type) help reduce overall container code size.
|
||||
|
||||
- Compile-Time Features:
|
||||
- Templated compile-time constants
|
||||
- Template-based design pattern base classes (e.g., Visitor, Observer)
|
||||
- Type-safe smart enumerations
|
||||
- Type-safe typedefs and constants
|
||||
|
||||
- Embedded System Frameworks:
|
||||
- Message routing
|
||||
- Finite state machines
|
||||
- Task scheduling
|
||||
|
||||
- C++11 Backports: Implements many C++11 features (type traits, algorithms, containers) for use in C++03 environments.
|
||||
|
||||
- Utilities:
|
||||
- CRC calculations (8, 16, 32 & 64-bit)
|
||||
- Checksums and hash functions
|
||||
- Variants (type-safe unions)
|
||||
- Extensive template support utilities
|
||||
|
||||
- Robust Error Handling: Configurable error checking using asserts, exceptions, error handlers, or no checks; user’s choice.
|
||||
|
||||
- Thoroughly Tested:
|
||||
- Over 10,000 unit tests
|
||||
- Tested with Visual Studio 2022, GCC 12, and Clang 14
|
||||
- Continuous integration via GitHub Actions.
|
||||
|
||||
- Readable and Well-Documented: Clean, maintainable source code with clear documentation.
|
||||
|
||||
- Support: Free email support available. A Slack group is available. Paid support on request.
|
||||
|
||||
- Archived: A snapshot of the ETL is preserved in the Arctic Code Vault for long-term digital preservation.
|
||||
|
||||
Any help porting the library to work under different platforms and compilers would be gratefully received.
|
||||
I am especially interested in people who are using Keil, IAR, Green Hills, TI Code Composer etc, bare metal or RTOS, and DSPs.
|
||||
@ -144,6 +182,84 @@ add_executable(foo main.cpp)
|
||||
target_link_libraries(foo PRIVATE etl::etl)
|
||||
```
|
||||
|
||||
## Profile definition
|
||||
|
||||
When using ETL in a project, there is typically an `etl_profile.h` defined to
|
||||
adjust ETL to the project needs. ETL will automatically find `etl_profile.h`
|
||||
if it is available in the include path(s). If it's not available, ETL will
|
||||
work with default values.
|
||||
|
||||
### Example
|
||||
|
||||
```
|
||||
#ifndef __ETL_PROFILE_H__
|
||||
#define __ETL_PROFILE_H__
|
||||
|
||||
#define ETL_TARGET_DEVICE_GENERIC
|
||||
#define ETL_TARGET_OS_NONE
|
||||
|
||||
#define ETL_NO_STL
|
||||
|
||||
#endif
|
||||
```
|
||||
|
||||
## Platform specific implementation
|
||||
|
||||
Although ETL is generally a self-contained header-only library, some interfaces need to be
|
||||
implemented in every project or platform, at least if those interfaces are actually being
|
||||
used, due to project specifics:
|
||||
|
||||
| ETL header | Platform specific API to be implemented | Needed when using |
|
||||
|------------|-----------------------------------------|-------------------------------------|
|
||||
| `chrono.h` | `etl_get_high_resolution_clock()` | `etl::high_resolution_clock::now()` |
|
||||
| | `etl_get_system_clock()` | `etl::system_clock::now()` |
|
||||
| | `etl_get_steady_clock()` | `etl::steady_clock::now()` |
|
||||
| `print.h` | `etl_putchar()` | `etl::print()` |
|
||||
| | | `etl::println()` |
|
||||
|
||||
### Example
|
||||
|
||||
```
|
||||
#include <etl/chrono.h>
|
||||
#include <etl/print.h>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
etl::chrono::high_resolution_clock::rep etl_get_high_resolution_clock()
|
||||
{
|
||||
return etl::chrono::high_resolution_clock::rep(static_cast<int64_t>(getSystemTimeNs()));
|
||||
}
|
||||
|
||||
etl::chrono::system_clock::rep etl_get_system_clock()
|
||||
{
|
||||
return etl::chrono::system_clock::rep(static_cast<int64_t>(getSystemTimeNs()));
|
||||
}
|
||||
|
||||
etl::chrono::system_clock::rep etl_get_steady_clock()
|
||||
{
|
||||
return etl::chrono::system_clock::rep(static_cast<int64_t>(getSystemTimeNs()));
|
||||
}
|
||||
|
||||
void etl_putchar(int c)
|
||||
{
|
||||
putByteToStdout(static_cast<uint8_t>(c));
|
||||
}
|
||||
|
||||
}
|
||||
```
|
||||
|
||||
The following default values apply if the respective macros are not defined
|
||||
(e.g. in `etl_profile.h`):
|
||||
|
||||
| Macro | Default |
|
||||
|-----------------------------------------------|----------------------------|
|
||||
| `ETL_CHRONO_SYSTEM_CLOCK_DURATION` | `etl::chrono::nanoseconds` |
|
||||
| `ETL_CHRONO_SYSTEM_CLOCK_IS_STEADY` | `true` |
|
||||
| `ETL_CHRONO_HIGH_RESOLUTION_CLOCK_DURATION` | `etl::chrono::nanoseconds` |
|
||||
| `ETL_CHRONO_HIGH_RESOLUTION_CLOCK_IS_STEADY` | `true` |
|
||||
| `ETL_CHRONO_STEADY_CLOCK_DURATION` | `etl::chrono::nanoseconds` |
|
||||
|
||||
## Arduino library
|
||||
|
||||
The content of this repo is available as a library in the Arduino IDE (search for the "Embedded Template Library" in the IDE library manager). The Arduino library repository is available at ```https://github.com/ETLCPP/etl-arduino```, see there for more details.
|
||||
|
||||
@ -2,79 +2,79 @@
|
||||
#ifndef ETL_EMBEDDED_TEMPLATE_LIBRARY_INCLUDED
|
||||
#define ETL_EMBEDDED_TEMPLATE_LIBRARY_INCLUDED
|
||||
|
||||
#if defined(TEENSYDUINO)
|
||||
#if defined(TEENSYDUINO)
|
||||
|
||||
#if defined(__AVR_ATmega32U4__)
|
||||
#define ARDUINO_BOARD "Teensy 2.0"
|
||||
#elif defined(__AVR_AT90USB1286__)
|
||||
#define ARDUINO_BOARD "Teensy++ 2.0"
|
||||
#elif defined(__MK20DX128__)
|
||||
#define ARDUINO_BOARD "Teensy 3.0"
|
||||
#elif defined(__MK20DX256__)
|
||||
#define ARDUINO_BOARD "Teensy 3.2" // and Teensy 3.1
|
||||
#elif defined(__MKL26Z64__)
|
||||
#define ARDUINO_BOARD "Teensy LC"
|
||||
#elif defined(__MK64FX512__)
|
||||
#define ARDUINO_BOARD "Teensy 3.5"
|
||||
#elif defined(__MK66FX1M0__)
|
||||
#define ARDUINO_BOARD "Teensy 3.6"
|
||||
#else
|
||||
#define ARDUINO_BOARD "Unknown"
|
||||
#endif
|
||||
#if defined(__AVR_ATmega32U4__)
|
||||
#define ARDUINO_BOARD "Teensy 2.0"
|
||||
#elif defined(__AVR_AT90USB1286__)
|
||||
#define ARDUINO_BOARD "Teensy++ 2.0"
|
||||
#elif defined(__MK20DX128__)
|
||||
#define ARDUINO_BOARD "Teensy 3.0"
|
||||
#elif defined(__MK20DX256__)
|
||||
#define ARDUINO_BOARD "Teensy 3.2" // and Teensy 3.1
|
||||
#elif defined(__MKL26Z64__)
|
||||
#define ARDUINO_BOARD "Teensy LC"
|
||||
#elif defined(__MK64FX512__)
|
||||
#define ARDUINO_BOARD "Teensy 3.5"
|
||||
#elif defined(__MK66FX1M0__)
|
||||
#define ARDUINO_BOARD "Teensy 3.6"
|
||||
#else
|
||||
#define ARDUINO_BOARD "Unknown"
|
||||
#endif
|
||||
|
||||
#else // --------------- Arduino ------------------
|
||||
|
||||
#if defined(ARDUINO_AVR_ADK)
|
||||
#define ARDUINO_BOARD "Mega Adk"
|
||||
#elif defined(ARDUINO_AVR_BT)
|
||||
#define ARDUINO_BOARD "Bt"
|
||||
#elif defined(ARDUINO_AVR_DUEMILANOVE)
|
||||
#define ARDUINO_BOARD "Duemilanove"
|
||||
#elif defined(ARDUINO_AVR_ESPLORA)
|
||||
#define ARDUINO_BOARD "Esplora"
|
||||
#elif defined(ARDUINO_AVR_ETHERNET)
|
||||
#define ARDUINO_BOARD "Ethernet"
|
||||
#elif defined(ARDUINO_AVR_FIO)
|
||||
#define ARDUINO_BOARD "Fio"
|
||||
#elif defined(ARDUINO_AVR_GEMMA)
|
||||
#define ARDUINO_BOARD "Gemma"
|
||||
#elif defined(ARDUINO_AVR_LEONARDO)
|
||||
#define ARDUINO_BOARD "Leonardo"
|
||||
#elif defined(ARDUINO_AVR_LILYPAD)
|
||||
#define ARDUINO_BOARD "Lilypad"
|
||||
#elif defined(ARDUINO_AVR_LILYPAD_USB)
|
||||
#define ARDUINO_BOARD "Lilypad Usb"
|
||||
#elif defined(ARDUINO_AVR_MEGA)
|
||||
#define ARDUINO_BOARD "Mega"
|
||||
#elif defined(ARDUINO_AVR_MEGA2560)
|
||||
#define ARDUINO_BOARD "Mega 2560"
|
||||
#elif defined(ARDUINO_AVR_MICRO)
|
||||
#define ARDUINO_BOARD "Micro"
|
||||
#elif defined(ARDUINO_AVR_MINI)
|
||||
#define ARDUINO_BOARD "Mini"
|
||||
#elif defined(ARDUINO_AVR_NANO)
|
||||
#define ARDUINO_BOARD "Nano"
|
||||
#elif defined(ARDUINO_AVR_NG)
|
||||
#define ARDUINO_BOARD "NG"
|
||||
#elif defined(ARDUINO_AVR_PRO)
|
||||
#define ARDUINO_BOARD "Pro"
|
||||
#elif defined(ARDUINO_AVR_ROBOT_CONTROL)
|
||||
#define ARDUINO_BOARD "Robot Ctrl"
|
||||
#elif defined(ARDUINO_AVR_ROBOT_MOTOR)
|
||||
#define ARDUINO_BOARD "Robot Motor"
|
||||
#elif defined(ARDUINO_AVR_UNO)
|
||||
#define ARDUINO_BOARD "Uno"
|
||||
#elif defined(ARDUINO_AVR_YUN)
|
||||
#define ARDUINO_BOARD "Yun"
|
||||
#elif defined(ARDUINO_SAM_DUE)
|
||||
#define ARDUINO_BOARD "Due"
|
||||
#elif defined(ARDUINO_SAMD_ZERO)
|
||||
#define ARDUINO_BOARD "Zero"
|
||||
#elif defined(ARDUINO_ARC32_TOOLS)
|
||||
#define ARDUINO_BOARD "101"
|
||||
#else
|
||||
#define ARDUINO_BOARD "Unknown"
|
||||
#endif
|
||||
#if defined(ARDUINO_AVR_ADK)
|
||||
#define ARDUINO_BOARD "Mega Adk"
|
||||
#elif defined(ARDUINO_AVR_BT)
|
||||
#define ARDUINO_BOARD "Bt"
|
||||
#elif defined(ARDUINO_AVR_DUEMILANOVE)
|
||||
#define ARDUINO_BOARD "Duemilanove"
|
||||
#elif defined(ARDUINO_AVR_ESPLORA)
|
||||
#define ARDUINO_BOARD "Esplora"
|
||||
#elif defined(ARDUINO_AVR_ETHERNET)
|
||||
#define ARDUINO_BOARD "Ethernet"
|
||||
#elif defined(ARDUINO_AVR_FIO)
|
||||
#define ARDUINO_BOARD "Fio"
|
||||
#elif defined(ARDUINO_AVR_GEMMA)
|
||||
#define ARDUINO_BOARD "Gemma"
|
||||
#elif defined(ARDUINO_AVR_LEONARDO)
|
||||
#define ARDUINO_BOARD "Leonardo"
|
||||
#elif defined(ARDUINO_AVR_LILYPAD)
|
||||
#define ARDUINO_BOARD "Lilypad"
|
||||
#elif defined(ARDUINO_AVR_LILYPAD_USB)
|
||||
#define ARDUINO_BOARD "Lilypad Usb"
|
||||
#elif defined(ARDUINO_AVR_MEGA)
|
||||
#define ARDUINO_BOARD "Mega"
|
||||
#elif defined(ARDUINO_AVR_MEGA2560)
|
||||
#define ARDUINO_BOARD "Mega 2560"
|
||||
#elif defined(ARDUINO_AVR_MICRO)
|
||||
#define ARDUINO_BOARD "Micro"
|
||||
#elif defined(ARDUINO_AVR_MINI)
|
||||
#define ARDUINO_BOARD "Mini"
|
||||
#elif defined(ARDUINO_AVR_NANO)
|
||||
#define ARDUINO_BOARD "Nano"
|
||||
#elif defined(ARDUINO_AVR_NG)
|
||||
#define ARDUINO_BOARD "NG"
|
||||
#elif defined(ARDUINO_AVR_PRO)
|
||||
#define ARDUINO_BOARD "Pro"
|
||||
#elif defined(ARDUINO_AVR_ROBOT_CONTROL)
|
||||
#define ARDUINO_BOARD "Robot Ctrl"
|
||||
#elif defined(ARDUINO_AVR_ROBOT_MOTOR)
|
||||
#define ARDUINO_BOARD "Robot Motor"
|
||||
#elif defined(ARDUINO_AVR_UNO)
|
||||
#define ARDUINO_BOARD "Uno"
|
||||
#elif defined(ARDUINO_AVR_YUN)
|
||||
#define ARDUINO_BOARD "Yun"
|
||||
#elif defined(ARDUINO_SAM_DUE)
|
||||
#define ARDUINO_BOARD "Due"
|
||||
#elif defined(ARDUINO_SAMD_ZERO)
|
||||
#define ARDUINO_BOARD "Zero"
|
||||
#elif defined(ARDUINO_ARC32_TOOLS)
|
||||
#define ARDUINO_BOARD "101"
|
||||
#else
|
||||
#define ARDUINO_BOARD "Unknown"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Embedded Template Library ETL",
|
||||
"version": "20.41.1",
|
||||
"version": "20.47.1",
|
||||
"authors": {
|
||||
"name": "John Wellbelove",
|
||||
"email": "john.wellbelove@etlcpp.com"
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
name=Embedded Template Library ETL
|
||||
version=20.41.1
|
||||
version=20.47.1
|
||||
author= John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
maintainer=John Wellbelove <john.wellbelove@etlcpp.com>
|
||||
license=MIT
|
||||
|
||||
6
docs/_config.yml
Normal file
6
docs/_config.yml
Normal file
@ -0,0 +1,6 @@
|
||||
plugins:
|
||||
- jekyll-relative-links
|
||||
relative_links:
|
||||
enabled: true
|
||||
include:
|
||||
- manchester.md
|
||||
7
docs/index.md
Normal file
7
docs/index.md
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
title: ETL documentation
|
||||
---
|
||||
|
||||
## Pages
|
||||
|
||||
* [Manchester](manchester.md)
|
||||
259
docs/manchester.md
Normal file
259
docs/manchester.md
Normal file
@ -0,0 +1,259 @@
|
||||
---
|
||||
title: Manchester encoding and decoding
|
||||
---
|
||||
|
||||
Efficient Manchester encoding and decoding of data. The Manchester code represents a data bit as a sequence of a 'high' and a 'low' value. In software this translates to a conversion from one to two bits, or in a practical situation, from `n` bytes to `n*2` bytes.
|
||||
|
||||
## See also
|
||||
|
||||
[Manchester code](https://en.wikipedia.org/wiki/Manchester_code)
|
||||
|
||||
## Features
|
||||
|
||||
- Normal and inverted Manchester encoding
|
||||
- Support for multiple encoding chunk sizes: 8-bit, 16-bit and 32-bit
|
||||
- Span-based operations or chunk-based operations
|
||||
- Constexpr functions for compile-time encoding/decoding
|
||||
- Validation of encoded data
|
||||
- Chunked span I/O uses little-endian byte order for multi-byte chunks, independent of host platform endianness
|
||||
|
||||
## Algorithm background
|
||||
|
||||
To encode the value `0b11001100` we must first duplicate all bits to create the value `0b1111000011110000`. We then perform an XOR of this value with the constant `0b1010101010101010` (`0xAAAA`) to obtain the Manchester coded value of `0b1010010110100101`. We have now replaced each `1` bit with the sequence `10` and each `0` bit with the sequence `01`.
|
||||
|
||||
### 2. Bit duplication
|
||||
|
||||
Bit duplication is achieved with the following steps. This is also called binary interleaving. The example shows encoding of an 8-bit value.
|
||||
|
||||
| Step | High Byte | Low Byte | Operation |
|
||||
|------|--------------------|--------------------|----------------------------|
|
||||
| 0 | `_ _ _ _ _ _ _ _` | `A B C D E F G H` | input value (i) |
|
||||
| 1 | `_ _ _ _ A B C D` | `_ _ _ _ E F G H` | `(i \| (i << 4)) & 0x0F0F` |
|
||||
| 2 | `_ _ A B _ _ C D` | `_ _ E F _ _ G H` | `(i \| (i << 2)) & 0x3333` |
|
||||
| 3 | `_ A _ B _ C _ D` | `_ E _ F _ G _ H` | `(i \| (i << 1)) & 0x5555` |
|
||||
| 4 | `A A B B C C D D` | `E E F F G G H H` | `(i \| (i << 1))` |
|
||||
|
||||
This process can be easily extended to 16-bit or 32-bit values by adding additional steps to the bit duplication.
|
||||
|
||||
### 3. Manchester Decoding
|
||||
|
||||
Manchester decoding is done in a similar, but reversed way.
|
||||
|
||||
### 4. Error Detection
|
||||
|
||||
Error detection in Manchester coded data is done by comparing 2 neighboring bits. If they are
|
||||
equal, then there is an error in the encoded input data.
|
||||
|
||||
Comparing all 8 bit pairs in a 16-bit word is done as follows.
|
||||
|
||||
| Step | Binary Value | Operation | Description |
|
||||
|------|--------------|-------------------|-----------------------------------------------------------------------------------------------|
|
||||
| 1 | `11011000` | Original | First bit pair (lsb, 00) is invalid. Last bit pair is also invalid. Other bit pairs are valid |
|
||||
| 2 | `01101100` | Shift right by 1 | Shift the original value right by one bit |
|
||||
| 3 | `10110100` | XOR | XOR the original with the shifted value |
|
||||
| 4 | `01010101` | Mask with 0x55 | Apply mask to isolate bit pairs |
|
||||
| 5 | `00010100` | Result | If result is not equal to 0x55, there was an error in the input |
|
||||
|
||||
## Analysis
|
||||
|
||||
Most traditional ways to Manchester encode data consist of a loop over all bits and a nested if-statement to check the value of the current bit. This approach does not scale well to increasing number of bits. The algorithm implemented here contains no conditional code and scales well. Doubling the number of processed bits per step (the chunk size) adds a single row to the bit duplication table. Because of the lack of loops and conditional code, this algorithm is likely to perform better than traditional ones on simple processors or when compiler optimization is disabled. On modern, powerful processors with caches and advanced optimization possibilities this algorithm may not show much benefit. In any case, the performance of the algorithm depends heavily on the processor type, compiler and compiler (optimization) settings.
|
||||
|
||||
## API Reference
|
||||
|
||||
### Classes
|
||||
|
||||
Classes `etl::manchester` and `etl::manchester_inverted` contain static functions for encoding, decoding and validity checking. It is not necessary to instantiate objects of these classes.
|
||||
|
||||
#### etl::manchester
|
||||
|
||||
```cpp
|
||||
typedef manchester_base<private_manchester::manchester_type_normal> manchester;
|
||||
```
|
||||
|
||||
Manchester encoder using normal encoding (no inversion).
|
||||
|
||||
#### etl::manchester_inverted
|
||||
|
||||
```cpp
|
||||
typedef manchester_base<private_manchester::manchester_type_inverted> manchester_inverted;
|
||||
```
|
||||
|
||||
Manchester encoder using inverted encoding.
|
||||
|
||||
### Encoding Functions
|
||||
|
||||
#### Encode single value
|
||||
|
||||
```cpp
|
||||
template <typename TDecoded>
|
||||
static ETL_CONSTEXPR14 typename encoded<TDecoded>::type encode(TDecoded decoded)
|
||||
```
|
||||
|
||||
Encodes a single value using Manchester encoding.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `decoded`: The value to encode (`uint8_t`, `uint16_t`, or `uint32_t`)
|
||||
|
||||
**Returns:**
|
||||
|
||||
- The Manchester encoded value (twice the bit width of input)
|
||||
|
||||
**Example:**
|
||||
|
||||
```cpp
|
||||
uint16_t encoded = etl::manchester::encode(0x55);
|
||||
```
|
||||
|
||||
#### Encode range
|
||||
|
||||
```cpp
|
||||
template <typename TChunk = uint_least8_t>
|
||||
static ETL_CONSTEXPR14 void encode(etl::span<const uint_least8_t> decoded,
|
||||
etl::span<uint_least8_t> encoded)
|
||||
```
|
||||
|
||||
Encodes a span of data using the specified chunk size.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `decoded`: Source data to encode
|
||||
- `encoded`: Destination for encoded data (must be twice the size of `decoded`)
|
||||
|
||||
**Template Parameters:**
|
||||
|
||||
- `TChunk`: Chunk size for encoding (`uint8_t`, `uint16_t` or `uint32_t`)
|
||||
|
||||
**Example:**
|
||||
|
||||
```cpp
|
||||
std::array<uint8_t, 4> data = {0x12, 0x34, 0x56, 0x78};
|
||||
std::array<uint8_t, 8> encoded_data1{};
|
||||
std::array<uint8_t, 8> encoded_data2{};
|
||||
|
||||
// Encode with TChunk == uint8_t
|
||||
etl::manchester::encode(data, encoded_data1);
|
||||
|
||||
// Encode with TChunk == uint32_t
|
||||
etl::manchester::encode<uint32_t>(data, encoded_data2);
|
||||
```
|
||||
|
||||
### Decoding Functions
|
||||
|
||||
#### Decode single value
|
||||
|
||||
```cpp
|
||||
template <typename TEncoded>
|
||||
static ETL_CONSTEXPR14 typename decoded<TEncoded>::type decode(TEncoded encoded)
|
||||
```
|
||||
|
||||
Decodes a single Manchester encoded value.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `encoded`: The encoded value to decode (`uint16_t`, `uint32_t`, or `uint64_t`)
|
||||
|
||||
**Returns:**
|
||||
|
||||
- The Manchester decoded value (half the bit width of input)
|
||||
|
||||
**Example:**
|
||||
|
||||
```cpp
|
||||
uint8_t decoded = etl::manchester::decode(0x5A5A);
|
||||
```
|
||||
|
||||
#### Decode range
|
||||
|
||||
```cpp
|
||||
template <typename TChunk = typename private_manchester::encoded<uint_least8_t>::type>
|
||||
static ETL_CONSTEXPR14 void decode(etl::span<const uint_least8_t> encoded,
|
||||
etl::span<uint_least8_t> decoded)
|
||||
```
|
||||
|
||||
Decodes a span of Manchester encoded data.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `encoded`: Source data to decode
|
||||
- `decoded`: Destination for decoded data (must be half the size of `encoded`)
|
||||
|
||||
**Template Parameters:**
|
||||
|
||||
- `TChunk`: Chunk type for decoding (`uint16_t`, `uint32_t`, or `uint64_t`)
|
||||
|
||||
**Example:**
|
||||
|
||||
```cpp
|
||||
std::array<uint8_t, 8> encoded = {/* ... */};
|
||||
std::array<uint8_t, 4> decoded1 {};
|
||||
std::array<uint8_t, 4> decoded2 {};
|
||||
|
||||
// Decode with TChunk == uint16_t
|
||||
etl::manchester::decode(encoded, decoded1);
|
||||
|
||||
// Decode with TChunk == uint64_t
|
||||
etl::manchester::decode<uint64_t>(encoded, decoded2);
|
||||
```
|
||||
|
||||
### Validation Functions
|
||||
|
||||
#### Single value
|
||||
|
||||
```cpp
|
||||
template <typename TChunk>
|
||||
static ETL_CONSTEXPR14 bool is_valid(TChunk encoded)
|
||||
```
|
||||
|
||||
Validates that a single value contains valid Manchester encoded data.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `encoded`: The encoded value to validate
|
||||
|
||||
**Returns:**
|
||||
|
||||
- `true` if the value contains valid Manchester encoded data, `false` otherwise
|
||||
|
||||
**Example:**
|
||||
|
||||
```cpp
|
||||
bool valid = etl::manchester::is_valid(0x5A5A);
|
||||
```
|
||||
|
||||
#### Range
|
||||
|
||||
```cpp
|
||||
static ETL_CONSTEXPR14 bool is_valid(etl::span<const uint_least8_t> encoded)
|
||||
```
|
||||
|
||||
Validates that a range contains valid Manchester encoded data.
|
||||
|
||||
**Parameters:**
|
||||
|
||||
- `encoded`: The range of encoded data to validate
|
||||
|
||||
**Returns:**
|
||||
|
||||
- `true` if all data is valid Manchester encoding, `false` otherwise
|
||||
|
||||
**Example:**
|
||||
|
||||
```cpp
|
||||
std::array<uint8_t, 8> encoded_data = {/* ... */};
|
||||
bool valid = etl::manchester::is_valid(encoded_data);
|
||||
```
|
||||
|
||||
## Supported Types
|
||||
|
||||
### Input/chunk types for encoding
|
||||
|
||||
- `uint8_t` → `uint16_t` (if 8-bit types are supported)
|
||||
- `uint16_t` → `uint32_t`
|
||||
- `uint32_t` → `uint64_t` (if 64-bit types are supported)
|
||||
|
||||
### Input/chunk types for decoding
|
||||
|
||||
- `uint16_t` → `uint8_t` (if 8-bit types are supported)
|
||||
- `uint32_t` → `uint16_t`
|
||||
- `uint64_t` → `uint32_t` (if 64-bit types are supported)
|
||||
328
docs/ranges.md
Normal file
328
docs/ranges.md
Normal file
@ -0,0 +1,328 @@
|
||||
# ETL C++17 Ranges Implementation
|
||||
|
||||
## Overview
|
||||
|
||||
The Embedded Template Library provides a C++17-compatible implementation of ranges, inspired by the C++20 ranges library. This implementation enables range-based algorithms and views for embedded and resource-constrained environments where full C++20 support may not be available.
|
||||
|
||||
## Features
|
||||
|
||||
- **Ranges**: Provides range types and iterator wrappers for composing operations over sequences.
|
||||
- **Views**: Includes lightweight, composable views such as `filter_view`, `transform_view`, and `subrange`.
|
||||
- **Algorithms**: Supports range-based algorithms compatible with ETL containers and standard containers.
|
||||
- **Compatibility**: Designed for C++17, with minimal dependencies and no reliance on C++20 features.
|
||||
|
||||
## Getting Started
|
||||
|
||||
Include the main header in your project:
|
||||
|
||||
```cpp
|
||||
#include <etl/ranges.h>
|
||||
```
|
||||
|
||||
### Example Usage
|
||||
|
||||
#### Using Ranges
|
||||
|
||||
```cpp
|
||||
#include <etl/print.h>
|
||||
#include <etl/ranges.h>
|
||||
#include <etl/vector.h>
|
||||
|
||||
...
|
||||
|
||||
etl::vector<int, 10> data = {6, 1, 3, 3, 2};
|
||||
etl::ranges::sort(data);
|
||||
etl::ranges::for_each(data, [](const int& i){etl::print(" {}", i);});
|
||||
```
|
||||
|
||||
Output:
|
||||
```text
|
||||
1 2 3 3 6
|
||||
```
|
||||
|
||||
#### Using Views
|
||||
|
||||
```cpp
|
||||
#include <etl/print.h>
|
||||
#include <etl/ranges.h>
|
||||
#include <etl/vector.h>
|
||||
|
||||
...
|
||||
|
||||
etl::vector<int, 10> data = {1, 2, 3, 4, 5};
|
||||
auto even = [](int v) { return v % 2 == 0; };
|
||||
auto filtered = etl::ranges::filter_view(data, even);
|
||||
etl::ranges::for_each(filtered, [](const int& i){etl::print(" {}", i);});
|
||||
```
|
||||
|
||||
Output:
|
||||
```text
|
||||
2 4
|
||||
```
|
||||
|
||||
#### Transforming Elements
|
||||
|
||||
```cpp
|
||||
#include <etl/print.h>
|
||||
#include <etl/ranges.h>
|
||||
#include <etl/vector.h>
|
||||
|
||||
...
|
||||
|
||||
etl::vector<int, 10> data = {1, 2, 3, 4, 5};
|
||||
auto squared = etl::ranges::transform_view(data, [](int v) { return v * v; });
|
||||
etl::ranges::for_each(squared, [](const int& i){etl::print(" {}", i);});
|
||||
```
|
||||
|
||||
Output:
|
||||
```text
|
||||
1 4 9 16 25
|
||||
```
|
||||
|
||||
#### Composition
|
||||
|
||||
Views can be composed using the pipe (`|`) operator, allowing you to chain multiple transformations in a readable, left-to-right style:
|
||||
|
||||
```cpp
|
||||
#include <etl/print.h>
|
||||
#include <etl/ranges.h>
|
||||
#include <etl/vector.h>
|
||||
|
||||
namespace views = etl::ranges::views;
|
||||
|
||||
...
|
||||
|
||||
etl::vector<int, 10> data = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||
|
||||
auto result = data
|
||||
| views::filter([](const int& v) { return v % 2 == 0; })
|
||||
| views::transform([](const int& v) { return v * v; });
|
||||
|
||||
etl::ranges::for_each(result, [](const int& i){ etl::print(" {}", i); });
|
||||
```
|
||||
|
||||
Output:
|
||||
```text
|
||||
4 16 36 64 100
|
||||
```
|
||||
|
||||
This first filters the even numbers and then squares them. Each `|` passes the result of the previous stage as input to the next view adaptor.
|
||||
|
||||
## Supported Views
|
||||
|
||||
All views are in the `etl::ranges` namespace. Corresponding range adaptor objects are available in `etl::ranges::views`.
|
||||
|
||||
### Range Factories
|
||||
|
||||
| View | `views::` adaptor | Description |
|
||||
|---|---|---|
|
||||
| `empty_view<T>` | `views::empty<T>` | A view with no elements. |
|
||||
| `single_view` | `views::single` | A view containing exactly one element. |
|
||||
| `iota_view` | `views::iota` | A view of sequentially increasing values. |
|
||||
| `repeat_view` | `views::repeat` | A view that repeats a value a given number of times. |
|
||||
|
||||
### Range Adaptors
|
||||
|
||||
| View | `views::` adaptor | Description |
|
||||
|---|---|---|
|
||||
| `ref_view` | `views::ref` | A non-owning view that wraps a reference to a range. |
|
||||
| `owning_view` | `views::owning` | A view that takes ownership of a range via move. |
|
||||
| — | `views::all` | Returns the range itself (if already a view), a `ref_view`, or an `owning_view`. |
|
||||
| `filter_view` | `views::filter` | Filters elements based on a predicate. |
|
||||
| `transform_view` | `views::transform` | Applies a transformation to each element. |
|
||||
| `as_rvalue_view` | `views::as_rvalue` | Casts each element to an rvalue reference. |
|
||||
| `as_const_view` | `views::as_const` | Provides a const view of the elements. |
|
||||
| `cache_latest_view` | `views::cache_latest` | Caches the most recently accessed element (avoids recomputation). |
|
||||
| `reverse_view` | `views::reverse` | Reverses the order of elements. |
|
||||
| `drop_view` | `views::drop` | Skips the first *n* elements. |
|
||||
| `drop_while_view` | `views::drop_while` | Skips leading elements while a predicate is true. |
|
||||
| `take_view` | `views::take` | Takes the first *n* elements. |
|
||||
| `take_while_view` | `views::take_while` | Takes leading elements while a predicate is true. |
|
||||
| `join_view` | `views::join` | Flattens a range of ranges into a single range. |
|
||||
| `join_with_view` | `views::join_with` | Flattens a range of ranges, inserting a delimiter between each. |
|
||||
| `split_view` | `views::split` | Splits a range into subranges around a delimiter pattern. |
|
||||
| `lazy_split_view` | `views::lazy_split` | Lazily splits a range by a pattern (inner ranges discovered on iteration). |
|
||||
| — | `views::counted` | Creates a view of *n* elements starting from an iterator. |
|
||||
| `concat_view` | `views::concat` | Concatenates multiple ranges into a single view. |
|
||||
| `zip_view` | `views::zip` | Zips multiple ranges into a view of tuples (length of shortest range). |
|
||||
| `zip_transform_view` | `views::zip_transform` | Zips multiple ranges and applies a function to each tuple of elements. |
|
||||
| `common_view` | `views::common` | Adapts a view so that its iterator and sentinel types are the same. |
|
||||
| `enumerate_view` | `views::enumerate` | Pairs each element with its index, producing tuples of (index, value). |
|
||||
| `elements_view` | `views::elements` | Extracts the *N*-th element from each tuple-like value. |
|
||||
| `keys_view` | `views::keys` | Alias for `elements_view` with *N*=0 (extracts first element of pairs/tuples). |
|
||||
| `values_view` | `views::values` | Alias for `elements_view` with *N*=1 (extracts second element of pairs/tuples). |
|
||||
| `adjacent_view` | `views::adjacent` | Produces a view of tuples of *N* adjacent elements (sliding window of tuples). |
|
||||
| — | `views::pairwise` | Alias for `views::adjacent<2>`. |
|
||||
| `adjacent_transform_view` | `views::adjacent_transform` | Applies a function to each group of *N* adjacent elements. |
|
||||
| — | `views::pairwise_transform` | Alias for `views::adjacent_transform<2>`. |
|
||||
| `chunk_view` | `views::chunk` | Splits a range into non-overlapping chunks of a given size. |
|
||||
| `slide_view` | `views::slide` | Produces overlapping subranges (sliding windows) of a given size. |
|
||||
| `chunk_by_view` | `views::chunk_by` | Splits a range into subranges between adjacent elements where a predicate is false. |
|
||||
| `stride_view` | `views::stride` | Yields every *N*-th element from the underlying range. |
|
||||
| `cartesian_product_view` | `views::cartesian_product` | Produces the Cartesian product of multiple ranges as a view of tuples. |
|
||||
| `to_input_view` | `views::to_input` | Downgrades iterator category to input iterator while preserving elements and order. |
|
||||
| `subrange` | — | Represents a sub-range defined by an iterator–sentinel pair. |
|
||||
|
||||
All views support range-based for-loop iteration and can be composed with the pipe (`|`) operator.
|
||||
|
||||
## Supported Algorithms
|
||||
|
||||
All algorithms are callable objects in the `etl::ranges` namespace. Each supports both an iterator-pair overload and a range overload (where applicable), and most accept optional projection and comparator arguments.
|
||||
|
||||
### Non-modifying Sequence Operations
|
||||
|
||||
| Algorithm | Description |
|
||||
|---|---|
|
||||
| `for_each` | Applies a function to each element in a range. |
|
||||
| `for_each_n` | Applies a function to the first *n* elements. |
|
||||
| `find` | Finds the first element equal to a value. |
|
||||
| `find_if` | Finds the first element satisfying a predicate. |
|
||||
| `find_if_not` | Finds the first element not satisfying a predicate. |
|
||||
| `find_end` | Finds the last occurrence of a subsequence. |
|
||||
| `find_first_of` | Finds the first element matching any in a second range. |
|
||||
| `adjacent_find` | Finds the first pair of adjacent equal elements. |
|
||||
| `count` | Counts elements equal to a value. |
|
||||
| `count_if` | Counts elements satisfying a predicate. |
|
||||
| `all_of` | Checks if all elements satisfy a predicate. |
|
||||
| `any_of` | Checks if any element satisfies a predicate. |
|
||||
| `none_of` | Checks if no elements satisfy a predicate. |
|
||||
| `mismatch` | Finds the first position where two ranges differ. |
|
||||
| `equal` | Checks if two ranges are equal. |
|
||||
| `is_permutation` | Checks if one range is a permutation of another. |
|
||||
| `search` | Searches for the first occurrence of a subsequence. |
|
||||
| `search_n` | Searches for *n* consecutive copies of a value. |
|
||||
| `starts_with` | Checks if a range starts with another range. |
|
||||
| `ends_with` | Checks if a range ends with another range. |
|
||||
| `lexicographical_compare` | Compares two ranges lexicographically. |
|
||||
|
||||
### Fold Operations
|
||||
|
||||
| Algorithm | Description |
|
||||
|---|---|
|
||||
| `fold_left` | Left-folds elements with a binary operation. |
|
||||
| `fold_left_with_iter` | Left-folds, returning both the result and an iterator. |
|
||||
| `fold_left_first` | Left-folds using the first element as the initial value. |
|
||||
| `fold_left_first_with_iter` | Like `fold_left_first`, also returning an iterator. |
|
||||
| `fold_right` | Right-folds elements with a binary operation. |
|
||||
| `fold_right_last` | Right-folds using the last element as the initial value. |
|
||||
|
||||
### Modifying Sequence Operations
|
||||
|
||||
| Algorithm | Description |
|
||||
|---|---|
|
||||
| `copy` | Copies elements to a destination range. |
|
||||
| `copy_n` | Copies *n* elements to a destination range. |
|
||||
| `copy_if` | Copies elements satisfying a predicate. |
|
||||
| `copy_backward` | Copies elements backwards to a destination range. |
|
||||
| `move` | Moves elements to a destination range. |
|
||||
| `move_backward` | Moves elements backwards to a destination range. |
|
||||
| `swap_ranges` | Swaps elements between two ranges. |
|
||||
| `replace` | Replaces elements equal to a value. |
|
||||
| `replace_if` | Replaces elements satisfying a predicate. |
|
||||
| `replace_copy` | Copies, replacing elements equal to a value. |
|
||||
| `replace_copy_if` | Copies, replacing elements satisfying a predicate. |
|
||||
| `remove` | Removes elements equal to a value. |
|
||||
| `remove_if` | Removes elements satisfying a predicate. |
|
||||
| `remove_copy` | Copies, omitting elements equal to a value. |
|
||||
| `fill` | Fills a range with a value. |
|
||||
| `fill_n` | Fills *n* elements with a value. |
|
||||
| `generate` | Assigns each element the result of a generator function. |
|
||||
| `generate_n` | Assigns *n* elements the result of a generator function. |
|
||||
| `iota` | Fills a range with sequentially increasing values. |
|
||||
| `unique` | Removes consecutive duplicate elements. |
|
||||
| `unique_copy` | Copies, removing consecutive duplicates. |
|
||||
| `transform` | Applies a transformation to each element. |
|
||||
| `reverse` | Reverses the order of elements. |
|
||||
| `reverse_copy` | Copies elements in reverse order. |
|
||||
| `rotate` | Rotates elements in a range. |
|
||||
| `rotate_copy` | Copies elements with rotation. |
|
||||
| `shift_left` | Shifts elements to the left. |
|
||||
| `shift_right` | Shifts elements to the right. |
|
||||
| `shuffle` | Randomly reorders elements. |
|
||||
| `sample` | Selects *n* random elements from a range. |
|
||||
|
||||
### Sorting Operations
|
||||
|
||||
| Algorithm | Description |
|
||||
|---|---|
|
||||
| `sort` | Sorts elements in a range. |
|
||||
| `stable_sort` | Sorts elements preserving relative order of equivalent elements. |
|
||||
| `partial_sort` | Partially sorts a range so that the first *n* elements are sorted. |
|
||||
| `partial_sort_copy` | Copies and partially sorts elements. |
|
||||
| `nth_element` | Partially sorts so that the *n*-th element is in its sorted position. |
|
||||
| `is_sorted` | Checks if a range is sorted. |
|
||||
| `is_sorted_until` | Finds the first unsorted element. |
|
||||
|
||||
### Partitioning Operations
|
||||
|
||||
| Algorithm | Description |
|
||||
|---|---|
|
||||
| `partition` | Partitions elements by a predicate. |
|
||||
| `stable_partition` | Partitions elements, preserving relative order. |
|
||||
| `is_partitioned` | Checks if a range is partitioned. |
|
||||
| `partition_copy` | Copies elements into two ranges based on a predicate. |
|
||||
| `partition_point` | Finds the partition point. |
|
||||
|
||||
### Binary Search (on sorted ranges)
|
||||
|
||||
| Algorithm | Description |
|
||||
|---|---|
|
||||
| `lower_bound` | Finds the first element not less than a value. |
|
||||
| `upper_bound` | Finds the first element greater than a value. |
|
||||
| `equal_range` | Returns the range of elements equal to a value. |
|
||||
| `binary_search` | Checks if a sorted range contains a value. |
|
||||
|
||||
### Set Operations (on sorted ranges)
|
||||
|
||||
| Algorithm | Description |
|
||||
|---|---|
|
||||
| `includes` | Checks if one sorted range includes another. |
|
||||
| `merge` | Merges two sorted ranges. |
|
||||
| `inplace_merge` | Merges two consecutive sorted sub-ranges in place. |
|
||||
| `set_union` | Computes the union of two sorted ranges. |
|
||||
| `set_intersection` | Computes the intersection of two sorted ranges. |
|
||||
| `set_difference` | Computes the difference of two sorted ranges. |
|
||||
| `set_symmetric_difference` | Computes the symmetric difference of two sorted ranges. |
|
||||
|
||||
### Heap Operations
|
||||
|
||||
| Algorithm | Description |
|
||||
|---|---|
|
||||
| `make_heap` | Creates a heap from a range. |
|
||||
| `push_heap` | Pushes an element onto a heap. |
|
||||
| `pop_heap` | Pops the top element from a heap. |
|
||||
| `sort_heap` | Sorts a heap into a sorted range. |
|
||||
| `is_heap` | Checks if a range is a heap. |
|
||||
| `is_heap_until` | Finds the first element that breaks the heap property. |
|
||||
|
||||
### Min/Max Operations
|
||||
|
||||
| Algorithm | Description |
|
||||
|---|---|
|
||||
| `min` | Returns the smaller of two values or the smallest in an initializer list. |
|
||||
| `min_element` | Finds the smallest element in a range. |
|
||||
| `max` | Returns the larger of two values or the largest in an initializer list. |
|
||||
| `max_element` | Finds the largest element in a range. |
|
||||
| `minmax` | Returns the smaller and larger of two values. |
|
||||
| `minmax_element` | Finds both the smallest and largest elements in a range. |
|
||||
| `clamp` | Clamps a value between a minimum and maximum. |
|
||||
|
||||
### Permutation Operations
|
||||
|
||||
| Algorithm | Description |
|
||||
|---|---|
|
||||
| `next_permutation` | Generates the next lexicographic permutation. |
|
||||
| `prev_permutation` | Generates the previous lexicographic permutation. |
|
||||
|
||||
|
||||
## Reference
|
||||
|
||||
For reference to the STD implementation, see also:
|
||||
|
||||
- Algorithms: https://en.cppreference.com/w/cpp/algorithm.html
|
||||
- Ranges/Views: https://en.cppreference.com/w/cpp/ranges.html
|
||||
|
||||
## Limitations
|
||||
|
||||
- Not all C++20 range features are available due to limitation to C++17. Especially C++20 concepts are not used.
|
||||
- Designed for ETL containers but can work with standard containers if compatible with ETL's iterator requirements.
|
||||
100
docs/source-formatting.md
Normal file
100
docs/source-formatting.md
Normal file
@ -0,0 +1,100 @@
|
||||
# Source Formatting
|
||||
|
||||
This project uses **clang-format** (version 18) to enforce a consistent coding style
|
||||
for C and C++ source files. For convenience, **treefmt** is also configured as a
|
||||
single-command wrapper that discovers and formats every file in the tree.
|
||||
|
||||
---
|
||||
|
||||
## clang-format
|
||||
|
||||
### Configuration file
|
||||
|
||||
The formatting rules live in [`.clang-format`](../.clang-format) at the repository
|
||||
root. The style is based on **LLVM**.
|
||||
|
||||
See the `.clang-format` file itself for the complete list.
|
||||
|
||||
### Version requirement
|
||||
|
||||
clang-format **18** is required.
|
||||
The helper script [`scripts/clang-format-wrapper`](../scripts/clang-format-wrapper)
|
||||
automatically resolves the correct binary: it first looks for `clang-format-18` on
|
||||
`PATH`, then falls back to `clang-format` and verifies that its major version is 18.
|
||||
All other tooling in the repo calls this wrapper instead of `clang-format` directly.
|
||||
|
||||
### Running clang-format manually
|
||||
|
||||
Format every tracked source file in the repository:
|
||||
|
||||
```bash
|
||||
git ls-files -z \
|
||||
'*.c' '*.cc' '*.cpp' \
|
||||
'*.h' '*.hh' '*.hpp' \
|
||||
':(exclude)include/etl/generators/*' \
|
||||
':(exclude)include/etl/private/*_cpp03.h' | xargs -0 scripts/clang-format-wrapper -i --verbose --style=file
|
||||
```
|
||||
|
||||
You can also format individual files directly:
|
||||
|
||||
```bash
|
||||
scripts/clang-format-wrapper -i --style=file path/to/file.cpp
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## treefmt
|
||||
|
||||
[treefmt](https://treefmt.com) is a language-agnostic source-tree formatter.
|
||||
It reads a single configuration file and dispatches each file to the appropriate
|
||||
formatter. In this project, it delegates all C/C++ formatting to the same
|
||||
`clang-format-wrapper` described above.
|
||||
|
||||
In comparison to calling clang-format directly, it brings a significant speedup.
|
||||
|
||||
### Configuration file
|
||||
|
||||
The configuration lives in [`.treefmt.toml`](../.treefmt.toml) at the repository root.
|
||||
|
||||
### Installing treefmt
|
||||
|
||||
treefmt is a standalone Go binary. Install it with any of:
|
||||
|
||||
```bash
|
||||
# Using the official install script
|
||||
curl -fsSL https://raw.githubusercontent.com/numtide/treefmt/main/install.sh | bash
|
||||
|
||||
# Or via Homebrew
|
||||
brew install treefmt
|
||||
|
||||
# Or via Nix
|
||||
nix profile install nixpkgs#treefmt2
|
||||
```
|
||||
|
||||
See the [treefmt documentation](https://treefmt.com) for more options.
|
||||
|
||||
### Running treefmt
|
||||
|
||||
From the repository root:
|
||||
|
||||
```bash
|
||||
# Format everything
|
||||
treefmt
|
||||
|
||||
# Check formatting without modifying files (useful in CI)
|
||||
treefmt --fail-on-change
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Excluded paths
|
||||
|
||||
`.treefmt.toml` excludes generated files under
|
||||
`include/etl/generators/`. Do **not** format those files manually via clang-format or treefmt.
|
||||
|
||||
## Pre-commit
|
||||
|
||||
Before submitting a PR / contribution, run `treefmt --fail-on-change` to catch
|
||||
unformatted code before merge.
|
||||
|
||||
Alternatively, a plain `treefmt` automatically fixes any issues.
|
||||
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,6 @@
|
||||
#define ETL_CALLBACK_TIMER_USE_ATOMIC_LOCK
|
||||
#define ETL_NO_STL
|
||||
|
||||
//#include "etl/profiles/auto.h"
|
||||
// #include "etl/profiles/auto.h"
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//#if (__cplusplus < 201103L)
|
||||
// #if (__cplusplus < 201103L)
|
||||
extern "C"
|
||||
{
|
||||
//#endif
|
||||
#include "Board_LED.h" // ::Board Support:LED
|
||||
// #endif
|
||||
#include "Board_Buttons.h" // ::Board Support:Buttons
|
||||
//#if (__cplusplus < 201103L)
|
||||
#include "Board_LED.h" // ::Board Support:LED
|
||||
// #if (__cplusplus < 201103L)
|
||||
}
|
||||
//#endif
|
||||
// #endif
|
||||
|
||||
#include "stm32f4xx.h" // Device header
|
||||
#include "stm32f4xx.h" // Device header
|
||||
|
||||
#include "etl/function.h"
|
||||
#include "etl/callback_timer.h"
|
||||
#include "etl/vector.h"
|
||||
#include "etl/iterator.h"
|
||||
#include "etl/binary.h"
|
||||
#include "etl/callback_timer.h"
|
||||
#include "etl/function.h"
|
||||
#include "etl/iterator.h"
|
||||
#include "etl/vector.h"
|
||||
|
||||
struct FP
|
||||
{
|
||||
@ -28,7 +28,7 @@ static etl::vector<FP, 10> power_callbacks;
|
||||
|
||||
void register_poweroff_callback(void (*function)())
|
||||
{
|
||||
FP fp = { function };
|
||||
FP fp = {function};
|
||||
power_callbacks.push_back(fp);
|
||||
}
|
||||
|
||||
@ -45,38 +45,38 @@ etl::timer::id::type swap_timers;
|
||||
* SystemCoreClockConfigure: configure SystemCoreClock using HSI
|
||||
(HSE is not populated on Nucleo board)
|
||||
*----------------------------------------------------------------------------*/
|
||||
void SystemCoreClockConfigure(void) {
|
||||
void SystemCoreClockConfigure(void)
|
||||
{
|
||||
RCC->CR |= ((uint32_t)RCC_CR_HSION); // Enable HSI
|
||||
while ((RCC->CR & RCC_CR_HSIRDY) == 0); // Wait for HSI Ready
|
||||
|
||||
RCC->CR |= ((uint32_t)RCC_CR_HSION); // Enable HSI
|
||||
while ((RCC->CR & RCC_CR_HSIRDY) == 0); // Wait for HSI Ready
|
||||
RCC->CFGR = RCC_CFGR_SW_HSI; // HSI is system clock
|
||||
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI); // Wait for HSI used as system clock
|
||||
|
||||
RCC->CFGR = RCC_CFGR_SW_HSI; // HSI is system clock
|
||||
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_HSI); // Wait for HSI used as system clock
|
||||
FLASH->ACR = FLASH_ACR_PRFTEN; // Enable Prefetch Buffer
|
||||
FLASH->ACR |= FLASH_ACR_ICEN; // Instruction cache enable
|
||||
FLASH->ACR |= FLASH_ACR_DCEN; // Data cache enable
|
||||
FLASH->ACR |= FLASH_ACR_LATENCY_5WS; // Flash 5 wait state
|
||||
|
||||
FLASH->ACR = FLASH_ACR_PRFTEN; // Enable Prefetch Buffer
|
||||
FLASH->ACR |= FLASH_ACR_ICEN; // Instruction cache enable
|
||||
FLASH->ACR |= FLASH_ACR_DCEN; // Data cache enable
|
||||
FLASH->ACR |= FLASH_ACR_LATENCY_5WS; // Flash 5 wait state
|
||||
RCC->CFGR |= RCC_CFGR_HPRE_DIV1; // HCLK = SYSCLK
|
||||
RCC->CFGR |= RCC_CFGR_PPRE1_DIV4; // APB1 = HCLK/4
|
||||
RCC->CFGR |= RCC_CFGR_PPRE2_DIV2; // APB2 = HCLK/2
|
||||
|
||||
RCC->CFGR |= RCC_CFGR_HPRE_DIV1; // HCLK = SYSCLK
|
||||
RCC->CFGR |= RCC_CFGR_PPRE1_DIV4; // APB1 = HCLK/4
|
||||
RCC->CFGR |= RCC_CFGR_PPRE2_DIV2; // APB2 = HCLK/2
|
||||
|
||||
RCC->CR &= ~RCC_CR_PLLON; // Disable PLL
|
||||
RCC->CR &= ~RCC_CR_PLLON; // Disable PLL
|
||||
|
||||
// PLL configuration: VCO = HSI/M * N, Sysclk = VCO/P
|
||||
RCC->PLLCFGR = ( 16ul | // PLL_M = 16
|
||||
(384ul << 6U) | // PLL_N = 384
|
||||
( 3ul << 16U) | // PLL_P = 8
|
||||
(RCC_PLLCFGR_PLLSRC_HSI) | // PLL_SRC = HSI
|
||||
( 8ul << 24U) ); // PLL_Q = 8
|
||||
RCC->PLLCFGR = (16ul | // PLL_M = 16
|
||||
(384ul << 6U) | // PLL_N = 384
|
||||
(3ul << 16U) | // PLL_P = 8
|
||||
(RCC_PLLCFGR_PLLSRC_HSI) | // PLL_SRC = HSI
|
||||
(8ul << 24U)); // PLL_Q = 8
|
||||
|
||||
RCC->CR |= RCC_CR_PLLON; // Enable PLL
|
||||
while((RCC->CR & RCC_CR_PLLRDY) == 0) __NOP(); // Wait till PLL is ready
|
||||
RCC->CR |= RCC_CR_PLLON; // Enable PLL
|
||||
while ((RCC->CR & RCC_CR_PLLRDY) == 0) __NOP(); // Wait till PLL is ready
|
||||
|
||||
RCC->CFGR &= ~RCC_CFGR_SW; // Select PLL as system clock source
|
||||
RCC->CFGR |= RCC_CFGR_SW_PLL;
|
||||
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); // Wait till PLL is system clock src
|
||||
RCC->CFGR &= ~RCC_CFGR_SW; // Select PLL as system clock source
|
||||
RCC->CFGR |= RCC_CFGR_SW_PLL;
|
||||
while ((RCC->CFGR & RCC_CFGR_SWS) != RCC_CFGR_SWS_PLL); // Wait till PLL is system clock src
|
||||
}
|
||||
|
||||
void StartTimers()
|
||||
@ -123,7 +123,7 @@ void LedToggle()
|
||||
|
||||
int main()
|
||||
{
|
||||
SystemCoreClockConfigure(); // configure HSI as System Clock
|
||||
SystemCoreClockConfigure(); // configure HSI as System Clock
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
LED_Initialize();
|
||||
@ -131,10 +131,10 @@ int main()
|
||||
|
||||
// The LEDs will start flashing fast after 2 seconds.
|
||||
// After another 5 seconds they will start flashing slower.
|
||||
short_toggle = callback_timer.register_timer(LedToggle, 50, etl::timer::mode::REPEATING);
|
||||
long_toggle = callback_timer.register_timer(LedToggle, 100, etl::timer::mode::REPEATING);
|
||||
short_toggle = callback_timer.register_timer(LedToggle, 50, etl::timer::mode::REPEATING);
|
||||
long_toggle = callback_timer.register_timer(LedToggle, 100, etl::timer::mode::REPEATING);
|
||||
start_timers = callback_timer.register_timer(StartTimers, 2000, etl::timer::mode::SINGLE_SHOT);
|
||||
swap_timers = callback_timer.register_timer(SwapTimers, 1500, etl::timer::mode::SINGLE_SHOT);
|
||||
swap_timers = callback_timer.register_timer(SwapTimers, 1500, etl::timer::mode::SINGLE_SHOT);
|
||||
|
||||
SysTick_Config(SystemCoreClock / 1000);
|
||||
|
||||
@ -152,7 +152,7 @@ extern "C"
|
||||
{
|
||||
void SysTick_Handler()
|
||||
{
|
||||
const uint32_t TICK = 1U;
|
||||
const uint32_t TICK = 1U;
|
||||
static uint32_t nticks = TICK;
|
||||
|
||||
if (callback_timer.tick(nticks))
|
||||
|
||||
@ -11,8 +11,8 @@ enum VectorId
|
||||
USART1_IRQ_HANDLER = 52,
|
||||
USART2_IRQ_HANDLER = 53,
|
||||
VECTOR_ID_END,
|
||||
VECTOR_ID_OFFSET = TIM1_CC_IRQ_HANDLER,
|
||||
VECTOR_ID_RANGE = VECTOR_ID_END - VECTOR_ID_OFFSET
|
||||
VECTOR_ID_OFFSET = TIM1_CC_IRQ_HANDLER,
|
||||
VECTOR_ID_RANGE = VECTOR_ID_END - VECTOR_ID_OFFSET
|
||||
};
|
||||
|
||||
typedef etl::delegate_service<VECTOR_ID_RANGE, VECTOR_ID_OFFSET> InterruptVectors;
|
||||
@ -91,8 +91,8 @@ public:
|
||||
|
||||
// Constructor.
|
||||
Uart(int port_id, size_t interruptId)
|
||||
: port_id(port_id),
|
||||
callback(etl::delegate<void(size_t)>::create<Uart, &Uart::InterruptHandler>(*this))
|
||||
: port_id(port_id)
|
||||
, callback(etl::delegate<void(size_t)>::create<Uart, &Uart::InterruptHandler>(*this))
|
||||
{
|
||||
GetInterruptVectorsInstance().register_delegate(interruptId, callback);
|
||||
}
|
||||
@ -119,7 +119,8 @@ Uart uart1(0, USART1_IRQ_HANDLER);
|
||||
Uart uart2(1, USART2_IRQ_HANDLER);
|
||||
|
||||
// Declare a global callback for the timer.
|
||||
// Uses the most efficient callback type for a class, as everything is known at compile time.
|
||||
// Uses the most efficient callback type for a class, as everything is known at
|
||||
// compile time.
|
||||
etl::delegate<void(size_t)> timer_member_callback = etl::delegate<void(size_t)>::create<Timer, timer, &Timer::InterruptHandler>();
|
||||
|
||||
// Declare the callbacks for the free functions.
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "etl/function.h"
|
||||
#include "etl/callback_service.h"
|
||||
#include "etl/function.h"
|
||||
|
||||
enum VectorId
|
||||
{
|
||||
@ -11,8 +11,8 @@ enum VectorId
|
||||
USART1_IRQ_HANDLER = 52,
|
||||
USART2_IRQ_HANDLER = 53,
|
||||
VECTOR_ID_END,
|
||||
VECTOR_ID_OFFSET = TIM1_CC_IRQ_HANDLER,
|
||||
VECTOR_ID_RANGE = VECTOR_ID_END - VECTOR_ID_OFFSET
|
||||
VECTOR_ID_OFFSET = TIM1_CC_IRQ_HANDLER,
|
||||
VECTOR_ID_RANGE = VECTOR_ID_END - VECTOR_ID_OFFSET
|
||||
};
|
||||
|
||||
typedef etl::callback_service<VECTOR_ID_RANGE, VECTOR_ID_OFFSET> InterruptVectors;
|
||||
@ -91,8 +91,8 @@ public:
|
||||
|
||||
// Constructor.
|
||||
Uart(int port_id, int interruptId)
|
||||
: port_id(port_id),
|
||||
callback(*this)
|
||||
: port_id(port_id)
|
||||
, callback(*this)
|
||||
{
|
||||
GetInterruptVectorsInstance().register_callback(interruptId, callback);
|
||||
}
|
||||
@ -119,7 +119,8 @@ Uart uart1(0, USART1_IRQ_HANDLER);
|
||||
Uart uart2(1, USART2_IRQ_HANDLER);
|
||||
|
||||
// Declare a global callback for the timer.
|
||||
// Uses the most efficient callback type for a class, as everything is known at compile time.
|
||||
// Uses the most efficient callback type for a class, as everything is known at
|
||||
// compile time.
|
||||
etl::function_imp<Timer, size_t, timer, &Timer::InterruptHandler> timer_member_callback;
|
||||
|
||||
// Declare the callbacks for the free functions.
|
||||
|
||||
@ -1,13 +1,13 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include "etl/mutex.h"
|
||||
#include "etl/message.h"
|
||||
#include "etl/message_router.h"
|
||||
#include "etl/mutex.h"
|
||||
|
||||
//*************************************
|
||||
struct Message1 : public etl::message<1>
|
||||
@ -48,9 +48,7 @@ public:
|
||||
}
|
||||
|
||||
//*****************
|
||||
void on_receive_unknown(const etl::imessage&)
|
||||
{
|
||||
}
|
||||
void on_receive_unknown(const etl::imessage&) {}
|
||||
|
||||
std::string result;
|
||||
|
||||
@ -61,7 +59,7 @@ private:
|
||||
|
||||
//*************************************
|
||||
etl::atomic<bool> start = false;
|
||||
Router router;
|
||||
Router router;
|
||||
|
||||
//*************************************
|
||||
void thread1()
|
||||
@ -106,5 +104,3 @@ int main()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -31,9 +31,9 @@ SOFTWARE.
|
||||
// derived class.
|
||||
//*****************************************************************************
|
||||
|
||||
#include "etl/queue.h"
|
||||
#include "etl/fsm.h"
|
||||
#include "etl/message_packet.h"
|
||||
#include "etl/queue.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -122,7 +122,7 @@ public:
|
||||
while (!queue.empty())
|
||||
{
|
||||
message_packet& packet = queue.front();
|
||||
etl::imessage& msg = packet.get();
|
||||
etl::imessage& msg = packet.get();
|
||||
std::cout << "Processing message " << int(msg.get_message_id()) << std::endl;
|
||||
|
||||
// Call the base class's receive function.
|
||||
@ -258,7 +258,7 @@ int main()
|
||||
State2 state2;
|
||||
|
||||
// The list of states.
|
||||
etl::ifsm_state* state_list[] = { &state1, &state2 };
|
||||
etl::ifsm_state* state_list[] = {&state1, &state2};
|
||||
|
||||
// Define some messages.
|
||||
Message1 m1(1);
|
||||
@ -285,4 +285,3 @@ int main()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
|
||||
#include "etl/queue.h"
|
||||
#include "etl/message_router.h"
|
||||
#include "etl/queue.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -81,7 +81,7 @@ public:
|
||||
while (!queue.empty())
|
||||
{
|
||||
message_packet& packet = queue.front();
|
||||
etl::imessage& msg = packet.get();
|
||||
etl::imessage& msg = packet.get();
|
||||
std::cout << "Processing message " << int(msg.get_message_id()) << std::endl;
|
||||
|
||||
// Call the base class's receive function.
|
||||
@ -146,4 +146,3 @@ int main()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -31,9 +31,9 @@ SOFTWARE.
|
||||
// Experiment with the different scheduling policies.
|
||||
//*****************************************************************************
|
||||
|
||||
#include "etl/function.h"
|
||||
#include "etl/scheduler.h"
|
||||
#include "etl/task.h"
|
||||
#include "etl/function.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
@ -50,13 +50,13 @@ public:
|
||||
: task(1)
|
||||
, work(3)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//*************************************
|
||||
uint32_t task_request_work() const
|
||||
{
|
||||
return work; // How much work do we still have to do? This could be a message queue length.
|
||||
return work; // How much work do we still have to do? This could be a
|
||||
// message queue length.
|
||||
}
|
||||
|
||||
//*************************************
|
||||
@ -83,13 +83,13 @@ public:
|
||||
: task(2)
|
||||
, work(4)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//*************************************
|
||||
uint32_t task_request_work() const
|
||||
{
|
||||
return work; // How much work do we still have to do? This could be a message queue length.
|
||||
return work; // How much work do we still have to do? This could be a
|
||||
// message queue length.
|
||||
}
|
||||
|
||||
//*************************************
|
||||
@ -115,7 +115,6 @@ public:
|
||||
Idle(etl::ischeduler& scheduler_)
|
||||
: scheduler(scheduler_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//*************************************
|
||||
@ -181,4 +180,3 @@ int main()
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -2,18 +2,18 @@
|
||||
// Shared message example
|
||||
//*****************************************************************************
|
||||
|
||||
#include "etl/shared_message.h"
|
||||
#include "etl/message.h"
|
||||
#include "etl/reference_counted_message_pool.h"
|
||||
#include "etl/message_router.h"
|
||||
#include "etl/message_bus.h"
|
||||
#include "etl/fixed_sized_memory_block_allocator.h"
|
||||
#include "etl/message.h"
|
||||
#include "etl/message_bus.h"
|
||||
#include "etl/message_router.h"
|
||||
#include "etl/queue.h"
|
||||
#include "etl/reference_counted_message_pool.h"
|
||||
#include "etl/shared_message.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <atomic>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
constexpr etl::message_router_id_t RouterId1 = 1U;
|
||||
constexpr etl::message_router_id_t RouterId2 = 2U;
|
||||
@ -26,9 +26,8 @@ struct Message1 : public etl::message<1>
|
||||
Message1(std::string s_)
|
||||
: s(s_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::string s;
|
||||
};
|
||||
|
||||
@ -40,10 +39,10 @@ struct Message2 : public etl::message<2>
|
||||
Message2(std::string s_)
|
||||
: s(s_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::string s;
|
||||
|
||||
char data[100];
|
||||
};
|
||||
|
||||
@ -55,7 +54,6 @@ struct Message3 : public etl::message<3>
|
||||
Message3(std::string s_)
|
||||
: s(s_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
std::string s;
|
||||
@ -199,7 +197,7 @@ struct Bus : public etl::message_bus<2U>
|
||||
//*****************************************************************************
|
||||
MessageRouter1 router1;
|
||||
MessageRouter2 router2;
|
||||
Bus bus;
|
||||
Bus bus;
|
||||
|
||||
//*****************************************************************************
|
||||
// The thread safe message pool. Uses atomic uint32_t for counting.
|
||||
@ -230,8 +228,8 @@ private:
|
||||
};
|
||||
|
||||
//*****************************************************************************
|
||||
// The memory block allocator that supplies the pool with memory
|
||||
// to store reference counted messages in.
|
||||
// The memory block allocator that supplies the pool with memory
|
||||
// to store reference counted messages in.
|
||||
|
||||
// The reference counted message parameters type for the messages we will use.
|
||||
using message_parameters_small = MessagePool::pool_message_parameters<Message1, Message3>;
|
||||
@ -243,10 +241,12 @@ constexpr size_t max_alignment_small = message_parameters_small::max_alignment;
|
||||
constexpr size_t max_size_large = message_parameters_large::max_size;
|
||||
constexpr size_t max_alignment_large = message_parameters_large::max_alignment;
|
||||
|
||||
// A fixed memory block allocator for 4 items, using the parameters from the smaller messages.
|
||||
// A fixed memory block allocator for 4 items, using the parameters from the
|
||||
// smaller messages.
|
||||
etl::fixed_sized_memory_block_allocator<max_size_small, max_alignment_small, 4U> memory_allocator;
|
||||
|
||||
// A fixed memory block allocator for 4 items, using the parameters from the larger message.
|
||||
// A fixed memory block allocator for 4 items, using the parameters from the
|
||||
// larger message.
|
||||
etl::fixed_sized_memory_block_allocator<max_size_large, max_alignment_large, 4U> memory_allocator_successor;
|
||||
|
||||
//*****************************************************************************
|
||||
@ -256,8 +256,8 @@ etl::fixed_sized_memory_block_allocator<max_size_large, max_alignment_large, 4U>
|
||||
MessagePool message_pool(memory_allocator);
|
||||
|
||||
//*****************************************************************************
|
||||
// A statically allocated reference counted message that is never allocated or released by a pool.
|
||||
// Contains a copy of Message3("Three").
|
||||
// A statically allocated reference counted message that is never allocated or
|
||||
// released by a pool. Contains a copy of Message3("Three").
|
||||
//*****************************************************************************
|
||||
etl::persistent_message<Message3> pm3(Message3("Three"));
|
||||
|
||||
@ -269,10 +269,15 @@ int main()
|
||||
|
||||
Message1 m1("One");
|
||||
Message2 m2("Two");
|
||||
|
||||
etl::shared_message sm1(message_pool, m1); // Created a shared message by allocating a reference counted message from message_pool containing a copy of m1.
|
||||
etl::shared_message sm2(message_pool, m2); // Created a shared message by allocating a reference counted message from message_pool containing a copy of m2.
|
||||
etl::shared_message sm3(pm3); // Created a shared message from a statically allocated persistent message.
|
||||
|
||||
etl::shared_message sm1(message_pool,
|
||||
m1); // Created a shared message by allocating a reference counted message
|
||||
// from message_pool containing a copy of m1.
|
||||
etl::shared_message sm2(message_pool,
|
||||
m2); // Created a shared message by allocating a reference counted message
|
||||
// from message_pool containing a copy of m2.
|
||||
etl::shared_message sm3(pm3); // Created a shared message from a statically
|
||||
// allocated persistent message.
|
||||
|
||||
bus.subscribe(router1); // Subscribe router1 to the bus.
|
||||
bus.subscribe(router2); // Subscribe router2 to the bus.
|
||||
|
||||
10
examples/UniquePtrWithPool/CmakeLists.txt
Normal file
10
examples/UniquePtrWithPool/CmakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(UniquePtrWithPool LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Add source files
|
||||
add_executable(UniquePtrWithPool Main.cpp)
|
||||
|
||||
target_include_directories(UniquePtrWithPool PRIVATE ../../include)
|
||||
38
examples/UniquePtrWithPool/Main.cpp
Normal file
38
examples/UniquePtrWithPool/Main.cpp
Normal file
@ -0,0 +1,38 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "etl/memory.h"
|
||||
#include "etl/pool.h"
|
||||
|
||||
struct S
|
||||
{
|
||||
S(int a_, double b_)
|
||||
: a(a_)
|
||||
, b(b_)
|
||||
{
|
||||
}
|
||||
|
||||
int a;
|
||||
double b;
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
etl::pool<S, 10> pool;
|
||||
auto pool_deleter = [&pool](auto ptr)
|
||||
{
|
||||
std::cout << "Releasing S(" << ptr->a << ", " << ptr->b << ") back to pool." << std::endl;
|
||||
pool.destroy(ptr);
|
||||
};
|
||||
using Unique = etl::unique_ptr<S, decltype(pool_deleter)>;
|
||||
|
||||
Unique us1(pool.create(1, 2), pool_deleter);
|
||||
std::cout << "Created S(" << us1->a << ", " << us1->b << ") from pool." << std::endl;
|
||||
|
||||
{
|
||||
Unique us2(pool.create(3, 4), pool_deleter);
|
||||
std::cout << "Created S(" << us2->a << ", " << us2->b << ") from pool." << std::endl;
|
||||
}
|
||||
|
||||
Unique us3(pool.create(5, 6), pool_deleter);
|
||||
std::cout << "Created S(" << us3->a << ", " << us3->b << ") from pool." << std::endl;
|
||||
}
|
||||
31
examples/UniquePtrWithPool/UniquePtrWithPool.sln
Normal file
31
examples/UniquePtrWithPool/UniquePtrWithPool.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36408.4 d17.14
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "UniquePtrWithPool", "UniquePtrWithPool.vcxproj", "{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Debug|x64.Build.0 = Debug|x64
|
||||
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Debug|x86.Build.0 = Debug|Win32
|
||||
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Release|x64.ActiveCfg = Release|x64
|
||||
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Release|x64.Build.0 = Release|x64
|
||||
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Release|x86.ActiveCfg = Release|Win32
|
||||
{B9ED2FDF-2529-4315-9AEF-02A98B804DEC}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {D21FA849-65C8-4A81-BD9D-B38BFBD73494}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@ -19,36 +19,36 @@
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>16.0</VCProjectVersion>
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{0523db70-0955-4eb0-a042-04514987a602}</ProjectGuid>
|
||||
<RootNamespace>etlinitialiserlist</RootNamespace>
|
||||
<ProjectGuid>{b9ed2fdf-2529-4315-9aef-02a98b804dec}</ProjectGuid>
|
||||
<RootNamespace>UniquePtrWithPool</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v142</PlatformToolset>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
@ -70,26 +70,13 @@
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;ETL_NO_STL;ETL_IN_UNIT_TEST_INITIALIZER_LIST;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<AdditionalIncludeDirectories>../../include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
@ -104,11 +91,10 @@
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
<AdditionalIncludeDirectories>../../include/;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@ -135,13 +121,11 @@
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\test_initializer_list.cpp" />
|
||||
<ClCompile Include="Main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
@ -88,35 +88,35 @@ public:
|
||||
// Notify observers about a position event.
|
||||
void Position_Event()
|
||||
{
|
||||
Position position = { 100, 200 };
|
||||
Position position = {100, 200};
|
||||
notify_observers(position);
|
||||
}
|
||||
|
||||
// Notify observers about a button up event.
|
||||
void Button_Event_Up()
|
||||
{
|
||||
Button button = { Button::Up };
|
||||
Button button = {Button::Up};
|
||||
notify_observers(button);
|
||||
}
|
||||
|
||||
// Notify observers about a button down event.
|
||||
void Button_Event_Down()
|
||||
{
|
||||
Button button = { Button::Down };
|
||||
Button button = {Button::Down};
|
||||
notify_observers(button);
|
||||
}
|
||||
|
||||
// Notify observers about a wheel up event.
|
||||
void Wheel_Event_Up()
|
||||
{
|
||||
Wheel wheel = { 50 };
|
||||
Wheel wheel = {50};
|
||||
notify_observers(wheel);
|
||||
}
|
||||
|
||||
// Notify observers about a wheel down event.
|
||||
void Wheel_Event_Down()
|
||||
{
|
||||
Wheel wheel = { -25 };
|
||||
Wheel wheel = {-25};
|
||||
notify_observers(wheel);
|
||||
}
|
||||
};
|
||||
@ -137,6 +137,6 @@ int main()
|
||||
mouse_driver.Position_Event();
|
||||
mouse_driver.Wheel_Event_Down();
|
||||
mouse_driver.Wheel_Event_Up();
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
15
hugo/layouts/_default/baseof.html
Normal file
15
hugo/layouts/_default/baseof.html
Normal file
@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>{{ .Title }} | {{ .Site.Title }}</title>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
{{ block "main" . }}{{ end }}
|
||||
</main>
|
||||
|
||||
{{ partial "footer.html" . }}
|
||||
</body>
|
||||
</html>
|
||||
4
hugo/layouts/_partials/footer.html
Normal file
4
hugo/layouts/_partials/footer.html
Normal file
@ -0,0 +1,4 @@
|
||||
<footer style="text-align: center;">
|
||||
<p>© 2014–{{ now.Format "2006" }} {{ .Site.Title }}. All rights reserved.</p>
|
||||
<p></p>
|
||||
</footer>
|
||||
BIN
images/QR Github.png
Normal file
BIN
images/QR Github.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@ -31,19 +31,41 @@ SOFTWARE.
|
||||
#ifndef ETL_ABSOLUTE_INCLUDED
|
||||
#define ETL_ABSOLUTE_INCLUDED
|
||||
|
||||
#include "type_traits.h"
|
||||
#include "platform.h"
|
||||
#include "error_handler.h"
|
||||
#include "integral_limits.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
namespace private_absolute
|
||||
{
|
||||
//*************************************************************************
|
||||
// Non-constexpr function that is never called for valid inputs.
|
||||
// If reached during constant evaluation, the compiler emits an error
|
||||
// because it's not constexpr.
|
||||
// At runtime, triggers the ETL assert handler.
|
||||
//*************************************************************************
|
||||
template <typename T>
|
||||
inline T signed_min_error()
|
||||
{
|
||||
ETL_ASSERT_FAIL(ETL_ERROR_GENERIC("absolute value of minimum signed integer is undefined"));
|
||||
return T(0);
|
||||
}
|
||||
} // namespace private_absolute
|
||||
|
||||
//***************************************************************************
|
||||
// For signed types.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR
|
||||
typename etl::enable_if<etl::is_signed<T>::value, T>::type
|
||||
absolute(T value) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if< etl::is_signed<T>::value && etl::is_integral<T>::value, T>::type absolute(T value)
|
||||
{
|
||||
return (value == etl::integral_limits<T>::min) ? etl::private_absolute::signed_min_error<T>() : static_cast<T>((value < T(0)) ? -value : value);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if< etl::is_signed<T>::value && !etl::is_integral<T>::value, T>::type absolute(T value)
|
||||
ETL_NOEXCEPT
|
||||
{
|
||||
return (value < T(0)) ? -value : value;
|
||||
}
|
||||
@ -52,10 +74,7 @@ namespace etl
|
||||
// For unsigned types.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
|
||||
absolute(T value) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if<etl::is_unsigned<T>::value, T>::type absolute(T value) ETL_NOEXCEPT
|
||||
{
|
||||
return value;
|
||||
}
|
||||
@ -64,18 +83,15 @@ namespace etl
|
||||
// For signed types.
|
||||
// Returns the result as the unsigned type.
|
||||
//***************************************************************************
|
||||
#if ETL_USING_CPP11
|
||||
template <typename T, typename TReturn = typename etl::make_unsigned<T>::type>
|
||||
#else
|
||||
template <typename T, typename TReturn>
|
||||
#endif
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR
|
||||
typename etl::enable_if<etl::is_signed<T>::value, TReturn>::type
|
||||
absolute_unsigned(T value) ETL_NOEXCEPT
|
||||
template <typename T>
|
||||
ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if<etl::is_signed<T>::value, typename etl::make_unsigned<T>::type>::type absolute_unsigned(T value)
|
||||
ETL_NOEXCEPT
|
||||
{
|
||||
typedef typename etl::make_unsigned<T>::type TReturn;
|
||||
|
||||
return (value == etl::integral_limits<T>::min) ? (etl::integral_limits<TReturn>::max / 2U) + 1U
|
||||
: (value < T(0)) ? TReturn(-value) : TReturn(value);
|
||||
: (value < T(0)) ? TReturn(-value)
|
||||
: TReturn(value);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -83,14 +99,10 @@ namespace etl
|
||||
// Returns the result as the unsigned type.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
|
||||
absolute_unsigned(T value) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR typename etl::enable_if<etl::is_unsigned<T>::value, T>::type absolute_unsigned(T value) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::absolute(value);
|
||||
}
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -32,10 +32,10 @@ SOFTWARE.
|
||||
#define ETL_ALIGNMENT_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
#include "static_assert.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <stdint.h>
|
||||
@ -124,28 +124,28 @@ namespace etl
|
||||
|
||||
// Matching alignment.
|
||||
template <size_t Alignment, typename T1, typename... TRest>
|
||||
class type_with_alignment_matcher<true, Alignment, T1, TRest...>
|
||||
class type_with_alignment_matcher<true, Alignment, T1, TRest...>
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
typedef T1 type;
|
||||
};
|
||||
|
||||
// Non-matching alignment
|
||||
template <size_t Alignment, typename T1, typename T2, typename... TRest>
|
||||
class type_with_alignment_matcher <false, Alignment, T1, T2, TRest...>
|
||||
class type_with_alignment_matcher<false, Alignment, T1, T2, TRest...>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename type_with_alignment_matcher < Alignment <= etl::alignment_of<T2>::value , Alignment, T2, TRest... > ::type type;
|
||||
|
||||
typedef typename type_with_alignment_matcher< Alignment <= etl::alignment_of<T2>::value, Alignment, T2, TRest... >::type type;
|
||||
};
|
||||
|
||||
// Non-matching alignment, none left.
|
||||
template <size_t Alignment, typename T1>
|
||||
class type_with_alignment_matcher <false, Alignment, T1>
|
||||
class type_with_alignment_matcher<false, Alignment, T1>
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
typedef char type;
|
||||
};
|
||||
|
||||
@ -153,23 +153,23 @@ namespace etl
|
||||
// Helper.
|
||||
//***************************************************************************
|
||||
template <size_t Alignment, typename T1, typename... T>
|
||||
class type_with_alignment_helper
|
||||
class type_with_alignment_helper
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T1>::value, Alignment, T1, T...>::type type;
|
||||
};
|
||||
#else
|
||||
//***************************************************************************
|
||||
// Matcher.
|
||||
//***************************************************************************
|
||||
template <bool Is_Match, const size_t Alignment, typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
|
||||
template <bool Is_Match, const size_t Alignment, typename T1 = void, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
|
||||
class type_with_alignment_matcher;
|
||||
|
||||
// Matching alignment.
|
||||
template <size_t Alignment, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
|
||||
class type_with_alignment_matcher <true, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
|
||||
class type_with_alignment_matcher<true, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
|
||||
{
|
||||
public:
|
||||
|
||||
@ -178,16 +178,17 @@ namespace etl
|
||||
|
||||
// Non-matching alignment.
|
||||
template <size_t Alignment, typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
|
||||
class type_with_alignment_matcher <false, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
|
||||
class type_with_alignment_matcher<false, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T2>::value, Alignment, T2, T3, T4, T5, T6, T7, T8, void>::type type;
|
||||
typedef
|
||||
typename type_with_alignment_matcher< Alignment <= etl::alignment_of<T2>::value, Alignment, T2, T3, T4, T5, T6, T7, T8, void>::type type;
|
||||
};
|
||||
|
||||
// Non-matching alignment, none left.
|
||||
template <size_t Alignment>
|
||||
class type_with_alignment_matcher <false, Alignment, void, void, void, void, void, void, void, void>
|
||||
class type_with_alignment_matcher<false, Alignment, void, void, void, void, void, void, void, void>
|
||||
{
|
||||
public:
|
||||
|
||||
@ -197,16 +198,16 @@ namespace etl
|
||||
//***************************************************************************
|
||||
// Helper.
|
||||
//***************************************************************************
|
||||
template <size_t Alignment, typename T1, typename T2 = void, typename T3 = void, typename T4 = void,
|
||||
typename T5 = void, typename T6 = void, typename T7 = void, typename T8 = void>
|
||||
template <size_t Alignment, typename T1, typename T2 = void, typename T3 = void, typename T4 = void, typename T5 = void, typename T6 = void,
|
||||
typename T7 = void, typename T8 = void>
|
||||
class type_with_alignment_helper
|
||||
{
|
||||
public:
|
||||
|
||||
typedef typename type_with_alignment_matcher<Alignment <= etl::alignment_of<T1>::value, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>::type type;
|
||||
typedef typename type_with_alignment_matcher< Alignment <= etl::alignment_of<T1>::value, Alignment, T1, T2, T3, T4, T5, T6, T7, T8>::type type;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
} // namespace private_alignment
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets a type that has the same as the specified alignment.
|
||||
@ -218,12 +219,17 @@ namespace etl
|
||||
public:
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
typedef struct { alignas(Alignment) char dummy; } type;
|
||||
typedef struct
|
||||
{
|
||||
alignas(Alignment) char dummy;
|
||||
} type;
|
||||
#else
|
||||
#if ETL_NOT_USING_64BIT_TYPES
|
||||
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
|
||||
typedef typename private_alignment::type_with_alignment_helper< Alignment, int_least8_t, int_least16_t, int32_t, float, double, void*>::type type;
|
||||
#else
|
||||
typedef typename private_alignment::type_with_alignment_helper<Alignment, int_least8_t, int_least16_t, int32_t, int64_t, float, double, void*>::type type;
|
||||
typedef
|
||||
typename private_alignment::type_with_alignment_helper< Alignment, int_least8_t, int_least16_t, int32_t, int64_t, float, double, void*>::type
|
||||
type;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -245,42 +251,37 @@ namespace etl
|
||||
{
|
||||
struct type
|
||||
{
|
||||
//type()
|
||||
// : data()
|
||||
//{
|
||||
//}
|
||||
|
||||
/// Convert to T reference.
|
||||
template <typename T>
|
||||
operator T& ()
|
||||
operator T&()
|
||||
{
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
T* t = *this;
|
||||
return *t;
|
||||
}
|
||||
|
||||
/// Convert to const T reference.
|
||||
template <typename T>
|
||||
operator const T& () const
|
||||
operator const T&() const
|
||||
{
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
const T* t = *this;
|
||||
return *t;
|
||||
}
|
||||
|
||||
/// Convert to T pointer.
|
||||
template <typename T>
|
||||
operator T* ()
|
||||
operator T*()
|
||||
{
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
return reinterpret_cast<T*>(data);
|
||||
}
|
||||
|
||||
/// Convert to const T pointer.
|
||||
template <typename T>
|
||||
operator const T* () const
|
||||
operator const T*() const
|
||||
{
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
return reinterpret_cast<const T*>(data);
|
||||
}
|
||||
|
||||
@ -288,7 +289,7 @@ namespace etl
|
||||
template <typename T>
|
||||
T& get_reference()
|
||||
{
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
T* t = *this;
|
||||
return *t;
|
||||
}
|
||||
@ -297,7 +298,7 @@ namespace etl
|
||||
template <typename T>
|
||||
const T& get_reference() const
|
||||
{
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
const T* t = *this;
|
||||
return *t;
|
||||
}
|
||||
@ -306,7 +307,7 @@ namespace etl
|
||||
template <typename T>
|
||||
T* get_address()
|
||||
{
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
return reinterpret_cast<T*>(data);
|
||||
}
|
||||
|
||||
@ -314,7 +315,7 @@ namespace etl
|
||||
template <typename T>
|
||||
const T* get_address() const
|
||||
{
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>:: value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
ETL_STATIC_ASSERT((etl::is_same<T*, void*>::value || ((Alignment % etl::alignment_of<T>::value) == 0)), "Incompatible alignment");
|
||||
return reinterpret_cast<const T*>(data);
|
||||
}
|
||||
|
||||
@ -323,8 +324,9 @@ namespace etl
|
||||
#else
|
||||
union
|
||||
{
|
||||
char data[Length];
|
||||
typename etl::type_with_alignment<Alignment>::type etl_alignment_type; // A POD type that has the same alignment as Alignment.
|
||||
char data[Length];
|
||||
typename etl::type_with_alignment<Alignment>::type etl_alignment_type; // A POD type that has the same alignment
|
||||
// as Alignment.
|
||||
};
|
||||
#endif
|
||||
};
|
||||
@ -368,147 +370,496 @@ namespace etl
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
|
||||
// Constructor
|
||||
typed_storage()
|
||||
//***************************************************************************
|
||||
// Default constructor
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR typed_storage() ETL_NOEXCEPT
|
||||
: valid(false)
|
||||
{
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//***************************************************************************
|
||||
/// Default destructor which will NOT call the destructor of the object which
|
||||
/// was created by calling create().
|
||||
/// Constructs the instance of T forwarding the given \p args to its
|
||||
/// constructor.
|
||||
//***************************************************************************
|
||||
~typed_storage() = default;
|
||||
template <typename... TArgs>
|
||||
typed_storage(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
: valid(false)
|
||||
{
|
||||
create(etl::forward<TArgs>(args)...);
|
||||
}
|
||||
#else
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with type T1
|
||||
//***************************************************************************
|
||||
template <typename T1>
|
||||
typed_storage(const T1& t1)
|
||||
: valid(false)
|
||||
{
|
||||
create(t1);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Calls the destructor of the wrapped object and asserts if has_value() is false.
|
||||
/// Constructs the instance of T with types T1, T2
|
||||
//***************************************************************************
|
||||
void destroy()
|
||||
template <typename T1, typename T2>
|
||||
typed_storage(const T1& t1, const T2& t2)
|
||||
: valid(false)
|
||||
{
|
||||
ETL_ASSERT(has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
data.template get_reference<T>().~T();
|
||||
valid = false;
|
||||
create(t1, t2);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with types T1, T2, T3
|
||||
//***************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
typed_storage(const T1& t1, const T2& t2, const T3& t3)
|
||||
: valid(false)
|
||||
{
|
||||
create(t1, t2, t3);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with types T1, T2, T3, T4
|
||||
//***************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
typed_storage(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
|
||||
: valid(false)
|
||||
{
|
||||
create(t1, t2, t3, t4);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Default destructor which will NOT call the destructor of the object
|
||||
/// which was created by calling create().
|
||||
//***************************************************************************
|
||||
~typed_storage() ETL_NOEXCEPT
|
||||
{
|
||||
// Intentionally empty.
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// \returns <b>true</b> if object has been constructed using create().
|
||||
/// \returns <b>false</b> otherwise.
|
||||
//***************************************************************************
|
||||
bool has_value() const
|
||||
bool has_value() const ETL_NOEXCEPT
|
||||
{
|
||||
return valid;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T forwarding the given \p args to its constructor and
|
||||
/// asserts if has_value() is false.
|
||||
///
|
||||
/// \returns the instance of T which has been constructed in the internal byte array.
|
||||
/// Constructs the instance of T forwarding the given \p args to its
|
||||
/// constructor. \returns the instance of T which has been constructed in
|
||||
/// the internal byte array.
|
||||
//***************************************************************************
|
||||
template<typename... Args>
|
||||
reference create(Args&&... args)
|
||||
template <typename... TArgs>
|
||||
reference create(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
{
|
||||
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
valid = true;
|
||||
return *::new (data.template get_address<char>()) value_type(etl::forward<Args>(args)...);
|
||||
pointer p = ::new (&storage.value) value_type(etl::forward<TArgs>(args)...);
|
||||
valid = true;
|
||||
return *p;
|
||||
}
|
||||
#else
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with type T1
|
||||
/// asserts if has_value() is false.
|
||||
///
|
||||
/// \returns the instance of T which has been constructed in the internal byte array.
|
||||
/// \returns the instance of T which has been constructed in the internal
|
||||
/// byte array.
|
||||
//***************************************************************************
|
||||
template<typename T1>
|
||||
template <typename T1>
|
||||
reference create(const T1& t1)
|
||||
{
|
||||
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
valid = true;
|
||||
return *::new (data.template get_address<char>()) value_type(t1);
|
||||
pointer p = ::new (&storage.value) value_type(t1);
|
||||
valid = true;
|
||||
return *p;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with types T1, T2
|
||||
/// asserts if has_value() is false.
|
||||
///
|
||||
/// \returns the instance of T which has been constructed in the internal byte array.
|
||||
/// \returns the instance of T which has been constructed in the internal
|
||||
/// byte array.
|
||||
//***************************************************************************
|
||||
template<typename T1, typename T2>
|
||||
template <typename T1, typename T2>
|
||||
reference create(const T1& t1, const T2& t2)
|
||||
{
|
||||
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
valid = true;
|
||||
return *::new (data.template get_address<char>()) value_type(t1, t2);
|
||||
pointer p = ::new (&storage.value) value_type(t1, t2);
|
||||
valid = true;
|
||||
return *p;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with types T1, T2, T3
|
||||
/// asserts if has_value() is false.
|
||||
///
|
||||
/// \returns the instance of T which has been constructed in the internal byte array.
|
||||
/// \returns the instance of T which has been constructed in the internal
|
||||
/// byte array.
|
||||
//***************************************************************************
|
||||
template<typename T1, typename T2, typename T3>
|
||||
template <typename T1, typename T2, typename T3>
|
||||
reference create(const T1& t1, const T2& t2, const T3& t3)
|
||||
{
|
||||
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
valid = true;
|
||||
return *::new (data.template get_address<char>()) value_type(t1, t2, t3);
|
||||
pointer p = ::new (&storage.value) value_type(t1, t2, t3);
|
||||
valid = true;
|
||||
return *p;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with types T1, T2, T3, T4
|
||||
/// asserts if has_value() is false.
|
||||
///
|
||||
/// \returns the instance of T which has been constructed in the internal byte array.
|
||||
/// \returns the instance of T which has been constructed in the internal
|
||||
/// byte array.
|
||||
//***************************************************************************
|
||||
template<typename T1, typename T2, typename T3, typename T4>
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
reference create(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
|
||||
{
|
||||
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
valid = true;
|
||||
return *::new (data.template get_address<char>()) value_type(t1, t2, t3, t4);
|
||||
pointer p = ::new (&storage.value) value_type(t1, t2, t3, t4);
|
||||
valid = true;
|
||||
return *p;
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Calls the destructor of the stored object, if created.
|
||||
//***************************************************************************
|
||||
void destroy() ETL_NOEXCEPT
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
storage.value.~T();
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// \returns a pointer of type T and asserts if has_value() is false.
|
||||
//***************************************************************************
|
||||
pointer operator->()
|
||||
pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
{
|
||||
ETL_ASSERT(has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
return data.template get_address<value_type>();
|
||||
|
||||
return &storage.value;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// \returns a const pointer of type T and asserts if has_value() is false.
|
||||
//***************************************************************************
|
||||
const_pointer operator->() const
|
||||
const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
{
|
||||
return operator->();
|
||||
ETL_ASSERT(has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
|
||||
return &storage.value;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// \returns reference of type T and asserts if has_value() is false.
|
||||
//***************************************************************************
|
||||
reference operator*()
|
||||
reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
{
|
||||
return *operator->();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// \returns const reference of type T and asserts if has_value() is false.
|
||||
/// \returns const_reference of type T and asserts if has_value() is false.
|
||||
//***************************************************************************
|
||||
const_reference operator*() const
|
||||
const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
{
|
||||
return *operator->();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
typename aligned_storage_as<sizeof(value_type), value_type>::type data;
|
||||
typed_storage(etl::typed_storage<T>&) ETL_DELETE;
|
||||
typed_storage& operator=(etl::typed_storage<T>&) ETL_DELETE;
|
||||
|
||||
struct dummy_t
|
||||
{
|
||||
};
|
||||
|
||||
//*******************************
|
||||
union union_type
|
||||
{
|
||||
ETL_CONSTEXPR union_type() ETL_NOEXCEPT
|
||||
: dummy()
|
||||
{
|
||||
}
|
||||
|
||||
~union_type() ETL_NOEXCEPT {}
|
||||
|
||||
dummy_t dummy;
|
||||
value_type value;
|
||||
} storage;
|
||||
|
||||
bool valid;
|
||||
};
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Wrapper class wraps a supplied memory area and lets the user create an
|
||||
/// instance of T in this memory at runtime. This class also erases the
|
||||
/// destructor call of T, i.e. if typed_storage goes out of scope, the
|
||||
/// destructor if the wrapped type will not be called. This can be done
|
||||
/// explicitly by calling destroy().
|
||||
/// \tparam T Type of element stored in this instance of typed_storage.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
class typed_storage_ext
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
|
||||
template <typename U>
|
||||
friend ETL_CONSTEXPR14 void swap(typed_storage_ext<U>& lhs, typed_storage_ext<U>& rhs) ETL_NOEXCEPT;
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructor.
|
||||
//***************************************************************************
|
||||
typed_storage_ext(void* pbuffer_) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
: pbuffer(reinterpret_cast<T*>(pbuffer_))
|
||||
, valid(false)
|
||||
{
|
||||
ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T forwarding the given \p args to its
|
||||
/// constructor.
|
||||
//***************************************************************************
|
||||
template <typename... TArgs>
|
||||
typed_storage_ext(void* pbuffer_, TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
: pbuffer(reinterpret_cast<T*>(pbuffer_))
|
||||
, valid(false)
|
||||
{
|
||||
ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
|
||||
create(etl::forward<TArgs>(args)...);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Move constructor.
|
||||
/// Transfers ownership of the buffer from \p other to this.
|
||||
//***************************************************************************
|
||||
typed_storage_ext(typed_storage_ext<T>&& other) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
: pbuffer(other.pbuffer)
|
||||
, valid(other.valid)
|
||||
{
|
||||
other.pbuffer = ETL_NULLPTR;
|
||||
other.valid = false;
|
||||
}
|
||||
#else
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with type T1
|
||||
//***************************************************************************
|
||||
template <typename T1>
|
||||
typed_storage_ext(void* pbuffer_, const T1& t1)
|
||||
: pbuffer(reinterpret_cast<T*>(pbuffer_))
|
||||
, valid(false)
|
||||
{
|
||||
ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
|
||||
create(t1);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with types T1, T2
|
||||
//***************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
typed_storage_ext(void* pbuffer_, const T1& t1, const T2& t2)
|
||||
: pbuffer(reinterpret_cast<T*>(pbuffer_))
|
||||
, valid(false)
|
||||
{
|
||||
ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
|
||||
create(t1, t2);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with types T1, T2, T3
|
||||
//***************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
typed_storage_ext(void* pbuffer_, const T1& t1, const T2& t2, const T3& t3)
|
||||
: pbuffer(reinterpret_cast<T*>(pbuffer_))
|
||||
, valid(false)
|
||||
{
|
||||
ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
|
||||
create(t1, t2, t3);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with types T1, T2, T3, T4
|
||||
//***************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
typed_storage_ext(void* pbuffer_, const T1& t1, const T2& t2, const T3& t3, const T4& t4)
|
||||
: pbuffer(reinterpret_cast<T*>(pbuffer_))
|
||||
, valid(false)
|
||||
{
|
||||
ETL_ASSERT(etl::is_aligned(pbuffer_, etl::alignment_of<T>::value), ETL_ERROR(etl::alignment_error));
|
||||
create(t1, t2, t3, t4);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Default destructor which will NOT call the destructor of the object
|
||||
/// which was created by calling create().
|
||||
//***************************************************************************
|
||||
~typed_storage_ext() ETL_NOEXCEPT
|
||||
{
|
||||
// Intentionally empty.
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// \returns <b>true</b> if object has been constructed using create().
|
||||
/// \returns <b>false</b> otherwise.
|
||||
//***************************************************************************
|
||||
bool has_value() const ETL_NOEXCEPT
|
||||
{
|
||||
return valid;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T forwarding the given \p args to its
|
||||
/// constructor. \returns the instance of T which has been constructed in
|
||||
/// the external buffer.
|
||||
//***************************************************************************
|
||||
template <typename... TArgs>
|
||||
reference create(TArgs&&... args) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
{
|
||||
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
pointer p = ::new (pbuffer) value_type(etl::forward<TArgs>(args)...);
|
||||
valid = true;
|
||||
return *p;
|
||||
}
|
||||
#else
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with type T1
|
||||
/// \returns the instance of T which has been constructed in the external
|
||||
/// buffer.
|
||||
//***************************************************************************
|
||||
template <typename T1>
|
||||
reference create(const T1& t1)
|
||||
{
|
||||
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
pointer p = ::new (pbuffer) value_type(t1);
|
||||
valid = true;
|
||||
return *p;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with types T1, T2
|
||||
/// \returns the instance of T which has been constructed in the external
|
||||
/// buffer.
|
||||
//***************************************************************************
|
||||
template <typename T1, typename T2>
|
||||
reference create(const T1& t1, const T2& t2)
|
||||
{
|
||||
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
pointer p = ::new (pbuffer) value_type(t1, t2);
|
||||
valid = true;
|
||||
return *p;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with types T1, T2, T3
|
||||
/// \returns the instance of T which has been constructed in the external
|
||||
/// buffer.
|
||||
//***************************************************************************
|
||||
template <typename T1, typename T2, typename T3>
|
||||
reference create(const T1& t1, const T2& t2, const T3& t3)
|
||||
{
|
||||
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
pointer p = ::new (pbuffer) value_type(t1, t2, t3);
|
||||
valid = true;
|
||||
return *p;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Constructs the instance of T with types T1, T2, T3, T4
|
||||
/// \returns the instance of T which has been constructed in the external
|
||||
/// buffer.
|
||||
//***************************************************************************
|
||||
template <typename T1, typename T2, typename T3, typename T4>
|
||||
reference create(const T1& t1, const T2& t2, const T3& t3, const T4& t4)
|
||||
{
|
||||
ETL_ASSERT(!has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
pointer p = ::new (pbuffer) value_type(t1, t2, t3, t4);
|
||||
valid = true;
|
||||
return *p;
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Calls the destructor of the stored object, if created.
|
||||
//***************************************************************************
|
||||
void destroy() ETL_NOEXCEPT
|
||||
{
|
||||
if (has_value())
|
||||
{
|
||||
pbuffer->~T();
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// \returns a pointer of type T and asserts if has_value() is false.
|
||||
//***************************************************************************
|
||||
pointer operator->() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
{
|
||||
ETL_ASSERT(has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
|
||||
return pbuffer;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// \returns a const pointer of type T and asserts if has_value() is false.
|
||||
//***************************************************************************
|
||||
const_pointer operator->() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
{
|
||||
ETL_ASSERT(has_value(), ETL_ERROR(etl::typed_storage_error));
|
||||
|
||||
return pbuffer;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// \returns reference of type T and asserts if has_value() is false.
|
||||
//***************************************************************************
|
||||
reference operator*() ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
{
|
||||
return *operator->();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// \returns const_reference of type T and asserts if has_value() is false.
|
||||
//***************************************************************************
|
||||
const_reference operator*() const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
|
||||
{
|
||||
return *operator->();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
typed_storage_ext(etl::typed_storage_ext<T>&) ETL_DELETE;
|
||||
typed_storage_ext& operator=(etl::typed_storage_ext<T>&) ETL_DELETE;
|
||||
|
||||
pointer pbuffer;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Swap two etl::typed_storage_ext
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14 void swap(etl::typed_storage_ext<T>& lhs, etl::typed_storage_ext<T>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
using ETL_OR_STD::swap;
|
||||
|
||||
swap(lhs.pbuffer, rhs.pbuffer);
|
||||
swap(lhs.valid, rhs.valid);
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -32,18 +32,18 @@ SOFTWARE.
|
||||
#define ETL_ARRAY_VIEW_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "memory.h"
|
||||
#include "algorithm.h"
|
||||
#include "array.h"
|
||||
#include "iterator.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "nullptr.h"
|
||||
#include "hash.h"
|
||||
#include "algorithm.h"
|
||||
#include "iterator.h"
|
||||
#include "memory.h"
|
||||
#include "nullptr.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#if ETL_USING_STL && ETL_USING_CPP11
|
||||
#include <array>
|
||||
#include <array>
|
||||
#endif
|
||||
|
||||
///\defgroup array array
|
||||
@ -93,6 +93,19 @@ namespace etl
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// The exception thrown when the view is empty.
|
||||
//***************************************************************************
|
||||
class array_view_empty : public array_view_exception
|
||||
{
|
||||
public:
|
||||
|
||||
array_view_empty(string_type file_name_, numeric_type line_number_)
|
||||
: array_view_exception(ETL_ERROR_TEXT("array_view:empty", ETL_ARRAY_VIEW_FILE_ID"C"), file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
/// Array view.
|
||||
//***************************************************************************
|
||||
@ -101,31 +114,31 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef size_t size_type;
|
||||
typedef const T& const_reference;
|
||||
typedef const T* const_pointer;
|
||||
typedef const T* const_iterator;
|
||||
typedef T value_type;
|
||||
typedef size_t size_type;
|
||||
typedef const T& const_reference;
|
||||
typedef const T* const_pointer;
|
||||
typedef const T* const_iterator;
|
||||
typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
#if defined(ETL_ARRAY_VIEW_IS_MUTABLE)
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
typedef T* iterator;
|
||||
typedef T* pointer;
|
||||
typedef T& reference;
|
||||
typedef T* iterator;
|
||||
typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
|
||||
#else
|
||||
typedef const_pointer pointer;
|
||||
typedef const_reference reference;
|
||||
typedef const_pointer iterator;
|
||||
typedef const_pointer pointer;
|
||||
typedef const_reference reference;
|
||||
typedef const_pointer iterator;
|
||||
typedef const_reverse_iterator reverse_iterator;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Default constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR array_view()
|
||||
: mbegin(ETL_NULLPTR),
|
||||
mend(ETL_NULLPTR)
|
||||
ETL_CONSTEXPR array_view() ETL_NOEXCEPT
|
||||
: mbegin(ETL_NULLPTR)
|
||||
, mend(ETL_NULLPTR)
|
||||
{
|
||||
}
|
||||
|
||||
@ -133,8 +146,9 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from etl::array.
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N, typename = typename etl::enable_if<etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
|
||||
ETL_CONSTEXPR array_view(etl::array<U, N>& a) ETL_NOEXCEPT
|
||||
template < typename U, size_t Size,
|
||||
typename = typename etl::enable_if< etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
|
||||
ETL_CONSTEXPR array_view(etl::array<U, Size>& a) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
@ -143,8 +157,9 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from etl::array.
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N, typename = typename etl::enable_if<etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
|
||||
ETL_CONSTEXPR array_view(const etl::array<U, N>& a) ETL_NOEXCEPT
|
||||
template < typename U, size_t Size,
|
||||
typename = typename etl::enable_if< etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
|
||||
ETL_CONSTEXPR array_view(const etl::array<U, Size>& a) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
@ -153,8 +168,10 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from etl::array.
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N>
|
||||
ETL_CONSTEXPR array_view(etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
template <typename U, size_t Size>
|
||||
ETL_CONSTEXPR array_view(
|
||||
etl::array<U, Size>& a,
|
||||
typename etl::enable_if< etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
@ -163,8 +180,10 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from etl::array.
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N>
|
||||
ETL_CONSTEXPR array_view(const etl::array<U, N>& a, typename etl::enable_if<etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
template <typename U, size_t Size>
|
||||
ETL_CONSTEXPR array_view(
|
||||
const etl::array<U, Size>& a,
|
||||
typename etl::enable_if< etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<U>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
@ -175,8 +194,9 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from std::array.
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N, typename = typename etl::enable_if<etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
|
||||
ETL_CONSTEXPR array_view(std::array<U, N>& a) ETL_NOEXCEPT
|
||||
template < typename U, size_t Size,
|
||||
typename = typename etl::enable_if< etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
|
||||
ETL_CONSTEXPR array_view(std::array<U, Size>& a) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
@ -185,8 +205,9 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Construct from std::array.
|
||||
//*************************************************************************
|
||||
template <typename U, size_t N, typename = typename etl::enable_if<etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
|
||||
ETL_CONSTEXPR array_view(const std::array<U, N>& a) ETL_NOEXCEPT
|
||||
template < typename U, size_t Size,
|
||||
typename = typename etl::enable_if< etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<U>>::value, void>::type>
|
||||
ETL_CONSTEXPR array_view(const std::array<U, Size>& a) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
@ -198,10 +219,12 @@ namespace etl
|
||||
/// Construct from a container or other type that supports
|
||||
/// data() and size() member functions.
|
||||
//*************************************************************************
|
||||
template <typename TContainer, typename = typename etl::enable_if<!etl::is_pointer<etl::remove_reference_t<TContainer>>::value &&
|
||||
!etl::is_array<etl::remove_reference_t<TContainer>>::value &&
|
||||
etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<typename etl::remove_reference_t<TContainer>::value_type>>::value, void>::type>
|
||||
ETL_CONSTEXPR array_view(TContainer&& a) ETL_NOEXCEPT
|
||||
template < typename TContainer,
|
||||
typename = typename etl::enable_if<
|
||||
!etl::is_pointer<etl::remove_reference_t<TContainer>>::value && !etl::is_array<etl::remove_reference_t<TContainer>>::value
|
||||
&& etl::is_same<etl::remove_cv_t<T>, etl::remove_cv_t<typename etl::remove_reference_t< TContainer>::value_type>>::value,
|
||||
void>::type>
|
||||
ETL_CONSTEXPR array_view(TContainer&& a) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
@ -212,9 +235,12 @@ namespace etl
|
||||
/// data() and size() member functions.
|
||||
//*************************************************************************
|
||||
template <typename TContainer>
|
||||
ETL_CONSTEXPR array_view(TContainer& a, typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TContainer>::type>::value &&
|
||||
!etl::is_array<TContainer>::value &&
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR array_view(TContainer& a,
|
||||
typename etl::enable_if<
|
||||
!etl::is_pointer< typename etl::remove_reference<TContainer>::type>::value && !etl::is_array<TContainer>::value
|
||||
&& etl::is_same< typename etl::remove_cv<T>::type,
|
||||
typename etl::remove_cv<typename etl::remove_reference< TContainer>::type::value_type>::type>::value,
|
||||
void>::type* = 0) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
@ -225,9 +251,12 @@ namespace etl
|
||||
/// data() and size() member functions.
|
||||
//*************************************************************************
|
||||
template <typename TContainer>
|
||||
ETL_CONSTEXPR array_view(const TContainer& a, typename etl::enable_if<!etl::is_pointer<typename etl::remove_reference<TContainer>::type>::value &&
|
||||
!etl::is_array<TContainer>::value &&
|
||||
etl::is_same<typename etl::remove_cv<T>::type, typename etl::remove_cv<typename etl::remove_reference<TContainer>::type::value_type>::type>::value, void>::type* = 0) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR array_view(const TContainer& a,
|
||||
typename etl::enable_if<
|
||||
!etl::is_pointer< typename etl::remove_reference<TContainer>::type>::value && !etl::is_array<TContainer>::value
|
||||
&& etl::is_same< typename etl::remove_cv<T>::type,
|
||||
typename etl::remove_cv<typename etl::remove_reference< TContainer>::type::value_type>::type>::value,
|
||||
void>::type* = 0) ETL_NOEXCEPT
|
||||
: mbegin(a.data())
|
||||
, mend(a.data() + a.size())
|
||||
{
|
||||
@ -238,78 +267,89 @@ namespace etl
|
||||
/// Construct from iterators
|
||||
//*************************************************************************
|
||||
template <typename TIterator>
|
||||
ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_)
|
||||
: mbegin(etl::to_address(begin_)),
|
||||
mend(etl::to_address(begin_) + etl::distance(begin_, end_))
|
||||
ETL_CONSTEXPR array_view(const TIterator begin_, const TIterator end_) ETL_NOEXCEPT
|
||||
: mbegin(etl::to_address(begin_))
|
||||
, mend(etl::to_address(begin_) + etl::distance(begin_, end_))
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from iterator and size
|
||||
//*************************************************************************
|
||||
template <typename TIterator,
|
||||
typename TSize>
|
||||
ETL_CONSTEXPR array_view(const TIterator begin_, const TSize size_)
|
||||
: mbegin(etl::to_address(begin_)),
|
||||
mend(etl::to_address(begin_) + size_)
|
||||
template <typename TIterator, typename TSize>
|
||||
ETL_CONSTEXPR array_view(const TIterator begin_, const TSize size_) ETL_NOEXCEPT
|
||||
: mbegin(etl::to_address(begin_))
|
||||
, mend(etl::to_address(begin_) + size_)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Construct from C array
|
||||
//*************************************************************************
|
||||
template<size_t Array_Size>
|
||||
ETL_CONSTEXPR array_view(T(&begin_)[Array_Size])
|
||||
: mbegin(begin_),
|
||||
mend(begin_ + Array_Size)
|
||||
template <size_t Array_Size>
|
||||
ETL_CONSTEXPR array_view(T (&begin_)[Array_Size]) ETL_NOEXCEPT
|
||||
: mbegin(begin_)
|
||||
, mend(begin_ + Array_Size)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Copy constructor
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR array_view(const array_view& other)
|
||||
: mbegin(other.mbegin),
|
||||
mend(other.mend)
|
||||
ETL_CONSTEXPR array_view(const array_view& other) ETL_NOEXCEPT
|
||||
: mbegin(other.mbegin)
|
||||
, mend(other.mend)
|
||||
{
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a reference to the first element.
|
||||
/// If asserts or exceptions are enabled, throws an etl::array_view_empty if
|
||||
/// the view is empty.
|
||||
//*************************************************************************
|
||||
reference front()
|
||||
{
|
||||
ETL_ASSERT_CHECK_EXTRA(!empty(), ETL_ERROR(array_view_empty));
|
||||
return *mbegin;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the first element.
|
||||
/// If asserts or exceptions are enabled, throws an etl::array_view_empty if
|
||||
/// the view is empty.
|
||||
//*************************************************************************
|
||||
const_reference front() const
|
||||
{
|
||||
ETL_ASSERT_CHECK_EXTRA(!empty(), ETL_ERROR(array_view_empty));
|
||||
return *mbegin;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a reference to the last element.
|
||||
/// If asserts or exceptions are enabled, throws an etl::array_view_empty if
|
||||
/// the view is empty.
|
||||
//*************************************************************************
|
||||
reference back()
|
||||
{
|
||||
ETL_ASSERT_CHECK_EXTRA(!empty(), ETL_ERROR(array_view_empty));
|
||||
return *(mend - 1);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the last element.
|
||||
/// If asserts or exceptions are enabled, throws an etl::array_view_empty if
|
||||
/// the view is empty.
|
||||
//*************************************************************************
|
||||
const_reference back() const
|
||||
{
|
||||
ETL_ASSERT_CHECK_EXTRA(!empty(), ETL_ERROR(array_view_empty));
|
||||
return *(mend - 1);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a pointer to the first element of the internal storage.
|
||||
//*************************************************************************
|
||||
pointer data()
|
||||
pointer data() ETL_NOEXCEPT
|
||||
{
|
||||
return mbegin;
|
||||
}
|
||||
@ -317,7 +357,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const pointer to the first element of the internal storage.
|
||||
//*************************************************************************
|
||||
const_pointer data() const
|
||||
const_pointer data() const ETL_NOEXCEPT
|
||||
{
|
||||
return mbegin;
|
||||
}
|
||||
@ -325,7 +365,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns an iterator to the beginning of the array.
|
||||
//*************************************************************************
|
||||
iterator begin()
|
||||
iterator begin() ETL_NOEXCEPT
|
||||
{
|
||||
return mbegin;
|
||||
}
|
||||
@ -333,7 +373,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const iterator to the beginning of the array.
|
||||
//*************************************************************************
|
||||
const_iterator begin() const
|
||||
const_iterator begin() const ETL_NOEXCEPT
|
||||
{
|
||||
return mbegin;
|
||||
}
|
||||
@ -341,7 +381,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const iterator to the beginning of the array.
|
||||
//*************************************************************************
|
||||
const_iterator cbegin() const
|
||||
const_iterator cbegin() const ETL_NOEXCEPT
|
||||
{
|
||||
return mbegin;
|
||||
}
|
||||
@ -349,7 +389,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns an iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
iterator end()
|
||||
iterator end() ETL_NOEXCEPT
|
||||
{
|
||||
return mend;
|
||||
}
|
||||
@ -357,7 +397,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
const_iterator end() const
|
||||
const_iterator end() const ETL_NOEXCEPT
|
||||
{
|
||||
return mend;
|
||||
}
|
||||
@ -365,7 +405,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Returns a const iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
const_iterator cend() const
|
||||
const_iterator cend() const ETL_NOEXCEPT
|
||||
{
|
||||
return mend;
|
||||
}
|
||||
@ -373,7 +413,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Returns an reverse iterator to the reverse beginning of the array.
|
||||
//*************************************************************************
|
||||
reverse_iterator rbegin()
|
||||
reverse_iterator rbegin() ETL_NOEXCEPT
|
||||
{
|
||||
return reverse_iterator(mend);
|
||||
}
|
||||
@ -381,7 +421,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the reverse beginning of the array.
|
||||
//*************************************************************************
|
||||
const_reverse_iterator rbegin() const
|
||||
const_reverse_iterator rbegin() const ETL_NOEXCEPT
|
||||
{
|
||||
return const_reverse_iterator(mend);
|
||||
}
|
||||
@ -389,7 +429,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the reverse beginning of the array.
|
||||
//*************************************************************************
|
||||
const_reverse_iterator crbegin() const
|
||||
const_reverse_iterator crbegin() const ETL_NOEXCEPT
|
||||
{
|
||||
return const_reverse_iterator(mend);
|
||||
}
|
||||
@ -397,7 +437,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a reverse iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
reverse_iterator rend()
|
||||
reverse_iterator rend() ETL_NOEXCEPT
|
||||
{
|
||||
return reverse_iterator(mbegin);
|
||||
}
|
||||
@ -405,7 +445,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
const_reverse_iterator rend() const
|
||||
const_reverse_iterator rend() const ETL_NOEXCEPT
|
||||
{
|
||||
return const_reverse_iterator(mbegin);
|
||||
}
|
||||
@ -413,7 +453,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
const_reverse_iterator crend() const
|
||||
const_reverse_iterator crend() const ETL_NOEXCEPT
|
||||
{
|
||||
return const_reverse_iterator(mbegin);
|
||||
}
|
||||
@ -421,7 +461,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns <b>true</b> if the array size is zero.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR bool empty() const
|
||||
ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
|
||||
{
|
||||
return (mbegin == mend);
|
||||
}
|
||||
@ -429,7 +469,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the size of the array.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR size_t size() const
|
||||
ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
|
||||
{
|
||||
return static_cast<size_t>(mend - mbegin);
|
||||
}
|
||||
@ -437,7 +477,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the maximum possible size of the array.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR size_t max_size() const
|
||||
ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
|
||||
{
|
||||
return size();
|
||||
}
|
||||
@ -445,7 +485,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assign from a view.
|
||||
//*************************************************************************
|
||||
array_view& operator=(const array_view& other)
|
||||
array_view& operator=(const array_view& other) ETL_NOEXCEPT
|
||||
{
|
||||
mbegin = other.mbegin;
|
||||
mend = other.mend;
|
||||
@ -465,8 +505,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Assign from iterator and size.
|
||||
//*************************************************************************
|
||||
template <typename TIterator,
|
||||
typename TSize>
|
||||
template <typename TIterator, typename TSize>
|
||||
void assign(const TIterator begin_, const TSize size_)
|
||||
{
|
||||
mbegin = etl::to_address(begin_);
|
||||
@ -476,18 +515,26 @@ namespace etl
|
||||
#if defined(ETL_ARRAY_VIEW_IS_MUTABLE)
|
||||
//*************************************************************************
|
||||
/// Returns a reference to the indexed value.
|
||||
/// If asserts or exceptions are enabled, throws an etl::array_view_bounds
|
||||
/// if the index is out of bounds.
|
||||
//*************************************************************************
|
||||
reference operator[](const size_t i)
|
||||
reference operator[](const size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
|
||||
{
|
||||
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < size(), ETL_ERROR(array_view_bounds));
|
||||
|
||||
return mbegin[i];
|
||||
}
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the indexed value.
|
||||
/// If asserts or exceptions are enabled, throws an etl::array_view_bounds
|
||||
/// if the index is out of bounds.
|
||||
//*************************************************************************
|
||||
const_reference operator[](const size_t i) const
|
||||
const_reference operator[](const size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
|
||||
{
|
||||
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < size(), ETL_ERROR(array_view_bounds));
|
||||
|
||||
return mbegin[i];
|
||||
}
|
||||
|
||||
@ -516,7 +563,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Swaps with another array_view.
|
||||
//*************************************************************************
|
||||
void swap(array_view& other)
|
||||
void swap(array_view& other) ETL_NOEXCEPT
|
||||
{
|
||||
using ETL_OR_STD::swap; // Allow ADL
|
||||
|
||||
@ -527,23 +574,23 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Shrinks the view by moving its start forward.
|
||||
//*************************************************************************
|
||||
void remove_prefix(const size_type n)
|
||||
void remove_prefix(const size_type n) ETL_NOEXCEPT
|
||||
{
|
||||
if (n < size())
|
||||
mbegin += n;
|
||||
else
|
||||
mbegin = mend;
|
||||
if (n < size())
|
||||
mbegin += n;
|
||||
else
|
||||
mbegin = mend;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Shrinks the view by moving its end backward.
|
||||
//*************************************************************************
|
||||
void remove_suffix(const size_type n)
|
||||
void remove_suffix(const size_type n) ETL_NOEXCEPT
|
||||
{
|
||||
if (n < size())
|
||||
mend -= n;
|
||||
else
|
||||
mend = mbegin;
|
||||
if (n < size())
|
||||
mend -= n;
|
||||
else
|
||||
mend = mbegin;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -557,16 +604,15 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Equality for array views.
|
||||
//*************************************************************************
|
||||
friend bool operator == (const array_view<T>& lhs, const array_view<T>& rhs)
|
||||
friend bool operator==(const array_view<T>& lhs, const array_view<T>& rhs)
|
||||
{
|
||||
return (lhs.size() == rhs.size()) &&
|
||||
etl::equal(lhs.begin(), lhs.end(), rhs.begin());
|
||||
return (lhs.size() == rhs.size()) && etl::equal(lhs.begin(), lhs.end(), rhs.begin());
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Inequality for array views.
|
||||
//*************************************************************************
|
||||
friend bool operator != (const array_view<T>& lhs, const array_view<T>& rhs)
|
||||
friend bool operator!=(const array_view<T>& lhs, const array_view<T>& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
@ -574,7 +620,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Less-than for array views.
|
||||
//*************************************************************************
|
||||
friend bool operator < (const array_view<T>& lhs, const array_view<T>& rhs)
|
||||
friend bool operator<(const array_view<T>& lhs, const array_view<T>& rhs)
|
||||
{
|
||||
return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
|
||||
}
|
||||
@ -582,7 +628,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Greater-than for array views.
|
||||
//*************************************************************************
|
||||
friend bool operator > (const array_view<T>& lhs, const array_view<T>& rhs)
|
||||
friend bool operator>(const array_view<T>& lhs, const array_view<T>& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
@ -590,7 +636,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Less-than-equal for array views.
|
||||
//*************************************************************************
|
||||
friend bool operator <= (const array_view<T>& lhs, const array_view<T>& rhs)
|
||||
friend bool operator<=(const array_view<T>& lhs, const array_view<T>& rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
@ -598,7 +644,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Greater-than-equal for array views.
|
||||
//*************************************************************************
|
||||
friend bool operator >= (const array_view<T>& lhs, const array_view<T>& rhs)
|
||||
friend bool operator>=(const array_view<T>& lhs, const array_view<T>& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
@ -614,18 +660,14 @@ namespace etl
|
||||
//*************************************************************************
|
||||
#if ETL_USING_CPP17
|
||||
template <typename TArray>
|
||||
array_view(TArray& a)
|
||||
-> array_view<typename TArray::value_type>;
|
||||
array_view(TArray& a) -> array_view<typename TArray::value_type>;
|
||||
|
||||
template <typename TIterator>
|
||||
array_view(const TIterator begin_, const TIterator end_)
|
||||
-> array_view<etl::remove_pointer_t<TIterator>>;
|
||||
array_view(const TIterator begin_, const TIterator end_) -> array_view<etl::remove_pointer_t<TIterator>>;
|
||||
|
||||
template <typename TIterator,
|
||||
typename TSize>
|
||||
array_view(const TIterator begin_, const TSize size_)
|
||||
-> array_view<etl::remove_pointer_t<TIterator>>;
|
||||
#endif
|
||||
template <typename TIterator, typename TSize>
|
||||
array_view(const TIterator begin_, const TSize size_) -> array_view<etl::remove_pointer_t<TIterator>>;
|
||||
#endif
|
||||
|
||||
//*************************************************************************
|
||||
/// Hash function.
|
||||
@ -641,13 +683,13 @@ namespace etl
|
||||
}
|
||||
};
|
||||
#endif
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Swaps the values.
|
||||
//*************************************************************************
|
||||
template <typename T>
|
||||
void swap(etl::array_view<T>& lhs, etl::array_view<T>& rhs)
|
||||
void swap(etl::array_view<T>& lhs, etl::array_view<T>& rhs) ETL_NOEXCEPT
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
@ -32,12 +32,12 @@ SOFTWARE.
|
||||
#define ETL_ARRAY_WRAPPER_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "iterator.h"
|
||||
#include "algorithm.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "hash.h"
|
||||
#include "iterator.h"
|
||||
#include "parameter_type.h"
|
||||
#include "algorithm.h"
|
||||
|
||||
///\defgroup array array
|
||||
/// A wrapper for arrays
|
||||
@ -75,19 +75,19 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Array wrapper.
|
||||
//***************************************************************************
|
||||
template <typename T, size_t SIZE_, T(&ARRAY_)[SIZE_]>
|
||||
template <typename T, size_t SIZE_, T (&ARRAY_)[SIZE_]>
|
||||
class array_wrapper
|
||||
{
|
||||
public:
|
||||
|
||||
typedef T value_type;
|
||||
typedef size_t size_type;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
typedef T value_type;
|
||||
typedef size_t size_type;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T* iterator;
|
||||
typedef const T* const_iterator;
|
||||
typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
|
||||
typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||
|
||||
@ -141,7 +141,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a pointer to the first element of the internal storage.
|
||||
//*************************************************************************
|
||||
pointer data()
|
||||
pointer data() ETL_NOEXCEPT
|
||||
{
|
||||
return &ARRAY_[BEGIN];
|
||||
}
|
||||
@ -149,7 +149,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const pointer to the first element of the internal storage.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_pointer data() const
|
||||
ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
|
||||
{
|
||||
return &ARRAY_[BEGIN];
|
||||
}
|
||||
@ -157,7 +157,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns an iterator to the beginning of the array.
|
||||
//*************************************************************************
|
||||
iterator begin()
|
||||
iterator begin() ETL_NOEXCEPT
|
||||
{
|
||||
return &ARRAY_[BEGIN];
|
||||
}
|
||||
@ -165,7 +165,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const iterator to the beginning of the array.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_iterator begin() const
|
||||
ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
|
||||
{
|
||||
return &ARRAY_[BEGIN];
|
||||
}
|
||||
@ -173,7 +173,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const iterator to the beginning of the array.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_iterator cbegin() const
|
||||
ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
|
||||
{
|
||||
return &ARRAY_[BEGIN];
|
||||
}
|
||||
@ -181,7 +181,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns an iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
iterator end()
|
||||
iterator end() ETL_NOEXCEPT
|
||||
{
|
||||
return &ARRAY_[END];
|
||||
}
|
||||
@ -189,7 +189,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_iterator end() const
|
||||
ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
|
||||
{
|
||||
return &ARRAY_[END];
|
||||
}
|
||||
@ -197,7 +197,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Returns a const iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_iterator cend() const
|
||||
ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
|
||||
{
|
||||
return &ARRAY_[END];
|
||||
}
|
||||
@ -205,7 +205,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Returns an reverse iterator to the reverse beginning of the array.
|
||||
//*************************************************************************
|
||||
reverse_iterator rbegin()
|
||||
reverse_iterator rbegin() ETL_NOEXCEPT
|
||||
{
|
||||
return reverse_iterator(&ARRAY_[END]);
|
||||
}
|
||||
@ -213,7 +213,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the reverse beginning of the array.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_reverse_iterator rbegin() const
|
||||
ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
|
||||
{
|
||||
return const_reverse_iterator(&ARRAY_[END]);
|
||||
}
|
||||
@ -221,7 +221,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the reverse beginning of the array.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_reverse_iterator crbegin() const
|
||||
ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
|
||||
{
|
||||
return const_reverse_iterator(&ARRAY_[END]);
|
||||
}
|
||||
@ -229,7 +229,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a reverse iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
reverse_iterator rend()
|
||||
reverse_iterator rend() ETL_NOEXCEPT
|
||||
{
|
||||
return reverse_iterator(&ARRAY_[BEGIN]);
|
||||
}
|
||||
@ -237,7 +237,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_reverse_iterator rend() const
|
||||
ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
|
||||
{
|
||||
return const_reverse_iterator(&ARRAY_[BEGIN]);
|
||||
}
|
||||
@ -245,7 +245,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns a const reverse iterator to the end of the array.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_reverse_iterator crend() const
|
||||
ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
|
||||
{
|
||||
return const_reverse_iterator(&ARRAY_[BEGIN]);
|
||||
}
|
||||
@ -253,7 +253,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the size of the array.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR size_t size() const
|
||||
ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
|
||||
{
|
||||
return SIZE;
|
||||
}
|
||||
@ -261,25 +261,36 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the maximum possible size of the array.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR size_t max_size() const
|
||||
ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
|
||||
{
|
||||
return MAX_SIZE;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a reference to the indexed value.
|
||||
/// If asserts or exceptions are enabled, throws an
|
||||
/// etl::array_wrapper_bounds if the index is out of bounds.
|
||||
//*************************************************************************
|
||||
reference operator[](size_t i)
|
||||
reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
|
||||
{
|
||||
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(etl::array_wrapper_bounds));
|
||||
return ARRAY_[i];
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns a const reference to the indexed value.
|
||||
/// If asserts or exceptions are enabled, throws an
|
||||
/// etl::array_wrapper_bounds if the index is out of bounds.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR const_reference operator[](size_t i) const
|
||||
ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
|
||||
{
|
||||
// Throwing from c++11 constexpr requires special syntax
|
||||
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_INDEX_OPERATOR
|
||||
return i < SIZE ? ARRAY_[i] : throw(ETL_ERROR(etl::array_wrapper_bounds));
|
||||
#else
|
||||
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(etl::array_wrapper_bounds));
|
||||
return ARRAY_[i];
|
||||
#endif
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -311,9 +322,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Swaps the contents of arrays.
|
||||
//*************************************************************************
|
||||
template <typename U, U(&ARRAYOTHER)[SIZE_]>
|
||||
typename etl::enable_if<etl::is_same<T, U>::value, void>::type
|
||||
swap(etl::array_wrapper<U, SIZE_, ARRAYOTHER>& other)
|
||||
template <typename U, U (&ARRAYOTHER)[SIZE_]>
|
||||
typename etl::enable_if<etl::is_same<T, U>::value, void>::type swap(etl::array_wrapper<U, SIZE_, ARRAYOTHER>& other)
|
||||
{
|
||||
using ETL_OR_STD::swap; // Allow ADL
|
||||
|
||||
@ -327,9 +337,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Equality for array wrappers.
|
||||
//*************************************************************************
|
||||
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL(&ARRAYL)[SIZEL], TR(&ARRAYR)[SIZER]>
|
||||
bool operator == (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
|
||||
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
|
||||
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL (&ARRAYL)[SIZEL], TR (&ARRAYR)[SIZER]>
|
||||
bool operator==(const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
|
||||
{
|
||||
return (SIZEL == SIZER) && etl::equal(lhs.begin(), lhs.end(), rhs.begin());
|
||||
}
|
||||
@ -337,9 +346,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Inequality for array wrapper.
|
||||
//*************************************************************************
|
||||
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL(&ARRAYL)[SIZEL], TR(&ARRAYR)[SIZER]>
|
||||
bool operator != (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
|
||||
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
|
||||
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL (&ARRAYL)[SIZEL], TR (&ARRAYR)[SIZER]>
|
||||
bool operator!=(const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
@ -347,9 +355,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Less-than for array wrapper.
|
||||
//*************************************************************************
|
||||
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL(&ARRAYL)[SIZEL], TR(&ARRAYR)[SIZER]>
|
||||
bool operator < (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
|
||||
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
|
||||
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL (&ARRAYL)[SIZEL], TR (&ARRAYR)[SIZER]>
|
||||
bool operator<(const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
|
||||
{
|
||||
return etl::lexicographical_compare(lhs.begin(), lhs.end(), rhs.begin(), rhs.end());
|
||||
}
|
||||
@ -357,9 +364,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Greater-than for array wrapper.
|
||||
//*************************************************************************
|
||||
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL(&ARRAYL)[SIZEL], TR(&ARRAYR)[SIZER]>
|
||||
bool operator > (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
|
||||
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
|
||||
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL (&ARRAYL)[SIZEL], TR (&ARRAYR)[SIZER]>
|
||||
bool operator>(const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
@ -367,9 +373,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Less-than-equal for array wrapper.
|
||||
//*************************************************************************
|
||||
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL(&ARRAYL)[SIZEL], TR(&ARRAYR)[SIZER]>
|
||||
bool operator <= (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
|
||||
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
|
||||
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL (&ARRAYL)[SIZEL], TR (&ARRAYR)[SIZER]>
|
||||
bool operator<=(const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
|
||||
{
|
||||
return !(lhs > rhs);
|
||||
}
|
||||
@ -377,9 +382,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Greater-than-equal for array wrapper.
|
||||
//*************************************************************************
|
||||
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL(&ARRAYL)[SIZEL], TR(&ARRAYR)[SIZER]>
|
||||
bool operator >= (const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs,
|
||||
const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
|
||||
template <typename TL, typename TR, size_t SIZEL, size_t SIZER, TL (&ARRAYL)[SIZEL], TR (&ARRAYR)[SIZER]>
|
||||
bool operator>=(const etl::array_wrapper<TL, SIZEL, ARRAYL>& lhs, const etl::array_wrapper<TR, SIZER, ARRAYR>& rhs)
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
@ -388,7 +392,7 @@ namespace etl
|
||||
/// Hash function.
|
||||
//*************************************************************************
|
||||
#if ETL_USING_8BIT_TYPES
|
||||
template <typename T, size_t SIZE, T(&ARRAY)[SIZE]>
|
||||
template <typename T, size_t SIZE, T (&ARRAY)[SIZE]>
|
||||
struct hash<etl::array_wrapper<T, SIZE, ARRAY> >
|
||||
{
|
||||
size_t operator()(const etl::array_wrapper<T, SIZE, ARRAY>& aw) const
|
||||
@ -400,19 +404,17 @@ namespace etl
|
||||
}
|
||||
};
|
||||
#endif
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
//*************************************************************************
|
||||
/// Swap.
|
||||
//*************************************************************************
|
||||
template <typename T, size_t SIZE, T(&ARRAYL)[SIZE], T(&ARRAYR)[SIZE]>
|
||||
void swap(etl::array_wrapper<T, SIZE, ARRAYL>& lhs,
|
||||
etl::array_wrapper<T, SIZE, ARRAYR>& rhs)
|
||||
template <typename T, size_t SIZE, T (&ARRAYL)[SIZE], T (&ARRAYR)[SIZE]>
|
||||
void swap(etl::array_wrapper<T, SIZE, ARRAYL>& lhs, etl::array_wrapper<T, SIZE, ARRAYR>& rhs)
|
||||
{
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
#define ETL_ARRAY_WRAPPER(arraytype, arrayobject) etl::array_wrapper<arraytype, ETL_ARRAY_SIZE(arrayobject), arrayobject>
|
||||
#define ETL_ARRAY_WRAPPER(arraytype, arrayobject) etl::array_wrapper<arraytype, ETL_ARRAY_SIZE(arrayobject), arrayobject>
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ SOFTWARE.
|
||||
#include "platform.h"
|
||||
|
||||
#if ETL_HAS_ATOMIC
|
||||
#if (ETL_USING_CPP11 && (ETL_USING_STL || defined(ETL_IN_UNIT_TEST)))
|
||||
#if (ETL_USING_CPP11 && (ETL_USING_STL || defined(ETL_IN_UNIT_TEST)))
|
||||
#include "atomic/atomic_std.h"
|
||||
#elif defined(ETL_COMPILER_ARM5)
|
||||
#include "atomic/atomic_arm.h"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -30,8 +30,8 @@ SOFTWARE.
|
||||
#define ETL_ATOMIC_STD_INCLUDED
|
||||
|
||||
#include "../platform.h"
|
||||
#include "../nullptr.h"
|
||||
#include "../char_traits.h"
|
||||
#include "../nullptr.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <stdint.h>
|
||||
@ -55,39 +55,39 @@ namespace etl
|
||||
static ETL_CONSTANT etl::memory_order memory_order_acq_rel = std::memory_order_acq_rel;
|
||||
static ETL_CONSTANT etl::memory_order memory_order_seq_cst = std::memory_order_seq_cst;
|
||||
|
||||
using atomic_bool = std::atomic<bool>;
|
||||
using atomic_char = std::atomic<char>;
|
||||
using atomic_schar = std::atomic<signed char>;
|
||||
using atomic_uchar = std::atomic<unsigned char>;
|
||||
using atomic_short = std::atomic<short>;
|
||||
using atomic_ushort = std::atomic<unsigned short>;
|
||||
using atomic_int = std::atomic<int>;
|
||||
using atomic_uint = std::atomic<unsigned int>;
|
||||
using atomic_long = std::atomic<long>;
|
||||
using atomic_ulong = std::atomic<unsigned long>;
|
||||
using atomic_llong = std::atomic<long long>;
|
||||
using atomic_ullong = std::atomic<unsigned long long>;
|
||||
using atomic_wchar_t = std::atomic<wchar_t>;
|
||||
using atomic_bool = std::atomic<bool>;
|
||||
using atomic_char = std::atomic<char>;
|
||||
using atomic_schar = std::atomic<signed char>;
|
||||
using atomic_uchar = std::atomic<unsigned char>;
|
||||
using atomic_short = std::atomic<short>;
|
||||
using atomic_ushort = std::atomic<unsigned short>;
|
||||
using atomic_int = std::atomic<int>;
|
||||
using atomic_uint = std::atomic<unsigned int>;
|
||||
using atomic_long = std::atomic<long>;
|
||||
using atomic_ulong = std::atomic<unsigned long>;
|
||||
using atomic_llong = std::atomic<long long>;
|
||||
using atomic_ullong = std::atomic<unsigned long long>;
|
||||
using atomic_wchar_t = std::atomic<wchar_t>;
|
||||
#if ETL_HAS_NATIVE_CHAR8_T
|
||||
using atomic_char8_t = std::atomic<char8_t>;
|
||||
#endif
|
||||
#if ETL_HAS_NATIVE_CHAR16_T
|
||||
using atomic_char16_t = std::atomic<char16_t>;
|
||||
using atomic_char16_t = std::atomic<char16_t>;
|
||||
#endif
|
||||
#if ETL_HAS_NATIVE_CHAR32_T
|
||||
using atomic_char32_t = std::atomic<char32_t>;
|
||||
using atomic_char32_t = std::atomic<char32_t>;
|
||||
#endif
|
||||
#if ETL_USING_8BIT_TYPES
|
||||
using atomic_uint8_t = std::atomic<uint8_t>;
|
||||
using atomic_int8_t = std::atomic<int8_t>;
|
||||
using atomic_uint8_t = std::atomic<uint8_t>;
|
||||
using atomic_int8_t = std::atomic<int8_t>;
|
||||
#endif
|
||||
using atomic_uint16_t = std::atomic<uint16_t>;
|
||||
using atomic_int16_t = std::atomic<int16_t>;
|
||||
using atomic_uint32_t = std::atomic<uint32_t>;
|
||||
using atomic_int32_t = std::atomic<int32_t>;
|
||||
using atomic_uint16_t = std::atomic<uint16_t>;
|
||||
using atomic_int16_t = std::atomic<int16_t>;
|
||||
using atomic_uint32_t = std::atomic<uint32_t>;
|
||||
using atomic_int32_t = std::atomic<int32_t>;
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
using atomic_uint64_t = std::atomic<uint64_t>;
|
||||
using atomic_int64_t = std::atomic<int64_t>;
|
||||
using atomic_uint64_t = std::atomic<uint64_t>;
|
||||
using atomic_int64_t = std::atomic<int64_t>;
|
||||
#endif
|
||||
using atomic_int_least8_t = std::atomic<int_least8_t>;
|
||||
using atomic_uint_least8_t = std::atomic<uint_least8_t>;
|
||||
@ -99,22 +99,22 @@ namespace etl
|
||||
using atomic_int_least64_t = std::atomic<int_least64_t>;
|
||||
using atomic_uint_least64_t = std::atomic<uint_least64_t>;
|
||||
#endif
|
||||
using atomic_int_fast8_t = std::atomic<int_fast8_t>;
|
||||
using atomic_uint_fast8_t = std::atomic<uint_fast8_t>;
|
||||
using atomic_int_fast16_t = std::atomic<int_fast16_t>;
|
||||
using atomic_uint_fast16_t = std::atomic<uint_fast16_t>;
|
||||
using atomic_int_fast32_t = std::atomic<int_fast32_t>;
|
||||
using atomic_uint_fast32_t = std::atomic<uint_fast32_t>;
|
||||
using atomic_int_fast8_t = std::atomic<int_fast8_t>;
|
||||
using atomic_uint_fast8_t = std::atomic<uint_fast8_t>;
|
||||
using atomic_int_fast16_t = std::atomic<int_fast16_t>;
|
||||
using atomic_uint_fast16_t = std::atomic<uint_fast16_t>;
|
||||
using atomic_int_fast32_t = std::atomic<int_fast32_t>;
|
||||
using atomic_uint_fast32_t = std::atomic<uint_fast32_t>;
|
||||
#if ETL_USING_64BIT_TYPES
|
||||
using atomic_int_fast64_t = std::atomic<int_fast64_t>;
|
||||
using atomic_uint_fast64_t = std::atomic<uint_fast64_t>;
|
||||
using atomic_int_fast64_t = std::atomic<int_fast64_t>;
|
||||
using atomic_uint_fast64_t = std::atomic<uint_fast64_t>;
|
||||
#endif
|
||||
using atomic_intptr_t = std::atomic<intptr_t>;
|
||||
using atomic_uintptr_t = std::atomic<uintptr_t>;
|
||||
using atomic_size_t = std::atomic<size_t>;
|
||||
using atomic_ptrdiff_t = std::atomic<ptrdiff_t>;
|
||||
using atomic_intmax_t = std::atomic<intmax_t>;
|
||||
using atomic_uintmax_t = std::atomic<uintmax_t>;
|
||||
}
|
||||
using atomic_intptr_t = std::atomic<intptr_t>;
|
||||
using atomic_uintptr_t = std::atomic<uintptr_t>;
|
||||
using atomic_size_t = std::atomic<size_t>;
|
||||
using atomic_ptrdiff_t = std::atomic<ptrdiff_t>;
|
||||
using atomic_intmax_t = std::atomic<intmax_t>;
|
||||
using atomic_uintmax_t = std::atomic<uintmax_t>;
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
@ -27,27 +27,29 @@ SOFTWARE.
|
||||
#define ETL_BASE64_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "static_assert.h"
|
||||
#include "exception.h"
|
||||
#include "error_handler.h"
|
||||
#include "type_traits.h"
|
||||
#include "enum_type.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "integral_limits.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/**************************************************************************************************************************************************************************
|
||||
* See https://en.wikipedia.org/wiki/Base64
|
||||
*
|
||||
* Encoding Encoding characters Separate encoding of lines Decoding non-encoding characters
|
||||
* 62nd 63rd Pad Separators Length Checksum
|
||||
* RFC 1421 : Base64 for Privacy - Enhanced Mail(deprecated) + / = mandatory CR + LF 64, or lower for the last line No No
|
||||
* RFC 2045 : Base64 transfer encoding for MIME + / = mandatory CR + LF At most 76 No Discarded
|
||||
* RFC 2152 : Base64 for UTF - 7 + / No No No
|
||||
* RFC 3501 : Base64 encoding for IMAP mailbox names + , No No No
|
||||
* RFC 4648 : base64(standard)[a] + / = optional No No
|
||||
* RFC 4648 : base64url(URL - and filename - safe standard) - _ = optional No No
|
||||
**************************************************************************************************************************************************************************/
|
||||
* See https://en.wikipedia.org/wiki/Base64
|
||||
*
|
||||
* Encoding Encoding characters
|
||||
*Separate encoding of lines Decoding non-encoding characters 62nd 63rd Pad
|
||||
*Separators Length Checksum RFC 1421 : Base64 for
|
||||
*Privacy - Enhanced Mail(deprecated) + / = mandatory CR + LF 64,
|
||||
*or lower for the last line No No RFC 2045 : Base64 transfer encoding for MIME
|
||||
*+ / = mandatory CR + LF At most 76 No Discarded RFC 2152 : Base64
|
||||
*for UTF - 7 + / No No No RFC
|
||||
*3501 : Base64 encoding for IMAP mailbox names + , No
|
||||
*No No RFC 4648 : base64(standard)[a] + / = optional No No RFC 4648 :
|
||||
*base64url(URL - and filename - safe standard) - _ = optional No No
|
||||
**************************************************************************************************************************************************************************/
|
||||
|
||||
namespace etl
|
||||
{
|
||||
@ -114,8 +116,8 @@ namespace etl
|
||||
{
|
||||
enum enum_type
|
||||
{
|
||||
//RFC_1421, // Not implemented
|
||||
//RFC_2045, // Not implemented
|
||||
// RFC_1421, // Not implemented
|
||||
// RFC_2045, // Not implemented
|
||||
RFC_2152,
|
||||
RFC_3501,
|
||||
RFC_4648,
|
||||
@ -125,8 +127,8 @@ namespace etl
|
||||
};
|
||||
|
||||
ETL_DECLARE_ENUM_TYPE(Encoding, int)
|
||||
//ETL_ENUM_TYPE(RFC_1421, "RFC_1421") // Not implemented
|
||||
//ETL_ENUM_TYPE(RFC_2045, "RFC_2045") // Not implemented
|
||||
// ETL_ENUM_TYPE(RFC_1421, "RFC_1421") // Not implemented
|
||||
// ETL_ENUM_TYPE(RFC_2045, "RFC_2045") // Not implemented
|
||||
ETL_ENUM_TYPE(RFC_2152, "RFC_2152")
|
||||
ETL_ENUM_TYPE(RFC_3501, "RFC_3501")
|
||||
ETL_ENUM_TYPE(RFC_4648, "RFC_4648")
|
||||
@ -166,16 +168,14 @@ namespace etl
|
||||
|
||||
enum
|
||||
{
|
||||
Invalid_Data = etl::integral_limits<int>::max,
|
||||
Invalid_Data = etl::integral_limits<int>::max,
|
||||
Min_Encode_Buffer_Size = 4,
|
||||
Min_Decode_Buffer_Size = 3
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
ETL_CONSTEXPR14
|
||||
base64(const char* encoder_table_,
|
||||
bool use_padding_)
|
||||
ETL_CONSTEXPR14 base64(const char* encoder_table_, bool use_padding_)
|
||||
: encoder_table(encoder_table_)
|
||||
, use_padding(use_padding_)
|
||||
{
|
||||
@ -184,9 +184,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Character set for RFC-1421, RFC-2045, RFC-2152 and RFC-4648
|
||||
//*************************************************************************
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
const char* character_set_1()
|
||||
static ETL_CONSTEXPR14 const char* character_set_1()
|
||||
{
|
||||
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
}
|
||||
@ -194,9 +192,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Character set for RFC-4648-URL
|
||||
//*************************************************************************
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
const char* character_set_2()
|
||||
static ETL_CONSTEXPR14 const char* character_set_2()
|
||||
{
|
||||
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
|
||||
}
|
||||
@ -204,9 +200,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Character set for RFC-3501-URL
|
||||
//*************************************************************************
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
const char* character_set_3()
|
||||
static ETL_CONSTEXPR14 const char* character_set_3()
|
||||
{
|
||||
return "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+,";
|
||||
}
|
||||
@ -214,5 +208,5 @@ namespace etl
|
||||
const char* encoder_table;
|
||||
const bool use_padding;
|
||||
};
|
||||
}
|
||||
} // namespace etl
|
||||
#endif
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//*************************************************************************
|
||||
///Decode from Base64 from and to pointer/length
|
||||
/// Decode from Base64 from and to pointer/length
|
||||
//*************************************************************************///\file
|
||||
|
||||
/******************************************************************************
|
||||
@ -29,16 +29,16 @@ SOFTWARE.
|
||||
#define ETL_BASE64_DECODER_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "static_assert.h"
|
||||
#include "error_handler.h"
|
||||
#include "type_traits.h"
|
||||
#include "binary.h"
|
||||
#include "algorithm.h"
|
||||
#include "binary.h"
|
||||
#include "delegate.h"
|
||||
#include "enum_type.h"
|
||||
#include "error_handler.h"
|
||||
#include "integral_limits.h"
|
||||
#include "iterator.h"
|
||||
#include "enum_type.h"
|
||||
#include "delegate.h"
|
||||
#include "span.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include "base64.h"
|
||||
|
||||
@ -48,11 +48,12 @@ SOFTWARE.
|
||||
#include <iterator>
|
||||
#endif
|
||||
|
||||
#define ETL_IS_8_BIT_INTEGRAL(Type) (etl::is_integral<typename etl::remove_cv<Type>::type>::value && \
|
||||
(etl::integral_limits<typename etl::remove_cv<Type>::type>::bits == 8U))
|
||||
#define ETL_IS_8_BIT_INTEGRAL(Type) \
|
||||
(etl::is_integral<typename etl::remove_cv<Type>::type>::value && (etl::integral_limits<typename etl::remove_cv<Type>::type>::bits == 8U))
|
||||
|
||||
#define ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(Type) (etl::is_integral<typename etl::iterator_traits<typename etl::remove_cv<Type>::type>::value_type>::value && \
|
||||
(etl::integral_limits<typename etl::iterator_traits<typename etl::remove_cv<Type>::type>::value_type>::bits == 8U))
|
||||
#define ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(Type) \
|
||||
(etl::is_integral< typename etl::iterator_traits< typename etl::remove_cv<Type>::type>::value_type>::value \
|
||||
&& (etl::integral_limits< typename etl::iterator_traits< typename etl::remove_cv<Type>::type>::value_type>::bits == 8U))
|
||||
|
||||
namespace etl
|
||||
{
|
||||
@ -70,8 +71,7 @@ namespace etl
|
||||
/// Decode to Base64
|
||||
//*************************************************************************
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14
|
||||
bool decode(T value)
|
||||
ETL_CONSTEXPR14 bool decode(T value)
|
||||
{
|
||||
ETL_STATIC_ASSERT(ETL_IS_8_BIT_INTEGRAL(T), "Input type must be an 8 bit integral");
|
||||
|
||||
@ -101,8 +101,7 @@ namespace etl
|
||||
/// Decode from Base64
|
||||
//*************************************************************************
|
||||
template <typename TInputIterator>
|
||||
ETL_CONSTEXPR14
|
||||
bool decode(TInputIterator input_begin, TInputIterator input_end)
|
||||
ETL_CONSTEXPR14 bool decode(TInputIterator input_begin, TInputIterator input_end)
|
||||
{
|
||||
ETL_STATIC_ASSERT(ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(TInputIterator), "Input type must be an 8 bit integral");
|
||||
|
||||
@ -121,8 +120,7 @@ namespace etl
|
||||
/// Decode from Base64
|
||||
//*************************************************************************
|
||||
template <typename TInputIterator>
|
||||
ETL_CONSTEXPR14
|
||||
bool decode(TInputIterator input_begin, size_t input_length)
|
||||
ETL_CONSTEXPR14 bool decode(TInputIterator input_begin, size_t input_length)
|
||||
{
|
||||
ETL_STATIC_ASSERT(ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(TInputIterator), "Input type must be an 8 bit integral");
|
||||
|
||||
@ -141,8 +139,7 @@ namespace etl
|
||||
/// Decode from Base64
|
||||
//*************************************************************************
|
||||
template <typename TInputIterator>
|
||||
ETL_CONSTEXPR14
|
||||
bool decode_final(TInputIterator input_begin, TInputIterator input_end)
|
||||
ETL_CONSTEXPR14 bool decode_final(TInputIterator input_begin, TInputIterator input_end)
|
||||
{
|
||||
return decode(input_begin, input_end) && flush();
|
||||
}
|
||||
@ -151,8 +148,7 @@ namespace etl
|
||||
/// Decode from Base64
|
||||
//*************************************************************************
|
||||
template <typename TInputIterator>
|
||||
ETL_CONSTEXPR14
|
||||
bool decode_final(TInputIterator input_begin, size_t input_length)
|
||||
ETL_CONSTEXPR14 bool decode_final(TInputIterator input_begin, size_t input_length)
|
||||
{
|
||||
return decode(input_begin, input_length) && flush();
|
||||
}
|
||||
@ -160,8 +156,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Flush any remaining data to the output.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
bool flush()
|
||||
ETL_CONSTEXPR14 bool flush()
|
||||
{
|
||||
// Encode any remaining input data.
|
||||
bool success = decode_block();
|
||||
@ -193,32 +188,28 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Reset the encoder.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
void restart()
|
||||
ETL_CONSTEXPR14 void restart()
|
||||
{
|
||||
reset_input_buffer();
|
||||
reset_output_buffer();
|
||||
overflow_detected = false;
|
||||
overflow_detected = false;
|
||||
invalid_data_detected = false;
|
||||
padding_received = false;
|
||||
padding_received = false;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the beginning of the output buffer.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const unsigned char* begin() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 const unsigned char* begin() const
|
||||
{
|
||||
return p_output_buffer;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// This only returns a useful value if a callback has not been set or called.
|
||||
/// This only returns a useful value if a callback has not been set or
|
||||
/// called.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const unsigned char* end() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 const unsigned char* end() const
|
||||
{
|
||||
return p_output_buffer + output_buffer_length;
|
||||
}
|
||||
@ -226,30 +217,26 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the beginning of the output buffer.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const unsigned char* cbegin() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 const unsigned char* cbegin() const
|
||||
{
|
||||
return p_output_buffer;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// This only returns a useful value if a callback has not been set or called.
|
||||
/// This only returns a useful value if a callback has not been set or
|
||||
/// called.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const unsigned char* cend() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 const unsigned char* cend() const
|
||||
{
|
||||
return p_output_buffer + output_buffer_length;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the size of the output buffer.
|
||||
/// This only returns a useful value if a callback has not been set or called.
|
||||
/// This only returns a useful value if a callback has not been set or
|
||||
/// called.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
size_t size() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 size_t size() const
|
||||
{
|
||||
return output_buffer_length;
|
||||
}
|
||||
@ -257,20 +244,17 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the maximum size of the output buffer.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
size_t buffer_size() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 size_t buffer_size() const
|
||||
{
|
||||
return output_buffer_max_size;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Get a span of the output data.
|
||||
/// This only returns a useful span if a callback has not been set or called.
|
||||
/// This only returns a useful span if a callback has not been set or
|
||||
/// called.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
span_type span() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 span_type span() const
|
||||
{
|
||||
return span_type(begin(), end());
|
||||
}
|
||||
@ -278,9 +262,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns true if the output buffer has overflowed
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
bool overflow() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 bool overflow() const
|
||||
{
|
||||
return overflow_detected;
|
||||
}
|
||||
@ -288,9 +270,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns true if an invalid character was detected.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
bool invalid_data() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 bool invalid_data() const
|
||||
{
|
||||
return invalid_data_detected;
|
||||
}
|
||||
@ -298,9 +278,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns true if an error was detected.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
bool error() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 bool error() const
|
||||
{
|
||||
return overflow() || invalid_data();
|
||||
}
|
||||
@ -310,12 +288,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Constructor
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
ibase64_decoder(const char* encoder_table_,
|
||||
bool use_padding_,
|
||||
unsigned char* p_output_buffer_,
|
||||
size_t ouput_buffer_max_size_,
|
||||
callback_type callback_)
|
||||
ETL_CONSTEXPR14 ibase64_decoder(const char* encoder_table_, bool use_padding_, unsigned char* p_output_buffer_, size_t ouput_buffer_max_size_,
|
||||
callback_type callback_)
|
||||
: base64(encoder_table_, use_padding_)
|
||||
, input_buffer()
|
||||
, input_buffer_length(0)
|
||||
@ -333,9 +307,7 @@ namespace etl
|
||||
/// Calculates the minimum buffer size required to decode from Base64
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t decoded_size_from_valid_input_length(size_t input_length)
|
||||
static ETL_CONSTEXPR14 size_t decoded_size_from_valid_input_length(size_t input_length)
|
||||
{
|
||||
return input_length - (input_length / 4U);
|
||||
}
|
||||
@ -343,14 +315,13 @@ namespace etl
|
||||
private:
|
||||
|
||||
//*************************************************************************
|
||||
// Translates a sextet into an index
|
||||
// Translates a sextet into an index
|
||||
//*************************************************************************
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14
|
||||
uint32_t get_index_from_sextet(T sextet)
|
||||
ETL_CONSTEXPR14 uint32_t get_index_from_sextet(T sextet)
|
||||
{
|
||||
const char* encoder_table_end = encoder_table + 64;
|
||||
const char* p_sextet = etl::find(encoder_table, encoder_table_end, static_cast<char>(sextet));
|
||||
const char* p_sextet = etl::find(encoder_table, encoder_table_end, static_cast<char>(sextet));
|
||||
|
||||
if (p_sextet != encoder_table_end)
|
||||
{
|
||||
@ -369,8 +340,7 @@ namespace etl
|
||||
template <typename T>
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
T padding()
|
||||
ETL_CONSTEXPR14 T padding()
|
||||
{
|
||||
return static_cast<T>('=');
|
||||
}
|
||||
@ -378,51 +348,50 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Decode one block of data.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
bool decode_block()
|
||||
ETL_CONSTEXPR14 bool decode_block()
|
||||
{
|
||||
switch (input_buffer_length)
|
||||
{
|
||||
// Only triggered on call to flush().
|
||||
case 2:
|
||||
{
|
||||
uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 6);
|
||||
sextets = sextets | (get_index_from_sextet(input_buffer[1]));
|
||||
push_to_output_buffer((sextets >> 4) & 0xFF);
|
||||
break;
|
||||
}
|
||||
{
|
||||
uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 6);
|
||||
sextets = sextets | (get_index_from_sextet(input_buffer[1]));
|
||||
push_to_output_buffer((sextets >> 4) & 0xFF);
|
||||
break;
|
||||
}
|
||||
|
||||
// Only triggered on call to flush().
|
||||
case 3:
|
||||
{
|
||||
uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 12);
|
||||
sextets = sextets | (get_index_from_sextet(input_buffer[1]) << 6);
|
||||
sextets = sextets | (get_index_from_sextet(input_buffer[2]));
|
||||
push_to_output_buffer((sextets >> 10) & 0xFF);
|
||||
push_to_output_buffer((sextets >> 2) & 0xFF);
|
||||
break;
|
||||
}
|
||||
{
|
||||
uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 12);
|
||||
sextets = sextets | (get_index_from_sextet(input_buffer[1]) << 6);
|
||||
sextets = sextets | (get_index_from_sextet(input_buffer[2]));
|
||||
push_to_output_buffer((sextets >> 10) & 0xFF);
|
||||
push_to_output_buffer((sextets >> 2) & 0xFF);
|
||||
break;
|
||||
}
|
||||
|
||||
// Only triggered on call to decode().
|
||||
case 4:
|
||||
{
|
||||
// Read in four sextets
|
||||
uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 18);
|
||||
sextets = sextets | (get_index_from_sextet(input_buffer[1]) << 12);
|
||||
sextets = sextets | (get_index_from_sextet(input_buffer[2]) << 6);
|
||||
sextets = sextets | (get_index_from_sextet(input_buffer[3]));
|
||||
{
|
||||
// Read in four sextets
|
||||
uint32_t sextets = (get_index_from_sextet(input_buffer[0]) << 18);
|
||||
sextets = sextets | (get_index_from_sextet(input_buffer[1]) << 12);
|
||||
sextets = sextets | (get_index_from_sextet(input_buffer[2]) << 6);
|
||||
sextets = sextets | (get_index_from_sextet(input_buffer[3]));
|
||||
|
||||
// Write out three octets
|
||||
push_to_output_buffer((sextets >> 16) & 0xFF);
|
||||
push_to_output_buffer((sextets >> 8) & 0xFF);
|
||||
push_to_output_buffer((sextets >> 0) & 0xFF);
|
||||
break;
|
||||
}
|
||||
// Write out three octets
|
||||
push_to_output_buffer((sextets >> 16) & 0xFF);
|
||||
push_to_output_buffer((sextets >> 8) & 0xFF);
|
||||
push_to_output_buffer((sextets >> 0) & 0xFF);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ETL_ASSERT(!invalid_data_detected, ETL_ERROR(etl::base64_invalid_data));
|
||||
@ -434,8 +403,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Push to the output buffer.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
void push_to_output_buffer(unsigned char c)
|
||||
ETL_CONSTEXPR14 void push_to_output_buffer(unsigned char c)
|
||||
{
|
||||
if (output_buffer_length < output_buffer_max_size)
|
||||
{
|
||||
@ -448,28 +416,25 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
//
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
bool output_buffer_is_full() const
|
||||
ETL_CONSTEXPR14 bool output_buffer_is_full() const
|
||||
{
|
||||
return output_buffer_length == output_buffer_max_size;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
//
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
bool output_buffer_is_empty() const
|
||||
ETL_CONSTEXPR14 bool output_buffer_is_empty() const
|
||||
{
|
||||
return output_buffer_length == 0;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
//
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
void reset_output_buffer()
|
||||
ETL_CONSTEXPR14 void reset_output_buffer()
|
||||
{
|
||||
output_buffer_length = 0;
|
||||
}
|
||||
@ -478,8 +443,7 @@ namespace etl
|
||||
// Push to the input buffer.
|
||||
//*************************************************************************
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14
|
||||
void push_to_input_buffer(T value)
|
||||
ETL_CONSTEXPR14 void push_to_input_buffer(T value)
|
||||
{
|
||||
if (value == padding<T>())
|
||||
{
|
||||
@ -494,25 +458,23 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
input_buffer[input_buffer_length++] = static_cast<uint8_t>(value);
|
||||
input_buffer[input_buffer_length++] = static_cast<char>(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
//
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
bool input_buffer_is_full() const
|
||||
ETL_CONSTEXPR14 bool input_buffer_is_full() const
|
||||
{
|
||||
return input_buffer_length == 4U;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
//
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
void reset_input_buffer()
|
||||
ETL_CONSTEXPR14 void reset_input_buffer()
|
||||
{
|
||||
input_buffer_length = 0;
|
||||
}
|
||||
@ -544,13 +506,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-2152 constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc2152_decoder()
|
||||
: ibase64_decoder(etl::base64::character_set_1(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_type())
|
||||
ETL_CONSTEXPR14 base64_rfc2152_decoder()
|
||||
: ibase64_decoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -558,13 +515,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-2152 constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc2152_decoder(callback_type callback_)
|
||||
: ibase64_decoder(etl::base64::character_set_1(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_)
|
||||
ETL_CONSTEXPR14 base64_rfc2152_decoder(callback_type callback_)
|
||||
: ibase64_decoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -574,8 +526,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t safe_output_buffer_size(size_t input_length)
|
||||
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
|
||||
{
|
||||
return ibase64_decoder::decoded_size_from_valid_input_length(input_length);
|
||||
}
|
||||
@ -599,13 +550,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-3501 constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc3501_decoder()
|
||||
: ibase64_decoder(etl::base64::character_set_3(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_type())
|
||||
ETL_CONSTEXPR14 base64_rfc3501_decoder()
|
||||
: ibase64_decoder(etl::base64::character_set_3(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -613,13 +559,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-3501 constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc3501_decoder(callback_type callback_)
|
||||
: ibase64_decoder(etl::base64::character_set_3(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_)
|
||||
ETL_CONSTEXPR14 base64_rfc3501_decoder(callback_type callback_)
|
||||
: ibase64_decoder(etl::base64::character_set_3(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -629,8 +570,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t safe_output_buffer_size(size_t input_length)
|
||||
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
|
||||
{
|
||||
return ibase64_decoder::decoded_size_from_valid_input_length(input_length);
|
||||
}
|
||||
@ -654,13 +594,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648 constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_decoder()
|
||||
: ibase64_decoder(etl::base64::character_set_1(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_type())
|
||||
ETL_CONSTEXPR14 base64_rfc4648_decoder()
|
||||
: ibase64_decoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -668,13 +603,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648 constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_decoder(callback_type callback_)
|
||||
: ibase64_decoder(etl::base64::character_set_1(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_)
|
||||
ETL_CONSTEXPR14 base64_rfc4648_decoder(callback_type callback_)
|
||||
: ibase64_decoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -683,9 +613,8 @@ namespace etl
|
||||
/// Calculate the required output encode buffer size.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t safe_output_buffer_size(size_t input_length)
|
||||
static
|
||||
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
|
||||
{
|
||||
return ibase64_decoder::decoded_size_from_valid_input_length(input_length);
|
||||
}
|
||||
@ -709,13 +638,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648-Padding constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_padding_decoder()
|
||||
: ibase64_decoder(etl::base64::character_set_1(),
|
||||
etl::base64::Padding::Use_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_type())
|
||||
ETL_CONSTEXPR14 base64_rfc4648_padding_decoder()
|
||||
: ibase64_decoder(etl::base64::character_set_1(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_type())
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -723,13 +647,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648-Padding constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_padding_decoder(callback_type callback_)
|
||||
: ibase64_decoder(etl::base64::character_set_1(),
|
||||
etl::base64::Padding::Use_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_)
|
||||
ETL_CONSTEXPR14 base64_rfc4648_padding_decoder(callback_type callback_)
|
||||
: ibase64_decoder(etl::base64::character_set_1(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_)
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -739,8 +658,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t safe_output_buffer_size(size_t input_length)
|
||||
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
|
||||
{
|
||||
return ibase64_decoder::decoded_size_from_valid_input_length(input_length);
|
||||
}
|
||||
@ -764,13 +682,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648-Padding constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_url_decoder()
|
||||
: ibase64_decoder(etl::base64::character_set_2(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_type())
|
||||
ETL_CONSTEXPR14 base64_rfc4648_url_decoder()
|
||||
: ibase64_decoder(etl::base64::character_set_2(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -778,13 +691,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648-Padding constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_url_decoder(callback_type callback_)
|
||||
: ibase64_decoder(etl::base64::character_set_2(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_)
|
||||
ETL_CONSTEXPR14 base64_rfc4648_url_decoder(callback_type callback_)
|
||||
: ibase64_decoder(etl::base64::character_set_2(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -794,8 +702,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t safe_output_buffer_size(size_t input_length)
|
||||
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
|
||||
{
|
||||
return ibase64_decoder::decoded_size_from_valid_input_length(input_length);
|
||||
}
|
||||
@ -819,13 +726,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648-Padding constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_url_padding_decoder()
|
||||
: ibase64_decoder(etl::base64::character_set_2(),
|
||||
etl::base64::Padding::Use_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_type())
|
||||
ETL_CONSTEXPR14 base64_rfc4648_url_padding_decoder()
|
||||
: ibase64_decoder(etl::base64::character_set_2(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_type())
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -833,13 +735,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648-Padding constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_url_padding_decoder(callback_type callback_)
|
||||
: ibase64_decoder(etl::base64::character_set_2(),
|
||||
etl::base64::Padding::Use_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_)
|
||||
ETL_CONSTEXPR14 base64_rfc4648_url_padding_decoder(callback_type callback_)
|
||||
: ibase64_decoder(etl::base64::character_set_2(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_)
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -849,8 +746,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t safe_output_buffer_size(size_t input_length)
|
||||
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
|
||||
{
|
||||
return ibase64_decoder::decoded_size_from_valid_input_length(input_length);
|
||||
}
|
||||
@ -860,7 +756,7 @@ namespace etl
|
||||
/// The internal output buffer.
|
||||
unsigned char output_buffer[Buffer_Size];
|
||||
};
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#undef ETL_IS_TYPE_8_BIT_INTEGRAL
|
||||
#undef ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
//*************************************************************************
|
||||
///Decode from Base64 from and to pointer/length
|
||||
/// Decode from Base64 from and to pointer/length
|
||||
//*************************************************************************///\file
|
||||
|
||||
/******************************************************************************
|
||||
@ -29,16 +29,16 @@ SOFTWARE.
|
||||
#define ETL_BASE64_ENCODER_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "static_assert.h"
|
||||
#include "error_handler.h"
|
||||
#include "type_traits.h"
|
||||
#include "binary.h"
|
||||
#include "algorithm.h"
|
||||
#include "binary.h"
|
||||
#include "delegate.h"
|
||||
#include "enum_type.h"
|
||||
#include "error_handler.h"
|
||||
#include "integral_limits.h"
|
||||
#include "iterator.h"
|
||||
#include "enum_type.h"
|
||||
#include "delegate.h"
|
||||
#include "span.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include "base64.h"
|
||||
|
||||
@ -48,11 +48,12 @@ SOFTWARE.
|
||||
#include <iterator>
|
||||
#endif
|
||||
|
||||
#define ETL_IS_8_BIT_INTEGRAL(Type) (etl::is_integral<typename etl::remove_cv<Type>::type>::value && \
|
||||
(etl::integral_limits<typename etl::remove_cv<Type>::type>::bits == 8U))
|
||||
#define ETL_IS_8_BIT_INTEGRAL(Type) \
|
||||
(etl::is_integral<typename etl::remove_cv<Type>::type>::value && (etl::integral_limits<typename etl::remove_cv<Type>::type>::bits == 8U))
|
||||
|
||||
#define ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(Type) (etl::is_integral<typename etl::iterator_traits<typename etl::remove_cv<Type>::type>::value_type>::value && \
|
||||
(etl::integral_limits<typename etl::iterator_traits<typename etl::remove_cv<Type>::type>::value_type>::bits == 8U))
|
||||
#define ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(Type) \
|
||||
(etl::is_integral< typename etl::iterator_traits< typename etl::remove_cv<Type>::type>::value_type>::value \
|
||||
&& (etl::integral_limits< typename etl::iterator_traits< typename etl::remove_cv<Type>::type>::value_type>::bits == 8U))
|
||||
|
||||
namespace etl
|
||||
{
|
||||
@ -70,8 +71,7 @@ namespace etl
|
||||
/// Encode to Base64
|
||||
//*************************************************************************
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14
|
||||
bool encode(T value)
|
||||
ETL_CONSTEXPR14 bool encode(T value)
|
||||
{
|
||||
ETL_STATIC_ASSERT(ETL_IS_8_BIT_INTEGRAL(T), "Input type must be an 8 bit integral");
|
||||
|
||||
@ -99,8 +99,7 @@ namespace etl
|
||||
/// Encode to Base64
|
||||
//*************************************************************************
|
||||
template <typename TInputIterator>
|
||||
ETL_CONSTEXPR14
|
||||
bool encode(TInputIterator input_begin, size_t input_length)
|
||||
ETL_CONSTEXPR14 bool encode(TInputIterator input_begin, size_t input_length)
|
||||
{
|
||||
ETL_STATIC_ASSERT(ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(TInputIterator), "Input type must be an 8 bit integral");
|
||||
|
||||
@ -119,8 +118,7 @@ namespace etl
|
||||
/// Encode to Base64
|
||||
//*************************************************************************
|
||||
template <typename TInputIterator>
|
||||
ETL_CONSTEXPR14
|
||||
bool encode(TInputIterator input_begin, TInputIterator input_end)
|
||||
ETL_CONSTEXPR14 bool encode(TInputIterator input_begin, TInputIterator input_end)
|
||||
{
|
||||
ETL_STATIC_ASSERT(ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL(TInputIterator), "Input type must be an 8 bit integral");
|
||||
|
||||
@ -139,8 +137,7 @@ namespace etl
|
||||
/// Encode to Base64
|
||||
//*************************************************************************
|
||||
template <typename TInputIterator>
|
||||
ETL_CONSTEXPR14
|
||||
bool encode_final(TInputIterator input_begin, size_t input_length)
|
||||
ETL_CONSTEXPR14 bool encode_final(TInputIterator input_begin, size_t input_length)
|
||||
{
|
||||
return encode(input_begin, input_length) && flush();
|
||||
}
|
||||
@ -149,8 +146,7 @@ namespace etl
|
||||
/// Encode to Base64
|
||||
//*************************************************************************
|
||||
template <typename TInputIterator>
|
||||
ETL_CONSTEXPR14
|
||||
bool encode_final(TInputIterator input_begin, TInputIterator input_end)
|
||||
ETL_CONSTEXPR14 bool encode_final(TInputIterator input_begin, TInputIterator input_end)
|
||||
{
|
||||
return encode(input_begin, input_end) && flush();
|
||||
}
|
||||
@ -158,8 +154,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Flush any remaining data to the output.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
bool flush()
|
||||
ETL_CONSTEXPR14 bool flush()
|
||||
{
|
||||
// Encode any remaining input data.
|
||||
bool success = encode_block();
|
||||
@ -189,8 +184,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Reset the encoder.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
void restart()
|
||||
ETL_CONSTEXPR14 void restart()
|
||||
{
|
||||
reset_input_buffer();
|
||||
reset_output_buffer();
|
||||
@ -199,19 +193,16 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the beginning of the output buffer.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const char* begin() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 const char* begin() const
|
||||
{
|
||||
return p_output_buffer;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// This only returns a useful value if a callback has not been set or called.
|
||||
/// This only returns a useful value if a callback has not been set or
|
||||
/// called.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const char* end() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 const char* end() const
|
||||
{
|
||||
return p_output_buffer + output_buffer_length;
|
||||
}
|
||||
@ -219,30 +210,26 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the beginning of the output buffer.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const char* cbegin() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 const char* cbegin() const
|
||||
{
|
||||
return p_output_buffer;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// This only returns a useful value if a callback has not been set or called.
|
||||
/// This only returns a useful value if a callback has not been set or
|
||||
/// called.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
const char* cend() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 const char* cend() const
|
||||
{
|
||||
return p_output_buffer + output_buffer_length;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Returns the size of the output buffer.
|
||||
/// This only returns a useful value if a callback has not been set or called.
|
||||
/// This only returns a useful value if a callback has not been set or
|
||||
/// called.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
size_t size() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 size_t size() const
|
||||
{
|
||||
return output_buffer_length;
|
||||
}
|
||||
@ -250,20 +237,17 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns the maximum size of the output buffer.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
size_t max_size() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 size_t max_size() const
|
||||
{
|
||||
return output_buffer_max_size;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
/// Get a span of the output data.
|
||||
/// This only returns a useful span if a callback has not been set or called.
|
||||
/// This only returns a useful span if a callback has not been set or
|
||||
/// called.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
span_type span() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 span_type span() const
|
||||
{
|
||||
return span_type(begin(), end());
|
||||
}
|
||||
@ -271,9 +255,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns true if the output buffer has overflowed
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
bool overflow() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 bool overflow() const
|
||||
{
|
||||
return overflowed;
|
||||
}
|
||||
@ -281,9 +263,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Returns true if an error was detected.
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
bool error() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 bool error() const
|
||||
{
|
||||
return overflow();
|
||||
}
|
||||
@ -293,12 +273,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Constructor
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
ibase64_encoder(const char* encoder_table_,
|
||||
bool use_padding_,
|
||||
char* p_output_buffer_,
|
||||
size_t ouput_buffer_max_size_,
|
||||
callback_type callback_)
|
||||
ETL_CONSTEXPR14 ibase64_encoder(const char* encoder_table_, bool use_padding_, char* p_output_buffer_, size_t ouput_buffer_max_size_,
|
||||
callback_type callback_)
|
||||
: base64(encoder_table_, use_padding_)
|
||||
, input_buffer()
|
||||
, input_buffer_length(0)
|
||||
@ -313,64 +289,65 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Encode one block of data.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
bool encode_block()
|
||||
ETL_CONSTEXPR14 bool encode_block()
|
||||
{
|
||||
switch (input_buffer_length)
|
||||
{
|
||||
// Only triggered on call to flush().
|
||||
case 1:
|
||||
{
|
||||
uint32_t octets = input_buffer[0];
|
||||
octets = octets << 4; // Adjust one octet (8 bits) for two sextets worth of data (12 bits)
|
||||
|
||||
// Write out two sextets + optional padding.
|
||||
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
|
||||
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
|
||||
|
||||
if (use_padding)
|
||||
{
|
||||
push_to_output_buffer('=');
|
||||
push_to_output_buffer('=');
|
||||
}
|
||||
break;
|
||||
}
|
||||
uint32_t octets = input_buffer[0];
|
||||
octets = octets << 4; // Adjust one octet (8 bits) for two sextets
|
||||
// worth of data (12 bits)
|
||||
|
||||
// Write out two sextets + optional padding.
|
||||
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
|
||||
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
|
||||
|
||||
if (use_padding)
|
||||
{
|
||||
push_to_output_buffer('=');
|
||||
push_to_output_buffer('=');
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Only triggered on call to flush().
|
||||
case 2:
|
||||
{
|
||||
uint32_t octets = (input_buffer[0] << 8) | input_buffer[1];
|
||||
octets <<= 2; // Adjust two octets (16 bits) for three sextets worth of data (18 bits)
|
||||
|
||||
// Write out three sextets + optional padding.
|
||||
push_to_output_buffer(encoder_table[(octets >> 12) & 0x3F]);
|
||||
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
|
||||
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
|
||||
|
||||
if (use_padding)
|
||||
{
|
||||
push_to_output_buffer('=');
|
||||
uint32_t octets = (static_cast<uint32_t>(input_buffer[0]) << 8) | input_buffer[1];
|
||||
octets <<= 2; // Adjust two octets (16 bits) for three sextets worth
|
||||
// of data (18 bits)
|
||||
|
||||
// Write out three sextets + optional padding.
|
||||
push_to_output_buffer(encoder_table[(octets >> 12) & 0x3F]);
|
||||
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
|
||||
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
|
||||
|
||||
if (use_padding)
|
||||
{
|
||||
push_to_output_buffer('=');
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Only triggered on call to encode().
|
||||
case 3:
|
||||
{
|
||||
uint32_t octets = (input_buffer[0] << 16) | (input_buffer[1] << 8) | input_buffer[2];
|
||||
{
|
||||
uint32_t octets = (static_cast<uint32_t>(input_buffer[0]) << 16) | (static_cast<uint32_t>(input_buffer[1]) << 8) | input_buffer[2];
|
||||
|
||||
// Write out four sextets
|
||||
push_to_output_buffer(encoder_table[(octets >> 18) & 0x3F]);
|
||||
push_to_output_buffer(encoder_table[(octets >> 12) & 0x3F]);
|
||||
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
|
||||
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
|
||||
break;
|
||||
}
|
||||
// Write out four sextets
|
||||
push_to_output_buffer(encoder_table[(octets >> 18) & 0x3F]);
|
||||
push_to_output_buffer(encoder_table[(octets >> 12) & 0x3F]);
|
||||
push_to_output_buffer(encoder_table[(octets >> 6) & 0x3F]);
|
||||
push_to_output_buffer(encoder_table[(octets >> 0) & 0x3F]);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ETL_ASSERT(!overflowed, ETL_ERROR(etl::base64_overflow));
|
||||
@ -383,8 +360,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t encoded_size(size_t input_length, bool use_padding)
|
||||
ETL_CONSTEXPR14 size_t encoded_size(size_t input_length, bool use_padding)
|
||||
{
|
||||
size_t required_output_length = 0;
|
||||
|
||||
@ -420,8 +396,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
// Push to the output buffer.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
void push_to_output_buffer(char c)
|
||||
ETL_CONSTEXPR14 void push_to_output_buffer(char c)
|
||||
{
|
||||
if (output_buffer_length < output_buffer_max_size)
|
||||
{
|
||||
@ -434,28 +409,25 @@ namespace etl
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
//
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
bool output_buffer_is_full() const
|
||||
ETL_CONSTEXPR14 bool output_buffer_is_full() const
|
||||
{
|
||||
return output_buffer_length == output_buffer_max_size;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
//
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
bool output_buffer_is_empty() const
|
||||
ETL_CONSTEXPR14 bool output_buffer_is_empty() const
|
||||
{
|
||||
return output_buffer_length == 0;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
//
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
void reset_output_buffer()
|
||||
ETL_CONSTEXPR14 void reset_output_buffer()
|
||||
{
|
||||
output_buffer_length = 0;
|
||||
}
|
||||
@ -464,26 +436,23 @@ namespace etl
|
||||
// Push to the input buffer.
|
||||
//*************************************************************************
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14
|
||||
void push_to_input_buffer(T value)
|
||||
ETL_CONSTEXPR14 void push_to_input_buffer(T value)
|
||||
{
|
||||
input_buffer[input_buffer_length++] = static_cast<uint8_t>(value);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
//
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
bool input_buffer_is_full() const
|
||||
ETL_CONSTEXPR14 bool input_buffer_is_full() const
|
||||
{
|
||||
return input_buffer_length == 3U;
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
//
|
||||
//
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
void reset_input_buffer()
|
||||
ETL_CONSTEXPR14 void reset_input_buffer()
|
||||
{
|
||||
input_buffer_length = 0;
|
||||
}
|
||||
@ -496,7 +465,7 @@ namespace etl
|
||||
const size_t output_buffer_max_size;
|
||||
|
||||
callback_type callback;
|
||||
|
||||
|
||||
bool overflowed;
|
||||
};
|
||||
|
||||
@ -508,19 +477,15 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0), "Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
|
||||
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
|
||||
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-2152 constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc2152_encoder()
|
||||
: ibase64_encoder(etl::base64::character_set_1(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_type())
|
||||
ETL_CONSTEXPR14 base64_rfc2152_encoder()
|
||||
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -528,13 +493,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-2152 constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc2152_encoder(callback_type callback_)
|
||||
: ibase64_encoder(etl::base64::character_set_1(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_)
|
||||
ETL_CONSTEXPR14 base64_rfc2152_encoder(callback_type callback_)
|
||||
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -544,8 +504,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t safe_output_buffer_size(size_t input_length)
|
||||
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
|
||||
{
|
||||
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::No_Padding);
|
||||
}
|
||||
@ -564,19 +523,15 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT(((Buffer_Size% etl::base64::Min_Encode_Buffer_Size) == 0), "Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
|
||||
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
|
||||
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-3501 constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc3501_encoder()
|
||||
: ibase64_encoder(etl::base64::character_set_3(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_type())
|
||||
ETL_CONSTEXPR14 base64_rfc3501_encoder()
|
||||
: ibase64_encoder(etl::base64::character_set_3(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -584,13 +539,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-3501 constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc3501_encoder(callback_type callback_)
|
||||
: ibase64_encoder(etl::base64::character_set_3(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_)
|
||||
ETL_CONSTEXPR14 base64_rfc3501_encoder(callback_type callback_)
|
||||
: ibase64_encoder(etl::base64::character_set_3(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -600,8 +550,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t safe_output_buffer_size(size_t input_length)
|
||||
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
|
||||
{
|
||||
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::No_Padding);
|
||||
}
|
||||
@ -620,19 +569,15 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0), "Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
|
||||
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
|
||||
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648 constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_encoder()
|
||||
: ibase64_encoder(etl::base64::character_set_1(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_type())
|
||||
ETL_CONSTEXPR14 base64_rfc4648_encoder()
|
||||
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -640,13 +585,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648 constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_encoder(callback_type callback_)
|
||||
: ibase64_encoder(etl::base64::character_set_1(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_)
|
||||
ETL_CONSTEXPR14 base64_rfc4648_encoder(callback_type callback_)
|
||||
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -656,8 +596,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t safe_output_buffer_size(size_t input_length)
|
||||
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
|
||||
{
|
||||
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::No_Padding);
|
||||
}
|
||||
@ -676,19 +615,15 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT(((Buffer_Size% etl::base64::Min_Encode_Buffer_Size) == 0), "Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
|
||||
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
|
||||
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648-Padding constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_padding_encoder()
|
||||
: ibase64_encoder(etl::base64::character_set_1(),
|
||||
etl::base64::Padding::Use_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_type())
|
||||
ETL_CONSTEXPR14 base64_rfc4648_padding_encoder()
|
||||
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_type())
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -696,13 +631,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648-Padding constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_padding_encoder(callback_type callback_)
|
||||
: ibase64_encoder(etl::base64::character_set_1(),
|
||||
etl::base64::Padding::Use_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_)
|
||||
ETL_CONSTEXPR14 base64_rfc4648_padding_encoder(callback_type callback_)
|
||||
: ibase64_encoder(etl::base64::character_set_1(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_)
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -712,8 +642,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t safe_output_buffer_size(size_t input_length)
|
||||
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
|
||||
{
|
||||
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::Use_Padding);
|
||||
}
|
||||
@ -732,19 +661,15 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0), "Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
|
||||
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
|
||||
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648-URL constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_url_encoder()
|
||||
: ibase64_encoder(etl::base64::character_set_2(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_type())
|
||||
ETL_CONSTEXPR14 base64_rfc4648_url_encoder()
|
||||
: ibase64_encoder(etl::base64::character_set_2(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_type())
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -752,13 +677,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648-URL constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_url_encoder(callback_type callback_)
|
||||
: ibase64_encoder(etl::base64::character_set_2(),
|
||||
etl::base64::Padding::No_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_)
|
||||
ETL_CONSTEXPR14 base64_rfc4648_url_encoder(callback_type callback_)
|
||||
: ibase64_encoder(etl::base64::character_set_2(), etl::base64::Padding::No_Padding, output_buffer, Buffer_Size, callback_)
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -768,8 +688,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t safe_output_buffer_size(size_t input_length)
|
||||
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
|
||||
{
|
||||
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::No_Padding);
|
||||
}
|
||||
@ -788,19 +707,15 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT(((Buffer_Size% etl::base64::Min_Encode_Buffer_Size) == 0), "Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT((Buffer_Size >= etl::base64::Min_Encode_Buffer_Size), "Buffer size must be greater than etl::base64::Min_Encode_Buffer_Size");
|
||||
ETL_STATIC_ASSERT(((Buffer_Size % etl::base64::Min_Encode_Buffer_Size) == 0),
|
||||
"Buffer size must be a multiple of etl::base64::Min_Encode_Buffer_Size");
|
||||
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648-URL constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_url_padding_encoder()
|
||||
: ibase64_encoder(etl::base64::character_set_2(),
|
||||
etl::base64::Padding::Use_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_type())
|
||||
ETL_CONSTEXPR14 base64_rfc4648_url_padding_encoder()
|
||||
: ibase64_encoder(etl::base64::character_set_2(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_type())
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -808,13 +723,8 @@ namespace etl
|
||||
//*************************************************************************
|
||||
/// Base64 RFC-4648-URL constructor.
|
||||
//*************************************************************************
|
||||
ETL_CONSTEXPR14
|
||||
base64_rfc4648_url_padding_encoder(callback_type callback_)
|
||||
: ibase64_encoder(etl::base64::character_set_2(),
|
||||
etl::base64::Padding::Use_Padding,
|
||||
output_buffer,
|
||||
Buffer_Size,
|
||||
callback_)
|
||||
ETL_CONSTEXPR14 base64_rfc4648_url_padding_encoder(callback_type callback_)
|
||||
: ibase64_encoder(etl::base64::character_set_2(), etl::base64::Padding::Use_Padding, output_buffer, Buffer_Size, callback_)
|
||||
, output_buffer()
|
||||
{
|
||||
}
|
||||
@ -824,8 +734,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
ETL_NODISCARD
|
||||
static
|
||||
ETL_CONSTEXPR14
|
||||
size_t safe_output_buffer_size(size_t input_length)
|
||||
ETL_CONSTEXPR14 size_t safe_output_buffer_size(size_t input_length)
|
||||
{
|
||||
return ibase64_encoder::encoded_size(input_length, etl::base64::Padding::Use_Padding);
|
||||
}
|
||||
@ -835,7 +744,7 @@ namespace etl
|
||||
/// The internal output buffer.
|
||||
char output_buffer[Buffer_Size];
|
||||
};
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#undef ETL_IS_TYPE_8_BIT_INTEGRAL
|
||||
#undef ETL_IS_ITERATOR_TYPE_8_BIT_INTEGRAL
|
||||
|
||||
@ -34,8 +34,9 @@ SOFTWARE.
|
||||
///\ingroup string
|
||||
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
#include "utility.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
@ -130,7 +131,7 @@ namespace etl
|
||||
struct right_spec
|
||||
{
|
||||
};
|
||||
}
|
||||
} // namespace private_basic_format_spec
|
||||
|
||||
//***************************************************************************
|
||||
// Stream formatting manipulators.
|
||||
@ -206,7 +207,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Default constructor.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR basic_format_spec()
|
||||
ETL_CONSTEXPR basic_format_spec() ETL_NOEXCEPT
|
||||
: base_(10U)
|
||||
, width_(0U)
|
||||
, precision_(0U)
|
||||
@ -221,14 +222,8 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Constructor.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR basic_format_spec(uint_least8_t base__,
|
||||
uint_least8_t width__,
|
||||
uint_least8_t precision__,
|
||||
bool upper_case__,
|
||||
bool left_justified__,
|
||||
bool boolalpha__,
|
||||
bool show_base__,
|
||||
typename TString::value_type fill__)
|
||||
ETL_CONSTEXPR basic_format_spec(uint_least8_t base__, uint_least8_t width__, uint_least8_t precision__, bool upper_case__, bool left_justified__,
|
||||
bool boolalpha__, bool show_base__, typename TString::value_type fill__) ETL_NOEXCEPT
|
||||
: base_(base__)
|
||||
, width_(width__)
|
||||
, precision_(precision__)
|
||||
@ -243,7 +238,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Clears the format spec back to default.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 void clear()
|
||||
ETL_CONSTEXPR14 void clear() ETL_NOEXCEPT
|
||||
{
|
||||
base_ = 10U;
|
||||
width_ = 0U;
|
||||
@ -259,56 +254,93 @@ namespace etl
|
||||
/// Sets the base.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& base(uint32_t b)
|
||||
ETL_CONSTEXPR14 basic_format_spec& base(uint32_t b) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
base_ = static_cast<uint_least8_t>(b);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& base(uint32_t b) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
base_ = static_cast<uint_least8_t>(b);
|
||||
return etl::move(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Sets the base to binary.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& binary()
|
||||
ETL_CONSTEXPR14 basic_format_spec& binary() ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
base(2);
|
||||
return *this;
|
||||
return base(2);
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& binary() ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
return etl::move(base(2));
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Sets the base to octal.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& octal()
|
||||
ETL_CONSTEXPR14 basic_format_spec& octal() ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
base(8);
|
||||
return *this;
|
||||
return base(8);
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& octal() ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
return etl::move(base(8));
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Sets the base to decimal.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& decimal()
|
||||
ETL_CONSTEXPR14 basic_format_spec& decimal() ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
base(10);
|
||||
return *this;
|
||||
return base(10);
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& decimal() ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
return etl::move(base(10));
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Sets the base to hex.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& hex()
|
||||
ETL_CONSTEXPR14 basic_format_spec& hex() ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
base(16);
|
||||
return *this;
|
||||
return base(16);
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& hex() ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
return etl::move(base(16));
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the base.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR uint32_t get_base() const
|
||||
ETL_CONSTEXPR uint32_t get_base() const ETL_NOEXCEPT
|
||||
{
|
||||
return base_;
|
||||
}
|
||||
@ -317,16 +349,25 @@ namespace etl
|
||||
/// Sets the show base flag.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& show_base(bool b)
|
||||
ETL_CONSTEXPR14 basic_format_spec& show_base(bool b) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
show_base_ = b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& show_base(bool b) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
show_base_ = b;
|
||||
return etl::move(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the show base flag.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR bool is_show_base() const
|
||||
ETL_CONSTEXPR bool is_show_base() const ETL_NOEXCEPT
|
||||
{
|
||||
return show_base_;
|
||||
}
|
||||
@ -335,16 +376,25 @@ namespace etl
|
||||
/// Sets the width.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& width(uint32_t w)
|
||||
ETL_CONSTEXPR14 basic_format_spec& width(uint32_t w) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
width_ = static_cast<uint_least8_t>(w);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& width(uint32_t w) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
width_ = static_cast<uint_least8_t>(w);
|
||||
return etl::move(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the width.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR uint32_t get_width() const
|
||||
ETL_CONSTEXPR uint32_t get_width() const ETL_NOEXCEPT
|
||||
{
|
||||
return width_;
|
||||
}
|
||||
@ -353,16 +403,25 @@ namespace etl
|
||||
/// Sets the precision.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& precision(uint32_t p)
|
||||
ETL_CONSTEXPR14 basic_format_spec& precision(uint32_t p) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
precision_ = static_cast<uint_least8_t>(p);
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& precision(uint32_t p) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
precision_ = static_cast<uint_least8_t>(p);
|
||||
return etl::move(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the precision.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR uint32_t get_precision() const
|
||||
ETL_CONSTEXPR uint32_t get_precision() const ETL_NOEXCEPT
|
||||
{
|
||||
return precision_;
|
||||
}
|
||||
@ -371,16 +430,25 @@ namespace etl
|
||||
/// Sets the upper case flag.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& upper_case(bool u)
|
||||
ETL_CONSTEXPR14 basic_format_spec& upper_case(bool u) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
upper_case_ = u;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& upper_case(bool u) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
upper_case_ = u;
|
||||
return etl::move(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the upper case flag.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR bool is_upper_case() const
|
||||
ETL_CONSTEXPR bool is_upper_case() const ETL_NOEXCEPT
|
||||
{
|
||||
return upper_case_;
|
||||
}
|
||||
@ -389,16 +457,25 @@ namespace etl
|
||||
/// Sets the fill character.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& fill(typename TString::value_type c)
|
||||
ETL_CONSTEXPR14 basic_format_spec& fill(typename TString::value_type c) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
fill_ = c;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& fill(typename TString::value_type c) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
fill_ = c;
|
||||
return etl::move(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the fill character.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR typename TString::value_type get_fill() const
|
||||
ETL_CONSTEXPR typename TString::value_type get_fill() const ETL_NOEXCEPT
|
||||
{
|
||||
return fill_;
|
||||
}
|
||||
@ -407,16 +484,25 @@ namespace etl
|
||||
/// Sets the left justify flag.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& left()
|
||||
ETL_CONSTEXPR14 basic_format_spec& left() ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
left_justified_ = true;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& left() ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
left_justified_ = true;
|
||||
return etl::move(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the left justify flag.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR bool is_left() const
|
||||
ETL_CONSTEXPR bool is_left() const ETL_NOEXCEPT
|
||||
{
|
||||
return left_justified_;
|
||||
}
|
||||
@ -425,16 +511,25 @@ namespace etl
|
||||
/// Sets the right justify flag.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& right()
|
||||
ETL_CONSTEXPR14 basic_format_spec& right() ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
left_justified_ = false;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& right() ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
left_justified_ = false;
|
||||
return etl::move(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the right justify flag.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR bool is_right() const
|
||||
ETL_CONSTEXPR bool is_right() const ETL_NOEXCEPT
|
||||
{
|
||||
return !left_justified_;
|
||||
}
|
||||
@ -443,16 +538,25 @@ namespace etl
|
||||
/// Sets the bool alpha flag.
|
||||
/// \return A reference to the basic_format_spec.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR14 basic_format_spec& boolalpha(bool b)
|
||||
ETL_CONSTEXPR14 basic_format_spec& boolalpha(bool b) ETL_LVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
boolalpha_ = b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
/// @overload
|
||||
ETL_CONSTEXPR14 basic_format_spec&& boolalpha(bool b) ETL_RVALUE_REF_QUALIFIER ETL_NOEXCEPT
|
||||
{
|
||||
boolalpha_ = b;
|
||||
return etl::move(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
//***************************************************************************
|
||||
/// Gets the boolalpha flag.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR bool is_boolalpha() const
|
||||
ETL_CONSTEXPR bool is_boolalpha() const ETL_NOEXCEPT
|
||||
{
|
||||
return boolalpha_;
|
||||
}
|
||||
@ -460,37 +564,32 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Equality operator.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR friend bool operator ==(const basic_format_spec& lhs, const basic_format_spec& rhs)
|
||||
ETL_CONSTEXPR friend bool operator==(const basic_format_spec& lhs, const basic_format_spec& rhs)
|
||||
{
|
||||
return (lhs.base_ == rhs.base_) &&
|
||||
(lhs.width_ == rhs.width_) &&
|
||||
(lhs.precision_ == rhs.precision_) &&
|
||||
(lhs.upper_case_ == rhs.upper_case_) &&
|
||||
(lhs.left_justified_ == rhs.left_justified_) &&
|
||||
(lhs.boolalpha_ == rhs.boolalpha_) &&
|
||||
(lhs.show_base_ == rhs.show_base_) &&
|
||||
(lhs.fill_ == rhs.fill_);
|
||||
return (lhs.base_ == rhs.base_) && (lhs.width_ == rhs.width_) && (lhs.precision_ == rhs.precision_) && (lhs.upper_case_ == rhs.upper_case_)
|
||||
&& (lhs.left_justified_ == rhs.left_justified_) && (lhs.boolalpha_ == rhs.boolalpha_) && (lhs.show_base_ == rhs.show_base_)
|
||||
&& (lhs.fill_ == rhs.fill_);
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Inequality operator.
|
||||
//***************************************************************************
|
||||
ETL_CONSTEXPR friend bool operator !=(const basic_format_spec& lhs, const basic_format_spec& rhs)
|
||||
ETL_CONSTEXPR friend bool operator!=(const basic_format_spec& lhs, const basic_format_spec& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
uint_least8_t base_;
|
||||
uint_least8_t width_;
|
||||
uint_least8_t precision_;
|
||||
bool upper_case_;
|
||||
bool left_justified_;
|
||||
bool boolalpha_;
|
||||
bool show_base_;
|
||||
uint_least8_t base_;
|
||||
uint_least8_t width_;
|
||||
uint_least8_t precision_;
|
||||
bool upper_case_;
|
||||
bool left_justified_;
|
||||
bool boolalpha_;
|
||||
bool show_base_;
|
||||
typename TString::value_type fill_;
|
||||
};
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -35,6 +35,10 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
#include "to_string.h"
|
||||
#include "to_u16string.h"
|
||||
#include "to_u32string.h"
|
||||
#include "to_u8string.h"
|
||||
#include "to_wstring.h"
|
||||
|
||||
namespace etl
|
||||
{
|
||||
@ -121,16 +125,17 @@ namespace etl
|
||||
//*********************************
|
||||
/// TFormat
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, const TFormat& fmt)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, const TFormat& fmt)
|
||||
{
|
||||
ss.format = fmt;
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::base_spec from etl::setbase, etl::bin, etl::oct, etl::dec & etl::hex stream manipulators
|
||||
/// etl::base_spec from etl::setbase, etl::bin, etl::oct, etl::dec &
|
||||
/// etl::hex stream manipulators
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::base_spec fmt)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::base_spec fmt)
|
||||
{
|
||||
ss.format.base(fmt.base);
|
||||
return ss;
|
||||
@ -139,7 +144,7 @@ namespace etl
|
||||
//*********************************
|
||||
/// etl::width_spec from etl::setw stream manipulator
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::width_spec fmt)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::width_spec fmt)
|
||||
{
|
||||
ss.format.width(fmt.width);
|
||||
return ss;
|
||||
@ -149,7 +154,7 @@ namespace etl
|
||||
/// etl::fill_spec from etl::setfill stream manipulator
|
||||
//*********************************
|
||||
template <typename TChar>
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::fill_spec<TChar> fmt)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::fill_spec<TChar> fmt)
|
||||
{
|
||||
ss.format.fill(fmt.fill);
|
||||
return ss;
|
||||
@ -158,34 +163,37 @@ namespace etl
|
||||
//*********************************
|
||||
/// etl::precision_spec from etl::setprecision stream manipulator
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::precision_spec fmt)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::precision_spec fmt)
|
||||
{
|
||||
ss.format.precision(fmt.precision);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::boolalpha_spec from etl::boolalpha & etl::noboolalpha stream manipulators
|
||||
/// etl::boolalpha_spec from etl::boolalpha & etl::noboolalpha stream
|
||||
/// manipulators
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::boolalpha_spec fmt)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::boolalpha_spec fmt)
|
||||
{
|
||||
ss.format.boolalpha(fmt.boolalpha);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::uppercase_spec from etl::uppercase & etl::nouppercase stream manipulators
|
||||
/// etl::uppercase_spec from etl::uppercase & etl::nouppercase stream
|
||||
/// manipulators
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::uppercase_spec fmt)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::uppercase_spec fmt)
|
||||
{
|
||||
ss.format.upper_case(fmt.upper_case);
|
||||
return ss;
|
||||
}
|
||||
|
||||
//*********************************
|
||||
/// etl::showbase_spec from etl::showbase & etl::noshowbase stream manipulators
|
||||
/// etl::showbase_spec from etl::showbase & etl::noshowbase stream
|
||||
/// manipulators
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::showbase_spec fmt)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::showbase_spec fmt)
|
||||
{
|
||||
ss.format.show_base(fmt.show_base);
|
||||
return ss;
|
||||
@ -194,7 +202,7 @@ namespace etl
|
||||
//*********************************
|
||||
/// etl::left_spec from etl::left stream manipulator
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::left_spec /*fmt*/)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::left_spec /*fmt*/)
|
||||
{
|
||||
ss.format.left();
|
||||
return ss;
|
||||
@ -203,7 +211,7 @@ namespace etl
|
||||
//*********************************
|
||||
/// etl::right_spec from etl::left stream manipulator
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, etl::private_basic_format_spec::right_spec /*fmt*/)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, etl::private_basic_format_spec::right_spec /*fmt*/)
|
||||
{
|
||||
ss.format.right();
|
||||
return ss;
|
||||
@ -212,7 +220,7 @@ namespace etl
|
||||
//*********************************
|
||||
/// From a string view
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, TStringView view)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, TStringView view)
|
||||
{
|
||||
etl::to_string(view, ss.text, ss.format, true);
|
||||
return ss;
|
||||
@ -221,7 +229,7 @@ namespace etl
|
||||
//*********************************
|
||||
/// From a character pointer to a string
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, pointer p)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, pointer p)
|
||||
{
|
||||
TStringView view(p);
|
||||
ss << view;
|
||||
@ -231,7 +239,7 @@ namespace etl
|
||||
//*********************************
|
||||
/// From a const character pointer to a string
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, const_pointer p)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, const_pointer p)
|
||||
{
|
||||
TStringView view(p);
|
||||
ss << view;
|
||||
@ -241,7 +249,7 @@ namespace etl
|
||||
//*********************************
|
||||
/// From a string interface
|
||||
//*********************************
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, const TIString& t)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, const TIString& t)
|
||||
{
|
||||
etl::to_string(t, ss.text, ss.format, true);
|
||||
return ss;
|
||||
@ -251,7 +259,7 @@ namespace etl
|
||||
/// From a string
|
||||
//*********************************
|
||||
template <template <size_t> class TString, size_t SIZE>
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, const TString<SIZE>& t)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, const TString<SIZE>& t)
|
||||
{
|
||||
const TIString& itext = t;
|
||||
etl::to_string(itext, ss.str(), ss.get_format(), true);
|
||||
@ -262,7 +270,7 @@ namespace etl
|
||||
/// From anything else
|
||||
//*********************************
|
||||
template <typename T>
|
||||
friend basic_string_stream& operator <<(basic_string_stream& ss, const T& value)
|
||||
friend basic_string_stream& operator<<(basic_string_stream& ss, const T& value)
|
||||
{
|
||||
etl::to_string(value, ss.text, ss.format, true);
|
||||
return ss;
|
||||
@ -274,8 +282,8 @@ namespace etl
|
||||
TFormat format;
|
||||
|
||||
basic_string_stream(const basic_string_stream&) ETL_DELETE;
|
||||
basic_string_stream& operator =(const basic_string_stream&) ETL_DELETE;
|
||||
basic_string_stream& operator=(const basic_string_stream&) ETL_DELETE;
|
||||
};
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -40,15 +40,15 @@ SOFTWARE.
|
||||
|
||||
#include "platform.h"
|
||||
#include "alignment.h"
|
||||
#include "parameter_type.h"
|
||||
#include "atomic.h"
|
||||
#include "error_handler.h"
|
||||
#include "file_error_numbers.h"
|
||||
#include "integral_limits.h"
|
||||
#include "memory.h"
|
||||
#include "memory_model.h"
|
||||
#include "integral_limits.h"
|
||||
#include "utility.h"
|
||||
#include "error_handler.h"
|
||||
#include "parameter_type.h"
|
||||
#include "span.h"
|
||||
#include "file_error_numbers.h"
|
||||
#include "utility.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@ -60,12 +60,12 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Base exception for a bip buffer.
|
||||
//***************************************************************************
|
||||
class bip_buffer_exception: public exception
|
||||
class bip_buffer_exception : public exception
|
||||
{
|
||||
public:
|
||||
|
||||
bip_buffer_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
|
||||
: exception(reason_, file_name_, line_number_)
|
||||
: exception(reason_, file_name_, line_number_)
|
||||
{
|
||||
}
|
||||
};
|
||||
@ -73,7 +73,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
/// Exception for an invalid reserve.
|
||||
//***************************************************************************
|
||||
class bip_buffer_reserve_invalid: public bip_buffer_exception
|
||||
class bip_buffer_reserve_invalid : public bip_buffer_exception
|
||||
{
|
||||
public:
|
||||
|
||||
@ -117,7 +117,7 @@ namespace etl
|
||||
size_type size() const
|
||||
{
|
||||
size_type write_index = write.load(etl::memory_order_acquire);
|
||||
size_type read_index = read.load(etl::memory_order_acquire);
|
||||
size_type read_index = read.load(etl::memory_order_acquire);
|
||||
|
||||
// no wraparound
|
||||
if (write_index >= read_index)
|
||||
@ -140,7 +140,7 @@ namespace etl
|
||||
size_type available() const
|
||||
{
|
||||
size_type write_index = write.load(etl::memory_order_acquire);
|
||||
size_type read_index = read.load(etl::memory_order_acquire);
|
||||
size_type read_index = read.load(etl::memory_order_acquire);
|
||||
|
||||
// no wraparound
|
||||
if (write_index >= read_index)
|
||||
@ -185,10 +185,10 @@ namespace etl
|
||||
/// Constructs the buffer.
|
||||
//*************************************************************************
|
||||
bip_buffer_spsc_atomic_base(size_type reserved_)
|
||||
: read(0)
|
||||
, write(0)
|
||||
, last(0)
|
||||
, Reserved(reserved_)
|
||||
: read(0)
|
||||
, write(0)
|
||||
, last(0)
|
||||
, Reserved(reserved_)
|
||||
{
|
||||
}
|
||||
|
||||
@ -204,7 +204,7 @@ namespace etl
|
||||
size_type get_write_reserve(size_type* psize, size_type fallback_size = numeric_limits<size_type>::max())
|
||||
{
|
||||
size_type write_index = write.load(etl::memory_order_relaxed);
|
||||
size_type read_index = read.load(etl::memory_order_acquire);
|
||||
size_type read_index = read.load(etl::memory_order_acquire);
|
||||
|
||||
// No wraparound
|
||||
if (write_index >= read_index)
|
||||
@ -262,7 +262,7 @@ namespace etl
|
||||
if (wsize > 0)
|
||||
{
|
||||
size_type write_index = write.load(etl::memory_order_relaxed);
|
||||
size_type read_index = read.load(etl::memory_order_acquire);
|
||||
size_type read_index = read.load(etl::memory_order_acquire);
|
||||
|
||||
// Wrapped around already
|
||||
if (write_index < read_index)
|
||||
@ -281,8 +281,11 @@ namespace etl
|
||||
else
|
||||
{
|
||||
ETL_ASSERT_OR_RETURN((windex == 0) && ((wsize + 1) <= read_index), ETL_ERROR(bip_buffer_reserve_invalid));
|
||||
|
||||
// Correct wrapping point
|
||||
last.store(write_index, etl::memory_order_release);
|
||||
}
|
||||
|
||||
|
||||
// Always update write index
|
||||
write.store(windex + wsize, etl::memory_order_release);
|
||||
}
|
||||
@ -291,7 +294,7 @@ namespace etl
|
||||
//*************************************************************************
|
||||
size_type get_read_reserve(size_type* psize)
|
||||
{
|
||||
size_type read_index = read.load(etl::memory_order_relaxed);
|
||||
size_type read_index = read.load(etl::memory_order_relaxed);
|
||||
size_type write_index = write.load(etl::memory_order_acquire);
|
||||
|
||||
if (read_index > write_index)
|
||||
@ -341,21 +344,19 @@ namespace etl
|
||||
etl::atomic<size_type> read;
|
||||
etl::atomic<size_type> write;
|
||||
etl::atomic<size_type> last;
|
||||
const size_type Reserved;
|
||||
const size_type Reserved;
|
||||
|
||||
#if defined(ETL_POLYMORPHIC_SPSC_BIP_BUFFER_ATOMIC) || defined(ETL_POLYMORPHIC_CONTAINERS)
|
||||
|
||||
#if defined(ETL_POLYMORPHIC_SPSC_BIP_BUFFER_ATOMIC) || defined(ETL_POLYMORPHIC_CONTAINERS)
|
||||
public:
|
||||
|
||||
virtual ~bip_buffer_spsc_atomic_base()
|
||||
{
|
||||
}
|
||||
#else
|
||||
virtual ~bip_buffer_spsc_atomic_base() {}
|
||||
#else
|
||||
|
||||
protected:
|
||||
|
||||
~bip_buffer_spsc_atomic_base()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
~bip_buffer_spsc_atomic_base() {}
|
||||
#endif
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -367,21 +368,21 @@ namespace etl
|
||||
private:
|
||||
|
||||
typedef typename etl::bip_buffer_spsc_atomic_base<Memory_Model> base_t;
|
||||
using base_t::reset;
|
||||
using base_t::get_read_reserve;
|
||||
using base_t::apply_read_reserve;
|
||||
using base_t::get_write_reserve;
|
||||
using base_t::apply_write_reserve;
|
||||
using base_t::get_read_reserve;
|
||||
using base_t::get_write_reserve;
|
||||
using base_t::reset;
|
||||
|
||||
public:
|
||||
|
||||
typedef T value_type; ///< The type stored in the buffer.
|
||||
typedef T& reference; ///< A reference to the type used in the buffer.
|
||||
typedef const T& const_reference; ///< A const reference to the type used in the buffer.
|
||||
#if ETL_USING_CPP11
|
||||
typedef T&& rvalue_reference;///< An rvalue_reference to the type used in the buffer.
|
||||
#endif
|
||||
typedef typename base_t::size_type size_type; ///< The type used for determining the size of the buffer.
|
||||
typedef T value_type; ///< The type stored in the buffer.
|
||||
typedef T& reference; ///< A reference to the type used in the buffer.
|
||||
typedef const T& const_reference; ///< A const reference to the type used in the buffer.
|
||||
#if ETL_USING_CPP11
|
||||
typedef T&& rvalue_reference; ///< An rvalue_reference to the type used in the buffer.
|
||||
#endif
|
||||
typedef typename base_t::size_type size_type; ///< The type used for determining the size of the buffer.
|
||||
|
||||
using base_t::max_size;
|
||||
|
||||
@ -391,8 +392,8 @@ namespace etl
|
||||
span<T> read_reserve(size_type max_reserve_size = numeric_limits<size_type>::max())
|
||||
{
|
||||
size_type reserve_size = max_reserve_size;
|
||||
size_type rindex = get_read_reserve(&reserve_size);
|
||||
|
||||
size_type rindex = get_read_reserve(&reserve_size);
|
||||
|
||||
return span<T>(p_buffer + rindex, reserve_size);
|
||||
}
|
||||
|
||||
@ -401,7 +402,7 @@ namespace etl
|
||||
// the reserve can be trimmed at the end before committing.
|
||||
// Throws bip_buffer_reserve_invalid
|
||||
//*************************************************************************
|
||||
void read_commit(const span<T> &reserve)
|
||||
void read_commit(const span<T>& reserve)
|
||||
{
|
||||
size_type rindex = etl::distance(p_buffer, reserve.data());
|
||||
apply_read_reserve(rindex, reserve.size());
|
||||
@ -413,8 +414,8 @@ namespace etl
|
||||
span<T> write_reserve(size_type max_reserve_size)
|
||||
{
|
||||
size_type reserve_size = max_reserve_size;
|
||||
size_type windex = get_write_reserve(&reserve_size);
|
||||
|
||||
size_type windex = get_write_reserve(&reserve_size);
|
||||
|
||||
return span<T>(p_buffer + windex, reserve_size);
|
||||
}
|
||||
|
||||
@ -424,10 +425,10 @@ namespace etl
|
||||
//*************************************************************************
|
||||
span<T> write_reserve_optimal(size_type min_reserve_size = 1U)
|
||||
{
|
||||
size_type reserve_size = numeric_limits<size_type>::max();
|
||||
size_type windex = get_write_reserve(&reserve_size, min_reserve_size);
|
||||
size_type reserve_size = numeric_limits<size_type>::max();
|
||||
size_type windex = get_write_reserve(&reserve_size, min_reserve_size);
|
||||
|
||||
return span<T>(p_buffer + windex, reserve_size);
|
||||
return span<T>(p_buffer + windex, reserve_size);
|
||||
}
|
||||
|
||||
//*************************************************************************
|
||||
@ -435,7 +436,7 @@ namespace etl
|
||||
// the reserve can be trimmed at the end before committing.
|
||||
// Throws bip_buffer_reserve_invalid
|
||||
//*************************************************************************
|
||||
void write_commit(const span<T> &reserve)
|
||||
void write_commit(const span<T>& reserve)
|
||||
{
|
||||
size_type windex = etl::distance(p_buffer, reserve.data());
|
||||
apply_write_reserve(windex, reserve.size());
|
||||
@ -472,12 +473,12 @@ namespace etl
|
||||
|
||||
// Disable copy construction and assignment.
|
||||
ibip_buffer_spsc_atomic(const ibip_buffer_spsc_atomic&) ETL_DELETE;
|
||||
ibip_buffer_spsc_atomic& operator =(const ibip_buffer_spsc_atomic&) ETL_DELETE;
|
||||
ibip_buffer_spsc_atomic& operator=(const ibip_buffer_spsc_atomic&) ETL_DELETE;
|
||||
|
||||
#if ETL_USING_CPP11
|
||||
ibip_buffer_spsc_atomic(ibip_buffer_spsc_atomic&&) = delete;
|
||||
ibip_buffer_spsc_atomic& operator =(ibip_buffer_spsc_atomic&&) = delete;
|
||||
#endif
|
||||
#if ETL_USING_CPP11
|
||||
ibip_buffer_spsc_atomic(ibip_buffer_spsc_atomic&&) = delete;
|
||||
ibip_buffer_spsc_atomic& operator=(ibip_buffer_spsc_atomic&&) = delete;
|
||||
#endif
|
||||
|
||||
T* const p_buffer;
|
||||
};
|
||||
@ -487,7 +488,8 @@ namespace etl
|
||||
/// This buffer supports concurrent access by one producer and one consumer.
|
||||
/// \tparam T The type this buffer should support.
|
||||
/// \tparam Size The maximum capacity of the buffer.
|
||||
/// \tparam Memory_Model The memory model for the buffer. Determines the type of the internal counter variables.
|
||||
/// \tparam Memory_Model The memory model for the buffer. Determines the type
|
||||
/// of the internal counter variables.
|
||||
//***************************************************************************
|
||||
template <typename T, const size_t Size, const size_t Memory_Model = etl::memory_model::MEMORY_MODEL_LARGE>
|
||||
class bip_buffer_spsc_atomic : public ibip_buffer_spsc_atomic<T, Memory_Model>
|
||||
@ -526,15 +528,15 @@ namespace etl
|
||||
base_t::clear();
|
||||
}
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
/// The uninitialised buffer of T used in the bip_buffer_spsc.
|
||||
etl::uninitialized_buffer_of<T, Reserved_Size> buffer;
|
||||
};
|
||||
|
||||
template <typename T, const size_t Size, const size_t Memory_Model>
|
||||
template <typename T, const size_t Size, const size_t Memory_Model>
|
||||
ETL_CONSTANT typename bip_buffer_spsc_atomic<T, Size, Memory_Model>::size_type bip_buffer_spsc_atomic<T, Size, Memory_Model>::Reserved_Size;
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#endif /* ETL_HAS_ATOMIC && ETL_USING_CPP11 */
|
||||
|
||||
|
||||
@ -32,10 +32,9 @@ SOFTWARE.
|
||||
#define ETL_BIT_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
#include "binary.h"
|
||||
#include "integral_limits.h"
|
||||
#include "endianness.h"
|
||||
#include "integral_limits.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <string.h>
|
||||
@ -51,11 +50,9 @@ namespace etl
|
||||
//***************************************************************************
|
||||
template <typename TDestination, typename TSource>
|
||||
ETL_NODISCARD
|
||||
typename etl::enable_if<!(etl::is_integral<TDestination>::value&& etl::is_integral<TSource>::value) &&
|
||||
(sizeof(TDestination) == sizeof(TSource)) &&
|
||||
etl::is_trivially_copyable<TSource>::value &&
|
||||
etl::is_trivially_copyable<TDestination>::value, TDestination>::type
|
||||
bit_cast(const TSource& source) ETL_NOEXCEPT
|
||||
typename etl::enable_if< !(etl::is_integral<TDestination>::value && etl::is_integral<TSource>::value) && (sizeof(TDestination) == sizeof(TSource))
|
||||
&& etl::is_trivially_copyable<TSource>::value && etl::is_trivially_copyable<TDestination>::value,
|
||||
TDestination>::type bit_cast(const TSource& source) ETL_NOEXCEPT
|
||||
{
|
||||
TDestination destination;
|
||||
|
||||
@ -68,11 +65,9 @@ namespace etl
|
||||
/// bit_cast - Integral to integral
|
||||
//***************************************************************************
|
||||
template <typename TDestination, typename TSource>
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR14
|
||||
typename etl::enable_if<(etl::is_integral<TDestination>::value && etl::is_integral<TSource>::value) &&
|
||||
(sizeof(TDestination) == sizeof(TSource)), TDestination>::type
|
||||
bit_cast(const TSource& source) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
typename etl::enable_if< (etl::is_integral<TDestination>::value && etl::is_integral<TSource>::value) && (sizeof(TDestination) == sizeof(TSource)),
|
||||
TDestination>::type bit_cast(const TSource& source) ETL_NOEXCEPT
|
||||
{
|
||||
return static_cast<TDestination>(source);
|
||||
}
|
||||
@ -81,9 +76,7 @@ namespace etl
|
||||
/// byteswap
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14
|
||||
typename etl::enable_if<etl::is_integral<T>::value, T>::type
|
||||
byteswap(T value) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_integral<T>::value, T>::type byteswap(T value) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::reverse_bytes(value);
|
||||
}
|
||||
@ -92,8 +85,7 @@ namespace etl
|
||||
/// has_single_bit
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, bool>::type has_single_bit(T value) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, bool>::type has_single_bit(T value) ETL_NOEXCEPT
|
||||
{
|
||||
return (value & (value - 1)) == 0;
|
||||
}
|
||||
@ -101,9 +93,7 @@ namespace etl
|
||||
/// countl_zero
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, int>::type
|
||||
countl_zero(T value) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, int>::type countl_zero(T value) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::count_leading_zeros(value);
|
||||
}
|
||||
@ -112,9 +102,7 @@ namespace etl
|
||||
/// countl_one
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, int>::type
|
||||
countl_one(T value) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, int>::type countl_one(T value) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::count_leading_ones(value);
|
||||
}
|
||||
@ -123,9 +111,7 @@ namespace etl
|
||||
/// countr_zero
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, int>::type
|
||||
countr_zero(T value) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, int>::type countr_zero(T value) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::count_trailing_zeros(value);
|
||||
}
|
||||
@ -134,26 +120,21 @@ namespace etl
|
||||
/// countr_one
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, int>::type
|
||||
countr_one(T value) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, int>::type countr_one(T value) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::count_trailing_ones(value);;
|
||||
return etl::count_trailing_ones(value);
|
||||
}
|
||||
|
||||
|
||||
//***************************************************************************
|
||||
/// bit_width
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_CONSTEXPR14
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
|
||||
bit_width(T value) ETL_NOEXCEPT
|
||||
ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, T>::type bit_width(T value) ETL_NOEXCEPT
|
||||
{
|
||||
#if ETL_USING_CPP20 && ETL_USING_STL
|
||||
return std::bit_width(value);
|
||||
return static_cast<T>(std::bit_width(value));
|
||||
#else
|
||||
return etl::integral_limits<T>::bits - etl::countl_zero(value);
|
||||
return static_cast<T>(etl::integral_limits<T>::bits - etl::countl_zero(value));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -161,9 +142,7 @@ namespace etl
|
||||
/// bit_ceil
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
|
||||
bit_ceil(T value)
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, T>::type bit_ceil(T value)
|
||||
{
|
||||
#if ETL_USING_CPP20 && ETL_USING_STL
|
||||
return std::bit_ceil(value);
|
||||
@ -183,9 +162,7 @@ namespace etl
|
||||
/// bit_floor
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
|
||||
bit_floor(T value) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, T>::type bit_floor(T value) ETL_NOEXCEPT
|
||||
{
|
||||
#if ETL_USING_CPP20 && ETL_USING_STL
|
||||
return std::bit_floor(value);
|
||||
@ -205,17 +182,15 @@ namespace etl
|
||||
/// rotl
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
|
||||
rotl(T value, int n) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, T>::type rotl(T value, int n) ETL_NOEXCEPT
|
||||
{
|
||||
if (n < 0)
|
||||
{
|
||||
return etl::rotate_right(value, -n);
|
||||
return etl::rotate_right(value, static_cast<size_t>(-n));
|
||||
}
|
||||
else
|
||||
{
|
||||
return etl::rotate_left(value, n);
|
||||
return etl::rotate_left(value, static_cast<size_t>(n));
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,30 +198,26 @@ namespace etl
|
||||
/// rotr
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, T>::type
|
||||
rotr(T value, int n) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, T>::type rotr(T value, int n) ETL_NOEXCEPT
|
||||
{
|
||||
if (n < 0)
|
||||
{
|
||||
return etl::rotate_left(value, -n);
|
||||
return etl::rotate_left(value, static_cast<size_t>(-n));
|
||||
}
|
||||
else
|
||||
{
|
||||
return etl::rotate_right(value, n);
|
||||
return etl::rotate_right(value, static_cast<size_t>(n));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//***************************************************************************
|
||||
/// popcount
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
ETL_NODISCARD ETL_CONSTEXPR14
|
||||
typename etl::enable_if<etl::is_unsigned<T>::value, int>::type
|
||||
popcount(T value) ETL_NOEXCEPT
|
||||
ETL_NODISCARD ETL_CONSTEXPR14 typename etl::enable_if<etl::is_unsigned<T>::value, int>::type popcount(T value) ETL_NOEXCEPT
|
||||
{
|
||||
return etl::count_bits(value);
|
||||
}
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
@ -27,22 +27,22 @@ SOFTWARE.
|
||||
#define ETL_BIT_STREAM_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "type_traits.h"
|
||||
#include "nullptr.h"
|
||||
#include "endianness.h"
|
||||
#include "integral_limits.h"
|
||||
#include "binary.h"
|
||||
#include "algorithm.h"
|
||||
#include "binary.h"
|
||||
#include "delegate.h"
|
||||
#include "endianness.h"
|
||||
#include "error_handler.h"
|
||||
#include "exception.h"
|
||||
#include "integral_limits.h"
|
||||
#include "iterator.h"
|
||||
#include "memory.h"
|
||||
#include "delegate.h"
|
||||
#include "span.h"
|
||||
#include "nullptr.h"
|
||||
#include "optional.h"
|
||||
#include "exception.h"
|
||||
#include "error_handler.h"
|
||||
#include "span.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "private/minmax_push.h"
|
||||
|
||||
@ -73,7 +73,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
bit_stream(void* begin_, void* end_)
|
||||
: pdata(reinterpret_cast<unsigned char*>(begin_))
|
||||
, length_chars(etl::distance(reinterpret_cast<unsigned char*>(begin_), reinterpret_cast<unsigned char*>(end_)))
|
||||
, length_chars(static_cast<size_t>(etl::distance(reinterpret_cast<unsigned char*>(begin_), reinterpret_cast<unsigned char*>(end_))))
|
||||
{
|
||||
restart();
|
||||
}
|
||||
@ -93,7 +93,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
void set_stream(void* begin_, size_t length_)
|
||||
{
|
||||
pdata = reinterpret_cast<unsigned char*>(begin_);
|
||||
pdata = reinterpret_cast<unsigned char*>(begin_);
|
||||
length_chars = length_;
|
||||
restart();
|
||||
}
|
||||
@ -103,7 +103,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
void set_stream(void* begin_, void* end_)
|
||||
{
|
||||
set_stream(begin_, etl::distance(reinterpret_cast<unsigned char*>(begin_), reinterpret_cast<unsigned char*>(end_)));
|
||||
set_stream(begin_, static_cast<size_t>(etl::distance(reinterpret_cast<unsigned char*>(begin_), reinterpret_cast<unsigned char*>(end_))));
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -112,8 +112,8 @@ namespace etl
|
||||
void restart()
|
||||
{
|
||||
bits_available_in_char = CHAR_BIT;
|
||||
char_index = 0U;
|
||||
bits_available = CHAR_BIT * length_chars;
|
||||
char_index = 0U;
|
||||
bits_available = CHAR_BIT * length_chars;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -148,8 +148,7 @@ namespace etl
|
||||
/// For integral types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_integral<T>::value, bool>::type
|
||||
put(T value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
typename etl::enable_if<etl::is_integral<T>::value, bool>::type put(T value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
{
|
||||
return put_integral(static_cast<uint32_t>(value), nbits);
|
||||
}
|
||||
@ -176,8 +175,7 @@ namespace etl
|
||||
/// For floating point types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_floating_point<T>::value, bool>::type
|
||||
put(T value)
|
||||
typename etl::enable_if<etl::is_floating_point<T>::value, bool>::type put(T value)
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
@ -207,7 +205,7 @@ namespace etl
|
||||
// Do we have enough bits?
|
||||
if (bits_available > 0U)
|
||||
{
|
||||
value = get_bit();
|
||||
value = get_bit();
|
||||
success = true;
|
||||
}
|
||||
}
|
||||
@ -219,11 +217,10 @@ namespace etl
|
||||
/// For integral types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_integral<T>::value, bool>::type
|
||||
get(T& value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
typename etl::enable_if<etl::is_integral<T>::value, bool>::type get(T& value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
{
|
||||
bool success = false;
|
||||
uint_least8_t bits = nbits;
|
||||
bool success = false;
|
||||
uint_least8_t bits = nbits;
|
||||
|
||||
if (pdata != ETL_NULLPTR)
|
||||
{
|
||||
@ -238,7 +235,7 @@ namespace etl
|
||||
unsigned char mask_width = static_cast<unsigned char>(etl::min(nbits, bits_available_in_char));
|
||||
|
||||
typedef typename etl::make_unsigned<T>::type chunk_t;
|
||||
chunk_t chunk = get_chunk(mask_width);
|
||||
chunk_t chunk = get_chunk(mask_width);
|
||||
|
||||
nbits -= mask_width;
|
||||
value |= static_cast<T>(chunk << nbits);
|
||||
@ -252,7 +249,7 @@ namespace etl
|
||||
if (etl::is_signed<T>::value && (bits != (CHAR_BIT * sizeof(T))))
|
||||
{
|
||||
typedef typename etl::make_signed<T>::type ST;
|
||||
value = etl::sign_extend<ST, ST>(value, bits);
|
||||
value = static_cast<T>(etl::sign_extend<ST, ST>(static_cast<ST>(value), bits));
|
||||
}
|
||||
|
||||
return success;
|
||||
@ -262,8 +259,7 @@ namespace etl
|
||||
/// For floating point types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_floating_point<T>::value, bool>::type
|
||||
get(T& value)
|
||||
typename etl::enable_if<etl::is_floating_point<T>::value, bool>::type get(T& value)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
@ -279,7 +275,7 @@ namespace etl
|
||||
|
||||
for (size_t i = 0UL; i < sizeof(T); ++i)
|
||||
{
|
||||
get(data.raw[i], CHAR_BIT);
|
||||
get(data.raw[i], CHAR_BIT);
|
||||
}
|
||||
|
||||
from_bytes(reinterpret_cast<const unsigned char*>(data.raw), value);
|
||||
@ -351,7 +347,7 @@ namespace etl
|
||||
unsigned char mask_width = static_cast<unsigned char>(etl::min(nbits, bits_available_in_char));
|
||||
nbits -= mask_width;
|
||||
uint32_t mask = ((1U << mask_width) - 1U) << nbits;
|
||||
//uint32_t mask = ((uint32_t(1U) << mask_width) - 1U) << nbits;
|
||||
// uint32_t mask = ((uint32_t(1U) << mask_width) - 1U) << nbits;
|
||||
|
||||
// Move chunk to lowest char bits.
|
||||
// Chunks are never larger than one char.
|
||||
@ -422,7 +418,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
unsigned char get_chunk(unsigned char nbits)
|
||||
{
|
||||
unsigned char value = pdata[char_index];
|
||||
unsigned char value = static_cast<unsigned char>(pdata[char_index]);
|
||||
|
||||
value >>= (bits_available_in_char - nbits);
|
||||
|
||||
@ -434,7 +430,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
mask = (1U << nbits) - 1;
|
||||
mask = static_cast<unsigned char>((1U << nbits) - 1);
|
||||
}
|
||||
|
||||
value &= mask;
|
||||
@ -449,7 +445,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
bool get_bit()
|
||||
{
|
||||
bool result = (pdata[char_index] & (1U << (bits_available_in_char - 1U))) != 0U;
|
||||
bool result = (static_cast<unsigned char>(pdata[char_index]) & (1U << (bits_available_in_char - 1U))) != 0U;
|
||||
|
||||
step(1U);
|
||||
|
||||
@ -467,11 +463,11 @@ namespace etl
|
||||
// Network to host.
|
||||
if (etl::endianness::value() == etl::endian::little)
|
||||
{
|
||||
etl::reverse_copy(data, data + sizeof(T), temp.raw);
|
||||
etl::reverse_copy(data, data + sizeof(T), reinterpret_cast<unsigned char*>(temp.raw));
|
||||
}
|
||||
else
|
||||
{
|
||||
etl::copy(data, data + sizeof(T), temp.raw);
|
||||
etl::copy(data, data + sizeof(T), reinterpret_cast<unsigned char*>(temp.raw));
|
||||
}
|
||||
|
||||
value = *reinterpret_cast<T*>(temp.raw);
|
||||
@ -513,11 +509,13 @@ namespace etl
|
||||
bits_available -= nbits;
|
||||
}
|
||||
|
||||
unsigned char *pdata; ///< The start of the bitstream buffer.
|
||||
size_t length_chars; ///< The length, in char, of the bitstream buffer.
|
||||
unsigned char bits_available_in_char; ///< The number of available bits in the current char.
|
||||
size_t char_index; ///< The index of the char in the bitstream buffer.
|
||||
size_t bits_available; ///< The number of bits still available in the bitstream buffer.
|
||||
unsigned char* pdata; ///< The start of the bitstream buffer.
|
||||
size_t length_chars; ///< The length, in char, of the bitstream buffer.
|
||||
unsigned char bits_available_in_char; ///< The number of available bits in
|
||||
///< the current char.
|
||||
size_t char_index; ///< The index of the char in the bitstream buffer.
|
||||
size_t bits_available; ///< The number of bits still available in the
|
||||
///< bitstream buffer.
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -527,10 +525,10 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef char value_type;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef etl::span<value_type> callback_parameter_type;
|
||||
typedef char value_type;
|
||||
typedef value_type* iterator;
|
||||
typedef const value_type* const_iterator;
|
||||
typedef etl::span<value_type> callback_parameter_type;
|
||||
typedef etl::delegate<void(callback_parameter_type)> callback_type;
|
||||
|
||||
//***************************************************************************
|
||||
@ -564,7 +562,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
bit_stream_writer(void* begin_, void* end_, etl::endian stream_endianness_, callback_type callback_ = callback_type())
|
||||
: pdata(reinterpret_cast<char*>(begin_))
|
||||
, length_chars(etl::distance(reinterpret_cast<unsigned char*>(begin_), reinterpret_cast<unsigned char*>(end_)))
|
||||
, length_chars(static_cast<size_t>(etl::distance(reinterpret_cast<unsigned char*>(begin_), reinterpret_cast<unsigned char*>(end_))))
|
||||
, stream_endianness(stream_endianness_)
|
||||
, callback(callback_)
|
||||
{
|
||||
@ -589,8 +587,8 @@ namespace etl
|
||||
void restart()
|
||||
{
|
||||
bits_available_in_char = CHAR_BIT;
|
||||
char_index = 0U;
|
||||
bits_available = capacity_bits();
|
||||
char_index = 0U;
|
||||
bits_available = capacity_bits();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
@ -653,8 +651,7 @@ namespace etl
|
||||
/// For integral types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_integral<T>::value, void>::type
|
||||
write_unchecked(T value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
typename etl::enable_if<etl::is_integral<T>::value, void>::type write_unchecked(T value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
{
|
||||
typedef typename etl::unsigned_type<T>::type unsigned_t;
|
||||
|
||||
@ -665,8 +662,7 @@ namespace etl
|
||||
/// For integral types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_integral<T>::value, bool>::type
|
||||
write(T value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
typename etl::enable_if<etl::is_integral<T>::value, bool>::type write(T value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
{
|
||||
bool success = (available(nbits) > 0U);
|
||||
|
||||
@ -975,10 +971,12 @@ namespace etl
|
||||
char* const pdata; ///< The start of the bitstream buffer.
|
||||
const size_t length_chars; ///< The length of the bitstream buffer.
|
||||
const etl::endian stream_endianness; ///< The endianness of the stream data.
|
||||
unsigned char bits_available_in_char; ///< The number of available bits in the current char.
|
||||
size_t char_index; ///< The index of the current char in the bitstream buffer.
|
||||
size_t bits_available; ///< The number of bits still available in the bitstream buffer.
|
||||
callback_type callback; ///< An optional callback on every filled byte in buffer.
|
||||
unsigned char bits_available_in_char; ///< The number of available bits in
|
||||
///< the current char.
|
||||
size_t char_index; ///< The index of the current char in the bitstream buffer.
|
||||
size_t bits_available; ///< The number of bits still available in the
|
||||
///< bitstream buffer.
|
||||
callback_type callback; ///< An optional callback on every filled byte in buffer.
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -1005,8 +1003,8 @@ namespace etl
|
||||
/// Overload this to support custom types.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_integral<T>::value, void>::type
|
||||
write_unchecked(etl::bit_stream_writer& stream, const T& value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
typename etl::enable_if<etl::is_integral<T>::value, void>::type write_unchecked(etl::bit_stream_writer& stream, const T& value,
|
||||
uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
{
|
||||
stream.write_unchecked(value, nbits);
|
||||
}
|
||||
@ -1017,8 +1015,8 @@ namespace etl
|
||||
/// Overload this to support custom types.
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_integral<T>::value, bool>::type
|
||||
write(etl::bit_stream_writer& stream, const T& value, uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
typename etl::enable_if<etl::is_integral<T>::value, bool>::type write(etl::bit_stream_writer& stream, const T& value,
|
||||
uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
{
|
||||
return stream.write(value, nbits);
|
||||
}
|
||||
@ -1030,7 +1028,7 @@ namespace etl
|
||||
{
|
||||
public:
|
||||
|
||||
typedef char value_type;
|
||||
typedef char value_type;
|
||||
typedef const char* const_iterator;
|
||||
|
||||
//***************************************************************************
|
||||
@ -1086,7 +1084,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
bit_stream_reader(const void* begin_, const void* end_, etl::endian stream_endianness_)
|
||||
: pdata(reinterpret_cast<const char*>(begin_))
|
||||
, length_chars(etl::distance(reinterpret_cast<const char*>(begin_), reinterpret_cast<const char*>(end_)))
|
||||
, length_chars(static_cast<size_t>(etl::distance(reinterpret_cast<const char*>(begin_), reinterpret_cast<const char*>(end_))))
|
||||
, stream_endianness(stream_endianness_)
|
||||
{
|
||||
restart();
|
||||
@ -1109,16 +1107,15 @@ namespace etl
|
||||
void restart()
|
||||
{
|
||||
bits_available_in_char = CHAR_BIT;
|
||||
char_index = 0U;
|
||||
bits_available = CHAR_BIT * length_chars;
|
||||
char_index = 0U;
|
||||
bits_available = CHAR_BIT * length_chars;
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// For bool types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_same<bool, T>::value, bool>::type
|
||||
read_unchecked()
|
||||
typename etl::enable_if<etl::is_same<bool, T>::value, bool>::type read_unchecked()
|
||||
{
|
||||
return get_bit();
|
||||
}
|
||||
@ -1127,8 +1124,7 @@ namespace etl
|
||||
/// For bool types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_same<bool, T>::value, etl::optional<bool> >::type
|
||||
read()
|
||||
typename etl::enable_if<etl::is_same<bool, T>::value, etl::optional<bool> >::type read()
|
||||
{
|
||||
etl::optional<bool> result;
|
||||
|
||||
@ -1144,12 +1140,12 @@ namespace etl
|
||||
/// For integral types
|
||||
//***************************************************************************
|
||||
template <typename T>
|
||||
typename etl::enable_if<etl::is_integral<T>::value && !etl::is_same<bool, T>::value, T>::type
|
||||
read_unchecked(uint_least8_t nbits = CHAR_BIT * sizeof(T))
|
||||
typename etl::enable_if< etl::is_integral<T>::value && !etl::is_same<bool, T>::value, T>::type read_unchecked(uint_least8_t nbits = CHAR_BIT
|
||||
* sizeof(T))
|
||||
{
|
||||
typedef typename etl::unsigned_type<T>::type unsigned_t;
|
||||
|
||||
T value = read_value<unsigned_t>(nbits, etl::is_signed<T>::value);
|
||||
T value = static_cast<T>(read_value<unsigned_t>(nbits, etl::is_signed<T>::value));
|
||||
|
||||
return static_cast<T>(value);
|
||||
}
|
||||
@ -1166,7 +1162,7 @@ namespace etl
|
||||
// Do we have enough bits?
|
||||
if (bits_available >= nbits)
|
||||
{
|
||||
result = read_unchecked<T>(nbits);
|
||||
result = read_unchecked<T>(nbits);
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -1266,8 +1262,8 @@ namespace etl
|
||||
// Make sure that we are not reading more bits than should be available.
|
||||
nbits = (nbits > (CHAR_BIT * sizeof(T))) ? (CHAR_BIT * sizeof(T)) : nbits;
|
||||
|
||||
T value = 0;
|
||||
uint_least8_t bits = nbits;
|
||||
T value = 0;
|
||||
uint_least8_t bits = nbits;
|
||||
|
||||
// Get the bits from the stream.
|
||||
while (nbits != 0)
|
||||
@ -1299,7 +1295,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
unsigned char get_chunk(unsigned char nbits)
|
||||
{
|
||||
unsigned char value = pdata[char_index];
|
||||
unsigned char value = static_cast<unsigned char>(pdata[char_index]);
|
||||
value >>= (bits_available_in_char - nbits);
|
||||
|
||||
unsigned char mask;
|
||||
@ -1310,7 +1306,7 @@ namespace etl
|
||||
}
|
||||
else
|
||||
{
|
||||
mask = (1U << nbits) - 1;
|
||||
mask = static_cast<unsigned char>((1U << nbits) - 1);
|
||||
}
|
||||
|
||||
value &= mask;
|
||||
@ -1325,7 +1321,7 @@ namespace etl
|
||||
//***************************************************************************
|
||||
bool get_bit()
|
||||
{
|
||||
bool result = (pdata[char_index] & (1U << (bits_available_in_char - 1U))) != 0U;
|
||||
bool result = (static_cast<unsigned char>(pdata[char_index]) & (1U << (bits_available_in_char - 1U))) != 0U;
|
||||
|
||||
step(1U);
|
||||
|
||||
@ -1352,9 +1348,11 @@ namespace etl
|
||||
const char* pdata; ///< The start of the bitstream buffer.
|
||||
size_t length_chars; ///< The length, in char, of the bitstream buffer.
|
||||
const etl::endian stream_endianness; ///< The endianness of the stream data.
|
||||
unsigned char bits_available_in_char; ///< The number of available bits in the current char.
|
||||
size_t char_index; ///< The index of the char in the bitstream buffer.
|
||||
size_t bits_available; ///< The number of bits still available in the bitstream buffer.
|
||||
unsigned char bits_available_in_char; ///< The number of available bits in
|
||||
///< the current char.
|
||||
size_t char_index; ///< The index of the char in the bitstream buffer.
|
||||
size_t bits_available; ///< The number of bits still available in the
|
||||
///< bitstream buffer.
|
||||
};
|
||||
|
||||
//***************************************************************************
|
||||
@ -1404,7 +1402,7 @@ namespace etl
|
||||
{
|
||||
return stream.read<bool>();
|
||||
}
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#include "private/minmax_pop.h"
|
||||
|
||||
|
||||
@ -32,12 +32,12 @@ SOFTWARE.
|
||||
#define ETL_BLOOM_FILTER_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "parameter_type.h"
|
||||
#include "bitset.h"
|
||||
#include "type_traits.h"
|
||||
#include "binary.h"
|
||||
#include "bitset.h"
|
||||
#include "log.h"
|
||||
#include "parameter_type.h"
|
||||
#include "power.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
///\defgroup bloom_filter bloom_filter
|
||||
/// A Bloom filter
|
||||
@ -51,34 +51,33 @@ namespace etl
|
||||
struct null_hash
|
||||
{
|
||||
template <typename T>
|
||||
size_t operator ()(T)
|
||||
size_t operator()(T)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
} // namespace private_bloom_filter
|
||||
|
||||
//***************************************************************************
|
||||
/// An implementation of a bloom filter.
|
||||
/// Allows up to three hashes to be defined.
|
||||
/// Hashes must support the () operator and define 'argument_type'.
|
||||
///\tparam Desired_Width The desired number of hash results that can be stored. Rounded up to best fit the underlying bitset.
|
||||
///\tparam THash1 The first hash generator class.
|
||||
///\tparam THash2 The second hash generator class. If omitted, uses the null hash.
|
||||
///\tparam THash3 The third hash generator class. If omitted, uses the null hash.
|
||||
/// The hash classes must define <b>argument_type</b>.
|
||||
///\tparam Desired_Width The desired number of hash results that can be
|
||||
/// stored. Rounded up to best fit the underlying
|
||||
/// bitset. \tparam THash1 The first hash generator class. \tparam
|
||||
/// THash2 The second hash generator class. If omitted, uses the null
|
||||
/// hash. \tparam THash3 The third hash generator class. If omitted,
|
||||
/// uses the null hash. The hash classes must define <b>argument_type</b>.
|
||||
///\ingroup bloom_filter
|
||||
//***************************************************************************
|
||||
template <size_t Desired_Width,
|
||||
typename THash1,
|
||||
typename THash2 = private_bloom_filter::null_hash,
|
||||
template <size_t Desired_Width, typename THash1, typename THash2 = private_bloom_filter::null_hash,
|
||||
typename THash3 = private_bloom_filter::null_hash>
|
||||
class bloom_filter
|
||||
{
|
||||
private:
|
||||
|
||||
typedef typename etl::parameter_type<typename THash1::argument_type>::type parameter_t;
|
||||
typedef private_bloom_filter::null_hash null_hash;
|
||||
typedef private_bloom_filter::null_hash null_hash;
|
||||
|
||||
public:
|
||||
|
||||
@ -90,11 +89,11 @@ namespace etl
|
||||
|
||||
//***************************************************************************
|
||||
/// Clears the bloom filter of all entries.
|
||||
//***************************************************************************
|
||||
void clear()
|
||||
{
|
||||
flags.reset();
|
||||
}
|
||||
//***************************************************************************
|
||||
void clear()
|
||||
{
|
||||
flags.reset();
|
||||
}
|
||||
|
||||
//***************************************************************************
|
||||
/// Adds a key to the filter.
|
||||
@ -184,7 +183,6 @@ namespace etl
|
||||
/// The Bloom filter flags.
|
||||
etl::bitset<WIDTH> flags;
|
||||
};
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -91,7 +91,7 @@ namespace etl
|
||||
//***************************************************
|
||||
/// Assignment operator
|
||||
//***************************************************
|
||||
const_iterator& operator =(const const_iterator& rhs)
|
||||
const_iterator& operator=(const const_iterator& rhs)
|
||||
{
|
||||
p_bresenham_line = rhs.p_bresenham_line;
|
||||
|
||||
@ -101,7 +101,7 @@ namespace etl
|
||||
//***************************************************
|
||||
/// Pre-increment operator
|
||||
//***************************************************
|
||||
const_iterator& operator ++()
|
||||
const_iterator& operator++()
|
||||
{
|
||||
// Has the end of the series has been reached?
|
||||
if (p_bresenham_line->get_coordinate() == p_bresenham_line->back())
|
||||
@ -120,7 +120,7 @@ namespace etl
|
||||
//***************************************************
|
||||
/// De-reference operator
|
||||
//***************************************************
|
||||
value_type operator *() const
|
||||
value_type operator*() const
|
||||
{
|
||||
return p_bresenham_line->get_coordinate();
|
||||
}
|
||||
@ -128,7 +128,7 @@ namespace etl
|
||||
//***************************************************
|
||||
/// Equality operator
|
||||
//***************************************************
|
||||
friend bool operator ==(const const_iterator& lhs, const const_iterator& rhs)
|
||||
friend bool operator==(const const_iterator& lhs, const const_iterator& rhs)
|
||||
{
|
||||
return lhs.p_bresenham_line == rhs.p_bresenham_line;
|
||||
}
|
||||
@ -136,7 +136,7 @@ namespace etl
|
||||
//***************************************************
|
||||
/// Inequality operator
|
||||
//***************************************************
|
||||
friend bool operator !=(const const_iterator& lhs, const const_iterator& rhs)
|
||||
friend bool operator!=(const const_iterator& lhs, const const_iterator& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
@ -240,18 +240,18 @@ namespace etl
|
||||
{
|
||||
if (y_is_major_axis())
|
||||
{
|
||||
return (dy / 2) + 1;
|
||||
return static_cast<size_t>((dy / 2) + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (dx / 2) + 1;
|
||||
return static_cast<size_t>((dx / 2) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
//***************************************************
|
||||
/// Equality operator
|
||||
//***************************************************
|
||||
friend bool operator ==(const bresenham_line& lhs, const bresenham_line& rhs)
|
||||
friend bool operator==(const bresenham_line& lhs, const bresenham_line& rhs)
|
||||
{
|
||||
return (lhs.front() == rhs.front()) && (lhs.back() == rhs.back());
|
||||
}
|
||||
@ -259,7 +259,7 @@ namespace etl
|
||||
//***************************************************
|
||||
/// Inequality operator
|
||||
//***************************************************
|
||||
friend bool operator !=(const bresenham_line& lhs, const bresenham_line& rhs)
|
||||
friend bool operator!=(const bresenham_line& lhs, const bresenham_line& rhs)
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
@ -272,7 +272,7 @@ namespace etl
|
||||
void initialise(T first_x, T first_y, T last_x, T last_y)
|
||||
{
|
||||
first = value_type(first_x, first_y);
|
||||
last = value_type(last_x, last_y);
|
||||
last = value_type(last_x, last_y);
|
||||
coordinate = first;
|
||||
x_increment = (last_x < first_x) ? -1 : 1;
|
||||
y_increment = (last_y < first_y) ? -1 : 1;
|
||||
@ -355,7 +355,6 @@ namespace etl
|
||||
work_t balance;
|
||||
bool do_minor_increment;
|
||||
};
|
||||
}
|
||||
} // namespace etl
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -32,12 +32,12 @@ SOFTWARE.
|
||||
#define ETL_BUFFER_DESCRIPTORS_INCLUDED
|
||||
|
||||
#include "platform.h"
|
||||
#include "array.h"
|
||||
#include "delegate.h"
|
||||
#include "type_traits.h"
|
||||
#include "static_assert.h"
|
||||
#include "cyclic_value.h"
|
||||
#include "algorithm.h"
|
||||
#include "array.h"
|
||||
#include "cyclic_value.h"
|
||||
#include "delegate.h"
|
||||
#include "static_assert.h"
|
||||
#include "type_traits.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@ -89,7 +89,7 @@ namespace etl
|
||||
}
|
||||
|
||||
//*********************************
|
||||
descriptor& operator =(const descriptor& other)
|
||||
descriptor& operator=(const descriptor& other)
|
||||
{
|
||||
pdesc_item = other.pdesc_item;
|
||||
return *this;
|
||||
@ -99,12 +99,13 @@ namespace etl
|
||||
pointer data() const
|
||||
{
|
||||
assert(pdesc_item != ETL_NULLPTR);
|
||||
#include "private/diagnostic_null_dereference_push.h"
|
||||
return pdesc_item->pbuffer;
|
||||
#include "private/diagnostic_pop.h"
|
||||
}
|
||||
|
||||
//*********************************
|
||||
ETL_NODISCARD
|
||||
ETL_CONSTEXPR size_type max_size() const
|
||||
ETL_NODISCARD ETL_CONSTEXPR size_type max_size() const
|
||||
{
|
||||
return BUFFER_SIZE;
|
||||
}
|
||||
@ -147,7 +148,7 @@ namespace etl
|
||||
//*********************************
|
||||
void allocate()
|
||||
{
|
||||
pdesc_item->in_use = true;;
|
||||
pdesc_item->in_use = true;
|
||||
}
|
||||
|
||||
/// The pointer to the buffer descriptor.
|
||||
@ -282,23 +283,26 @@ namespace etl
|
||||
//*********************************
|
||||
struct descriptor_item
|
||||
{
|
||||
pointer pbuffer;
|
||||
pointer pbuffer;
|
||||
volatile flag_type in_use;
|
||||
};
|
||||
|
||||
callback_type callback;
|
||||
etl::array<descriptor_item, N_BUFFERS> descriptor_items;
|
||||
callback_type callback;
|
||||
etl::array<descriptor_item, N_BUFFERS> descriptor_items;
|
||||
etl::cyclic_value<uint_least8_t, 0U, N_BUFFERS - 1> next;
|
||||
};
|
||||
|
||||
template <typename TBuffer, size_t BUFFER_SIZE_, size_t N_BUFFERS_, typename TFlag>
|
||||
ETL_CONSTANT typename buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::size_type buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::N_BUFFERS;
|
||||
ETL_CONSTANT typename buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::size_type
|
||||
buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::N_BUFFERS;
|
||||
|
||||
template <typename TBuffer, size_t BUFFER_SIZE_, size_t N_BUFFERS_, typename TFlag>
|
||||
ETL_CONSTANT typename buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::size_type buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::BUFFER_SIZE;
|
||||
|
||||
ETL_CONSTANT typename buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::size_type
|
||||
buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::BUFFER_SIZE;
|
||||
|
||||
template <typename TBuffer, size_t BUFFER_SIZE_, size_t N_BUFFERS_, typename TFlag>
|
||||
ETL_CONSTANT typename buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::size_type buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::descriptor::MAX_SIZE;
|
||||
}
|
||||
ETL_CONSTANT typename buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::size_type
|
||||
buffer_descriptors<TBuffer, BUFFER_SIZE_, N_BUFFERS_, TFlag>::descriptor::MAX_SIZE;
|
||||
} // namespace etl
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user