mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 18:14:44 +00:00
Pipeline: City rename, add address/postal-code generation, add xeger generation (#232)
This commit is contained in:
38
tooling/pipeline/includes/services/xeger/xeger.h
Normal file
38
tooling/pipeline/includes/services/xeger/xeger.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef BIERGARTEN_PIPELINE_INCLUDES_SERVICES_XEGER_XEGER_H_
|
||||
#define BIERGARTEN_PIPELINE_INCLUDES_SERVICES_XEGER_XEGER_H_
|
||||
|
||||
#include <random>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
|
||||
/**
|
||||
* @brief Generates a random string matching @p pattern.
|
||||
*
|
||||
* Supported syntax:
|
||||
* - literals
|
||||
* - `.`
|
||||
* - alternation `|`
|
||||
* - groups `(...)` and non-capturing groups `(?:...)`
|
||||
* - quantifiers `*` `+` `?` `{n}` `{n,}` `{n,m}`
|
||||
* - character classes `[...]` / `[^...]`
|
||||
* - shorthand escapes `\d \D \w \W \s \S \n \t \r`
|
||||
*
|
||||
* Not supported: lookaround, backreferences, and lazy quantifiers.
|
||||
*
|
||||
* @param pattern Regular expression to generate a matching
|
||||
* string for.
|
||||
* @param rng Random source driving alternation/quantifier/
|
||||
* class choices.
|
||||
* @param unbounded_repeat_cap Extra repeats allowed on top of the declared
|
||||
* minimum for unbounded quantifiers
|
||||
* (`*`, `+`, `{n,}`).
|
||||
*
|
||||
* @return A string satisfying `std::regex_match(result, std::regex(pattern))`
|
||||
* for any @p pattern within the supported syntax subset.
|
||||
*
|
||||
* @throws std::runtime_error if @p pattern cannot be parsed.
|
||||
*/
|
||||
std::string GenerateStringFromRegex(std::string_view pattern, std::mt19937& rng,
|
||||
int unbounded_repeat_cap = 8);
|
||||
|
||||
#endif // BIERGARTEN_PIPELINE_INCLUDES_SERVICES_XEGER_XEGER_H_
|
||||
Reference in New Issue
Block a user