fileNameI.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 | Copyright (C) 2011 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 
58 :
59  string(fn)
60 {}
61 
63 :
64  string(w)
65 {}
66 
67 
68 inline Foam::fileName::fileName(const string& str)
69 :
70  string(str)
71 {
72  stripInvalid();
73 }
74 
75 
76 inline Foam::fileName::fileName(const std::string& str)
77 :
78  string(str)
79 {
80  stripInvalid();
81 }
82 
83 
84 inline Foam::fileName::fileName(const char* str)
85 :
86  string(str)
87 {
88  stripInvalid();
89 }
90 
91 
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
93 
94 inline bool Foam::fileName::valid(char c)
95 {
96  return
97  (
98  !isspace(c)
99  && c != '"' // string quote
100  && c != '\'' // string quote
101  );
102 }
103 
104 
105 // ************************************************************************* //
fileName()
Construct null.
Definition: fileNameI.H:52
A class for handling words, derived from string.
Definition: word.H:59
A class for handling character strings derived from std::string.
Definition: string.H:74
bool removeRepeated(const char)
Remove repeated characters returning true if string changed.
Definition: string.C:106
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
static int debug
Definition: fileName.H:94
bool removeTrailing(const char)
Remove trailing character returning true if string changed.
Definition: string.C:154
errorManip< error > abort(error &err)
Definition: errorManip.H:131
static bool valid(char)
Is this character valid for a fileName?
Definition: fileNameI.H:94
A class for handling file names.
Definition: fileName.H:69
const dimensionedScalar c
Speed of light in a vacuum.
bool isspace(char c)
Definition: char.H:53