char.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) 2011 OpenFOAM Foundation
9  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Primitive
28  char
29 
30 Description
31  A character and a pointer to a character string.
32 
33 SourceFiles
34  char.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_primitives_char_H
39 #define Foam_primitives_char_H
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward Declarations
47 class Istream;
48 class Ostream;
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 //- Read single character
53 char readChar(Istream& is);
54 
55 //- Read single character
56 Istream& operator>>(Istream& is, char& c);
57 
58 //- Write single character
59 Ostream& operator<<(Ostream& os, const char c);
60 
61 //- Write a nul-terminated C-string
62 Ostream& operator<<(Ostream& os, const char* str);
63 
64 //- Test for whitespace (C-locale)
65 inline bool isspace(char c) noexcept
66 {
67  return
68  (
69  c == ' ' // (0x20) space (SPC)
70  || c == '\t' // (0x09) horizontal tab (TAB)
71  || c == '\n' // (0x0a) newline (LF)
72  || c == '\v' // (0x0b) vertical tab (VT)
73  || c == '\f' // (0x0c) feed (FF)
74  || c == '\r' // (0x0d) carriage return (CR)
75  );
76 }
77 
78 
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 
81 } // End namespace Foam
82 
83 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
84 
85 #include "pTraits.H"
86 
87 namespace Foam
88 {
89 
90 //- Template specialisation for pTraits<char>
91 template<>
92 class pTraits<char>
93 {
94  char p_;
95 
96 public:
97 
98  // Static Data Members
99 
100  static const char* const typeName;
101 
102 
103  // Constructors
104 
105  //- Copy construct from primitive
106  explicit pTraits(char val) noexcept
107  :
108  p_(val)
109  {}
110 
111  //- Read construct from Istream
112  explicit pTraits(Istream& is);
113 
114 
115  // Member Functions
117  //- Return the value
118  operator char() const noexcept
119  {
120  return p_;
121  }
122 
123  //- Access the value
124  operator char&() noexcept
125  {
126  return p_;
127  }
128 };
129 
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 } // End namespace Foam
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 #endif
138 
139 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
pTraits(const Base &obj)
Copy construct from base class.
Definition: pTraits.H:61
Istream & operator>>(Istream &, directionInfo &)
char readChar(Istream &is)
Read single character.
Definition: char.C:40
const direction noexcept
Definition: Scalar.H:258
OBJstream os(runTime.globalPath()/outputName)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:76
const dimensionedScalar c
Speed of light in a vacuum.
bool isspace(char c) noexcept
Test for whitespace (C-locale)
Definition: char.H:71
Namespace for OpenFOAM.