|
tgen
|
String generator. More...

Classes | |
| struct | value |
| String value. More... | |
Public Member Functions | |
| str (int size, char value_left='a', char value_right='z') | |
| Creates string generator defined by size and range of characters. | |
| str (int size, std::set< char > chars) | |
| Creates string generator defined by character set. | |
| template<typename... Args> | |
| str (const std::string ®ex, Args &&...args) | |
| Creates string generator defined by regex. | |
| str & | fix (int idx, char character) |
| Restricts generator s.t. character at index is fixed. | |
| str & | equal (std::set< int > indices) |
| Restricts generator s.t. all characters in index set are equal. | |
| str & | equal (int idx_1, int idx_2) |
| Restricts generator s.t. characters at two indices are equal. | |
| str & | equal_range (int left, int right) |
| Restricts generator s.t. all characters at index range are equal. | |
| str & | all_equal () |
| Restricts generator s.t. all values are equal. | |
| str & | palindrome (int left, int right) |
| Restricts generator s.t. range is a palindrome. | |
| str & | palindrome () |
| Restricts generator s.t. string is a palindrome. | |
| str & | different (std::set< int > indices) |
| Restricts generator s.t. all characters in index set are different. | |
| str & | different (int idx_1, int idx_2) |
| Restricts generator s.t. characters at two indices are different. | |
| str & | different_range (int left, int right) |
| Restricts generator s.t. all characters at index range are different. | |
| str & | all_different () |
| Restricts generator s.t. all characters are different. | |
| value | gen () const |
| Generates a random value from the set of valid strings. | |
| Public Member Functions inherited from tgen::gen_base< str > | |
| auto | gen_list (int size, Args &&...args) const |
| Generates a list of several generation calls. | |
| auto | gen_until (Pred predicate, int max_tries, Args &&...args) const |
| Generates a random value from the valid set until a condition is met. | |
| auto | distinct (Args &&...args) const |
| Creates distinct generator for current generator. | |
String generator.
Defines a set of strings, subject to restrictions.
A uniformly random tgen::str::value from this set of strings (that satisfies the restrictions) can be generated with tgen::str::gen.
|
inline |
Creates string generator defined by size and range of characters.
| size | Size of the string. |
| value_left | Left endpoint of character range. |
| value_right | Right endpoint of character range. |
Defines a generator of strings of length size with characters in [value_left, value_right].
|
inline |
|
inline |
Creates string generator defined by regex.
| regex | Regex. |
| args | Arguments for the regex. |
Defines a generator of strings generated by regex (see Strings), with the given args.
|
inline |
Restricts generator s.t. all characters are different.
Equivalent to tgen::str::different({0, 1, ... size-1}).
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
|
inline |
Restricts generator s.t. all values are equal.
Equivalent to tgen::str::equal({0, 1, ... size-1}).
|
inline |
Restricts generator s.t. characters at two indices are different.
| idx_1 | First index. |
| idx_2 | Second index. |
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
Equivalent to tgen::str::different({idx_1, idx_2}).
|
inline |
Restricts generator s.t. all characters in index set are different.
| indices | Index set. |
| std::runtime_error | if the generator was created from regex (restrictions cannot be added for regex). |
|
inline |
Restricts generator s.t. all characters at index range are different.
| left | Left endpoint of index range (inclusive). |
| right | Right endpoint of index range (inclusive). |
Equivalent to tgen::str::different({left, left+1, ... , right}).
|
inline |
Restricts generator s.t. characters at two indices are equal.
| idx_1 | First index. |
| idx_2 | Second index. |
Equivalent to tgen::str::equal({idx_1, idx_2}).
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
|
inline |
|
inline |
Restricts generator s.t. all characters at index range are equal.
| left | Left endpoint of index range (inclusive). |
| right | Right endpoint of index range (inclusive). |
Equivalent to tgen::str::equal({left, left+1, ... , right}).
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
|
inline |
Restricts generator s.t. character at index is fixed.
| idx | Index. |
| character | Character. |
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
|
inline |
Generates a random value from the set of valid strings.
| std::runtime_error | if there is no valid string satisfying all restrictions. |
If created from restrictions: O(n log n).
If created from regex: expected linear.
|
inline |
Restricts generator s.t. string is a palindrome.
Equivalent to tgen::str::palindrome(0, size - 1).
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |
|
inline |
Restricts generator s.t. range is a palindrome.
| left | Left endpoint of the index range (inclusive). |
| right | Right endpoint of the index range (inclusive). |
| std::runtime_error | if the generator was created from a regex (restrictions cannot be added for regex). |