ensightFileNameI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "error.H"
29 #include <cctype>
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
34 :
35  fileName(fn, false)
36 {}
37 
38 
40 :
41  fileName(s, false)
42 {
43  stripInvalid();
44 }
45 
46 
47 inline Foam::ensight::FileName::FileName(const std::string& s)
48 :
49  fileName(s, false)
50 {
51  stripInvalid();
52 }
53 
54 
55 
56 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
57 
59 {
60  return
61  (
62  fileName::valid(c) // includes space, quotes
63  && c != '*' // wild-card
64  && c != '%' // structured block continuation
65  );
66 }
67 
68 
70 {
71  string::stripInvalid<FileName>(*this);
72 
73  removeRepeated('/');
74  removeEnd('/');
75 
76  if (empty())
77  {
79  << "ensight::FileName empty after stripping" << nl
80  << exit(FatalError);
81  }
82 }
83 
84 
85 // ************************************************************************* //
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
s
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.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))
Definition: gmvOutputSpray.H:25
Foam::fileName::valid
static bool valid(char c)
Is this character valid for a fileName?
Definition: fileNameI.H:102
Foam::ensight::FileName
Specification of a valid Ensight file-name.
Definition: ensightFileName.H:56
error.H
Foam::ensight::FileName::FileName
FileName(const FileName &fn)
Copy construct.
Definition: ensightFileNameI.H:33
Foam::ensight::FileName::valid
static bool valid(char c)
Is this character valid for an ensight file-name.
Definition: ensightFileNameI.H:58
Foam::FatalError
error FatalError
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.
Foam::ensight::FileName::stripInvalid
void stripInvalid()
Strip invalid characters.
Definition: ensightFileNameI.H:69