Pair: Updated IO to ASCII only, consistent with Tuple2

This commit is contained in:
Henry Weller
2020-12-21 12:08:22 +00:00
parent 17796ffa17
commit 7652fe14fa
2 changed files with 55 additions and 20 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -37,13 +37,24 @@ See also
#define Pair_H
#include "FixedList.H"
#include "Istream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
template<class Type>
class Pair;
template<class Type>
inline Istream& operator>>(Istream&, Pair<Type>&);
template<class Type>
inline Ostream& operator<<(Ostream&, const Pair<Type>&);
/*---------------------------------------------------------------------------*\
Class Pair Declaration
\*---------------------------------------------------------------------------*/
@ -77,9 +88,9 @@ public:
//- Construct from Istream
inline Pair(Istream& is)
:
FixedList<Type, 2>(is)
{}
{
is >> *this;
}
// Member Functions
@ -215,6 +226,31 @@ bool operator>=(const Pair<Type>& a, const Pair<Type>& b)
}
template<class Type>
inline Istream& operator>>(Istream& is, Pair<Type>& p)
{
is.readBegin("Pair");
is >> p.first() >> p.second();
is.readEnd("Pair");
// Check state of Istream
is.check("operator>>(Istream&, Pair<Type>&)");
return is;
}
template<class Type>
inline Ostream& operator<<(Ostream& os, const Pair<Type>& p)
{
os << token::BEGIN_LIST
<< p.first() << token::SPACE << p.second()
<< token::END_LIST;
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,7 +48,6 @@ namespace Foam
template<class T, unsigned Size> class FixedList;
template<class T> class Pair;
//- Assume the data associated with type T are not contiguous
template<class T>
inline bool contiguous() {return false;}
@ -58,91 +57,91 @@ inline bool contiguous() {return false;}
// - only size 2 defined here) are contiguous
template<>
inline bool contiguous<bool>() {return true;}
inline bool contiguous<bool>() {return true;}
template<>
inline bool contiguous<FixedList<bool, 2>>() {return true;}
template<>
inline bool contiguous<Pair<bool>>() {return true;}
template<>
inline bool contiguous<char>() {return true;}
inline bool contiguous<char>() {return true;}
template<>
inline bool contiguous<FixedList<char, 2>>() {return true;}
template<>
inline bool contiguous<Pair<char>>() {return true;}
template<>
inline bool contiguous<int8_t>() {return true;}
inline bool contiguous<int8_t>() {return true;}
template<>
inline bool contiguous<FixedList<int8_t, 2>>() {return true;}
template<>
inline bool contiguous<Pair<int8_t>>() {return true;}
template<>
inline bool contiguous<uint8_t>() {return true;}
inline bool contiguous<uint8_t>() {return true;}
template<>
inline bool contiguous<FixedList<uint8_t, 2>>() {return true;}
template<>
inline bool contiguous<Pair<uint8_t>>() {return true;}
template<>
inline bool contiguous<int16_t>() {return true;}
inline bool contiguous<int16_t>() {return true;}
template<>
inline bool contiguous<FixedList<int16_t, 2>>() {return true;}
template<>
inline bool contiguous<Pair<int16_t>>() {return true;}
template<>
inline bool contiguous<uint16_t>() {return true;}
inline bool contiguous<uint16_t>() {return true;}
template<>
inline bool contiguous<FixedList<uint16_t, 2>>() {return true;}
template<>
inline bool contiguous<Pair<uint16_t>>() {return true;}
template<>
inline bool contiguous<int32_t>() {return true;}
inline bool contiguous<int32_t>() {return true;}
template<>
inline bool contiguous<FixedList<int32_t, 2>>() {return true;}
template<>
inline bool contiguous<Pair<int32_t>>() {return true;}
template<>
inline bool contiguous<uint32_t>() {return true;}
inline bool contiguous<uint32_t>() {return true;}
template<>
inline bool contiguous<FixedList<uint32_t, 2>>() {return true;}
template<>
inline bool contiguous<Pair<uint32_t>>() {return true;}
template<>
inline bool contiguous<int64_t>() {return true;}
inline bool contiguous<int64_t>() {return true;}
template<>
inline bool contiguous<FixedList<int64_t, 2>>() {return true;}
template<>
inline bool contiguous<Pair<int64_t>>() {return true;}
template<>
inline bool contiguous<uint64_t>() {return true;}
inline bool contiguous<uint64_t>() {return true;}
template<>
inline bool contiguous<FixedList<uint64_t, 2>>() {return true;}
template<>
inline bool contiguous<Pair<uint64_t>>() {return true;}
template<>
inline bool contiguous<float>() {return true;}
inline bool contiguous<float>() {return true;}
template<>
inline bool contiguous<FixedList<float, 2>>() {return true;}
template<>
inline bool contiguous<Pair<float>>() {return true;}
template<>
inline bool contiguous<double>() {return true;}
inline bool contiguous<double>() {return true;}
template<>
inline bool contiguous<FixedList<double, 2>>() {return true;}
template<>
inline bool contiguous<Pair<double>>() {return true;}
template<>
inline bool contiguous<long double>() {return true;}
inline bool contiguous<long double>() {return true;}
template<>
inline bool contiguous<FixedList<long double, 2>>() {return true;}
template<>