Skip to content
Snippets Groups Projects
Commit 46fc21ef authored by Nikita Nemkin's avatar Nikita Nemkin
Browse files

RegularExpression: Remove redundant overloads

This also makes RegexMatchResult::start/end to reliably report npos
for failed matches. Note that start/end of individual capture groups
might still contain data even if the match has failed overall.

Issue: cmake/cmake#26629
parent 2fbdf7e5
No related branches found
No related tags found
Loading
......@@ -42,11 +42,9 @@ public:
bool isValid() const;
void clear();
std::string::size_type start() const;
std::string::size_type end() const;
std::string::size_type start(int n) const;
std::string::size_type end(int n) const;
std::string match(int n) const;
std::string::size_type start(int n = 0) const;
std::string::size_type end(int n = 0) const;
std::string match(int n = 0) const;
enum
{
......@@ -99,22 +97,6 @@ inline void RegularExpressionMatch::clear()
searchstring = nullptr;
}
/**
* \brief Returns the start index of the full match.
*/
inline std::string::size_type RegularExpressionMatch::start() const
{
return static_cast<std::string::size_type>(this->startp[0] - searchstring);
}
/**
* \brief Returns the end index of the full match.
*/
inline std::string::size_type RegularExpressionMatch::end() const
{
return static_cast<std::string::size_type>(this->endp[0] - searchstring);
}
/**
* \brief Returns the start index of nth submatch.
* start(0) is the start of the full match.
......@@ -363,15 +345,13 @@ public:
* Match indices
*/
inline RegularExpressionMatch const& regMatch() const;
inline std::string::size_type start() const;
inline std::string::size_type end() const;
inline std::string::size_type start(int n) const;
inline std::string::size_type end(int n) const;
inline std::string::size_type start(int n = 0) const;
inline std::string::size_type end(int n = 0) const;
/**
* Match strings
*/
inline std::string match(int n) const;
inline std::string match(int n = 0) const;
/**
* Copy the given regular expression.
......@@ -505,22 +485,6 @@ inline RegularExpressionMatch const& RegularExpression::regMatch() const
return this->regmatch;
}
/**
* Returns the start index of the full match.
*/
inline std::string::size_type RegularExpression::start() const
{
return regmatch.start();
}
/**
* Returns the end index of the full match.
*/
inline std::string::size_type RegularExpression::end() const
{
return regmatch.end();
}
/**
* Return start index of nth submatch. start(0) is the start of the full match.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment