Loading...
Searching...
No Matches
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-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
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
33inline Foam::ensight::FileName::FileName(const char* s)
35 fileName(s, false)
36{
38}
39
40
41inline Foam::ensight::FileName::FileName(const std::string& s)
43 fileName(s, false)
44{
46}
47
48
49inline Foam::ensight::FileName::FileName(std::string&& s)
50:
51 fileName(std::move(s), false)
54}
55
56
57// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
58
59inline bool Foam::ensight::FileName::valid(char c)
60{
61 return
62 (
63 fileName::valid(c) // includes space, quotes
64 && c != '*' // wild-card
65 && c != '%' // structured block continuation
66 );
67}
68
69
71{
73
74 // Avoid characters that upset Windows or others
75 string::replaceAny(":<>[]", '_');
77
78 // Minor cleanup of fileName
81
82 if (empty())
83 {
85 << "ensight::FileName empty after stripping" << nl
86 << exit(FatalError);
87 }
88}
89
90
91// ************************************************************************* //
static bool valid(char c)
Is this character valid for an ensight file-name.
FileName(const FileName &)=default
Copy construct.
void stripInvalid()
Strip invalid characters.
A class for handling file names.
Definition fileName.H:75
fileName()=default
Default construct.
static bool valid(char c)
Is this character valid for a fileName?
Definition fileNameI.H:95
static bool stripInvalid(std::string &str)
Strip invalid characters from the given string.
Definition stringI.H:164
bool removeRepeated(const char character)
Remove repeated characters.
Definition string.C:173
string & replaceAny(const std::string &s1, const char c2, size_type pos=0)
Replace any occurrence of s1 characters with c2, beginning at pos in the string.
Definition string.C:140
bool removeEnd(const std::string &text)
Remove the given text from the end of the string.
Definition string.C:222
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
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))
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50