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-------------------------------------------------------------------------------
11License
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
27Primitive
28 char
29
30Description
31 A character and a pointer to a character string.
32
33SourceFiles
34 char.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef Foam_primitives_char_H
39#define Foam_primitives_char_H
40
41// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42
43namespace Foam
44{
45
46// Forward Declarations
47class Istream;
48class Ostream;
49
50// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51
52//- Read single character
53char readChar(Istream& is);
54
55//- Read single character
56Istream& operator>>(Istream& is, char& c);
57
58//- Write single character
59Ostream& operator<<(Ostream& os, const char c);
60
61//- Write a nul-terminated C-string
62Ostream& operator<<(Ostream& os, const char* str);
63
64//- Test for whitespace (C-locale)
65inline 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
87namespace Foam
88{
89
90//- Template specialisation for pTraits<char>
91template<>
92class pTraits<char>
93{
94 char p_;
95
96public:
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
116
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// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132
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:64
pTraits(char val) noexcept
Copy construct from primitive.
Definition: char.H:106
static const char *const typeName
Definition: char.H:100
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
bool isspace(char c) noexcept
Test for whitespace (C-locale)
Definition: char.H:65
char readChar(Istream &is)
Read single character.
Definition: char.C:47
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Istream & operator>>(Istream &, directionInfo &)
const direction noexcept
Definition: Scalar.H:223