[colorer/Colorer-library] cregexp_refactoring: Make CRegExp getters const and delete copy/move of CRegExp and SRegInfo. (186b1e4)

0 views
Skip to first unread message

farg...@farmanager.com

unread,
Aug 16, 2026, 3:31:10 PM (12 hours ago) Aug 16
to farco...@googlegroups.com
Repository : https://github.com/colorer/Colorer-library
On branch : cregexp_refactoring
Link : https://github.com/colorer/Colorer-library/commit/186b1e4c264bbf8bdc696973350ade29341037db

>---------------------------------------------------------------

commit 186b1e4c264bbf8bdc696973350ade29341037db
Author: Aleksey Dobrunov <cta...@ctapmex.com>
Date: Sun Aug 16 22:46:36 2026 +0500

Make CRegExp getters const and delete copy/move of CRegExp and SRegInfo.


>---------------------------------------------------------------

186b1e4c264bbf8bdc696973350ade29341037db
src/colorer/cregexp/cregexp.cpp | 10 +++++-----
src/colorer/cregexp/cregexp.h | 22 +++++++++++++++-------
2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/src/colorer/cregexp/cregexp.cpp b/src/colorer/cregexp/cregexp.cpp
index 3405b6c..fc48f3f 100644
--- a/src/colorer/cregexp/cregexp.cpp
+++ b/src/colorer/cregexp/cregexp.cpp
@@ -1527,11 +1527,11 @@ bool CRegExp::setRE(const UnicodeString* re)
error = setRELow(*re);
return error == EError::EOK;
}
-bool CRegExp::isOk()
+bool CRegExp::isOk() const
{
return error == EError::EOK;
}
-EError CRegExp::getError()
+EError CRegExp::getError() const
{
return error;
}
@@ -1549,14 +1549,14 @@ void CRegExp::clearRegExpStack()
CRegExp::RegExpStack = nullptr;
}

-int CRegExp::getBracketNo(const UnicodeString* brname)
+int CRegExp::getBracketNo(const UnicodeString* brname) const
{
for (int brn = 0; brn < cnMatch; brn++)
if (UStr::caseCompare(*brname, *brnames[brn]) == 0)
return brn;
return -1;
}
-UnicodeString* CRegExp::getBracketName(int no)
+const UnicodeString* CRegExp::getBracketName(int no) const
{
if (no >= cnMatch)
return nullptr;
@@ -1575,7 +1575,7 @@ bool CRegExp::setBackTrace(const UnicodeString* str, SMatches* trace)
backStr = str;
return true;
}
-bool CRegExp::getBackTrace(const UnicodeString** str, SMatches** trace)
+bool CRegExp::getBackTrace(const UnicodeString** str, SMatches** trace) const
{
*str = backStr;
*trace = backTrace;
diff --git a/src/colorer/cregexp/cregexp.h b/src/colorer/cregexp/cregexp.h
index 1380ed8..ef438c3 100644
--- a/src/colorer/cregexp/cregexp.h
+++ b/src/colorer/cregexp/cregexp.h
@@ -117,6 +117,10 @@ class SRegInfo
public:
SRegInfo();
~SRegInfo();
+ SRegInfo(const SRegInfo&) = delete;
+ SRegInfo& operator=(const SRegInfo&) = delete;
+ SRegInfo(SRegInfo&&) = delete;
+ SRegInfo& operator=(SRegInfo&&) = delete;

union {
EMetaSymbols metaSymbol;
@@ -233,29 +237,33 @@ class CRegExp
*/
CRegExp(const UnicodeString* text);
~CRegExp();
+ CRegExp(const CRegExp&) = delete;
+ CRegExp& operator=(const CRegExp&) = delete;
+ CRegExp(CRegExp&&) = delete;
+ CRegExp& operator=(CRegExp&&) = delete;

/**
Is compilied RE well-formed.
*/
- bool isOk();
+ bool isOk() const;

/**
Returns information about RE compilation error.
*/
- EError getError();
+ EError getError() const;

/**
Tells RE parser, that it must make moves on tested string while RE matching.
*/
bool setPositionMoves(bool moves);
/**
- Returns count of named brackets.
+ Returns named bracket index, or -1 if the name is unknown.
*/
- int getBracketNo(const UnicodeString* brname);
+ int getBracketNo(const UnicodeString* brname) const;
/**
- Returns named bracked name by it's index.
+ Returns named bracket name by its index. Owned by this CRegExp.
*/
- UnicodeString* getBracketName(int no);
+ const UnicodeString* getBracketName(int no) const;
#ifdef COLORERMODE
bool setBackRE(CRegExp* bkre);
/**
@@ -265,7 +273,7 @@ class CRegExp
/**
Returns current RE object, used for backreferences with \y \Y operators.
*/
- bool getBackTrace(const UnicodeString** str, SMatches** trace);
+ bool getBackTrace(const UnicodeString** str, SMatches** trace) const;
#endif
/**
Compiles specified regular expression and drops all


Reply all
Reply to author
Forward
0 new messages