diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 72fdd52a9b..cf8d885a98 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -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-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -160,7 +160,6 @@ public: // Member Functions - // Access //- Return the forward circular index, i.e. the next index @@ -213,17 +212,28 @@ public: inline void checkIndex(const label i) const; - //- Copy the pointer held by the given UList - inline void shallowCopy(const UList&); + // Edit - //- Copy elements of the given UList - void deepCopy(const UList&); + //- Copy the pointer held by the given UList + inline void shallowCopy(const UList&); - //- Write the UList as a dictionary entry - void writeEntry(Ostream&) const; + //- Copy elements of the given UList + void deepCopy(const UList&); - //- Write the UList as a dictionary entry with keyword - void writeEntry(const word& keyword, Ostream&) const; + + // Write + + //- Write the UList as a dictionary entry + void writeEntry(Ostream&) const; + + //- Write the UList as a dictionary entry with keyword + void writeEntry(const word& keyword, Ostream&) const; + + //- Write the UList as a dictionary entry + void writeEntryList(Ostream&) const; + + //- Write the UList as a dictionary entry with keyword + void writeEntryList(const word& keyword, Ostream&) const; // Member operators diff --git a/src/OpenFOAM/containers/Lists/UList/UListIO.C b/src/OpenFOAM/containers/Lists/UList/UListIO.C index 269e62c625..2e92c9549e 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListIO.C +++ b/src/OpenFOAM/containers/Lists/UList/UListIO.C @@ -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-2019 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,7 +29,7 @@ License #include "SLList.H" #include "contiguous.H" -// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::UList::writeEntry(Ostream& os) const @@ -59,6 +59,35 @@ void Foam::UList::writeEntry(const word& keyword, Ostream& os) const } +template +void Foam::UList::writeEntryList(Ostream& os) const +{ + // Write size and start delimiter + os << nl << size() << nl << token::BEGIN_LIST; + + // Write contents + forAll(*this, i) + { + this->operator[](i).writeEntry(os); + os << nl; + } + + // Write end delimiter + os << nl << token::END_LIST << nl; +} + + +template +void Foam::UList::writeEntryList(const word& keyword, Ostream& os) const +{ + os.writeKeyword(keyword); + writeEntryList(os); + os << token::END_STATEMENT << endl; +} + + +// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // + template Foam::Ostream& Foam::operator<<(Foam::Ostream& os, const Foam::UList& L) {