variable.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) 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 Class
25  Foam::variable
26 
27 Description
28  A variable is a word with support for additional characters, in particular
29  '$' and '/'.
30 
31 SourceFiles
32  variable.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef variable_H
37 #define variable_H
38 
39 #include "word.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of friend functions and operators
47 class variable;
48 class Istream;
49 class Ostream;
50 
51 Istream& operator>>(Istream&, variable&);
52 Ostream& operator<<(Ostream&, const variable&);
53 
54 
55 /*---------------------------------------------------------------------------*\
56  Class variable Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class variable
60 :
61  public word
62 {
63  // Private Member Functions
64 
65  //- Strip invalid characters from this variable
66  inline void stripInvalid();
67 
68 
69 public:
70 
71  // Static Data Members
72 
73  static const char* const typeName;
74  static int debug;
75 
76  //- An empty variable
77  static const variable null;
78 
79 
80  // Constructors
81 
82  //- Construct null
83  inline variable();
84 
85  //- Copy constructor
86  inline variable(const variable&);
87 
88  //- Copy constructor of word
89  inline explicit variable(const word&);
90 
91  //- Copy constructor of string
92  inline explicit variable(const string&, const bool doStripInvalid=true);
93 
94  //- Copy constructor of std::string
95  inline explicit variable
96  (
97  const std::string&,
98  const bool doStripInvalid=true
99  );
100 
101  //- Copy constructor of character array
102  inline explicit variable(const char*, const bool doStripInvalid=true);
103 
104  //- Construct from Istream
105  // Words are treated as literals, strings with an auto-test
106  explicit variable(Istream&);
107 
108 
109  // Member Functions
110 
111  //- Is this character valid for a variable
112  inline static bool valid(char);
113 
114 
115  // Member Operators
116 
117  // Assignment
118 
119  inline void operator=(const variable&);
120  inline void operator=(const word&);
121  inline void operator=(const string&);
122  inline void operator=(const std::string&);
123  inline void operator=(const char*);
124 
125 
126  // IOstream Operators
127 
128  friend Istream& operator>>(Istream&, variable&);
129  friend Ostream& operator<<(Ostream&, const variable&);
130 };
131 
132 
133 void writeEntry(Ostream& os, const variable& value);
134 
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace Foam
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 #include "variableI.H"
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 #endif
147 
148 // ************************************************************************* //
static bool valid(char)
Is this character valid for a variable.
Definition: variableI.H:106
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
friend Ostream & operator<<(Ostream &, const variable &)
static int debug
Definition: variable.H:73
variable()
Construct null.
Definition: variableI.H:53
A class for handling words, derived from string.
Definition: word.H:59
Istream & operator>>(Istream &, directionInfo &)
void operator=(const variable &)
Definition: variableI.H:122
friend Istream & operator>>(Istream &, variable &)
static const variable null
An empty variable.
Definition: variable.H:76
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
Ostream & operator<<(Ostream &, const ensightPart &)
A variable is a word with support for additional characters, in particular &#39;$&#39; and &#39;/&#39;...
Definition: variable.H:58
static const char *const typeName
Definition: variable.H:72
Namespace for OpenFOAM.