surfaceFormatsCore.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-2024 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 "surfaceFormatsCore.H"
27 #include "Time.H"
28 #include "IFstream.H"
29 #include "OFstream.H"
30 #include "SortableList.H"
31 #include "surfMesh.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
36 
37 
38 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
39 
41 (
42  IFstream& is
43 )
44 {
45  string line;
46  do
47  {
48  is.getLine(line);
49  }
50  while ((line.empty() || line[0] == '#') && is.good());
51 
52  return line;
53 }
54 
55 
57 (
58  const wordHashSet& available,
59  const word& ext,
60  const bool verbose,
61  const word& functionName
62 )
63 {
64  if (available.found(ext))
65  {
66  return true;
67  }
68  else if (verbose)
69  {
70  wordList known = available.sortedToc();
71 
72  Info<< "Unknown file extension for " << functionName
73  << " : " << ext << nl
74  << "Valid types: (";
75 
76  forAll(known, i)
77  {
78  Info<< " " << known[i];
79  }
80 
81  Info<< " )" << endl;
82  }
83 
84  return false;
85 }
86 
87 
88 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
A HashTable with keys but without contents.
Definition: HashSet.H:62
List< Key > sortedToc() const
Return the table of contents as a sorted list.
Definition: HashTable.C:242
bool found(const Key &) const
Return true if hashedEntry is found in table.
Definition: HashTable.C:138
Input from file stream.
Definition: IFstream.H:85
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:330
ISstream & getLine(string &, const bool continuation=true)
Read line into a string.
Definition: ISstream.C:703
static string getLineNoComment(IFstream &)
Read non-comment line.
static word nativeExt
The file extension corresponding to 'native' surface format.
static bool checkSupport(const wordHashSet &available, const word &ext, const bool verbose, const word &functionName)
...
A functionName is a word starting with '#'.
Definition: functionName.H:60
A line primitive.
Definition: line.H:71
A class for handling character strings derived from std::string.
Definition: string.H:79
A class for handling words, derived from string.
Definition: word.H:62
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
messageStream Info
static const char nl
Definition: Ostream.H:266