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 char_H
39 #define 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(const char p) noexcept;
107 
108  //- Read construct from Istream
109  explicit pTraits(Istream& is);
110 
111 
112  // Member Functions
113 
114  //- Read access to primitive value
115  operator char() const noexcept
116  {
117  return p_;
118  }
119 
120  //- Write access to primitive value
121  operator char&() noexcept
122  {
123  return p_;
124  }
125 };
126 
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 } // End namespace Foam
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 #endif
135 
136 // ************************************************************************* //
Foam::pTraits::pTraits
pTraits(const Base &obj)
Copy construct from base class.
Definition: pTraits.H:65
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::pTraits< char >::typeName
static const char *const typeName
Definition: char.H:100
Foam::isspace
bool isspace(char c) noexcept
Test for whitespace (C-locale)
Definition: char.H:65
Foam::readChar
char readChar(Istream &is)
Read single character.
Definition: char.C:53
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
os
OBJstream os(runTime.globalPath()/outputName)
pTraits.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::constant::universal::c
const dimensionedScalar c
Speed of light in a vacuum.