Skip to content

Commit

Permalink
Update docs and README
Browse files Browse the repository at this point in the history
  • Loading branch information
Bingran Hu committed Jul 19, 2024
1 parent fd6122a commit e4dfa7e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 5 deletions.
31 changes: 28 additions & 3 deletions components/core/src/clp/regex_utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,49 @@ metacharacters above, CLP should use the wildcard version.

### Includes

* To use the translator:
* The translator function returns a `Result<T,E>` type, which can either contain a value or an error
code.

```shell
To use the translator:

```cpp
#include <regex_utils/regex_translation_utils.hpp>

using clp::regex_utils::regex_to_wildcard;

// Other code

auto result = regex_to_wildcard(wildcard_str);
if (result.has_error()) {
auto err_code = result.error();
// Handle error
} else {
auto regex_str = result.value();
// Do things with the translated string
}
```

* To add custom configuration to the translator:

```shell
```cpp
#include <regex_utils/RegexToWildcardTranslatorConfig.hpp>

RegexToWildcardTranslatorConfig config{true, false, //...other booleans};
auto result = regex_to_wildcard(wildcard_str, config);

// Same as above
```
For a detailed description on the options order and usage, see the
[Custom Configuration](#custom-configuration) section.
### Functionalities
* Wildcards
- Turn `.` into `?`
- Turn `.*` into `*`
- Turn `.+` into `?*`
- E.g. `abc.*def.ghi.+` will get translated to `abc*def?ghi?*`
### Custom configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ auto normal_state_transition(
}

/**
* Attempt to translate regex wildcard patterns that start with `.` character.
* Attempts to translate regex wildcard patterns that start with `.` character.
*
* Performs the following translation if possible:
* <ul>
Expand Down Expand Up @@ -201,7 +201,9 @@ auto dot_state_transition(
return ErrorCode::Success;
}

// Once we've seen the end anchor, we should not expect any other character to appear.
/**
* Disallows the appearances of other characters after encountering an end anchor in the string.
*/
auto end_state_transition(
[[maybe_unused]] TranslatorState& state,
string_view::const_iterator& it,
Expand Down

0 comments on commit e4dfa7e

Please sign in to comment.