mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add pTraits for uint8_t
This commit is contained in:
@ -44,7 +44,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
//NONE Info<<"int16:" << pTraits<int16_t>::max << nl;
|
//NONE Info<<"int16:" << pTraits<int16_t>::max << nl;
|
||||||
Info<< "=max=" << nl;
|
Info<< "=max=" << nl;
|
||||||
Info<< "uint8:" << std::numeric_limits<uint8_t>::max() << nl;
|
Info<< "uint8:" << pTraits<uint8_t>::max << nl;
|
||||||
Info<< "int16:" << std::numeric_limits<int16_t>::max() << nl;
|
Info<< "int16:" << std::numeric_limits<int16_t>::max() << nl;
|
||||||
Info<< "int32:" << pTraits<int32_t>::max << nl;
|
Info<< "int32:" << pTraits<int32_t>::max << nl;
|
||||||
Info<< "uint32:" << pTraits<uint32_t>::max << nl;
|
Info<< "uint32:" << pTraits<uint32_t>::max << nl;
|
||||||
|
|||||||
@ -37,6 +37,8 @@ $(chars)/wchar/wcharIO.C
|
|||||||
primitives/direction/directionIO.C
|
primitives/direction/directionIO.C
|
||||||
|
|
||||||
ints = primitives/ints
|
ints = primitives/ints
|
||||||
|
$(ints)/uint8/uint8.C
|
||||||
|
$(ints)/uint8/uint8IO.C
|
||||||
$(ints)/uint16/uint16.C
|
$(ints)/uint16/uint16.C
|
||||||
$(ints)/uint32/uint32.C
|
$(ints)/uint32/uint32.C
|
||||||
$(ints)/uint32/uint32IO.C
|
$(ints)/uint32/uint32IO.C
|
||||||
|
|||||||
@ -34,6 +34,8 @@ namespace Foam
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* const pTraits<Scalar>::typeName = "scalar";
|
const char* const pTraits<Scalar>::typeName = "scalar";
|
||||||
|
const char* const pTraits<Scalar>::componentNames[] = { "" };
|
||||||
|
|
||||||
const Scalar pTraits<Scalar>::zero = 0.0;
|
const Scalar pTraits<Scalar>::zero = 0.0;
|
||||||
const Scalar pTraits<Scalar>::one = 1.0;
|
const Scalar pTraits<Scalar>::one = 1.0;
|
||||||
const Scalar pTraits<Scalar>::min = -ScalarVGREAT;
|
const Scalar pTraits<Scalar>::min = -ScalarVGREAT;
|
||||||
@ -42,8 +44,6 @@ const Scalar pTraits<Scalar>::rootMin = -ScalarROOTVGREAT;
|
|||||||
const Scalar pTraits<Scalar>::rootMax = ScalarROOTVGREAT;
|
const Scalar pTraits<Scalar>::rootMax = ScalarROOTVGREAT;
|
||||||
const Scalar pTraits<Scalar>::vsmall = ScalarVSMALL;
|
const Scalar pTraits<Scalar>::vsmall = ScalarVSMALL;
|
||||||
|
|
||||||
const char* const pTraits<Scalar>::componentNames[] = { "" };
|
|
||||||
|
|
||||||
|
|
||||||
pTraits<Scalar>::pTraits(const Scalar& val)
|
pTraits<Scalar>::pTraits(const Scalar& val)
|
||||||
:
|
:
|
||||||
|
|||||||
@ -34,10 +34,11 @@ License
|
|||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
const char* const Foam::pTraits<bool>::typeName = "bool";
|
const char* const Foam::pTraits<bool>::typeName = "bool";
|
||||||
|
const char* const Foam::pTraits<bool>::componentNames[] = { "" };
|
||||||
|
|
||||||
const bool Foam::pTraits<bool>::zero = false;
|
const bool Foam::pTraits<bool>::zero = false;
|
||||||
const bool Foam::pTraits<bool>::one = true;
|
const bool Foam::pTraits<bool>::one = true;
|
||||||
|
|
||||||
const char* const Foam::pTraits<bool>::componentNames[] = { "" };
|
|
||||||
|
|
||||||
Foam::pTraits<bool>::pTraits(const bool& p)
|
Foam::pTraits<bool>::pTraits(const bool& p)
|
||||||
:
|
:
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -27,13 +28,16 @@ Primitive
|
|||||||
direction
|
direction
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Direction is an 8-bit unsigned integer type used to represent the Cartesian
|
Direction is an 8-bit unsigned integer type used to represent
|
||||||
directions etc.
|
Cartesian directions, components etc.
|
||||||
|
|
||||||
|
Note
|
||||||
|
If a different typedef is used, "uint8.H" must be modified accordingly.
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifndef direction_H
|
#ifndef primitives_direction_H
|
||||||
#define direction_H
|
#define primitives_direction_H
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -43,6 +47,7 @@ Description
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
class Istream;
|
class Istream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
@ -50,10 +55,14 @@ class Ostream;
|
|||||||
|
|
||||||
typedef uint8_t direction;
|
typedef uint8_t direction;
|
||||||
|
|
||||||
|
//- Read direction (uint8_t) from stream.
|
||||||
direction readDirection(Istream& is);
|
direction readDirection(Istream& is);
|
||||||
Istream& operator>>(Istream& is, direction& d);
|
|
||||||
Ostream& operator<<(Ostream& os, const direction d);
|
Istream& operator>>(Istream& is, direction& val);
|
||||||
std::ostream& operator<<(std::ostream& os, const direction d);
|
Ostream& operator<<(Ostream& os, const direction val);
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream& os, const direction val);
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2016 OpenFOAM Foundation
|
Copyright (C) 2016 OpenFOAM Foundation
|
||||||
Copyright (C) 2018 OpenCFD Ltd.
|
Copyright (C) 2018-2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -40,7 +40,7 @@ Foam::direction Foam::readDirection(Istream& is)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Istream& Foam::operator>>(Istream& is, direction& d)
|
Foam::Istream& Foam::operator>>(Istream& is, direction& val)
|
||||||
{
|
{
|
||||||
token t(is);
|
token t(is);
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ Foam::Istream& Foam::operator>>(Istream& is, direction& d)
|
|||||||
|
|
||||||
if (t.isLabel())
|
if (t.isLabel())
|
||||||
{
|
{
|
||||||
d = direction(t.labelToken());
|
val = direction(t.labelToken());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -72,17 +72,17 @@ Foam::Istream& Foam::operator>>(Istream& is, direction& d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const direction d)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const direction val)
|
||||||
{
|
{
|
||||||
os.write(label(d));
|
os.write(label(val));
|
||||||
os.check(FUNCTION_NAME);
|
os.check(FUNCTION_NAME);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::ostream& Foam::operator<<(std::ostream& os, const direction d)
|
std::ostream& Foam::operator<<(std::ostream& os, const direction val)
|
||||||
{
|
{
|
||||||
os << int(d);
|
os << int(val);
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,6 +45,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
class Istream;
|
class Istream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,8 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* const Foam::pTraits<int32_t>::componentNames[] = { "" };
|
||||||
|
|
||||||
const int32_t Foam::pTraits<int32_t>::zero = 0;
|
const int32_t Foam::pTraits<int32_t>::zero = 0;
|
||||||
const int32_t Foam::pTraits<int32_t>::one = 1;
|
const int32_t Foam::pTraits<int32_t>::one = 1;
|
||||||
const int32_t Foam::pTraits<int32_t>::min = INT32_MIN;
|
const int32_t Foam::pTraits<int32_t>::min = INT32_MIN;
|
||||||
@ -37,8 +39,6 @@ const int32_t Foam::pTraits<int32_t>::max = INT32_MAX;
|
|||||||
const int32_t Foam::pTraits<int32_t>::rootMin = pTraits<int32_t>::min;
|
const int32_t Foam::pTraits<int32_t>::rootMin = pTraits<int32_t>::min;
|
||||||
const int32_t Foam::pTraits<int32_t>::rootMax = pTraits<int32_t>::max;
|
const int32_t Foam::pTraits<int32_t>::rootMax = pTraits<int32_t>::max;
|
||||||
|
|
||||||
const char* const Foam::pTraits<int32_t>::componentNames[] = { "" };
|
|
||||||
|
|
||||||
Foam::pTraits<int32_t>::pTraits(const int32_t& val)
|
Foam::pTraits<int32_t>::pTraits(const int32_t& val)
|
||||||
:
|
:
|
||||||
p_(val)
|
p_(val)
|
||||||
|
|||||||
@ -43,15 +43,16 @@ SourceFiles
|
|||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "word.H"
|
|
||||||
#include "pTraits.H"
|
|
||||||
#include "direction.H"
|
#include "direction.H"
|
||||||
|
#include "pTraits.H"
|
||||||
|
#include "word.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
class Istream;
|
class Istream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
|
|||||||
@ -78,6 +78,15 @@ bool Foam::readInt32(const char* buf, int32_t& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int32_t Foam::readInt32(Istream& is)
|
||||||
|
{
|
||||||
|
int32_t val(0);
|
||||||
|
is >> val;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Istream& Foam::operator>>(Istream& is, int32_t& val)
|
Foam::Istream& Foam::operator>>(Istream& is, int32_t& val)
|
||||||
{
|
{
|
||||||
token t(is);
|
token t(is);
|
||||||
@ -138,15 +147,6 @@ Foam::Istream& Foam::operator>>(Istream& is, int32_t& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int32_t Foam::readInt32(Istream& is)
|
|
||||||
{
|
|
||||||
int32_t val(0);
|
|
||||||
is >> val;
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const int32_t val)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const int32_t val)
|
||||||
{
|
{
|
||||||
os.write(label(val));
|
os.write(label(val));
|
||||||
|
|||||||
@ -30,6 +30,8 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* const Foam::pTraits<int64_t>::componentNames[] = { "" };
|
||||||
|
|
||||||
const int64_t Foam::pTraits<int64_t>::zero = 0;
|
const int64_t Foam::pTraits<int64_t>::zero = 0;
|
||||||
const int64_t Foam::pTraits<int64_t>::one = 1;
|
const int64_t Foam::pTraits<int64_t>::one = 1;
|
||||||
const int64_t Foam::pTraits<int64_t>::min = INT64_MIN;
|
const int64_t Foam::pTraits<int64_t>::min = INT64_MIN;
|
||||||
@ -37,8 +39,6 @@ const int64_t Foam::pTraits<int64_t>::max = INT64_MAX;
|
|||||||
const int64_t Foam::pTraits<int64_t>::rootMin = pTraits<int64_t>::min;
|
const int64_t Foam::pTraits<int64_t>::rootMin = pTraits<int64_t>::min;
|
||||||
const int64_t Foam::pTraits<int64_t>::rootMax = pTraits<int64_t>::max;
|
const int64_t Foam::pTraits<int64_t>::rootMax = pTraits<int64_t>::max;
|
||||||
|
|
||||||
const char* const Foam::pTraits<int64_t>::componentNames[] = { "" };
|
|
||||||
|
|
||||||
Foam::pTraits<int64_t>::pTraits(const int64_t& val)
|
Foam::pTraits<int64_t>::pTraits(const int64_t& val)
|
||||||
:
|
:
|
||||||
p_(val)
|
p_(val)
|
||||||
|
|||||||
@ -43,15 +43,16 @@ SourceFiles
|
|||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "word.H"
|
|
||||||
#include "pTraits.H"
|
|
||||||
#include "direction.H"
|
#include "direction.H"
|
||||||
|
#include "pTraits.H"
|
||||||
|
#include "word.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
class Istream;
|
class Istream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
|
|||||||
@ -78,6 +78,15 @@ bool Foam::readInt64(const char* buf, int64_t& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int64_t Foam::readInt64(Istream& is)
|
||||||
|
{
|
||||||
|
int64_t val(0);
|
||||||
|
is >> val;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Istream& Foam::operator>>(Istream& is, int64_t& val)
|
Foam::Istream& Foam::operator>>(Istream& is, int64_t& val)
|
||||||
{
|
{
|
||||||
token t(is);
|
token t(is);
|
||||||
@ -138,15 +147,6 @@ Foam::Istream& Foam::operator>>(Istream& is, int64_t& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int64_t Foam::readInt64(Istream& is)
|
|
||||||
{
|
|
||||||
int64_t val(0);
|
|
||||||
is >> val;
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const int64_t val)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const int64_t val)
|
||||||
{
|
{
|
||||||
os.write(label(val));
|
os.write(label(val));
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
|
Copyright (C) 2020 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -37,6 +38,7 @@ SourceFiles
|
|||||||
#ifndef uint_H
|
#ifndef uint_H
|
||||||
#define uint_H
|
#define uint_H
|
||||||
|
|
||||||
|
#include "uint8.H"
|
||||||
#include "uint16.H"
|
#include "uint16.H"
|
||||||
#include "uint32.H"
|
#include "uint32.H"
|
||||||
#include "uint64.H"
|
#include "uint64.H"
|
||||||
|
|||||||
@ -45,6 +45,7 @@ SourceFiles
|
|||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
class Istream;
|
class Istream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,8 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* const Foam::pTraits<uint32_t>::componentNames[] = { "" };
|
||||||
|
|
||||||
const uint32_t Foam::pTraits<uint32_t>::zero = 0;
|
const uint32_t Foam::pTraits<uint32_t>::zero = 0;
|
||||||
const uint32_t Foam::pTraits<uint32_t>::one = 1;
|
const uint32_t Foam::pTraits<uint32_t>::one = 1;
|
||||||
const uint32_t Foam::pTraits<uint32_t>::min = 0;
|
const uint32_t Foam::pTraits<uint32_t>::min = 0;
|
||||||
@ -37,8 +39,6 @@ const uint32_t Foam::pTraits<uint32_t>::max = UINT32_MAX;
|
|||||||
const uint32_t Foam::pTraits<uint32_t>::rootMin = 0;
|
const uint32_t Foam::pTraits<uint32_t>::rootMin = 0;
|
||||||
const uint32_t Foam::pTraits<uint32_t>::rootMax = pTraits<uint32_t>::max;
|
const uint32_t Foam::pTraits<uint32_t>::rootMax = pTraits<uint32_t>::max;
|
||||||
|
|
||||||
const char* const Foam::pTraits<uint32_t>::componentNames[] = { "" };
|
|
||||||
|
|
||||||
Foam::pTraits<uint32_t>::pTraits(const uint32_t& val)
|
Foam::pTraits<uint32_t>::pTraits(const uint32_t& val)
|
||||||
:
|
:
|
||||||
p_(val)
|
p_(val)
|
||||||
|
|||||||
@ -43,15 +43,16 @@ SourceFiles
|
|||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "word.H"
|
|
||||||
#include "pTraits.H"
|
|
||||||
#include "direction.H"
|
#include "direction.H"
|
||||||
|
#include "pTraits.H"
|
||||||
|
#include "word.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
class Istream;
|
class Istream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
|
|||||||
@ -77,6 +77,15 @@ bool Foam::readUint32(const char* buf, uint32_t& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t Foam::readUint32(Istream& is)
|
||||||
|
{
|
||||||
|
uint32_t val(0);
|
||||||
|
is >> val;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Istream& Foam::operator>>(Istream& is, uint32_t& val)
|
Foam::Istream& Foam::operator>>(Istream& is, uint32_t& val)
|
||||||
{
|
{
|
||||||
token t(is);
|
token t(is);
|
||||||
@ -137,15 +146,6 @@ Foam::Istream& Foam::operator>>(Istream& is, uint32_t& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t Foam::readUint32(Istream& is)
|
|
||||||
{
|
|
||||||
uint32_t val(0);
|
|
||||||
is >> val;
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const uint32_t val)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const uint32_t val)
|
||||||
{
|
{
|
||||||
os.write(label(val));
|
os.write(label(val));
|
||||||
|
|||||||
@ -30,6 +30,8 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* const Foam::pTraits<uint64_t>::componentNames[] = { "" };
|
||||||
|
|
||||||
const uint64_t Foam::pTraits<uint64_t>::zero = 0;
|
const uint64_t Foam::pTraits<uint64_t>::zero = 0;
|
||||||
const uint64_t Foam::pTraits<uint64_t>::one = 1;
|
const uint64_t Foam::pTraits<uint64_t>::one = 1;
|
||||||
const uint64_t Foam::pTraits<uint64_t>::min = 0;
|
const uint64_t Foam::pTraits<uint64_t>::min = 0;
|
||||||
@ -37,8 +39,6 @@ const uint64_t Foam::pTraits<uint64_t>::max = UINT64_MAX;
|
|||||||
const uint64_t Foam::pTraits<uint64_t>::rootMin = 0;
|
const uint64_t Foam::pTraits<uint64_t>::rootMin = 0;
|
||||||
const uint64_t Foam::pTraits<uint64_t>::rootMax = pTraits<uint64_t>::max;
|
const uint64_t Foam::pTraits<uint64_t>::rootMax = pTraits<uint64_t>::max;
|
||||||
|
|
||||||
const char* const Foam::pTraits<uint64_t>::componentNames[] = { "" };
|
|
||||||
|
|
||||||
Foam::pTraits<uint64_t>::pTraits(const uint64_t& val)
|
Foam::pTraits<uint64_t>::pTraits(const uint64_t& val)
|
||||||
:
|
:
|
||||||
p_(val)
|
p_(val)
|
||||||
|
|||||||
@ -43,15 +43,16 @@ SourceFiles
|
|||||||
#include <climits>
|
#include <climits>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
#include "word.H"
|
|
||||||
#include "pTraits.H"
|
|
||||||
#include "direction.H"
|
#include "direction.H"
|
||||||
|
#include "pTraits.H"
|
||||||
|
#include "word.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
namespace Foam
|
namespace Foam
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
class Istream;
|
class Istream;
|
||||||
class Ostream;
|
class Ostream;
|
||||||
|
|
||||||
|
|||||||
@ -77,6 +77,15 @@ bool Foam::readUint64(const char* buf, uint64_t& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint64_t Foam::readUint64(Istream& is)
|
||||||
|
{
|
||||||
|
uint64_t val(0);
|
||||||
|
is >> val;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::Istream& Foam::operator>>(Istream& is, uint64_t& val)
|
Foam::Istream& Foam::operator>>(Istream& is, uint64_t& val)
|
||||||
{
|
{
|
||||||
token t(is);
|
token t(is);
|
||||||
@ -137,15 +146,6 @@ Foam::Istream& Foam::operator>>(Istream& is, uint64_t& val)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint64_t Foam::readUint64(Istream& is)
|
|
||||||
{
|
|
||||||
uint64_t val(0);
|
|
||||||
is >> val;
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::Ostream& Foam::operator<<(Ostream& os, const uint64_t val)
|
Foam::Ostream& Foam::operator<<(Ostream& os, const uint64_t val)
|
||||||
{
|
{
|
||||||
os.write(label(val));
|
os.write(label(val));
|
||||||
|
|||||||
54
src/OpenFOAM/primitives/ints/uint8/uint8.C
Normal file
54
src/OpenFOAM/primitives/ints/uint8/uint8.C
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2020 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "uint8.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const char* const Foam::pTraits<uint8_t>::typeName = "uint8";
|
||||||
|
const char* const Foam::pTraits<uint8_t>::componentNames[] = { "" };
|
||||||
|
|
||||||
|
const uint8_t Foam::pTraits<uint8_t>::zero = 0;
|
||||||
|
const uint8_t Foam::pTraits<uint8_t>::one = 1;
|
||||||
|
const uint8_t Foam::pTraits<uint8_t>::min = 0;
|
||||||
|
const uint8_t Foam::pTraits<uint8_t>::max = UINT8_MAX;
|
||||||
|
const uint8_t Foam::pTraits<uint8_t>::rootMin = 0;
|
||||||
|
const uint8_t Foam::pTraits<uint8_t>::rootMax = UINT8_MAX;
|
||||||
|
|
||||||
|
|
||||||
|
Foam::pTraits<uint8_t>::pTraits(const uint8_t& val)
|
||||||
|
:
|
||||||
|
p_(val)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Foam::pTraits<uint8_t>::pTraits(Istream& is)
|
||||||
|
{
|
||||||
|
is >> p_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
159
src/OpenFOAM/primitives/ints/uint8/uint8.H
Normal file
159
src/OpenFOAM/primitives/ints/uint8/uint8.H
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2020 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Primitive
|
||||||
|
uint8_t
|
||||||
|
|
||||||
|
Description
|
||||||
|
8bit unsigned integer
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
uint8.C
|
||||||
|
uint8IO.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef primitives_uint8_H
|
||||||
|
#define primitives_uint8_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <climits>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
#include "direction.H"
|
||||||
|
#include "pTraits.H"
|
||||||
|
#include "word.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward Declarations
|
||||||
|
class Istream;
|
||||||
|
class Ostream;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//- A word representation of uint8 value
|
||||||
|
inline word name(const uint8_t val)
|
||||||
|
{
|
||||||
|
return word(std::to_string(int(val)), false); // Needs no stripping
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- A word representation of uint8 value
|
||||||
|
template<>
|
||||||
|
struct nameOp<uint8_t>
|
||||||
|
{
|
||||||
|
inline word operator()(const uint8_t val) const
|
||||||
|
{
|
||||||
|
return word(std::to_string(int(val)), false); // Needs no stripping
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//- Read uint8_t from stream.
|
||||||
|
uint8_t readUint8(Istream& is);
|
||||||
|
|
||||||
|
// IO operators are identical to direction, which is uint8_t
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//- Template specialization for pTraits<uint8_t>
|
||||||
|
template<>
|
||||||
|
class pTraits<uint8_t>
|
||||||
|
{
|
||||||
|
uint8_t p_;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Typedefs
|
||||||
|
|
||||||
|
//- Component type
|
||||||
|
typedef uint8_t cmptType;
|
||||||
|
|
||||||
|
|
||||||
|
// Member Constants
|
||||||
|
|
||||||
|
//- Dimensionality of space
|
||||||
|
static constexpr direction dim = 3;
|
||||||
|
|
||||||
|
//- Rank of uint8_t is 0
|
||||||
|
static constexpr direction rank = 0;
|
||||||
|
|
||||||
|
//- Number of components in uint8_t is 1
|
||||||
|
static constexpr direction nComponents = 1;
|
||||||
|
|
||||||
|
|
||||||
|
// Static Data Members
|
||||||
|
|
||||||
|
static const char* const typeName;
|
||||||
|
static const char* const componentNames[];
|
||||||
|
static const uint8_t zero;
|
||||||
|
static const uint8_t one;
|
||||||
|
static const uint8_t min;
|
||||||
|
static const uint8_t max;
|
||||||
|
static const uint8_t rootMax;
|
||||||
|
static const uint8_t rootMin;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Copy construct from primitive
|
||||||
|
explicit pTraits(const uint8_t& val);
|
||||||
|
|
||||||
|
//- Read construct from Istream
|
||||||
|
explicit pTraits(Istream& is);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Access to the value
|
||||||
|
operator uint8_t() const
|
||||||
|
{
|
||||||
|
return p_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Access to the value
|
||||||
|
operator uint8_t&()
|
||||||
|
{
|
||||||
|
return p_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
44
src/OpenFOAM/primitives/ints/uint8/uint8IO.C
Normal file
44
src/OpenFOAM/primitives/ints/uint8/uint8IO.C
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2020 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "uint8.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
uint8_t Foam::readUint8(Istream& is)
|
||||||
|
{
|
||||||
|
uint8_t val(0);
|
||||||
|
is >> val;
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
// IO operators are identical to direction, which is uint8_t
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Reference in New Issue
Block a user