Commit 1458b4f6 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

ENH: remove uniform compact output for FixedList (#1160)

- a FixedList is generally small so there is little advantage
  in a compact output form for uniform content.  Eg, "2{-1}"

  By avoiding this compact form we obtain output that is also
  consistent with Tuple2, for example.

- make FixedList construct from Istream explicit
parent 8eefc7b3
...@@ -180,7 +180,7 @@ public: ...@@ -180,7 +180,7 @@ public:
inline explicit FixedList(const SLList<T>& list); inline explicit FixedList(const SLList<T>& list);
//- Construct from Istream //- Construct from Istream
FixedList(Istream& is); explicit FixedList(Istream& is);
//- Clone //- Clone
inline autoPtr<FixedList<T, Size>> clone() const; inline autoPtr<FixedList<T, Size>> clone() const;
......
...@@ -29,7 +29,6 @@ License ...@@ -29,7 +29,6 @@ License
#include "token.H" #include "token.H"
#include "contiguous.H" #include "contiguous.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
template<class T, unsigned Size> template<class T, unsigned Size>
...@@ -70,15 +69,14 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList ...@@ -70,15 +69,14 @@ Foam::Ostream& Foam::FixedList<T, Size>::writeList
const FixedList<T, Size>& list = *this; const FixedList<T, Size>& list = *this;
// Write list contents depending on data format // Write list contents depending on data format
// Unlike UList, no compact output form (eg, "2{-1}") since a
// FixedList is generally small and we also want the same appearance
// for FixedList<T, 2> as Tuple2<T,T>
if (os.format() == IOstream::ASCII || !contiguous<T>()) if (os.format() == IOstream::ASCII || !contiguous<T>())
{ {
if (contiguous<T>() && list.uniform()) if
{
// Two or more entries, and all entries have identical values.
os << Size << token::BEGIN_BLOCK << list[0] << token::END_BLOCK;
}
else if
( (
Size <= 1 || !shortListLen Size <= 1 || !shortListLen
|| (Size <= unsigned(shortListLen) && contiguous<T>()) || (Size <= unsigned(shortListLen) && contiguous<T>())
...@@ -145,7 +143,8 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& list) ...@@ -145,7 +143,8 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList<T, Size>& list)
is.fatalCheck is.fatalCheck
( (
"operator>>(Istream&, FixedList<T, Size>&) : reading first token" "operator>>(Istream&, FixedList<T, Size>&) : "
"reading first token"
); );
if (firstToken.isCompound()) if (firstToken.isCompound())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment