ENH: disentangle testing and quoting of regex characters

- originally had tests for regex meta characters strewn across
  regExp classes as well as wordRe, keyType, string.
  And had special-purpose quotemeta static function within string
  that relied on special naming convention for testing the meta
  characters.

  The regex meta character testing/handling now relegated entirely
  to the regExp class(es).
  Relocate quotemeta to stringOps, with a predicate.

- avoid code duplication. Reuse some regExpCxx methods in regExpPosix
This commit is contained in:
Mark Olesen
2021-04-09 10:49:13 +02:00
committed by Andrew Heather
parent cdbc3e2de6
commit 57c1fceabf
14 changed files with 273 additions and 254 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2012 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -77,6 +77,15 @@ namespace stringOps
return wordRes::matcher(patterns)(text);
}
//- Quote any meta-characters in given string
template<class StringType, class UnaryPredicate>
StringType quotemeta
(
const StringType& str,
const UnaryPredicate& meta,
const char quote = '\\'
);
//- Expand occurrences of variables according to the mapping
//- and return the expanded string.
//