mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 02:59:01 -04:00
Add methods for extracting specific regex captures.
This commit is contained in:
parent
0f84414b39
commit
a0850bc53f
@ -174,9 +174,28 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
/** Retrieves a specific captured substring by index.
|
||||
* @param idx The index of the captured substring to return.
|
||||
* The requested captured substring or std::nullopt if it does not exist.
|
||||
*/
|
||||
const std::optional<std::string> GetCapture(size_t idx) const
|
||||
{
|
||||
return captures.size() > idx ? std::nullopt : std::make_optional(captures[idx]);
|
||||
}
|
||||
|
||||
/** Retrieves the substrings that were captured. */
|
||||
const Captures& GetCaptures() const { return captures; }
|
||||
|
||||
/** Retrieves a specific captured substring by index.
|
||||
* @param name The name of the captured substring to return.
|
||||
* The requested captured substring or std::nullopt if it does not exist.
|
||||
*/
|
||||
const std::optional<std::string> GetNamedCapture(const std::string& name) const
|
||||
{
|
||||
auto capture = namedcaptures.find(name);
|
||||
return capture == namedcaptures.end() ? std::nullopt : std::make_optional(capture->second);
|
||||
}
|
||||
|
||||
/** Retrieves the substrings that were captured by name. */
|
||||
const NamedCaptures& GetNamedCaptures() const { return namedcaptures; }
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user