40 while (
pos != std::string::npos)
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
256 const entry* ePtr =
dict.lookupScopedEntryPtr(
name,
true,
false);
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] ==
'}')
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
586 const entry* ePtr =
dict.lookupScopedEntryPtr
600 buf.
precision(IOstream::defaultPrecision());
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);
951 const string& message,
956 const string indent(nIndent, token::SPACE);
964 message.find_first_of(token::NL, i1);
966 message.find_first_of(token::SPACE, i1);
971 iNewLine != string::npos
972 && (iSpace == string::npos || iNewLine < iSpace)
975 result +=
indent + message.substr(i0, iNewLine - i0) +
'\n';
976 i0 = i1 = iNewLine + 1;
980 else if (iSpace != string::npos)
982 if (iSpace - i0 > nLength - nIndent)
984 result +=
indent + message.substr(i0, i1 - i0) +
'\n';
996 result +=
indent + message.substr(i0);
Functions used by OpenFOAM that are specific to POSIX compliant operating systems and need to be repl...
graph_traits< Graph >::vertices_size_type size_type
An STL-conforming const_iterator.
An STL-conforming hash table.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
virtual int precision() const
Get precision of output field.
Output to memory buffer stream.
string str() const
Return the string.
A list of keyword definitions, which are a keyword followed by any number of values (e....
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
A keyword and a list of tokens is an 'entry'.
virtual bool isDict() const
Return true if this entry is a dictionary.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
A class for handling file names.
A class for handling character strings derived from std::string.
A class for handling words, derived from string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Functions to search 'etc' directories for configuration files etc.
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.name(), 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.
string & inplaceTrimRight(string &)
Trim trailing whitespace inplace.
string trim(const string &)
Return string trimmed of leading and trailing whitespace.
string trimRight(const string &)
Return string trimmed of trailing whitespace.
string breakIntoIndentedLines(const string &str, const string::size_type nLength=80, const string::size_type nIndent=0)
Break a string up into indented lines.
string trimLeft(const string &)
Return string trimmed of leading whitespace.
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 & inplaceExpand(string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Inplace expand occurrences of variables according to the mapping.
string & inplaceTrimLeft(string &)
Trim leading whitespace inplace.
errorManipArg< error, int > exit(error &err, const int errNo=1)
fileName cwd()
Return current working directory path name.
dimensionedScalar pos(const dimensionedScalar &ds)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
fileName findEtcFile(const fileName &, bool mandatory=false)
Search for a file using findEtcFiles.
IOstream & scientific(IOstream &io)
string getEnv(const word &)
Return environment variable of given name.
word name(const complex &)
Return a string representation of a complex.
Ostream & indent(Ostream &os)
Indent stream.
fileName home()
Return home directory path name for the current user.
static int findParameterAlternative(const std::string &s, std::string::size_type &pos, std::string::size_type endPos)