NCBI C++ ToolKit
|
Classes | |
class | CRegexp |
CRegexp –. More... | |
class | CRegexpUtil |
CRegexpUtil –. More... | |
class | CRegexpException |
CRegexpException –. More... | |
class | CRegexpTemplateTester |
CRegexpTemplateTester –. More... | |
class | CRegexpTemplateTesterException |
CRegexpTemplateTesterException –. More... | |
Typedefs | |
typedef size_t | CRegexp::TOffset |
Element type for GetResults(). More... | |
typedef unsigned int | CRegexp::TCompile |
Type definitions used for code clarity. More... | |
typedef unsigned int | CRegexp::TMatch |
Match options. More... | |
typedef unsigned int | CRegexpTemplateTester::TFlags |
Binary OR of "EFlags". More... | |
typedef map< string, string > | CRegexpTemplateTester::TVarMap |
typedef list< string > | CRegexpTemplateTester::TVarList |
typedef unsigned int CRegexp::TCompile |
Type definitions used for code clarity.
Compilation options.
Definition at line 84 of file regexp.hpp.
typedef unsigned int CRegexpTemplateTester::TFlags |
Binary OR of "EFlags".
Definition at line 209 of file regexp_template_tester.hpp.
typedef unsigned int CRegexp::TMatch |
Match options.
Definition at line 85 of file regexp.hpp.
typedef size_t CRegexp::TOffset |
Element type for GetResults().
Definition at line 78 of file regexp.hpp.
|
private |
Definition at line 300 of file regexp_template_tester.hpp.
typedef map<string, string> CRegexpTemplateTester::TVarMap |
Definition at line 272 of file regexp_template_tester.hpp.
enum CRegexp::ECompile |
Flags for compile regular expressions.
PCRE compiler flags used in the constructor and in Set(). If fCompile_ignore_case is set, matches are case insensitive. If fCompile_dotall is set, a dot meta-character in the pattern matches all characters, including newlines. Without it, newlines are excluded. If fCompile_newline is set then ^ matches the start of a line and $ matches the end of a line. If not set, ^ matches only the start of the entire string and $ matches only the end of the entire string. If fCompile_ungreedy inverts the "greediness" of the quantifiers so that they are not greedy by default, but become greedy if followed by "?". It is not compatible with Perl.
The settings can be changed from within the pattern by a sequence of Perl option letters enclosed between "(?" and ")". The option letters are: i for PCRE_CASELESS m for PCRE_MULTILINE s for PCRE_DOTALL x for PCRE_EXTENDED U for PCRE_UNGREEDY
Enumerator | |
---|---|
fCompile_default | |
fCompile_ignore_case | |
fCompile_dotall | |
fCompile_newline | |
fCompile_ungreedy | |
fCompile_extended |
Definition at line 109 of file regexp.hpp.
Enumerator | |
---|---|
eCompile_default | |
eCompile_ignore_case | |
eCompile_dotall | |
eCompile_newline | |
eCompile_ungreedy |
Definition at line 118 of file regexp.hpp.
Enumerator | |
---|---|
eCompile | |
eBadFlags |
Definition at line 555 of file regexp.hpp.
Error types that tester can generate.
Definition at line 357 of file regexp_template_tester.hpp.
Enumerator | |
---|---|
fSkipEmptySourceLines | Skip empty lines in the source. |
fSkipEmptyTemplateLines | Skip empty lines in the template. |
fSkipEmptyLines |
Definition at line 204 of file regexp_template_tester.hpp.
enum CRegexp::EMatch |
Flags for match string against a precompiled pattern.
Setting fMatch_not_begin causes ^ not to match before the first character of a line. Without setting fCompile_newline, ^ won't match anything if fMatch_not_begin is set. Setting fMatch_not_end causes $ not to match immediately before a new line. Without setting fCompile_newline, $ won't match anything if fMatch_not_end is set.
Enumerator | |
---|---|
fMatch_default | |
fMatch_not_begin | ^ won't match string begin. |
fMatch_not_end | $ won't match string end. |
fMatch_not_both |
Definition at line 134 of file regexp.hpp.
Enumerator | |
---|---|
eMatch_default | |
eMatch_not_begin | |
eMatch_not_end | |
eMatch_not_both |
Definition at line 141 of file regexp.hpp.
enum CRegexpUtil::ERange |
Range processing type.
Defines which part of the specified range should be processed.
Enumerator | |
---|---|
eInside | Process substrings inside range. |
eOutside | Process substrings outside range. |
Definition at line 447 of file regexp.hpp.
|
private |
The reason of stopping x_Compare(), if no error.
Enumerator | |
---|---|
eTemplateEOF | |
eStop |
Definition at line 296 of file regexp_template_tester.hpp.
|
private |
Processing source.
Enumerator | |
---|---|
eFile | source file/stream |
eTemplate | template |
Definition at line 290 of file regexp_template_tester.hpp.
|
inline |
Clear range for range-dependent functions.
Have the same effect as SetRange() without parameters.
Definition at line 626 of file regexp.hpp.
References CRegexpUtil::SetRange().
Compare file against template (file version).
file_path | Path to the checking file. |
template_path | Path to the corresponding template. |
Definition at line 159 of file regexp_template_tester.cpp.
References CRegexpTemplateTester::eFile, ERROR_FILE, ERROR_TEMPLATE, CRegexpTemplateTester::eStop, CRegexpTemplateTester::m_FileName, CRegexpTemplateTester::m_TemplateName, CRegexpTemplateTester::x_Compare(), CRegexpTemplateTester::x_GetLine(), and CRegexpTemplateTester::x_Reset().
void CRegexpTemplateTester::Compare | ( | istream & | file_stream, |
istream & | template_stream | ||
) |
Compare file against template (stream version).
file_stream | Input stream with checking data. |
template_stream | Input stream with corresponding template data. |
Definition at line 185 of file regexp_template_tester.cpp.
References CRegexpTemplateTester::eFile, ERROR_TEMPLATE, CRegexpTemplateTester::eStop, CRegexpTemplateTester::x_Compare(), CRegexpTemplateTester::x_GetLine(), and CRegexpTemplateTester::x_Reset().
Convert dates from an arbitrary format to corresponding ISO 8601.
value | String in some arbitrary date format. |
Definition at line 104 of file convert_dates_iso8601.cpp.
References extract_date_iso8601(), get_date_range_rule_collection(), get_date_rule_collection(), get_transform_for_ambiguous_date(), result, and rapidjson::value.
Convert dates from an arbitrary format to corresponding ISO 8601, with annotation.
value | String in some arbitrary data/time format. |
Definition at line 114 of file convert_dates_iso8601.cpp.
References extract_date_iso8601(), get_date_range_rule_collection(), get_date_rule_collection(), get_transform_for_ambiguous_date(), and rapidjson::value.
CRegexp::CRegexp | ( | CTempStringEx | pattern, |
TCompile | flags = fCompile_default |
||
) |
Constructor.
Set and compile the PCRE pattern specified by argument according to compile options. Also allocate memory for compiled PCRE.
pattern | Perl regular expression to compile. |
flags | Regular expression compilation flags. |
Definition at line 111 of file regexp.cpp.
References flags, and CRegexp::Set().
CRegexpTemplateTester::CRegexpTemplateTester | ( | TFlags | flags = 0 | ) |
Default constructor.
Definition at line 74 of file regexp_template_tester.cpp.
References CRegexpTemplateTester::x_Reset().
CRegexpUtil::CRegexpUtil | ( | CTempString | str = kEmptyStr | ) |
Constructor.
Set string for processing.
str | String to process. |
Definition at line 329 of file regexp.cpp.
References CRegexpUtil::Reset(), and str().
|
static |
Escape all regular expression meta characters in the string.
Definition at line 260 of file regexp.cpp.
References NPOS, out(), prev(), s_Special, and str().
Referenced by CFindASN1Dlg::OnReplaceButton().
|
inline |
Check existence of substring which match a specified pattern.
pattern | Perl regular expression to search. |
compile_flags | Regular expression compilation flags. |
match_flags | Flags to match. |
Definition at line 632 of file regexp.hpp.
References CRegexp::GetMatch(), CRegexpUtil::m_Content, CRegexp::NumFound(), and CRegexpUtil::x_Join().
|
inline |
Get matching pattern/subpattern from string.
pattern | Perl regular expression to search. |
compile_flags | Regular expression compilation flags. |
match_flags | Flags to match. |
pattern_idx | Index of pattern/subpattern to extract. Use pattern_idx = 0 for pattern, pattern_idx > 0 for sub patterns. |
Definition at line 646 of file regexp.hpp.
References CRegexp::GetMatch(), CRegexpUtil::m_Content, and CRegexpUtil::x_Join().
Referenced by CPsgPerfApplication::ProcessLine().
|
overridevirtual |
Get error code interpreted as text.
Reimplemented from CException.
Definition at line 548 of file regexp.cpp.
References CRegexpException::eBadFlags, CRegexpException::eCompile, CException::GetErrCode(), and CException::GetErrCodeString().
|
overridevirtual |
CRegexpTemplateTesterException –.
Reimplemented from CCoreException.
Definition at line 694 of file regexp_template_tester.cpp.
References CRegexpTemplateTesterException::eMismatchContent, CRegexpTemplateTesterException::eMismatchLength, CRegexpTemplateTesterException::eOpenFile, CRegexpTemplateTesterException::eOpErr, CRegexpTemplateTesterException::eOpTest, CRegexpTemplateTesterException::eOpUnknown, CRegexpTemplateTesterException::eVarErr, CRegexpTemplateTesterException::eVarNotFound, CCoreException::GetErrCode(), and CException::GetErrCodeString().
CTempString CRegexp::GetMatch | ( | CTempString | str, |
size_t | offset = 0 , |
||
size_t | idx = 0 , |
||
TMatch | flags = fMatch_default , |
||
bool | noreturn = false |
||
) |
Get matching pattern and subpatterns.
Return a string corresponding to the match to pattern or subpattern. Set noreturn to true when GetSub() or GetResults() will be used to retrieve pattern and subpatterns. Calling GetMatch() causes the entire search to be performed again. If you want to retrieve a different pattern/subpattern from an already performed search, it is more efficient to use GetSub() or GetResults(). If you need to get numeric offset of the found pattern or subpattern, that use GetResults() method. Doo not use functions like strstr(), or string's find() method and etc, because in general they give you wrong results. This is very dependent from used regular expression.
str | String to search. |
offset | Starting offset in str. |
idx | (Sub) match to return. Use idx = 0 for complete pattern. Use idx > 0 for subpatterns. |
flags | Flags to match. |
noreturn | Return empty string if noreturn is true. |
Definition at line 242 of file regexp.cpp.
References flags, CRegexp::GetSub(), offset, str(), and CRegexp::x_Match().
Referenced by BrBookURLToCCddBookRef(), BrFcgiBookTermToEutilsTerm(), CapitalizeAfterApostrophe(), CPepXML::ConvertScanID(), DoesPatternMatchHighlightedResidues(), CRegexpUtil::Exists(), CRegexpUtil::Extract(), extract_date_iso8601(), CFindPattern::Find(), FixAffiliationShortWordsInElement(), FixOrdinalNumbers(), NMItemData::GetResolveFuncForPubQual(), CSpectrumSet::LoadMultDTA(), PortalBookURLToCCddBookRef(), CRegexpUtil::Replace(), CRegexpUtil::ReplaceRange(), NSearchFeatPanel::SplitPosOrRange(), transform_range(), CMsvcConfigure::WriteBuildVer(), CConvertAuthorToConsortiumWhereConstraint::x_ApplyToCAuth(), COrfSearchJob::x_DoSearch(), CSequenceSearchJob::x_GetMatches(), and CFeatureSearchJob::x_Match().
|
inline |
Get result string.
Definition at line 597 of file regexp.hpp.
References CRegexpUtil::m_Content, CRegexpUtil::m_IsDivided, and CRegexpUtil::x_Join().
Referenced by CapitalizeSAfterNumber(), CPhyObjectLoader::Execute(), FindReplaceString_CountryFixes(), FixAbbreviationsInElement(), FixAffiliationShortWordsInElement(), CFixProductNames::FixCaps(), FixCountryCapitalization(), FixKnownAbbreviationsInElement(), FixShortWordsInElement(), FixupMouseStrain(), InsertMissingSpacesAfterCommas(), InsertMissingSpacesAfterNo(), CFindASN1Dlg::ReplaceValue(), CMacroFunction_EditStringQual::s_EditText(), s_RegexpReplace(), and CMacroFunction_FixSpelling::s_SpellingFixes().
|
inline |
Get location of pattern/subpattern for the last GetMatch().
idx | Index of pattern/subpattern to obtaining. Use idx = 0 for pattern, idx > 0 for sub patterns. |
Definition at line 584 of file regexp.hpp.
References CRegexp::m_NumFound, and CRegexp::m_Results.
Referenced by CapitalizeAfterApostrophe(), CFindPattern::Find(), FixAffiliationShortWordsInElement(), FixOrdinalNumbers(), CNcbiApplogApp::GetRawAppName(), CRegexpUtil::Replace(), CNcbiApplogApp::Run(), and CSequenceSearchJob::x_GetMatches().
void CRegexp::GetSub | ( | CTempString | str, |
size_t | idx, | ||
string & | dst | ||
) | const |
Get pattern/subpattern from previous GetMatch().
Definition at line 189 of file regexp.cpp.
References CRegexp::GetSub(), and str().
CTempString CRegexp::GetSub | ( | CTempString | str, |
size_t | idx = 0 |
||
) | const |
Get pattern/subpattern from previous GetMatch().
Should only be called after GetMatch() has been called with the same string. GetMatch() internally stores locations on string where pattern and subpatterns were found.
str | String to search. |
idx | (Sub) match to return. |
Definition at line 200 of file regexp.cpp.
References CRegexp::m_NumFound, CRegexp::m_Results, PCRE2_SIZE, PCRE2_UNSET, and str().
Referenced by BrBookURLToCCddBookRef(), BrFcgiBookTermToEutilsTerm(), extract_date_iso8601(), CRegexp::GetMatch(), NMItemData::GetResolveFuncForPubQual(), CRegexp::GetSub(), PortalBookURLToCCddBookRef(), CReadBlastApp::ReadBlast(), s_ChrName(), CTabularFormatter::SetFormat(), sParseVersion(), NSearchFeatPanel::SplitPosOrRange(), transform_ambiguous_date(), transform_range(), CRegexpTemplateTester::x_CompareLines(), and CSeq_id_Resolver__LRG::x_Create().
Definition at line 128 of file regexp_template_tester.cpp.
References map_checker< Container >::end(), ERROR_TEMPLATE, map_checker< Container >::find(), and CRegexpTemplateTester::m_Vars.
Referenced by CRegexpTemplateTester::PrintVar(), and CRegexpTemplateTester::x_SubstituteVars().
const CRegexpTemplateTester::TVarMap & CRegexpTemplateTester::GetVars | ( | void | ) | const |
Definition at line 138 of file regexp_template_tester.cpp.
References CRegexpTemplateTester::m_Vars.
bool CRegexp::IsMatch | ( | CTempString | str, |
TMatch | flags = fMatch_default |
||
) |
Check existence substring which match a specified pattern.
Using IsMatch() reset all results from previous GetMatch() call. The subsequent NumFound() always returns 1 for successful IsMatch().
str | String to search. |
flags | Flags to match. |
Definition at line 253 of file regexp.cpp.
References flags, CRegexp::m_NumFound, str(), and CRegexp::x_Match().
Referenced by CSeq_id_Resolver::CanCreate(), CProjectsLstFileFilter::CheckProject(), CPepXML::ConvertScanID(), extract_date_iso8601(), NSearchFeatPanel::GatherFeatures(), CDiscrepancyContext::IsBadLocusTagFormat(), CAssemblyInfo::IsSameAssembly(), CMaskRegexp::Match(), CFilterColumnsDlg::OnRangeTextctrlTextUpdated(), CReadBlastApp::ReadBlast(), CNcbiApplogApp::Redirect(), CNcbiApplogApp::Run(), s_ChrName(), s_IsAllDigits(), CTabularFormatter::SetFormat(), sParseVersion(), NSearchFeatPanel::SplitPosOrRange(), SuspiciousId(), CRegexpTemplateFilter::TestAttribute(), transform_ambiguous_date(), transform_range(), CRegexpValidator::Validate(), CRemoveDescDlg::x_ApplyToSeq_entry(), CRegexpTemplateTester::x_CompareLines(), CFeatureCheckPanel::x_InitTree(), CPSGS_AnnotProcessor::x_IsNameValid(), CFeatureSearchJob::x_IsSNP(), CRegexpTemplateTester::x_Op_Test(), and CGenBankLoadOptionPanel::x_ProccessText().
CRegexpException::NCBI_EXCEPTION_DEFAULT | ( | CRegexpException | , |
CException | |||
) |
CRegexpTemplateTesterException::NCBI_EXCEPTION_DEFAULT | ( | CRegexpTemplateTesterException | , |
CCoreException | |||
) |
|
inline |
Get number of patterns + subpatterns.
Definition at line 577 of file regexp.hpp.
References CRegexp::m_NumFound.
Referenced by BrBookURLToCCddBookRef(), CapitalizeAfterApostrophe(), DoesPatternMatchHighlightedResidues(), CRegexpUtil::Exists(), FixAffiliationShortWordsInElement(), FixOrdinalNumbers(), PortalBookURLToCCddBookRef(), CRegexpUtil::Replace(), CRegexpUtil::ReplaceRange(), NSearchFeatPanel::SplitPosOrRange(), CConvertAuthorToConsortiumWhereConstraint::x_ApplyToCAuth(), CRegexpTemplateTester::x_CompareLines(), and CSequenceSearchJob::x_GetMatches().
|
inline |
Get result string.
The same as GetResult().
Definition at line 614 of file regexp.hpp.
|
inline |
Reset the content of the string to process.
The same as Reset().
str | String to process. |
Definition at line 620 of file regexp.hpp.
References CRegexpUtil::Reset(), and str().
Definition at line 144 of file regexp_template_tester.cpp.
References CRegexpTemplateTester::GetVar(), NStr::PrintableString(), and rapidjson::value.
void CRegexpTemplateTester::PrintVars | ( | void | ) | const |
Definition at line 151 of file regexp_template_tester.cpp.
References ITERATE, CRegexpTemplateTester::m_Vars, and NStr::PrintableString().
size_t CRegexpUtil::Replace | ( | CTempStringEx | search, |
CTempString | replace, | ||
CRegexp::TCompile | compile_flags = CRegexp::fCompile_default , |
||
CRegexp::TMatch | match_flags = CRegexp::fMatch_default , |
||
size_t | max_replace = 0 |
||
) |
Replace occurrences of a substring within a string by pattern.
search | Regular expression to match a substring value that is replaced. |
replace | Replace "search" substring with this value. The matched subpatterns (if any) can be found and inserted into replace string using variables $1, $2, $3, and so forth. The variable can be enclosed in the curly brackets {}, that will be deleted on substitution. |
compile_flags | Regular expression compilation flags. |
match_flags | Flags to match. |
max_replace | Replace no more than "max_replace" occurrences of substring "search". If "max_replace" is zero (default), then replace all occurrences with "replace". |
Definition at line 349 of file regexp.cpp.
References CTempString::assign(), count, CTempString::data(), CTempString::empty(), CRegexp::GetMatch(), CRegexp::GetResults(), int, kMax_Int, CTempString::length(), CRegexpUtil::m_Content, n, NPOS, CRegexp::NumFound(), result, rapidjson::value, and CRegexpUtil::x_Join().
Referenced by CapitalizeSAfterNumber(), CPhyObjectLoader::Execute(), FindReplaceString_CountryFixes(), FixAbbreviationsInElement(), FixAffiliationShortWordsInElement(), CFixProductNames::FixCaps(), FixCountryCapitalization(), FixKnownAbbreviationsInElement(), FixShortWordsInElement(), FixupMouseStrain(), InsertMissingSpacesAfterCommas(), InsertMissingSpacesAfterNo(), CRegexpUtil::ReplaceRange(), CFindASN1Dlg::ReplaceValue(), CMacroFunction_EditStringQual::s_EditText(), s_RegexpReplace(), and CMacroFunction_FixSpelling::s_SpellingFixes().
size_t CRegexpUtil::ReplaceRange | ( | CTempStringEx | search, |
CTempString | replace, | ||
CRegexp::TCompile | compile_flags = CRegexp::fCompile_default , |
||
CRegexp::TMatch | match_flags = CRegexp::fMatch_default , |
||
CRegexpUtil::ERange | process_within = eInside , |
||
size_t | max_replace = 0 |
||
) |
Replace all occurrences of a substring within a string by pattern.
Use range specified by SetRange() method. Work like SED command s/.
search | Regular expression to match a substring value that is replaced. |
replace | Replace "search" substring with this value. The matched subpatterns (if any) can be found and inserted into replace string using variables $1, $2, $3, and so forth. The variable can be enclosed in the curly brackets {}, that will be deleted on substitution. |
compile_flags | Regular expression compilation flags. |
match_flags | Flags to match. |
process_within | Define which part of the range should be processed. |
max_replace | Replace no more than "max_replace" occurrences of substring "search" in the every substring. If "max_replace" is zero (default), then replace all occurrences with "replace". |
Definition at line 444 of file regexp.cpp.
References CRegexpUtil::eInside, CTempString::empty(), CRegexpUtil::eOutside, CRegexp::fMatch_default, CRegexp::GetMatch(), i, CRegexpUtil::m_ContentList, CRegexpUtil::m_RangeEnd, CRegexpUtil::m_RangeStart, NON_CONST_ITERATE, CRegexp::NumFound(), CRegexpUtil::Replace(), and CRegexpUtil::x_Divide().
|
inline |
Reset the content of the string to process.
str | String to process. |
Definition at line 606 of file regexp.hpp.
References CRegexpUtil::m_Content, CRegexpUtil::m_ContentList, CRegexpUtil::m_IsDivided, and str().
Referenced by CRegexpUtil::CRegexpUtil(), CRegexpUtil::operator=(), and CPsgPerfApplication::ProcessLine().
void CRegexp::Set | ( | CTempStringEx | pattern, |
TCompile | flags = fCompile_default |
||
) |
Set and compile PCRE.
Set and compile the PCRE pattern specified by argument according to compile options. Also deallocate/allocate memory for compiled PCRE.
pattern | Perl regular expression to compile. |
flags | Regular expression compilation flags. |
Definition at line 138 of file regexp.cpp.
References ArraySize(), CTempString::data(), flags, CTempStringEx::HasZeroAtEnd(), CRegexp::m_MatchData, CRegexp::m_PReg, NCBI_THROW, NULL, pcre2_code, pcre2_code_free(), pcre2_compile(), pcre2_get_error_message(), pcre2_match_data, pcre2_match_data_create_from_pattern(), pcre2_match_data_free(), PCRE2_SPTR, PCRE2_UCHAR, s_GetRealCompileFlags(), and CTempString::size().
Referenced by CRegexp::CRegexp(), and CRemoveDescDlg::x_ApplyToSeq_entry().
void CRegexpTemplateTester::SetCommandStart | ( | string & | str | ) |
Change string defining start of template commands and operations.
Default value: "#"
Definition at line 116 of file regexp_template_tester.cpp.
References CRegexpTemplateTester::m_OpStart, and str().
void CRegexpTemplateTester::SetCommentStart | ( | string & | str | ) |
Change string defining start of comments line in templates.
Default value: "//"
Definition at line 110 of file regexp_template_tester.cpp.
References CRegexpTemplateTester::m_CommentStart, and str().
void CRegexpTemplateTester::SetDelimiters | ( | string & | str | ) |
Change delimiters string, used for comparing data and templates.
Default value: "\r\n"
Definition at line 122 of file regexp_template_tester.cpp.
References CRegexpTemplateTester::m_EOLs, and str().
void CRegexpUtil::SetRange | ( | CTempStringEx | addr_start = kEmptyStr , |
CTempStringEx | addr_end = kEmptyStr , |
||
CTempString | delimiter = "\n" |
||
) |
Set new range for range-dependent functions.
The matched string will be split up by "delimiter". And then in range-dependent functions every part (substring) is checked to fall into the range, specified by start and end addresses.
The addresses works similar to the Unix utility SED, except that regular expressions is Perl-compatible:
Specified range have effect only for range-dependent functions. Otherwise range is ignored.
addr_start | Regular expression which assign a starting address of range. |
addr_end | Regular expression which assign an ending address of range. Should be empty if the start address is empty. |
delimiter | Split a source string by "delimiter. |
Definition at line 337 of file regexp.cpp.
References delimiter, CRegexpUtil::m_Delimiter, CRegexpUtil::m_RangeEnd, CRegexpUtil::m_RangeStart, and CRegexpUtil::x_Divide().
Referenced by CRegexpUtil::ClearRange().
Change strings defining start/end of variables.
By default use next syntax: ${var}
Definition at line 103 of file regexp_template_tester.cpp.
References CRegexpTemplateTester::m_VarEnd, and CRegexpTemplateTester::m_VarStart.
|
static |
Convert wildcard mask to regular expression.
Escapes all regular expression meta characters in the string, except '*' and '?'. They will be replaced with '.*' and '.' accordingly.
mask | Wildcard mask. |
Definition at line 288 of file regexp.cpp.
References mask, NPOS, out(), prev(), and s_Special.
Referenced by CSequenceSearchJob::x_DoSearch(), and CFeatureCheckPanel::x_InitTree().
|
private |
Main compare method, compare streams.
Can be used recursively to process includes. Return TRUE if 'stop' command found.
Definition at line 199 of file regexp_template_tester.cpp.
References CRegexpTemplateTester::eFile, ERROR_TEMPLATE, CRegexpTemplateTester::eStop, CRegexpTemplateTester::eTemplate, CRegexpTemplateTester::eTemplateEOF, len, CRegexpTemplateTester::m_CommentStart, CRegexpTemplateTester::m_FileLine, CRegexpTemplateTester::m_FileLineNum, CRegexpTemplateTester::m_OpStart, CRegexpTemplateTester::m_ReprocessFileLine, CRegexpTemplateTester::m_TemplateLine, NStr::StartsWith(), str(), NStr::TruncateSpaces_Unsafe(), CRegexpTemplateTester::x_CompareLines(), CRegexpTemplateTester::x_GetLine(), CRegexpTemplateTester::x_Op_Echo(), CRegexpTemplateTester::x_Op_Include(), CRegexpTemplateTester::x_Op_Set(), CRegexpTemplateTester::x_Op_Skip(), and CRegexpTemplateTester::x_Op_Test().
Referenced by CRegexpTemplateTester::Compare(), and CRegexpTemplateTester::x_Op_Include().
|
private |
Process/compare lines.
Definition at line 294 of file regexp_template_tester.cpp.
References ERROR_TEMPLATE, CRegexp::GetSub(), i, CRegexp::IsMatch(), ITERATE, CRegexpTemplateTester::m_Vars, NULL, CRegexp::NumFound(), and CRegexpTemplateTester::x_SubstituteVars().
Referenced by CRegexpTemplateTester::x_Compare().
|
private |
Divide source string to substrings by delimiter for separate processing.
Definition at line 510 of file regexp.cpp.
References delimiter, CRegexpUtil::m_Content, CRegexpUtil::m_ContentList, CRegexpUtil::m_Delimiter, CRegexpUtil::m_IsDivided, NPOS, and CRegexpUtil::x_Join().
|
inlineprivate |
Definition at line 528 of file regexp.hpp.
References CRegexpUtil::m_Delimiter, and CRegexpUtil::x_Divide().
Referenced by CRegexpUtil::ReplaceRange(), CRegexpUtil::SetRange(), and CRegexpUtil::x_Divide().
|
private |
Get line from the stream 'is'.
Definition at line 263 of file regexp_template_tester.cpp.
References _TROUBLE, CRegexpTemplateTester::eFile, CRegexpTemplateTester::eTemplate, CRegexpTemplateTester::fSkipEmptySourceLines, CRegexpTemplateTester::fSkipEmptyTemplateLines, CRegexpTemplateTester::m_EOLs, CRegexpTemplateTester::m_FileLine, CRegexpTemplateTester::m_FileLineNum, CRegexpTemplateTester::m_Flags, CRegexpTemplateTester::m_TemplateLine, CRegexpTemplateTester::m_TemplateLineNum, NcbiGetline(), NULL, and str().
Referenced by CRegexpTemplateTester::Compare(), CRegexpTemplateTester::x_Compare(), and CRegexpTemplateTester::x_Op_Skip().
|
private |
Join substrings back to entire string.
Definition at line 540 of file regexp.cpp.
References NStr::Join(), CRegexpUtil::m_Content, CRegexpUtil::m_ContentList, CRegexpUtil::m_Delimiter, and CRegexpUtil::m_IsDivided.
Referenced by CRegexpUtil::Exists(), CRegexpUtil::Extract(), CRegexpUtil::GetResult(), CRegexpUtil::Replace(), and CRegexpUtil::x_Divide().
|
private |
Definition at line 219 of file regexp.cpp.
References f, flags, kRegexpMaxSubPatterns, CRegexp::m_JITStatus, CRegexp::m_MatchData, CRegexp::m_NumFound, CRegexp::m_PReg, CRegexp::m_Results, match_data, NULL, offset, pcre2_code, pcre2_get_ovector_count(), pcre2_get_ovector_pointer(), pcre2_jit_match(), pcre2_match(), pcre2_match_data, PCRE2_UCHAR, s_GetRealMatchFlags(), and str().
Referenced by CRegexp::GetMatch(), and CRegexp::IsMatch().
|
private |
Definition at line 467 of file regexp_template_tester.cpp.
References i, len, NULL, SKIP_SPACES, str(), and CRegexpTemplateTester::x_SubstituteVars().
Referenced by CRegexpTemplateTester::x_Compare().
|
private |
Definition at line 541 of file regexp_template_tester.cpp.
References _ASSERT, CDirEntry::ConcatPath(), ERROR_TEMPLATE, i, len, CRegexpTemplateTester::m_TemplateLineNum, CRegexpTemplateTester::m_TemplateName, SKIP_SPACES, CDirEntry::SplitPath(), str(), and CRegexpTemplateTester::x_Compare().
Referenced by CRegexpTemplateTester::x_Compare().
|
private |
Definition at line 443 of file regexp_template_tester.cpp.
References _ASSERT, ERROR_TEMPLATE, i, len, CRegexpTemplateTester::m_Vars, n, NULL, SKIP_SPACES, str(), CRegexpTemplateTester::x_ParseVarName(), and CRegexpTemplateTester::x_SubstituteVars().
Referenced by CRegexpTemplateTester::x_Compare().
|
private |
Definition at line 577 of file regexp_template_tester.cpp.
References _ASSERT, CRegexpTemplateTester::eFile, CTempString::empty(), eNumber, ERROR_TEMPLATE, i, len, CRegexpTemplateTester::m_FileLine, CRegexpTemplateTester::m_ReprocessFileLine, NULL, NStr::NumericToString(), NStr::PrintableString(), AutoPtr< X, Del >::reset(), SKIP_SPACES, NStr::StartsWith(), str(), CTempString::substr(), CRegexpTemplateTester::x_GetLine(), and CRegexpTemplateTester::x_SubstituteVars().
Referenced by CRegexpTemplateTester::x_Compare().
|
private |
Definition at line 477 of file regexp_template_tester.cpp.
References _ASSERT, ncbi::grid::netcache::search::eEqual, eMatch, ERROR_TEMPLATE, NStr::Find(), i, CRegexp::IsMatch(), len, NPOS, NULL, NStr::PrintableString(), SKIP_SPACES, str(), and CRegexpTemplateTester::x_SubstituteVars().
Referenced by CRegexpTemplateTester::x_Compare().
|
private |
Parse variable from string, return its length.
Can process nested variables.
Definition at line 322 of file regexp_template_tester.cpp.
References NStr::CompareCase(), len, CRegexpTemplateTester::m_VarEnd, CRegexpTemplateTester::m_VarStart, NPOS, and str().
Referenced by CRegexpTemplateTester::x_SubstituteVars().
|
private |
Parse/check variable name from string, return its length.
Definition at line 347 of file regexp_template_tester.cpp.
References _ASSERT, ERROR_TEMPLATE, isalnum(), isalpha(), isspace(), len, NPOS, and str().
Referenced by CRegexpTemplateTester::x_Op_Set(), and CRegexpTemplateTester::x_SubstituteVars().
|
private |
Reset object state.
Definition at line 86 of file regexp_template_tester.cpp.
References map_checker< Container >::clear(), CRegexpTemplateTester::m_FileLine, CRegexpTemplateTester::m_FileLineNum, CRegexpTemplateTester::m_FileName, CRegexpTemplateTester::m_ReprocessFileLine, CRegexpTemplateTester::m_TemplateLineNum, CRegexpTemplateTester::m_TemplateName, and CRegexpTemplateTester::m_Vars.
Referenced by CRegexpTemplateTester::Compare(), and CRegexpTemplateTester::CRegexpTemplateTester().
|
private |
Replace all variables in the string with corresponding values.
Also used for preparing inline variables for consecutive regexp matching.
Definition at line 365 of file regexp_template_tester.cpp.
References CTempString::empty(), ERROR_TEMPLATE, CTempString::find(), NStr::Find(), CRegexpTemplateTester::GetVar(), last(), CTempString::length(), CRegexpTemplateTester::m_VarEnd, CRegexpTemplateTester::m_VarStart, n, NPOS, NULL, out(), str(), CTempString::substr(), CRegexpTemplateTester::x_ParseVar(), and CRegexpTemplateTester::x_ParseVarName().
Referenced by CRegexpTemplateTester::x_CompareLines(), CRegexpTemplateTester::x_Op_Echo(), CRegexpTemplateTester::x_Op_Set(), CRegexpTemplateTester::x_Op_Skip(), and CRegexpTemplateTester::x_Op_Test().
|
virtual |
Destructor.
Deallocate compiled Perl-compatible regular expression.
Definition at line 126 of file regexp.cpp.
References CRegexp::m_MatchData, CRegexp::m_PReg, pcre2_code, pcre2_code_free(), pcre2_match_data, and pcre2_match_data_free().
const size_t kRegexpMaxSubPatterns = 100 |
Specifies the maximum number of subpatterns that can be found.
Definition at line 56 of file regexp.hpp.
Referenced by CRegexp::x_Match().
|
private |
Start of the comment line.
Definition at line 329 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::SetCommentStart(), and CRegexpTemplateTester::x_Compare().
|
private |
Content string.
Definition at line 534 of file regexp.hpp.
Referenced by CRegexpUtil::Exists(), CRegexpUtil::Extract(), CRegexpUtil::GetResult(), CRegexpUtil::Replace(), CRegexpUtil::Reset(), CRegexpUtil::x_Divide(), and CRegexpUtil::x_Join().
|
private |
Content list.
Definition at line 537 of file regexp.hpp.
Referenced by CRegexpUtil::ReplaceRange(), CRegexpUtil::Reset(), CRegexpUtil::x_Divide(), and CRegexpUtil::x_Join().
|
private |
Delimiter used to split m_Content.
Definition at line 542 of file regexp.hpp.
Referenced by CRegexpUtil::SetRange(), CRegexpUtil::x_Divide(), and CRegexpUtil::x_Join().
|
private |
Lines delimiters.
Definition at line 330 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::SetDelimiters(), and CRegexpTemplateTester::x_GetLine().
|
private |
Currently processing file line.
Definition at line 335 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::x_Compare(), CRegexpTemplateTester::x_GetLine(), CRegexpTemplateTester::x_Op_Skip(), and CRegexpTemplateTester::x_Reset().
|
private |
Current file/stream line number.
Definition at line 336 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::x_Compare(), CRegexpTemplateTester::x_GetLine(), and CRegexpTemplateTester::x_Reset().
|
private |
Current file name (if any)
Definition at line 334 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::Compare(), and CRegexpTemplateTester::x_Reset().
|
private |
Processing flags.
Definition at line 325 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::x_GetLine().
|
private |
TRUE if m_ContentList is newer than m_Content, and FALSE otherwise.
Definition at line 538 of file regexp.hpp.
Referenced by CRegexpUtil::GetResult(), CRegexpUtil::Reset(), CRegexpUtil::x_Divide(), and CRegexpUtil::x_Join().
|
private |
Definition at line 302 of file regexp.hpp.
Referenced by CRegexp::x_Match().
|
private |
Pointer to compiled PCRE pattern.
Definition at line 300 of file regexp.hpp.
Referenced by CRegexp::Set(), CRegexp::x_Match(), and CRegexp::~CRegexp().
|
private |
The total number of pattern + subpatterns resulting from the last call to GetMatch.
Definition at line 315 of file regexp.hpp.
Referenced by CRegexp::GetResults(), CRegexp::GetSub(), CRegexp::IsMatch(), CRegexp::NumFound(), and CRegexp::x_Match().
|
private |
Start of the template command line.
Definition at line 328 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::SetCommandStart(), and CRegexpTemplateTester::x_Compare().
|
private |
Definition at line 297 of file regexp.hpp.
Referenced by CRegexp::Set(), CRegexp::x_Match(), and CRegexp::~CRegexp().
|
private |
Regexp to determine end of range.
Definition at line 541 of file regexp.hpp.
Referenced by CRegexpUtil::ReplaceRange(), and CRegexpUtil::SetRange().
|
private |
Regexp to determine start of range.
Definition at line 540 of file regexp.hpp.
Referenced by CRegexpUtil::ReplaceRange(), and CRegexpUtil::SetRange().
|
private |
TRUE if m_FileLine should be reprocessed with next template data line.
Definition at line 341 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::x_Compare(), CRegexpTemplateTester::x_Op_Skip(), and CRegexpTemplateTester::x_Reset().
|
private |
Definition at line 301 of file regexp.hpp.
Referenced by CRegexp::GetResults(), CRegexp::GetSub(), and CRegexp::x_Match().
|
private |
Currently processing template line.
Definition at line 338 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::x_Compare(), and CRegexpTemplateTester::x_GetLine().
|
private |
Current template line number.
Definition at line 339 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::x_GetLine(), CRegexpTemplateTester::x_Op_Include(), and CRegexpTemplateTester::x_Reset().
|
private |
Current template name.
Definition at line 337 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::Compare(), CRegexpTemplateTester::x_Op_Include(), and CRegexpTemplateTester::x_Reset().
|
private |
Variable definition end.
Definition at line 327 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::SetVarScope(), CRegexpTemplateTester::x_ParseVar(), and CRegexpTemplateTester::x_SubstituteVars().
|
private |
Map of variables/values.
Definition at line 331 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::GetVar(), CRegexpTemplateTester::GetVars(), CRegexpTemplateTester::PrintVars(), CRegexpTemplateTester::x_CompareLines(), CRegexpTemplateTester::x_Op_Set(), and CRegexpTemplateTester::x_Reset().
|
private |
Variable definition start.
Definition at line 326 of file regexp_template_tester.hpp.
Referenced by CRegexpTemplateTester::SetVarScope(), CRegexpTemplateTester::x_ParseVar(), and CRegexpTemplateTester::x_SubstituteVars().