Skip to content

Commit 110ae42

Browse files
committed
Add support for outputting character classes as metadata
1 parent e41e3f3 commit 110ae42

93 files changed

Lines changed: 488 additions & 4 deletions

File tree

Some content is hidden

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

Src/FastData.Cli.Tests/CommandOutputs/cpp_-s HashTable_Files_Strings.input.verified.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ public:
6161
static constexpr size_t item_count = 2;
6262
static constexpr size_t min_key_length = 5;
6363
static constexpr size_t max_key_length = 5;
64+
static constexpr bool has_number = true;
65+
static constexpr bool has_uppercase = false;
66+
static constexpr bool has_lowercase = true;
67+
static constexpr bool has_symbol = false;
68+
static constexpr bool has_whitespace = false;
6469
};
6570
,
6671
Item2:

Src/FastData.Cli.Tests/CommandOutputs/cpp_Files_Strings.input.verified.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public:
2323
static constexpr size_t item_count = 2;
2424
static constexpr size_t min_key_length = 5;
2525
static constexpr size_t max_key_length = 5;
26+
static constexpr bool has_number = true;
27+
static constexpr bool has_uppercase = false;
28+
static constexpr bool has_lowercase = true;
29+
static constexpr bool has_symbol = false;
30+
static constexpr bool has_whitespace = false;
2631
};
2732
,
2833
Item2:

Src/FastData.Cli.Tests/CommandOutputs/csharp_-s HashTable_Files_Strings.input.verified.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ internal static class MyData
8181
public const uint ItemCount = 2;
8282
public const uint MinKeyLength = 5;
8383
public const uint MaxKeyLength = 5;
84+
public const bool HasNumber = true;
85+
public const bool HasUppercase = false;
86+
public const bool HasLowercase = true;
87+
public const bool HasSymbol = false;
88+
public const bool HasWhitespace = false;
8489
}
8590
,
8691
Item2:

Src/FastData.Cli.Tests/CommandOutputs/csharp_Files_Strings.input.verified.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ internal static class MyData
2929
public const uint ItemCount = 2;
3030
public const uint MinKeyLength = 5;
3131
public const uint MaxKeyLength = 5;
32+
public const bool HasNumber = true;
33+
public const bool HasUppercase = false;
34+
public const bool HasLowercase = true;
35+
public const bool HasSymbol = false;
36+
public const bool HasWhitespace = false;
3237
}
3338
,
3439
Item2:

Src/FastData.Cli.Tests/CommandOutputs/rust_-s HashTable_Files_Strings.input.verified.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ const ENTRIES: [e; 2] = [
5555
pub const ITEM_COUNT: usize = 2;
5656
pub const MIN_KEY_LENGTH: usize = 5;
5757
pub const MAX_KEY_LENGTH: usize = 5;
58+
pub const HAS_NUMBER: bool = true;
59+
pub const HAS_UPPERCASE: bool = false;
60+
pub const HAS_LOWERCASE: bool = true;
61+
pub const HAS_SYMBOL: bool = false;
62+
pub const HAS_WHITESPACE: bool = false;
5863
}
5964
,
6065
Item2:

Src/FastData.Cli.Tests/CommandOutputs/rust_Files_Strings.input.verified.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ impl MyData {
2727
pub const ITEM_COUNT: usize = 2;
2828
pub const MIN_KEY_LENGTH: usize = 5;
2929
pub const MAX_KEY_LENGTH: usize = 5;
30+
pub const HAS_NUMBER: bool = true;
31+
pub const HAS_UPPERCASE: bool = false;
32+
pub const HAS_LOWERCASE: bool = true;
33+
pub const HAS_SYMBOL: bool = false;
34+
pub const HAS_WHITESPACE: bool = false;
3035
}
3136
,
3237
Item2:
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Runtime.CompilerServices;
2+
using VerifyTests.DiffPlex;
3+
4+
namespace Genbox.FastData.Cli.Tests.Properties;
5+
6+
internal static class ModuleInitializer
7+
{
8+
[ModuleInitializer]
9+
public static void Initialize() => VerifyDiffPlex.Initialize(OutputType.Compact);
10+
}

Src/FastData.Generator.CPlusPlus/Internal/Framework/CPlusPlusConstantsDef.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Genbox.FastData.Generator.Framework.Interfaces;
2+
using Genbox.FastData.Generators;
23

