foamEndian.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) 2016-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::endian
28 
29 Description
30  Help with architecture-specific aspects, primarily used
31  as a namespace, but defined as a class to allow pTraits specialization.
32 
33 SourceFiles
34  foamEndianI.H
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_foamEndian_H
39 #define Foam_foamEndian_H
40 
41 #include "foamEndianFwd.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class endian Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class endian
53 {
54 public:
55 
56  // Public Methods
57 
58  // FUTURE?
59  // #if defined (WM_BIG_ENDIAN)
60  // //- The endian name as a string
61  // static constexpr const char* name() noexcept { return "MSB"; }
62  // #else
63  // //- The endian name as a string
64  // static constexpr const char* name() noexcept { return "LSB"; }
65  // #endif
66 
67  //- Runtime check for big endian.
68  inline static bool isBig() noexcept;
69 
70  //- Runtime check for little endian.
71  inline static bool isLittle() noexcept;
72 
73  //- Byte endian swapping for 32-bits
74  inline static uint32_t swap32(uint32_t);
75 
76  //- Byte endian swapping for 64-bits
77  inline static uint64_t swap64(uint64_t);
78 };
79 
80 
81 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
82 
83 } // End namespace Foam
84 
85 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 
87 #include "foamEndianI.H"
88 
89 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
90 
91 #endif
92 
93 // ************************************************************************* //
static uint32_t swap32(uint32_t)
Byte endian swapping for 32-bits.
Definition: foamEndianI.H:54
const direction noexcept
Definition: Scalar.H:258
static bool isLittle() noexcept
Runtime check for little endian.
Definition: foamEndianI.H:45
Define WM_BIG_ENDIAN or WM_LITTLE_ENDIAN and forward declare Foam::endian class.
static bool isBig() noexcept
Runtime check for big endian.
Definition: foamEndianI.H:36
Help with architecture-specific aspects, primarily used as a namespace, but defined as a class to all...
Definition: foamEndian.H:47
static uint64_t swap64(uint64_t)
Byte endian swapping for 64-bits.
Definition: foamEndianI.H:76
Namespace for OpenFOAM.