Skip to content

Commit e48cf74

Browse files
committed
refactor: move regex definitions into ParameterRegistry constructor for better encapsulation
1 parent b3e53f7 commit e48cf74

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

cucumber_cpp/library/cucumber_expression/ParameterRegistry.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,6 @@ namespace cucumber_cpp::library::cucumber_expression
3838
return str;
3939
};
4040
}
41-
42-
const std::string integerNegativeRegex{ R"__(-?\d+)__" };
43-
const std::string integerPositiveRegex{ R"__(\d+)__" };
44-
const std::string floatRegex{ R"__((?=.*\d.*)[-+]?\d*(?:\.(?=\d.*))?\d*(?:\d+[E][+-]?\d+)?)__" };
45-
const std::string stringDoubleRegex{ R"__("([^\"\\]*(\\.[^\"\\]*)*)")__" };
46-
const std::string stringSingleRegex{ R"__('([^'\\]*(\\.[^'\\]*)*)')__" };
47-
const std::string wordRegex{ R"__([^\s]+)__" };
4841
}
4942

5043
std::smatch::const_iterator MatchRange::begin() const
@@ -69,6 +62,13 @@ namespace cucumber_cpp::library::cucumber_expression
6962

7063
ParameterRegistry::ParameterRegistry()
7164
{
65+
const static std::string integerNegativeRegex{ R"__(-?\d+)__" };
66+
const static std::string integerPositiveRegex{ R"__(\d+)__" };
67+
const static std::string floatRegex{ R"__((?=.*\d.*)[-+]?\d*(?:\.(?=\d.*))?\d*(?:\d+[E][+-]?\d+)?)__" };
68+
const static std::string stringDoubleRegex{ R"__("([^\"\\]*(\\.[^\"\\]*)*)")__" };
69+
const static std::string stringSingleRegex{ R"__('([^'\\]*(\\.[^'\\]*)*)')__" };
70+
const static std::string wordRegex{ R"__([^\s]+)__" };
71+
7272
Add("int", { integerNegativeRegex, integerPositiveRegex }, CreateStreamConverter<std::int32_t>());
7373
Add("float", { floatRegex }, CreateStreamConverter<float>());
7474
Add("word", { wordRegex }, CreateStreamConverter<std::string>());

0 commit comments

Comments
 (0)