stringOps.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "stringOps.H"
27 #include "OSspecific.H"
28 #include "etcFiles.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 
37 // Find the type/position of the ":-" or ":+" alternative values
38 static inline int findParameterAlternative
39 (
40  const string& s,
42  string::size_type endPos
43 )
44 {
45  while (pos != std::string::npos)
46  {
47  pos = s.find(':', pos);
48  if (pos != std::string::npos)
49  {
50  if (pos < endPos)
51  {
52  // Nn-range: check for '+' or '-' following the ':'
53  const int altType = s[pos + 1];
54  if (altType == '+' || altType == '-')
55  {
56  return altType;
57  }
58 
59  ++pos; // Unknown/unsupported - continue at next position
60  }
61  else
62  {
63  // Out-of-range: abort
64  pos = std::string::npos;
65  }
66  }
67  }
68 
69  return 0;
70 }
71 
72 
73 // Get dictionary or (optionally) environment variable
75 (
76  const word& name,
77  const dictionary& dict,
78  const bool allowEnvVars,
79  const bool allowEmpty
80 )
81 {
82  const entry* ePtr = dict.lookupScopedEntryPtr(name, true, false);
83 
84  if (ePtr)
85  {
86  OStringStream buf;
87 
88  // Force floating point numbers to be printed with at least
89  // some decimal digits.
90  buf << scientific;
91 
93 
94  // Fail for non-primitiveEntry
95  dynamicCast<const primitiveEntry>(*ePtr).write(buf, true);
96 
97  return buf.str();
98  }
99  else if (allowEnvVars)
100  {
101  string::const_iterator iter = name.begin();
102 
103  // Search for the sub-set of characters in name which are allowed
104  // in environment variables
105  string::size_type begVar = 0;
106  string::size_type endVar = begVar;
107  while (iter != name.end() && (isalnum(*iter) || *iter == '_'))
108  {
109  ++iter;
110  ++endVar;
111  }
112 
113  const word varName(name.substr(begVar, endVar - begVar), false);
114 
115  string varValue = getEnv(varName);
116 
117  if (!allowEmpty && varValue.empty())
118  {
120  (
121  dict
122  ) << "Cannot find dictionary or environment variable "
123  << name << exit(FatalIOError);
124  }
125 
126  varValue += name.substr(endVar, name.size() - endVar);
127 
128  return varValue;
129  }
130  else
131  {
133  (
134  dict
135  ) << "Cannot find dictionary variable "
136  << name << exit(FatalIOError);
137 
138  return string::null;
139  }
140 }
141 
142 
143 // Recursively expands dictionary or environment variable starting at index
144 // in string. Updates index.
145 string expand
146 (
147  const string& s,
148  string::size_type& index,
149  const dictionary& dict,
150  const bool allowEnvVars,
151  const bool allowEmpty
152 )
153 {
154  string newString;
155 
156  while (index < s.size())
157  {
158  if (s[index] == '$' && s[index + 1] == '{')
159  {
160  // Recurse to parse variable name
161  index += 2;
162  string val = expand(s, index, dict, allowEnvVars, allowEmpty);
163  newString.append(val);
164  }
165  else if (s[index] == '}')
166  {
167  return getVariable(newString, dict, allowEnvVars, allowEmpty);
168  }
169  else
170  {
171  newString.append(string(s[index]));
172  }
173  index++;
174  }
175  return newString;
176 }
177 
178 
179 // Expand path parts of a string
181 {
182  if (!s.empty())
183  {
184  if (s[0] == '~')
185  {
186  // Expand initial ~
187  // ~/ => home directory
188  // ~OpenFOAM => site/user OpenFOAM configuration directory
189  // ~user => home directory for specified user
190 
191  string user;
192  fileName file;
193 
194  const string::size_type pos = s.find('/');
195  if (pos != string::npos)
196  {
197  user = s.substr(1, pos - 1);
198  file = s.substr(pos + 1);
199  }
200  else
201  {
202  user = s.substr(1);
203  }
204 
205  // NB: be a bit lazy and expand ~unknownUser as an
206  // empty string rather than leaving it untouched.
207  // otherwise add extra test
208  if (user == "OpenFOAM")
209  {
210  s = findEtcFile(file);
211  }
212  else
213  {
214  s = home(user)/file;
215  }
216  }
217  else if (s[0] == '.')
218  {
219  // Expand a lone '.' and an initial './' into cwd
220  if (s.size() == 1)
221  {
222  s = cwd();
223  }
224  else if (s[1] == '/')
225  {
226  s.std::string::replace(0, 1, cwd());
227  }
228  }
229  }
230 
231  return s;
232 }
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 } // End namespace Foam
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
241 (
242  const string& original,
243  const bool allowEmpty
244 )
245 {
246  string s(original);
247  return inplaceExpandEnvVar(s, allowEmpty);
248 }
249 
250 
252 (
253  string& s,
254  const bool allowEmpty
255 )
256 {
257  string::size_type begVar = 0;
258 
259  // Expand $VARS
260  // Repeat until nothing more is found
261  while
262  (
263  (begVar = s.find('$', begVar)) != string::npos
264  && begVar < s.size() - 1
265  )
266  {
267  if (begVar == 0 || s[begVar - 1] != '\\')
268  {
269  // Find end of first occurrence
270  string::size_type endVar = begVar;
271  string::size_type delim = 0;
272 
273  // The type/position of the ":-" or ":+" alternative values
274  int altType = 0;
275  string::size_type altPos = string::npos;
276 
277  if (s[begVar + 1] == '{')
278  {
279  endVar = s.find('}', begVar);
280  delim = 1;
281 
282  // Check for ${parameter:-word} or ${parameter:+word}
283  if (endVar != string::npos)
284  {
285  altPos = begVar;
286  altType = findParameterAlternative(s, altPos, endVar);
287  }
288  }
289  else
290  {
291  string::iterator iter = s.begin() + begVar + 1;
292 
293  while
294  (
295  iter != s.end()
296  && (isalnum(*iter) || *iter == '_')
297  )
298  {
299  ++iter;
300  ++endVar;
301  }
302  }
303 
304  if (endVar == string::npos)
305  {
306  // Likely parsed '${...' without closing '}' - abort
307  break;
308  }
309  else if (endVar == begVar)
310  {
311  // Parsed '${}' or $badChar - skip over
312  begVar = endVar + 1;
313  }
314  else
315  {
316  const word varName
317  (
318  s.substr
319  (
320  begVar + 1 + delim,
321  (
322  (altPos == string::npos ? endVar : altPos)
323  - begVar - 2*delim
324  )
325  ),
326  false
327  );
328 
329  std::string altValue;
330  if (altPos != string::npos)
331  {
332  // Had ":-" or ":+" alternative value
333  altValue = s.substr
334  (
335  altPos + 2,
336  endVar - altPos - 2*delim
337  );
338  }
339 
340  const string varValue = getEnv(varName);
341  if (varValue.size())
342  {
343  if (altPos != string::npos && altType == '+')
344  {
345  // Was found, use ":+" alternative
346  s.std::string::replace
347  (
348  begVar,
349  endVar - begVar + 1,
350  altValue
351  );
352  begVar += altValue.size();
353  }
354  else
355  {
356  // Was found, use value
357  s.std::string::replace
358  (
359  begVar,
360  endVar - begVar + 1,
361  varValue
362  );
363  begVar += varValue.size();
364  }
365  }
366  else if (altPos != string::npos)
367  {
368  // Use ":-" or ":+" alternative values
369  if (altType == '-')
370  {
371  // Was not found, use ":-" alternative
372  s.std::string::replace
373  (
374  begVar,
375  endVar - begVar + 1,
376  altValue
377  );
378  begVar += altValue.size();
379  }
380  else
381  {
382  // Was not found, ":+" alternative implies
383  // substitute with nothing
384  s.std::string::erase(begVar, endVar - begVar + 1);
385  }
386  }
387  else if (allowEmpty)
388  {
389  s.std::string::erase(begVar, endVar - begVar + 1);
390  }
391  else
392  {
394  << "Unknown variable name '" << varName << "'"
395  << exit(FatalError);
396  }
397  }
398  }
399  else
400  {
401  ++begVar;
402  }
403  }
404 
405  return inplaceExpandPath(s);
406 }
407 
408 
410 (
411  string& s,
412  const dictionary& dict,
413  const word& dictVar,
414  const char sigil
415 )
416 {
417  string::size_type begVar = 0;
418 
419  // Expand $VAR or ${VAR}
420  // Repeat until nothing more is found
421  while
422  (
423  (begVar = s.find(sigil, begVar)) != string::npos
424  && begVar < s.size() - 1
425  )
426  {
427  if (begVar == 0 || s[begVar - 1] != '\\')
428  {
429  // Find end of first occurrence
430  string::size_type endVar = begVar;
431  string::size_type begDelim = 0, endDelim = 0;
432 
433  // Get the type, if any
434  word varType;
435  if (s[begVar + 1] == '<')
436  {
437  begDelim += s.findClosing('>', begVar + 1) - begVar;
438  varType = s.substr(begVar + 2, begDelim - 2);
439  }
440 
441  // Parse any braces and find the end of the variable
442  if (s[begVar+begDelim + 1] == '{')
443  {
444  // endVar = s.find('}', begVar+begDelim);
445  endVar = s.findClosing('}', begVar+begDelim + 1);
446  begDelim += 1;
447  endDelim += 1;
448  }
449  else
450  {
451  endVar = begVar + begDelim;
452 
453  string::iterator iter = s.begin() + begVar + begDelim + 1;
454 
455  // Accept all dictionary and environment variable characters
456  while
457  (
458  iter != s.end()
459  &&
460  (
461  isalnum(*iter)
462  || *iter == '/' // For dictionary slash syntax
463  || *iter == '!' // For dictionary slash syntax
464  || *iter == '.' // For dictionary dot syntax
465  || *iter == ':' // For dictionary dot syntax
466  || *iter == '_'
467  )
468  )
469  {
470  ++iter;
471  ++endVar;
472  }
473  }
474 
475  if (endVar == string::npos)
476  {
477  // Likely parsed '${...' without closing '}' - abort
478  break;
479  }
480  else if (endVar == begVar)
481  {
482  // Parsed '${}' or $badChar - skip over
483  begVar = endVar + 1;
484  }
485  else
486  {
487  word varName
488  (
489  s.substr
490  (
491  begVar + begDelim + 1,
492  (endVar - endDelim) - (begVar + begDelim)
493  ),
494  false
495  );
496 
497  // Expand any environment variable paths in the variable name
498  inplaceExpandEnvVar(varName);
499 
500  // Lookup in the dictionary
501  const entry* ePtr = dict.lookupScopedEntryPtr
502  (
503  varName,
504  true,
505  false // Wildcards disabled. See primitiveEntry
506  );
507 
508  // Substitute if found
509  if (ePtr)
510  {
511  OStringStream buf;
512 
513  // If the variable type is not specified
514  // check if it can be obtained from the single token type
515  if (varType.empty())
516  {
517  if (!ePtr->isDict())
518  {
519  const primitiveEntry& pe =
520  dynamicCast<const primitiveEntry>(*ePtr);
521 
522  // Check that the primitive entry is a single token
523  if (pe.size() == 1)
524  {
525  const token& t = pe[0];
526 
527  // Map the token type to the variable type
528  if (t.isScalar())
529  {
530  varType = "scalar";
531  }
532  else if (t.isLabel())
533  {
534  varType = "label";
535  }
536  else if (t.isString())
537  {
538  varType = "string";
539  }
540  }
541  }
542  }
543 
544  if (!dictVar.empty())
545  {
546  if (!varType.empty())
547  {
548  // If the dictionary is accessible and the variable
549  // type is specified or could be deduced
550  // from the value, then lookup the variable in the
551  // code, rather than substituting its value. That
552  // way we don't need to recompile this string if the
553  // value changes.
554  buf << dictVar
555  << ".lookupScoped<" << varType << ">"
556  << "(\"" << varName << "\", true, false)";
557  }
558  else
559  {
560  // If the dictionary is accessible but the
561  // variable type is not specified and cannot be
562  // deduced from the value issue an error
564  << "Type not specified for variable "
565  << varName << " in code string " << nl
566  << " " << s << nl
567  << "Variable " << varName << " expands to "
568  << nl;
569 
570  if (ePtr->isDict())
571  {
572  ePtr->dict().write(FatalIOError, false);
573  }
574  else
575  {
576  dynamicCast<const primitiveEntry>(*ePtr)
577  .write(FatalIOError, true);
578  }
579 
581  }
582  }
583  else
584  {
585  if (!varType.empty())
586  {
587  // If the dictionary is not accessible but the
588  // type is known, then read the substituted value
589  // from a string
590  buf << "read<" << varType << ">(\"";
591  }
592 
593  // If the dictionary is not accessible and/or the type
594  // is not known, then we need to substitute the
595  // variable's value
596 
597  // Make sure floating point values print with at least
598  // some decimal points
599  buf << scientific;
600  buf.precision(IOstream::defaultPrecision());
601 
602  // Write the dictionary or primitive entry.
603  // Fail if anything else.
604  if (ePtr->isDict())
605  {
606  ePtr->dict().write(buf, false);
607  }
608  else
609  {
610  dynamicCast<const primitiveEntry>(*ePtr)
611  .write(buf, true);
612  }
613 
614  if (!varType.empty())
615  {
616  // Close the string and read function as necessary
617  buf << "\")";
618  }
619  }
620 
621  s.std::string::replace
622  (
623  begVar,
624  endVar - begVar + 1,
625  buf.str()
626  );
627  begVar += buf.str().size();
628  }
629  else
630  {
631  // Not found. Leave original string untouched.
632  begVar = endVar + 1;
633  }
634  }
635  }
636  else
637  {
638  ++begVar;
639  }
640  }
641 
642  return s;
643 }
644 
645 
647 (
648  string& s,
650  const char sigil
651 )
652 {
653  string::size_type begVar = 0;
654 
655  // Expand $VAR or ${VAR}
656  // Repeat until nothing more is found
657  while
658  (
659  (begVar = s.find(sigil, begVar)) != string::npos
660  && begVar < s.size() - 1
661  )
662  {
663  if (begVar == 0 || s[begVar - 1] != '\\')
664  {
665  // Find end of first occurrence
666  string::size_type endVar = begVar;
667  string::size_type delim = 0;
668 
669  if (s[begVar + 1] == '{')
670  {
671  endVar = s.findClosing('}', begVar + 1);
672  delim = 1;
673  }
674  else
675  {
676  string::iterator iter = s.begin() + begVar + 1;
677 
678  // Accept all dictionary and environment variable characters
679  while
680  (
681  iter != s.end()
682  &&
683  (
684  isalnum(*iter)
685  || *iter == '/' // For dictionary slash syntax
686  || *iter == '!' // For dictionary slash syntax
687  || *iter == '.' // For dictionary dot syntax
688  || *iter == ':' // For dictionary dot syntax
689  || *iter == '_'
690  )
691  )
692  {
693  ++iter;
694  ++endVar;
695  }
696  }
697 
698  if (endVar == string::npos)
699  {
700  // Likely parsed '${...' without closing '}' - abort
701  break;
702  }
703  else if (endVar == begVar)
704  {
705  // Parsed '${}' or $badChar - skip over
706  begVar = endVar + 1;
707  }
708  else
709  {
710  const word varName
711  (
712  s.substr
713  (
714  begVar + 1 + delim,
715  endVar - begVar - 2*delim
716  ),
717  false
718  );
719 
720  // Lookup in the table
722  mapping.find(varName);
723 
724  // Substitute if found
726  {
727  s.std::string::replace
728  (
729  begVar,
730  endVar - begVar + 1,
731  *fnd
732  );
733  begVar += (*fnd).size();
734  }
735  else
736  {
737  // Not found. Remove.
738  s.std::string::erase(begVar, endVar - begVar + 1);
739  }
740  }
741  }
742  else
743  {
744  ++begVar;
745  }
746  }
747 
748  return s;
749 }
750 
751 
753 (
754  string& s,
755  const dictionary& dict,
756  const bool allowEnvVars,
757  const bool allowEmpty,
758  const char sigil
759 )
760 {
761  string::size_type begVar = 0;
762 
763  // Expand $VAR or ${VAR}
764  // Repeat until nothing more is found
765  while
766  (
767  (begVar = s.find(sigil, begVar)) != string::npos
768  && begVar < s.size() - 1
769  )
770  {
771  if (begVar == 0 || s[begVar - 1] != '\\')
772  {
773  if (s[begVar + 1] == '{')
774  {
775  // Recursive variable expansion mode
776  label stringStart = begVar;
777  begVar += 2;
778  string varValue
779  (
780  expand
781  (
782  s,
783  begVar,
784  dict,
785  allowEnvVars,
786  allowEmpty
787  )
788  );
789 
790  s.std::string::replace
791  (
792  stringStart,
793  begVar - stringStart + 1,
794  varValue
795  );
796 
797  begVar = stringStart+varValue.size();
798  }
799  else
800  {
801  string::iterator iter = s.begin() + begVar + 1;
802 
803  // Accept all dictionary and environment variable characters
804  string::size_type endVar = begVar;
805  while
806  (
807  iter != s.end()
808  &&
809  (
810  isalnum(*iter)
811  || *iter == '/' // For dictionary slash syntax
812  || *iter == '!' // For dictionary slash syntax
813  || *iter == '.' // For dictionary dot syntax
814  || *iter == ':' // For dictionary dot syntax
815  || *iter == '_'
816  )
817  )
818  {
819  ++iter;
820  ++endVar;
821  }
822 
823  const word varName
824  (
825  s.substr
826  (
827  begVar + 1,
828  endVar - begVar
829  ),
830  false
831  );
832 
833  string varValue
834  (
836  (
837  varName,
838  dict,
839  allowEnvVars,
840  allowEmpty
841  )
842  );
843 
844  s.std::string::replace
845  (
846  begVar,
847  varName.size() + 1,
848  varValue
849  );
850  begVar += varValue.size();
851  }
852  }
853  else
854  {
855  ++begVar;
856  }
857  }
858 
859  return inplaceExpandPath(s);
860 }
861 
862 
864 {
865  if (!s.empty())
866  {
867  string::size_type beg = 0;
868  while (beg < s.size() && isspace(s[beg]))
869  {
870  ++beg;
871  }
872 
873  if (beg)
874  {
875  return s.substr(beg);
876  }
877  }
878 
879  return s;
880 }
881 
882 
884 {
885  if (!s.empty())
886  {
887  string::size_type beg = 0;
888  while (beg < s.size() && isspace(s[beg]))
889  {
890  ++beg;
891  }
892 
893  if (beg)
894  {
895  s.erase(0, beg);
896  }
897  }
898 
899  return s;
900 }
901 
902 
904 {
905  if (!s.empty())
906  {
907  string::size_type sz = s.size();
908  while (sz && isspace(s[sz - 1]))
909  {
910  --sz;
911  }
912 
913  if (sz < s.size())
914  {
915  return s.substr(0, sz);
916  }
917  }
918 
919  return s;
920 }
921 
922 
924 {
925  if (!s.empty())
926  {
927  string::size_type sz = s.size();
928  while (sz && isspace(s[sz - 1]))
929  {
930  --sz;
931  }
932 
933  s.resize(sz);
934  }
935 
936  return s;
937 }
938 
939 
940 Foam::string Foam::stringOps::trim(const string& original)
941 {
942  return trimLeft(trimRight(original));
943 }
944 
945 
947 {
950 
951  return s;
952 }
953 
954 
956 (
957  const string& message,
958  const string::size_type nLength,
959  const string::size_type nIndent
960 )
961 {
962  const string indent(nIndent, token::SPACE);
963 
964  string result;
965 
966  word::size_type i0 = 0, i1 = 0;
967  while (true)
968  {
969  const word::size_type iNewLine =
970  message.find_first_of(token::NL, i1);
971  const word::size_type iSpace =
972  message.find_first_of(token::SPACE, i1);
973 
974  // New line next
975  if
976  (
977  iNewLine != string::npos
978  && (iSpace == string::npos || iNewLine < iSpace)
979  )
980  {
981  result += indent + message.substr(i0, iNewLine - i0) + '\n';
982  i0 = i1 = iNewLine + 1;
983  }
984 
985  // Space next
986  else if (iSpace != string::npos)
987  {
988  if (iSpace - i0 > nLength - nIndent)
989  {
990  result += indent + message.substr(i0, i1 - i0) + '\n';
991  i0 = i1;
992  }
993  else
994  {
995  i1 = iSpace + 1;
996  }
997  }
998 
999  // End of string
1000  else
1001  {
1002  result += indent + message.substr(i0);
1003  break;
1004  }
1005  }
1006 
1007  return result;
1008 }
1009 
1010 
1011 // ************************************************************************* //
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
Definition: SloanRenumber.C:73
An STL-conforming const_iterator.
Definition: HashTable.H:484
An STL-conforming hash table.
Definition: HashTable.H:127
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Definition: HashTable.C:142
static unsigned int defaultPrecision()
Return the default precision.
Definition: IOstream.H:458
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
virtual int precision() const
Get precision of output field.
Definition: OSstream.C:246
Output to memory buffer stream.
Definition: OStringStream.H:52
string str() const
Return the string.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:211
const entry * lookupScopedEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present,.
Definition: dictionary.C:887
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:68
virtual bool isDict() const
Return true if this entry is a dictionary.
Definition: entry.H:156
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
A class for handling file names.
Definition: fileName.H:82
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read,...
A class for handling character strings derived from std::string.
Definition: string.H:79
static const string null
An empty string.
Definition: string.H:88
A token holds items read from Istream.
Definition: token.H:73
bool isLabel() const
Definition: tokenI.H:392
bool isScalar() const
Definition: tokenI.H:467
bool isString() const
Definition: tokenI.H:315
A class for handling words, derived from string.
Definition: word.H:62
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
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 & inplaceExpandCodeString(string &, const dictionary &dict, const word &dictVar="dict", const char sigil='$')
Inplace expand occurrences of variables according to the dictionary.
Definition: stringOps.C:410
string & inplaceTrimRight(string &)
Trim trailing whitespace inplace.
Definition: stringOps.C:923
string trim(const string &)
Return string trimmed of leading and trailing whitespace.
Definition: stringOps.C:940
string & inplaceExpandCodeTemplate(string &, const HashTable< string, word, string::hash > &mapping, const char sigil='$')
Inplace expand occurrences of variables according to the mapping.
Definition: stringOps.C:647
string & inplaceExpandEnvVar(string &, const bool allowEmpty=false)
Expand all occurrences of environment variables and paths.
Definition: stringOps.C:252
string expandEnvVar(const string &, const bool allowEmpty=false)
Expand all occurrences of environment variables and paths.
Definition: stringOps.C:241
string & inplaceExpandEntry(string &s, const dictionary &dict, const bool allowEnvVars, const bool allowEmpty, const char sigil='$')
Inplace expand occurrences of variables according to the dictionary.
Definition: stringOps.C:753
string trimRight(const string &)
Return string trimmed of trailing whitespace.
Definition: stringOps.C:903
string breakIntoIndentedLines(const string &str, const string::size_type nLength=80, const string::size_type nIndent=0)
Break a string up into indented lines.
Definition: stringOps.C:956
string trimLeft(const string &)
Return string trimmed of leading whitespace.
Definition: stringOps.C:863
string & inplaceTrim(string &)
Trim leading and trailing whitespace inplace.
Definition: stringOps.C:946
string & inplaceTrimLeft(string &)
Trim leading whitespace inplace.
Definition: stringOps.C:883
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
fileName cwd()
Return current working directory path name.
Definition: POSIX.C:241
dimensionedScalar pos(const dimensionedScalar &ds)
Foam::string & inplaceExpandPath(string &s)
Definition: stringOps.C:180
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
fileName findEtcFile(const fileName &, bool mandatory=false)
Search for a file using findEtcFiles.
Definition: etcFiles.C:252
static int findParameterAlternative(const string &s, string::size_type &pos, string::size_type endPos)
Definition: stringOps.C:39
IOstream & scientific(IOstream &io)
Definition: IOstream.H:579
string getEnv(const word &)
Return environment variable of given name.
Definition: POSIX.C:97
string getVariable(const word &name, const dictionary &dict, const bool allowEnvVars, const bool allowEmpty)
Definition: stringOps.C:75
IOerror FatalIOError
error FatalError
bool isspace(char c)
Definition: char.H:53
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
fileName home()
Return home directory path name for the current user.
Definition: POSIX.C:186
static const char nl
Definition: Ostream.H:260
string expand(const string &s, string::size_type &index, const dictionary &dict, const bool allowEnvVars, const bool allowEmpty)
Definition: stringOps.C:146
dictionary dict