40 while (pos != std::string::npos)
42 pos = s.find(
':', pos);
43 if (pos != std::string::npos)
48 const int altType = s[pos+1];
49 if (altType ==
'+' || altType ==
'-')
59 pos = std::string::npos;
70 const string& original,
93 (begVar = s.find(sigil, begVar)) != string::npos
94 && begVar < s.size()-1
97 if (begVar == 0 || s[begVar-1] !=
'\\')
107 if (s[begVar+1] ==
'{')
109 endVar = s.find(
'}', begVar);
113 if (endVar != string::npos)
121 string::iterator iter = s.begin() + begVar + 1;
143 if (endVar == string::npos)
148 else if (endVar == begVar)
161 (altPos == string::npos ? endVar : altPos)
168 std::string altValue;
169 if (altPos != string::npos)
175 endVar - altPos - 2*delim
181 mapping.
find(varName);
185 if (altPos != string::npos && altType ==
'+')
188 s.std::string::replace
194 begVar += altValue.size();
199 s.std::string::replace
205 begVar += (*fnd).size();
208 else if (altPos != string::npos && altType ==
'-')
211 s.std::string::replace
217 begVar += altValue.size();
222 s.std::string::erase(begVar, endVar - begVar + 1);
238 const string& original,
252 const bool allowEnvVars,
253 const bool allowEmpty
266 buf.
precision(IOstream::defaultPrecision());
269 dynamicCast<const primitiveEntry>(*ePtr).write(buf,
true);
273 else if (allowEnvVars)
275 string::const_iterator iter = name.begin();
281 while (iter != name.end() && (isalnum(*iter) || *iter ==
'_'))
287 const word varName(name.substr(begVar, endVar - begVar),
false);
289 string varValue =
getEnv(varName);
291 if (!allowEmpty && varValue.empty())
296 ) <<
"Cannot find dictionary or environment variable " 300 varValue += name.substr(endVar, name.size() - endVar);
309 ) <<
"Cannot find dictionary variable " 322 const bool allowEnvVars,
323 const bool allowEmpty
328 while (index < s.size())
330 if (s[index] ==
'$' && s[index+1] ==
'{')
334 string val =
expand(s, index, dict, allowEnvVars, allowEmpty);
335 newString.append(val);
337 else if (s[index] ==
'}')
339 return getVariable(newString, dict, allowEnvVars, allowEmpty);
343 newString.append(
string(s[index]));
355 const bool allowEnvVars,
356 const bool allowEmpty,
366 (begVar = s.find(sigil, begVar)) != string::npos
367 && begVar < s.size()-1
370 if (begVar == 0 || s[begVar-1] !=
'\\')
372 if (s[begVar+1] ==
'{')
375 label stringStart = begVar;
389 s.std::string::replace
392 begVar - stringStart + 1,
396 begVar = stringStart+varValue.size();
400 string::iterator iter = s.begin() + begVar + 1;
443 s.std::string::replace
449 begVar += varValue.size();
470 if ((begVar = s.find(
'/')) != string::npos)
472 user = s.substr(1, begVar - 1);
473 file = s.substr(begVar + 1);
483 if (user ==
"OpenFOAM")
492 else if (s[0] ==
'.')
499 else if (s[1] ==
'/')
501 s.std::string::replace(0, 1,
cwd());
523 (begVar = s.find(sigil, begVar)) != string::npos
524 && begVar < s.size()-1
527 if (begVar == 0 || s[begVar-1] !=
'\\')
533 if (s[begVar+1] ==
'{')
535 endVar = s.find(
'}', begVar);
540 string::iterator iter = s.begin() + begVar + 1;
562 if (endVar == string::npos)
567 else if (endVar == begVar)
579 endVar - begVar - 2*delim
600 buf.
precision(IOstream::defaultPrecision());
603 ePtr->dict().write(buf,
false);
608 dynamicCast<const primitiveEntry>
614 s.std::string::replace
620 begVar += buf.
str().size();
641 const string& original,
642 const bool allowEmpty
653 const bool allowEmpty
662 (begVar = s.find(
'$', begVar)) != string::npos
663 && begVar < s.size()-1
666 if (begVar == 0 || s[begVar-1] !=
'\\')
676 if (s[begVar+1] ==
'{')
678 endVar = s.find(
'}', begVar);
682 if (endVar != string::npos)
690 string::iterator iter = s.begin() + begVar + 1;
695 && (isalnum(*iter) || *iter ==
'_')
704 if (endVar == string::npos)
709 else if (endVar == begVar)
722 (altPos == string::npos ? endVar : altPos)
729 std::string altValue;
730 if (altPos != string::npos)
736 endVar - altPos - 2*delim
740 const string varValue =
getEnv(varName);
743 if (altPos != string::npos && altType ==
'+')
746 s.std::string::replace
752 begVar += altValue.size();
757 s.std::string::replace
763 begVar += varValue.size();
766 else if (altPos != string::npos)
772 s.std::string::replace
778 begVar += altValue.size();
784 s.std::string::erase(begVar, endVar - begVar + 1);
789 s.std::string::erase(begVar, endVar - begVar + 1);
794 <<
"Unknown variable name '" << varName <<
"'" 817 if ((begVar = s.find(
'/')) != string::npos)
819 user = s.substr(1, begVar - 1);
820 file = s.substr(begVar + 1);
830 if (user ==
"OpenFOAM")
839 else if (s[0] ==
'.')
846 else if (s[1] ==
'/')
848 s.std::string::replace(0, 1,
cwd());
862 while (beg < s.size() &&
isspace(s[beg]))
869 return s.substr(beg);
882 while (beg < s.size() &&
isspace(s[beg]))
909 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.
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.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
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.
static int findParameterAlternative(const std::string &s, std::string::size_type &pos, std::string::size_type endPos)
IOstream & scientific(IOstream &io)
A keyword and a list of tokens is an 'entry'.