Go to the documentation of this file.
37 static inline int findParameterAlternative
44 while (
pos != std::string::npos)
47 if (
pos != std::string::npos)
52 const int altType =
s[
pos+1];
53 if (altType ==
'+' || altType ==
'-')
63 pos = std::string::npos;
75 const string& original,
98 (begVar =
s.find(sigil, begVar)) != string::npos
99 && begVar <
s.size()-1
102 if (begVar == 0 ||
s[begVar-1] !=
'\\')
112 if (
s[begVar+1] ==
'{')
114 endVar =
s.find(
'}', begVar);
118 if (endVar != string::npos)
121 altType = findParameterAlternative(
s, altPos, endVar);
126 string::iterator iter =
s.begin() + begVar + 1;
146 if (endVar == string::npos)
151 else if (endVar == begVar)
164 (altPos == string::npos ? endVar : altPos)
171 std::string altValue;
172 if (altPos != string::npos)
178 endVar - altPos - 2*delim
184 mapping.
find(varName);
188 if (altPos != string::npos && altType ==
'+')
191 s.std::string::replace
197 begVar += altValue.size();
202 s.std::string::replace
208 begVar += (*fnd).size();
211 else if (altPos != string::npos && altType ==
'-')
214 s.std::string::replace
220 begVar += altValue.size();
225 s.std::string::erase(begVar, endVar - begVar + 1);
241 const string& original,
255 const bool allowEnvVars,
256 const bool allowEmpty
261 const entry* ePtr =
dict.lookupScopedEntryPtr
273 buf.
precision(IOstream::defaultPrecision());
276 dynamicCast<const primitiveEntry>
283 else if (allowEnvVars)
292 ) <<
"Cannot find dictionary or environment variable "
301 ) <<
"Cannot find dictionary variable "
314 const bool allowEnvVars,
315 const bool allowEmpty
320 while (index <
s.size())
322 if (
s[index] ==
'$' &&
s[index+1] ==
'{')
326 string val =
expand(
s, index,
dict, allowEnvVars, allowEmpty);
327 newString.append(val);
329 else if (
s[index] ==
'}')
335 newString.append(
string(
s[index]));
347 const bool allowEnvVars,
348 const bool allowEmpty,
358 (begVar =
s.find(sigil, begVar)) != string::npos
359 && begVar <
s.size()-1
362 if (begVar == 0 ||
s[begVar-1] !=
'\\')
364 if (
s[begVar+1] ==
'{')
367 label stringStart = begVar;
381 s.std::string::replace
384 begVar - stringStart + 1,
388 begVar = stringStart+varValue.size();
392 string::iterator iter =
s.begin() + begVar + 1;
433 s.std::string::replace
439 begVar += varValue.size();
460 if ((begVar =
s.find(
'/')) != string::npos)
462 user =
s.substr(1, begVar - 1);
463 file =
s.substr(begVar + 1);
473 if (user ==
"OpenFOAM")
482 else if (
s[0] ==
'.')
489 else if (
s[1] ==
'/')
491 s.std::string::replace(0, 1,
cwd());
513 (begVar =
s.find(sigil, begVar)) != string::npos
514 && begVar <
s.size()-1
517 if (begVar == 0 ||
s[begVar-1] !=
'\\')
523 if (
s[begVar+1] ==
'{')
525 endVar =
s.find(
'}', begVar);
530 string::iterator iter =
s.begin() + begVar + 1;
550 if (endVar == string::npos)
555 else if (endVar == begVar)
567 endVar - begVar - 2*delim
574 const entry* ePtr =
dict.lookupScopedEntryPtr
588 buf.
precision(IOstream::defaultPrecision());
596 dynamicCast<const primitiveEntry>
602 s.std::string::replace
608 begVar += buf.
str().size();
629 const string& original,
630 const bool allowEmpty
641 const bool allowEmpty
650 (begVar =
s.find(
'$', begVar)) != string::npos
651 && begVar <
s.size()-1
654 if (begVar == 0 ||
s[begVar-1] !=
'\\')
664 if (
s[begVar+1] ==
'{')
666 endVar =
s.find(
'}', begVar);
670 if (endVar != string::npos)
673 altType = findParameterAlternative(
s, altPos, endVar);
678 string::iterator iter =
s.begin() + begVar + 1;
683 && (isalnum(*iter) || *iter ==
'_')
692 if (endVar == string::npos)
697 else if (endVar == begVar)
710 (altPos == string::npos ? endVar : altPos)
717 std::string altValue;
718 if (altPos != string::npos)
724 endVar - altPos - 2*delim
728 const string varValue =
getEnv(varName);
731 if (altPos != string::npos && altType ==
'+')
734 s.std::string::replace
740 begVar += altValue.size();
745 s.std::string::replace
751 begVar += varValue.size();
754 else if (altPos != string::npos)
760 s.std::string::replace
766 begVar += altValue.size();
772 s.std::string::erase(begVar, endVar - begVar + 1);
777 s.std::string::erase(begVar, endVar - begVar + 1);
782 <<
"Unknown variable name '" << varName <<
"'"
805 if ((begVar =
s.find(
'/')) != string::npos)
807 user =
s.substr(1, begVar - 1);
808 file =
s.substr(begVar + 1);
818 if (user ==
"OpenFOAM")
827 else if (
s[0] ==
'.')
834 else if (
s[1] ==
'/')
836 s.std::string::replace(0, 1,
cwd());
850 while (beg <
s.size() &&
isspace(
s[beg]))
857 return s.substr(beg);
870 while (beg <
s.size() &&
isspace(
s[beg]))
897 return s.substr(0, sz);
A keyword and a list of tokens is an 'entry'.
string & inplaceTrimLeft(string &)
Trim leading whitespace inplace.
fileName findEtcFile(const fileName &, bool mandatory=false)
Search for a file using findEtcFiles.
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
A class for handling words, derived from string.
A class for handling file names.
string trimLeft(const string &)
Return string trimmed of leading whitespace.
An STL-conforming const_iterator.
A class for handling character strings derived from std::string.
string str() const
Return the string.
string getEnv(const word &)
Return environment variable of given name.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual bool isDict() const
Return true if this entry is a dictionary.
graph_traits< Graph >::vertices_size_type size_type
IOstream & fixed(IOstream &io)
A list of keyword definitions, which are a keyword followed by any number of values (e....
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
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))
string getVariable(const word &name, const dictionary &dict, const bool allowEnvVars, const bool allowEmpty)
Get dictionary or (optionally) environment variable.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
errorManipArg< error, int > exit(error &err, const int errNo=1)
An STL-conforming hash table.
virtual int precision() const
Get precision of output field.
string trimRight(const string &)
Return string trimmed of trailing whitespace.
fileName home()
Return home directory path name for the current user.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
string & inplaceTrimRight(string &)
Trim trailing whitespace inplace.
Output to memory buffer stream.
string & inplaceTrim(string &)
Trim leading and trailing whitespace inplace.
fileName cwd()
Return current working directory path name.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
string & inplaceExpand(string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Inplace expand occurences of variables according to the mapping.
word name(const complex &)
Return a string representation of a complex.
string expand(const string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Expand occurences of variables according to the mapping.
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
dimensionedScalar pos(const dimensionedScalar &ds)
string trim(const string &)
Return string trimmed of leading and trailing whitespace.