34
namespace Genbox.FastData.Generator.CPlusPlus.Internal.Framework;
45

@@ -10,4 +11,13 @@ internal class CPlusPlusConstantsDef : IConstantsDef
1011
public Func<string, string, string> MinValueTemplate => (type, value) => $" static constexpr {type} min_key = {value};";
1112
public Func<string, string, string> MaxValueTemplate => (type, value) => $" static constexpr {type} max_key = {value};";
1213
public Func<string, string, string> ItemCountTemplate => (type, value) => $" static constexpr {type} item_count = {value};";
14+
15+
public Func<CharacterClass, string> CharacterClassesTemplate => value =>
16+
$"""
17+
static constexpr bool has_number = {(value.HasFlag(CharacterClass.Number) ? "true" : "false")};
18+
static constexpr bool has_uppercase = {(value.HasFlag(CharacterClass.Uppercase) ? "true" : "false")};
19+
static constexpr bool has_lowercase = {(value.HasFlag(CharacterClass.Lowercase) ? "true" : "false")};
20+
static constexpr bool has_symbol = {(value.HasFlag(CharacterClass.Symbol) ? "true" : "false")};
21+
static constexpr bool has_whitespace = {(value.HasFlag(CharacterClass.Whitespace) ? "true" : "false")};
22+
""";
1323
}

Src/FastData.Generator.CSharp/Internal/Framework/CSharpConstantsDef.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Genbox.FastData.Generator.Framework.Interfaces;
2+
using Genbox.FastData.Generators;
23

34
namespace Genbox.FastData.Generator.CSharp.Internal.Framework;
45

@@ -10,4 +11,13 @@ internal class CSharpConstantsDef : IConstantsDef
1011
public Func<string, string, string> MinValueTemplate => (type, value) => $" public const {type} MinKey = {value};";
1112
public Func<string, string, string> MaxValueTemplate => (type, value) => $" public const {type} MaxKey = {value};";
1213
public Func<string, string, string> ItemCountTemplate => (type, value) => $" public const {type} ItemCount = {value};";
14+
15+
public Func<CharacterClass, string> CharacterClassesTemplate => value =>
16+
$"""
17+
public const bool HasNumber = {(value.HasFlag(CharacterClass.Number) ? "true" : "false")};
18+
public const bool HasUppercase = {(value.HasFlag(CharacterClass.Uppercase) ? "true" : "false")};
19+
public const bool HasLowercase = {(value.HasFlag(CharacterClass.Lowercase) ? "true" : "false")};
20+
public const bool HasSymbol = {(value.HasFlag(CharacterClass.Symbol) ? "true" : "false")};
21+
public const bool HasWhitespace = {(value.HasFlag(CharacterClass.Whitespace) ? "true" : "false")};
22+
""";
1323
}

Src/FastData.Generator.Rust/Internal/Framework/RustConstantsDef.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Genbox.FastData.Generator.Framework.Interfaces;
2+
using Genbox.FastData.Generators;
23

34
namespace Genbox.FastData.Generator.Rust.Internal.Framework;
45

@@ -10,4 +11,13 @@ internal class RustConstantsDef : IConstantsDef
1011
public Func<string, string, string> MinValueTemplate => (type, value) => $" pub const MIN_KEY: {type} = {value};";
1112
public Func<string, string, string> MaxValueTemplate => (type, value) => $" pub const MAX_KEY: {type} = {value};";
1213
public Func<string, string, string> ItemCountTemplate => (type, value) => $" pub const ITEM_COUNT: {type} = {value};";
14+
15+
public Func<CharacterClass, string> CharacterClassesTemplate => value =>
16+
$"""
17+
pub const HAS_NUMBER: bool = {(value.HasFlag(CharacterClass.Number) ? "true" : "false")};
18+
pub const HAS_UPPERCASE: bool = {(value.HasFlag(CharacterClass.Uppercase) ? "true" : "false")};
19+
pub const HAS_LOWERCASE: bool = {(value.HasFlag(CharacterClass.Lowercase) ? "true" : "false")};
20+
pub const HAS_SYMBOL: bool = {(value.HasFlag(CharacterClass.Symbol) ? "true" : "false")};
21+
pub const HAS_WHITESPACE: bool = {(value.HasFlag(CharacterClass.Whitespace) ? "true" : "false")};
22+
""";
1323
}

0 commit comments

Comments
 (0)