Loading...
Searching...
No Matches
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,2025 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#include "pTraits.H"
42
43// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44
45namespace Foam
46{
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50//- Read single character
51char readChar(Istream& is);
52
53//- Read single character
54Istream& operator>>(Istream& is, char& c);
55
56//- Write single character
57Ostream& operator<<(Ostream& os, const char c);
58
59//- Write a nul-terminated C-string
60Ostream& operator<<(Ostream& os, const char* str);
61
62//- Test for digits [0-9] (C-locale only)
63inline constexpr bool isdigit(char c) noexcept
64{
65 return (c >= '0' && c <= '9');
66}
67
68//- Test for whitespace (C-locale only)
69inline constexpr bool isspace(char c) noexcept
70{
71 return
72 (
73 c == ' ' // (0x20) space (SPC)
74 || c == '\t' // (0x09) horizontal tab (TAB)
75 || c == '\n' // (0x0a) newline (LF)
76 || c == '\v' // (0x0b) vertical tab (VT)
77 || c == '\f' // (0x0c) feed (FF)
78 || c == '\r' // (0x0d) carriage return (CR)
79 );
80}
81
82
83/*---------------------------------------------------------------------------*\
84 Specialization pTraits<char>
85\*---------------------------------------------------------------------------*/
86
87//- Template specialisation for pTraits<char>
88template<>
89class pTraits<char>
90{
91 char p_;
92
93public:
94
95 // Static Data Members
96
97 static const char* const typeName;
98
100 // Constructors
101
102 //- Copy construct from primitive
103 explicit pTraits(char val) noexcept : p_(val) {}
104
105 //- Read construct from Istream
106 explicit pTraits(Istream& is);
108
109 // Member Functions
110
111 //- Return the value
112 operator char() const noexcept { return p_; }
113
114 //- Access the value
115 operator char&() noexcept { return p_; }
116};
117
118
119// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120
121} // End namespace Foam
122
123// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124
125#endif
126
127// ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
pTraits(char val) noexcept
Copy construct from primitive.
Definition char.H:115
static const char *const typeName
Definition char.H:107
pTraits(const Base &obj)
Copy construct from base class.
Definition pTraits.H:72
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
constexpr bool isspace(char c) noexcept
Test for whitespace (C-locale only).
Definition char.H:77
char readChar(Istream &is)
Read single character.
Definition char.C:40
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Istream & operator>>(Istream &, directionInfo &)
const direction noexcept
Definition scalarImpl.H:265
constexpr bool isdigit(char c) noexcept
Test for digits [0-9] (C-locale only).
Definition char.H:69