Skip to content

Commit a93a9e3

Browse files
committed
Finish up keyed support
1 parent 35d8d69 commit a93a9e3

File tree

328 files changed

+1900
-1536
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

328 files changed

+1900
-1536
lines changed

Src/FastData.Generator.CPlusPlus.Tests/Verify/ArrayStructure_Byte_3.verified.txt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,41 @@
88

99
class ArrayStructure_Byte_3 final
1010
{
11-
static constexpr std::array<uint8_t, 3> entries = {
11+
static constexpr std::array<uint8_t, 3> values = {
12+
42, 42, 42
13+
};
14+
15+
static constexpr std::array<uint8_t, 3> keys = {
1216
0, 1, std::numeric_limits<uint8_t>::max()
1317
};
1418

1519
public:
1620
[[nodiscard]]
17-
static bool contains(const uint8_t value) noexcept
21+
static bool try_lookup(const uint8_t key, uint8_t& value) noexcept
22+
{
23+
if (key < 0 || key > std::numeric_limits<uint8_t>::max())
24+
return false;
25+
26+
for (size_t i = 0; i < 3; i++)
27+
{
28+
if (keys[i] == key)
29+
{
30+
value = values[i];
31+
return true;
32+
}
33+
}
34+
return false;
35+
}
36+
37+
[[nodiscard]]
38+
static bool contains(const uint8_t key) noexcept
1839
{
19-
if (value < 0 || value > std::numeric_limits<uint8_t>::max())
40+
if (key < 0 || key > std::numeric_limits<uint8_t>::max())
2041
return false;
2142

2243
for (size_t i = 0; i < 3; i++)
2344
{
24-
if (entries[i] == value)
45+
if (keys[i] == key)
2546
return true;
2647
}
2748
return false;

Src/FastData.Generator.CPlusPlus.Tests/Verify/ArrayStructure_Char_3.verified.txt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,41 @@
88

99
class ArrayStructure_Char_3 final
1010
{
11-
static constexpr std::array<char, 3> entries = {
11+
static constexpr std::array<uint8_t, 3> values = {
12+
42, 42, 42
13+
};
14+
15+
static constexpr std::array<char, 3> keys = {
1216
0, 97, 127
1317
};
1418

1519
public:
1620
[[nodiscard]]
17-
static bool contains(const char value) noexcept
21+
static bool try_lookup(const char key, uint8_t& value) noexcept
22+
{
23+
if (key < 0 || key > 127)
24+
return false;
25+
26+
for (size_t i = 0; i < 3; i++)
27+
{
28+
if (keys[i] == key)
29+
{
30+
value = values[i];
31+
return true;
32+
}
33+
}
34+
return false;
35+
}
36+
37+
[[nodiscard]]
38+
static bool contains(const char key) noexcept
1839
{
19-
if (value < 0 || value > 127)
40+
if (key < 0 || key > 127)
2041
return false;
2142

2243
for (size_t i = 0; i < 3; i++)
2344
{
24-
if (entries[i] == value)
45+
if (keys[i] == key)
2546
return true;
2647
}
2748
return false;

Src/FastData.Generator.CPlusPlus.Tests/Verify/ArrayStructure_Double_4.verified.txt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,41 @@
88

99
class ArrayStructure_Double_4 final
1010
{
11-
static constexpr std::array<double, 4> entries = {
11+
static constexpr std::array<uint8_t, 4> values = {
12+
42, 42, 42, 42
13+
};
14+
15+
static constexpr std::array<double, 4> keys = {
1216
std::numeric_limits<double>::lowest(), 0.0, 1.0, std::numeric_limits<double>::max()
1317
};
1418

1519
public:
1620
[[nodiscard]]
17-
static bool contains(const double value) noexcept
21+
static bool try_lookup(const double key, uint8_t& value) noexcept
22+
{
23+
if (key < std::numeric_limits<double>::lowest() || key > std::numeric_limits<double>::max())
24+
return false;
25+
26+
for (size_t i = 0; i < 4; i++)
27+
{
28+
if (keys[i] == key)
29+
{
30+
value = values[i];
31+
return true;
32+
}
33+
}
34+
return false;
35+
}
36+
37+
[[nodiscard]]
38+
static bool contains(const double key) noexcept
1839
{
19-
if (value < std::numeric_limits<double>::lowest() || value > std::numeric_limits<double>::max())
40+
if (key < std::numeric_limits<double>::lowest() || key > std::numeric_limits<double>::max())
2041
return false;
2142

2243
for (size_t i = 0; i < 4; i++)
2344
{
24-
if (entries[i] == value)
45+
if (keys[i] == key)
2546
return true;
2647
}
2748
return false;

Src/FastData.Generator.CPlusPlus.Tests/Verify/ArrayStructure_Int16_5.verified.txt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,41 @@
88

99
class ArrayStructure_Int16_5 final
1010
{
11-
static constexpr std::array<int16_t, 5> entries = {
11+
static constexpr std::array<uint8_t, 5> values = {
12+
42, 42, 42, 42, 42
13+
};
14+
15+
static constexpr std::array<int16_t, 5> keys = {
1216
std::numeric_limits<int16_t>::lowest(), -1, 0, 1, std::numeric_limits<int16_t>::max()
1317
};
1418

1519
public:
1620
[[nodiscard]]
17-
static bool contains(const int16_t value) noexcept
21+
static bool try_lookup(const int16_t key, uint8_t& value) noexcept
22+
{
23+
if (key < std::numeric_limits<int16_t>::lowest() || key > std::numeric_limits<int16_t>::max())
24+
return false;
25+
26+
for (size_t i = 0; i < 5; i++)
27+
{
28+
if (keys[i] == key)
29+
{
30+
value = values[i];
31+
return true;
32+
}
33+
}
34+
return false;
35+
}
36+
37+
[[nodiscard]]
38+
static bool contains(const int16_t key) noexcept
1839
{
19-
if (value < std::numeric_limits<int16_t>::lowest() || value > std::numeric_limits<int16_t>::max())
40+
if (key < std::numeric_limits<int16_t>::lowest() || key > std::numeric_limits<int16_t>::max())
2041
return false;
2142

2243
for (size_t i = 0; i < 5; i++)
2344
{
24-
if (entries[i] == value)
45+
if (keys[i] == key)
2546
return true;
2647
}
2748
return false;

Src/FastData.Generator.CPlusPlus.Tests/Verify/ArrayStructure_Int32_100.verified.txt

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,20 @@
88

99
class ArrayStructure_Int32_100 final
1010
{
11-
static constexpr std::array<int32_t, 100> entries = {
11+
static constexpr std::array<uint8_t, 100> values = {
12+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
13+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
14+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
15+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
16+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
17+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
18+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
19+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
20+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
21+
42, 42, 42, 42, 42, 42, 42, 42, 42, 42
22+
};
23+
24+
static constexpr std::array<int32_t, 100> keys = {
1225
0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
1326
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
1427
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
@@ -23,14 +36,31 @@ class ArrayStructure_Int32_100 final
2336

2437
public:
2538
[[nodiscard]]
26-
static bool contains(const int32_t value) noexcept
39+
static bool try_lookup(const int32_t key, uint8_t& value) noexcept
40+
{
41+
if (key < 0 || key > 99)
42+
return false;
43+
44+
for (size_t i = 0; i < 100; i++)
45+
{
46+
if (keys[i] == key)
47+
{
48+
value = values[i];
49+
return true;
50+
}
51+
}
52+
return false;
53+
}
54+
55+
[[nodiscard]]
56+
static bool contains(const int32_t key) noexcept
2757
{
28-
if (value < 0 || value > 99)
58+
if (key < 0 || key > 99)
2959
return false;
3060

3161
for (size_t i = 0; i < 100; i++)
3262
{
33-
if (entries[i] == value)
63+
if (keys[i] == key)
3464
return true;
3565
}
3666
return false;

Src/FastData.Generator.CPlusPlus.Tests/Verify/ArrayStructure_Int32_5.verified.txt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,41 @@
88

99
class ArrayStructure_Int32_5 final
1010
{
11-
static constexpr std::array<int32_t, 5> entries = {
11+
static constexpr std::array<uint8_t, 5> values = {
12+
42, 42, 42, 42, 42
13+
};
14+
15+
static constexpr std::array<int32_t, 5> keys = {
1216
std::numeric_limits<int32_t>::lowest(), -1, 0, 1, std::numeric_limits<int32_t>::max()
1317
};
1418

1519
public:
1620
[[nodiscard]]
17-
static bool contains(const int32_t value) noexcept
21+
static bool try_lookup(const int32_t key, uint8_t& value) noexcept
22+
{
23+
if (key < std::numeric_limits<int32_t>::lowest() || key > std::numeric_limits<int32_t>::max())
24+
return false;
25+
26+
for (size_t i = 0; i < 5; i++)
27+
{
28+
if (keys[i] == key)
29+
{
30+
value = values[i];
31+
return true;
32+
}
33+
}
34+
return false;
35+
}
36+
37+
[[nodiscard]]
38+
static bool contains(const int32_t key) noexcept
1839
{
19-
if (value < std::numeric_limits<int32_t>::lowest() || value > std::numeric_limits<int32_t>::max())
40+
if (key < std::numeric_limits<int32_t>::lowest() || key > std::numeric_limits<int32_t>::max())
2041
return false;
2142

2243
for (size_t i = 0; i < 5; i++)
2344
{
24-
if (entries[i] == value)
45+
if (keys[i] == key)
2546
return true;
2647
}
2748
return false;

Src/FastData.Generator.CPlusPlus.Tests/Verify/ArrayStructure_Int64_5.verified.txt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,41 @@
88

99
class ArrayStructure_Int64_5 final
1010
{
11-
static constexpr std::array<int64_t, 5> entries = {
11+
static constexpr std::array<uint8_t, 5> values = {
12+
42, 42, 42, 42, 42
13+
};
14+
15+
static constexpr std::array<int64_t, 5> keys = {
1216
std::numeric_limits<int64_t>::lowest(), -1ll, 0ll, 1ll, std::numeric_limits<int64_t>::max()
1317
};
1418

1519
public:
1620
[[nodiscard]]
17-
static bool contains(const int64_t value) noexcept
21+
static bool try_lookup(const int64_t key, uint8_t& value) noexcept
22+
{
23+
if (key < std::numeric_limits<int64_t>::lowest() || key > std::numeric_limits<int64_t>::max())
24+
return false;
25+
26+
for (size_t i = 0; i < 5; i++)
27+
{
28+
if (keys[i] == key)
29+
{
30+
value = values[i];
31+
return true;
32+
}
33+
}
34+
return false;
35+
}
36+
37+
[[nodiscard]]
38+
static bool contains(const int64_t key) noexcept
1839
{
19-
if (value < std::numeric_limits<int64_t>::lowest() || value > std::numeric_limits<int64_t>::max())
40+
if (key < std::numeric_limits<int64_t>::lowest() || key > std::numeric_limits<int64_t>::max())
2041
return false;
2142

2243
for (size_t i = 0; i < 5; i++)
2344
{
24-
if (entries[i] == value)
45+
if (keys[i] == key)
2546
return true;
2647
}
2748
return false;

Src/FastData.Generator.CPlusPlus.Tests/Verify/ArrayStructure_SByte_5.verified.txt

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,41 @@
88

99
class ArrayStructure_SByte_5 final
1010
{
11-
static constexpr std::array<int8_t, 5> entries = {
11+
static constexpr std::array<uint8_t, 5> values = {
12+
42, 42, 42, 42, 42
13+
};
14+
15+
static constexpr std::array<int8_t, 5> keys = {
1216
std::numeric_limits<int8_t>::lowest(), -1, 0, 1, std::numeric_limits<int8_t>::max()
1317
};
1418

1519
public:
1620
[[nodiscard]]
17-
static bool contains(const int8_t value) noexcept
21+
static bool try_lookup(const int8_t key, uint8_t& value) noexcept
22+
{
23+
if (key < std::numeric_limits<int8_t>::lowest() || key > std::numeric_limits<int8_t>::max())
24+
return false;
25+
26+
for (size_t i = 0; i < 5; i++)
27+
{
28+
if (keys[i] == key)
29+
{
30+
value = values[i];
31+
return true;
32+
}
33+
}
34+
return false;
35+
}
36+
37+
[[nodiscard]]
38+
static bool contains(const int8_t key) noexcept
1839
{
19-
if (value < std::numeric_limits<int8_t>::lowest() || value > std::numeric_limits<int8_t>::max())
40+
if (key < std::numeric_limits<int8_t>::lowest() || key > std::numeric_limits<int8_t>::max())
2041
return false;
2142

2243
for (size_t i = 0; i < 5; i++)
2344
{
24-
if (entries[i] == value)
45+
if (keys[i] == key)
2546
return true;
2647
}
2748
return false;

0 commit comments

Comments
 (0)