fileNameI.H
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-2019 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 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
27 
28 inline void Foam::fileName::stripInvalid()
29 {
30  if (debug && string::stripInvalid<fileName>(*this))
31  {
32  std::cerr
33  << "fileName::stripInvalid() called for invalid fileName "
34  << this->c_str() << std::endl;
35 
36  if (debug > 1)
37  {
38  std::cerr
39  << " For debug level (= " << debug
40  << ") > 1 this is considered fatal" << std::endl;
41  std::abort();
42  }
43 
44  removeRepeated('/');
45  removeTrailing('/');
46  }
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
53 :
54  string()
55 {}
56 
57 
59 :
60  string(fn)
61 {}
62 
63 
65 :
66  string(move(fn))
67 {}
68 
69 
71 :
72  string(w)
73 {}
74 
75 
76 inline Foam::fileName::fileName(const string& str)
77 :
78  string(str)
79 {
80  stripInvalid();
81 }
82 
83 
84 inline Foam::fileName::fileName(const std::string& str)
85 :
86  string(str)
87 {
88  stripInvalid();
89 }
90 
91 
92 inline Foam::fileName::fileName(const char* str)
93 :
94  string(str)
95 {
96  stripInvalid();
97 }
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
102 inline bool Foam::fileName::valid(char c)
103 {
104  return
105  (
106  !isspace(c)
107  && c != '"' // string quote
108  && c != '\'' // string quote
109  );
110 }
111 
112 
113 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:82
static bool valid(char)
Is this character valid for a fileName?
Definition: fileNameI.H:102
fileName()
Construct null.
Definition: fileNameI.H:52
static int debug
Definition: fileName.H:94
A class for handling character strings derived from std::string.
Definition: string.H:79
bool removeTrailing(const char)
Remove trailing character returning true if string changed.
Definition: string.C:219
bool removeRepeated(const char)
Remove repeated character returning true if string changed.
Definition: string.C:175
A class for handling words, derived from string.
Definition: word.H:62
const dimensionedScalar c
Speed of light in a vacuum.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
errorManip< error > abort(error &err)
Definition: errorManip.H:131
bool isspace(char c)
Definition: char.H:53