edgeMeshFormatsCore.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 "edgeMeshFormatsCore.H"
27 #include "Time.H"
28 #include "IFstream.H"
29 #include "OFstream.H"
30 #include "edgeMesh.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
35 
36 
37 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
38 
40 (
41  IFstream& is
42 )
43 {
44  string line;
45  do
46  {
47  is.getLine(line);
48  }
49  while ((line.empty() || line[0] == '#') && is.good());
50 
51  return line;
52 }
53 
54 
56 (
57  const wordHashSet& available,
58  const word& ext,
59  const bool verbose,
60  const word& functionName
61 )
62 {
63  if (available.found(ext))
64  {
65  return true;
66  }
67  else if (verbose)
68  {
69  wordList known = available.sortedToc();
70 
71  Info<< "Unknown file extension for " << functionName
72  << " : " << ext << nl
73  << "Valid types: (";
74 
75  forAll(known, i)
76  {
77  Info<< " " << known[i];
78  }
79 
80  Info<< " )" << endl;
81  }
82 
83  return false;
84 }
85 
86 
87 // ************************************************************************* //
#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' edge 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