45Foam::substitutionModels::fileRegEx::fileRegEx
62 matchSeparator_(
dict.getOrDefault<
string>(
"matchSeparator",
" ")),
63 lastMatch_(
dict.getOrDefault<bool>(
"lastMatch", true))
67 for (
const auto&
e : entriesDict)
69 entries_.insert(
cleanKey(
e.keyword()),
string(
e.stream()));
78 return entries_.found(keyName);
88 if (!valid(key))
return false;
97 <<
"Unable to find file at " << path_
98 <<
". Deactivating." <<
endl;
103 Info<<
"Scanning for sections beginning with "
104 << sectionSeparator_ <<
endl;
110 bool started = sectionSeparator_.empty() ? true :
false;
114 if (
line.starts_with(sectionSeparator_))
125 Info<<
"Cached " << lines.size() <<
" lines" <<
endl;
128 const regExp re(entries_[key].c_str());
130 for (
const string& data : lines)
133 if (
re.match(data, match))
137 for (
size_t i = 1; i <
match.size(); ++i)
139 if (i > 1) oss << matchSeparator_;
140 oss <<
match[i].str().c_str();
143 if (!lastMatch_)
break;
159 return entries_.sortedToc();
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
Input from file stream as an ISstream, normally using std::ifstream for the actual input.
bool good() const noexcept
True if next operation might succeed.
ISstream & getLine(std::string &str, char delim='\n')
Raw, low-level getline (until delimiter) into a string.
An OSstream with internal List storage.
auto str() const
For OStringStream compatibility, return the buffer as string copy.
std::streamsize count() const
The number of bytes outputted.
virtual void rewind()
Rewind the stream, clearing any old errors.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
void size(const label n)
Older name for setAddressableSize.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A class for handling file names.
std::smatch results_type
Type for matches.
A class for handling character strings derived from std::string.
string & replaceAll(const std::string &s1, const std::string &s2, size_type pos=0)
Replace all occurrences of sub-string s1 with s2, beginning at pos in the string.
Base class for substitution models.
static word cleanKey(const string &str)
Clean the key text.
static string keyify(const word &w)
Return a key representation from a word.
static bool replaceBuiltin(const word &key, string &str)
Replace key in string.
The fileRegEx substitution model.
virtual bool apply(const word &key, string &buffer) const
Apply substitutions to this string buffer.
virtual bool valid(const word &keyName) const
Return true of model applies to this keyName.
virtual wordList keys() const
Return a word list of the keys.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
fileName path(UMean.rootPath()/UMean.caseName()/"graphs"/UMean.instance())
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionedScalar re
Classical electron radius: default SI units: [m].
bool match(const UList< wordRe > &selectors, const std::string &text)
True if text matches one of the selector expressions.
List< word > wordList
List of word.
messageStream Info
Information stream (stdout output on master, null elsewhere).
regExpCxx regExp
Selection of preferred regular expression implementation.
Ostream & endl(Ostream &os)
Add newline and flush stream.