38 static inline int findParameterAlternative
45 while (pos != std::string::npos)
47 pos = s.find(
':', pos);
48 if (pos != std::string::npos)
53 const int altType = s[pos+1];
54 if (altType ==
'+' || altType ==
'-')
64 pos = std::string::npos;
76 const string& original,
99 (begVar = s.find(sigil, begVar)) != string::npos
100 && begVar < s.size()-1
103 if (begVar == 0 || s[begVar-1] !=
'\\')
113 if (s[begVar+1] ==
'{')
115 endVar = s.find(
'}', begVar);
119 if (endVar != string::npos)
122 altType = findParameterAlternative(s, altPos, endVar);
127 string::iterator iter = s.begin() + begVar + 1;
147 if (endVar == string::npos)
152 else if (endVar == begVar)
165 (altPos == string::npos ? endVar : altPos)
172 std::string altValue;
173 if (altPos != string::npos)
179 endVar - altPos - 2*delim
185 mapping.
find(varName);
189 if (altPos != string::npos && altType ==
'+')
192 s.std::string::replace
198 begVar += altValue.size();
203 s.std::string::replace
209 begVar += (*fnd).size();
212 else if (altPos != string::npos && altType ==
'-')
215 s.std::string::replace
221 begVar += altValue.size();
226 s.std::string::erase(begVar, endVar - begVar + 1);
242 const string& original,
256 const bool allowEnvVars,
257 const bool allowEmpty
274 buf.
precision(IOstream::defaultPrecision());
277 dynamicCast<const primitiveEntry>
284 else if (allowEnvVars)
288 if (!allowEmpty && value.empty())
293 ) <<
"Cannot find dictionary or environment variable " 302 ) <<
"Cannot find dictionary variable " 315 const bool allowEnvVars,
316 const bool allowEmpty
321 while (index < s.size())
323 if (s[index] ==
'$' && s[index+1] ==
'{')
327 string val =
expand(s, index, dict, allowEnvVars, allowEmpty);
328 newString.append(val);
330 else if (s[index] ==
'}')
332 return getVariable(newString, dict, allowEnvVars, allowEmpty);
336 newString.append(
string(s[index]));
348 const bool allowEnvVars,
349 const bool allowEmpty,
359 (begVar = s.find(sigil, begVar)) != string::npos
360 && begVar < s.size()-1
363 if (begVar == 0 || s[begVar-1] !=
'\\')
365 if (s[begVar+1] ==
'{')
368 label stringStart = begVar;
382 s.std::string::replace
385 begVar - stringStart + 1,
389 begVar = stringStart+varValue.size();
393 string::iterator iter = s.begin() + begVar + 1;
434 s.std::string::replace
440 begVar += varValue.size();
461 if ((begVar = s.find(
'/')) != string::npos)
463 user = s.substr(1, begVar - 1);
464 file = s.substr(begVar + 1);
474 if (user ==
"OpenFOAM")
483 else if (s[0] ==
'.')
490 else if (s[1] ==
'/')
492 s.std::string::replace(0, 1,
cwd());
514 (begVar = s.find(sigil, begVar)) != string::npos
515 && begVar < s.size()-1
518 if (begVar == 0 || s[begVar-1] !=
'\\')
524 if (s[begVar+1] ==
'{')
526 endVar = s.find(
'}', begVar);
531 string::iterator iter = s.begin() + begVar + 1;
551 if (endVar == string::npos)
556 else if (endVar == begVar)
568 endVar - begVar - 2*delim
589 buf.
precision(IOstream::defaultPrecision());
592 ePtr->dict().write(buf,
false);
597 dynamicCast<const primitiveEntry>
603 s.std::string::replace
609 begVar += buf.
str().size();
630 const string& original,
631 const bool allowEmpty
642 const bool allowEmpty
651 (begVar = s.find(
'$', begVar)) != string::npos
652 && begVar < s.size()-1
655 if (begVar == 0 || s[begVar-1] !=
'\\')
665 if (s[begVar+1] ==
'{')
667 endVar = s.find(
'}', begVar);
671 if (endVar != string::npos)
674 altType = findParameterAlternative(s, altPos, endVar);
679 string::iterator iter = s.begin() + begVar + 1;
684 && (isalnum(*iter) || *iter ==
'_')
693 if (endVar == string::npos)
698 else if (endVar == begVar)
711 (altPos == string::npos ? endVar : altPos)
718 std::string altValue;
719 if (altPos != string::npos)
725 endVar - altPos - 2*delim
729 const string varValue =
getEnv(varName);
732 if (altPos != string::npos && altType ==
'+')
735 s.std::string::replace
741 begVar += altValue.size();
746 s.std::string::replace
752 begVar += varValue.size();
755 else if (altPos != string::npos)
761 s.std::string::replace
767 begVar += altValue.size();
773 s.std::string::erase(begVar, endVar - begVar + 1);
778 s.std::string::erase(begVar, endVar - begVar + 1);
783 <<
"Unknown variable name '" << varName <<
"'" 806 if ((begVar = s.find(
'/')) != string::npos)
808 user = s.substr(1, begVar - 1);
809 file = s.substr(begVar + 1);
819 if (user ==
"OpenFOAM")
828 else if (s[0] ==
'.')
835 else if (s[1] ==
'/')
837 s.std::string::replace(0, 1,
cwd());
851 while (beg < s.size() &&
isspace(s[beg]))
858 return s.substr(beg);
871 while (beg < s.size() &&
isspace(s[beg]))
898 return s.substr(0, sz);
string getEnv(const word &)
Return environment variable of given name.
string & inplaceTrim(string &)
Trim leading and trailing whitespace inplace.
string expand(const string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Expand occurrences of variables according to the mapping.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
string getVariable(const word &name, const dictionary &dict, const bool allowEnvVars, const bool allowEmpty)
Get dictionary or (optionally) environment variable.
A class for handling file names.
An STL-conforming const_iterator.
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual int precision() const
Get precision of output field.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
fileName home()
Return home directory path name for the current user.
const entry * lookupScopedEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
string trim(const string &)
Return string trimmed of leading and trailing whitespace.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
dimensionedScalar pos(const dimensionedScalar &ds)
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A class for handling words, derived from string.
Functions to search 'etc' directories for configuration files etc.
An STL-conforming hash table.
graph_traits< Graph >::vertices_size_type size_type
fileName findEtcFile(const fileName &, bool mandatory=false)
Search for a file using findEtcFiles.
string & inplaceTrimRight(string &)
Trim trailing whitespace inplace.
string trimRight(const string &)
Return string trimmed of trailing whitespace.
string & inplaceExpand(string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Inplace expand occurrences of variables according to the mapping.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
string str() const
Return the string.
fileName cwd()
Return current working directory path name.
string & inplaceTrimLeft(string &)
Trim leading whitespace inplace.
A class for handling character strings derived from std::string.
string trimLeft(const string &)
Return string trimmed of leading whitespace.
Output to memory buffer stream.
IOstream & scientific(IOstream &io)
A keyword and a list of tokens is an 'entry'.