COMP/STYLE: change read() -> readIstream() for private methods

- this eliminates a degree of ambiguity when resolving a read() method
  in inherited classes.
This commit is contained in:
Mark Olesen
2018-07-24 09:23:46 +02:00
parent 94a89d530a
commit d362c2235b
14 changed files with 108 additions and 79 deletions

View File

@ -56,7 +56,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Forward declaration of friend functions and operators // Forward declarations
template<class IDLListType, class T> template<class IDLListType, class T>
class DictionaryBase; class DictionaryBase;
@ -96,34 +96,34 @@ public:
DictionaryBase(const label size = 128); DictionaryBase(const label size = 128);
//- Copy construct //- Copy construct
DictionaryBase(const DictionaryBase&); DictionaryBase(const DictionaryBase& dict);
//- Construct from Istream using given Istream constructor class //- Construct from Istream using given Istream constructor class
template<class INew> template<class INew>
DictionaryBase(Istream&, const INew&); DictionaryBase(Istream& is, const INew& inew);
//- Construct from Istream using default Istream constructor class //- Construct from Istream using default Istream constructor class
DictionaryBase(Istream&); DictionaryBase(Istream& is);
// Member functions // Member functions
// Search and lookup // Search and lookup
//- Search DictionaryBase for given keyword //- Search for given keyword
bool found(const word&) const; bool found(const word& keyword) const;
//- Find and return an entry if present, otherwise return nullptr //- Find and return an entry if present, otherwise return nullptr
const T* lookupPtr(const word&) const; const T* lookupPtr(const word& keyword) const;
//- Find and return an entry if present, otherwise return nullptr //- Find and return an entry if present, otherwise return nullptr
T* lookupPtr(const word&); T* lookupPtr(const word& keyword);
//- Find and return entry //- Find and return entry
const T* lookup(const word&) const; const T* lookup(const word& keyword) const;
//- Find and return entry //- Find and return entry
T* lookup(const word&); T* lookup(const word& keyword);
//- Return the table of contents //- Return the table of contents
wordList toc() const; wordList toc() const;

View File

@ -56,6 +56,4 @@ Foam::PtrDictionary<T>::PtrDictionary(Istream& is)
{} {}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* // // ************************************************************************* //

View File

@ -64,14 +64,14 @@ public:
PtrDictionary(const label size = 128); PtrDictionary(const label size = 128);
//- Copy construct //- Copy construct
PtrDictionary(const PtrDictionary&); PtrDictionary(const PtrDictionary& dict);
//- Construct from Istream using given Istream constructor class //- Construct from Istream using given Istream constructor class
template<class INew> template<class INew>
PtrDictionary(Istream&, const INew&); PtrDictionary(Istream& is, const INew& inew);
//- Construct from Istream //- Construct from Istream
PtrDictionary(Istream&); PtrDictionary(Istream& is);
// Member operators // Member operators

View File

@ -64,14 +64,14 @@ public:
PtrListDictionary(const label size); PtrListDictionary(const label size);
//- Copy construct //- Copy construct
PtrListDictionary(const PtrListDictionary&); PtrListDictionary(const PtrListDictionary& dict);
//- Construct from Istream using given Istream constructor class //- Construct from Istream using given Istream constructor class
template<class INew> template<class INew>
PtrListDictionary(Istream&, const INew&); PtrListDictionary(Istream& is, const INew& inew);
//- Construct from Istream //- Construct from Istream
PtrListDictionary(Istream&); PtrListDictionary(Istream& is);
// Member functions // Member functions

View File

@ -69,11 +69,11 @@ class HashPtrTable
{ {
// Private Member Functions // Private Member Functions
//- Read from Istream using given Istream constructor class //- Read from Istream using Istream constructor class
template<class INew> template<class INew>
void read(Istream& is, const INew& inew); void readIstream(Istream& is, const INew& inew);
//- Read from dictionary using given dictionary constructor class //- Read from dictionary using Istream constructor class
template<class INew> template<class INew>
void read(const dictionary& dict, const INew& inew); void read(const dictionary& dict, const INew& inew);

View File

@ -33,7 +33,11 @@ License
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
template<class INew> template<class INew>
void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inew) void Foam::HashPtrTable<T, Key, Hash>::readIstream
(
Istream& is,
const INew& inew
)
{ {
is.fatalCheck(FUNCTION_NAME); is.fatalCheck(FUNCTION_NAME);
@ -41,7 +45,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inew)
is.fatalCheck is.fatalCheck
( (
"HashPtrTable::read(Istream&, const INew&) : " "HashPtrTable::readIstream : "
"reading first token" "reading first token"
); );
@ -69,7 +73,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inew)
is.fatalCheck is.fatalCheck
( (
"HashPtrTable::read(Istream&, const INew&) : " "HashPtrTable::readIstream : "
"reading entry" "reading entry"
); );
} }
@ -114,7 +118,7 @@ void Foam::HashPtrTable<T, Key, Hash>::read(Istream& is, const INew& inew)
is.fatalCheck is.fatalCheck
( (
"HashPtrTable::read(Istream&, const INew&) : " "HashPtrTable::readIstream : "
"reading entry" "reading entry"
); );
@ -172,14 +176,14 @@ template<class T, class Key, class Hash>
template<class INew> template<class INew>
Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(Istream& is, const INew& inew) Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(Istream& is, const INew& inew)
{ {
this->read(is, inew); this->readIstream(is, inew);
} }
template<class T, class Key, class Hash> template<class T, class Key, class Hash>
Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(Istream& is) Foam::HashPtrTable<T, Key, Hash>::HashPtrTable(Istream& is)
{ {
this->read(is, INew<T>()); this->readIstream(is, INew<T>());
} }
@ -196,7 +200,7 @@ template<class T, class Key, class Hash>
Foam::Istream& Foam::operator>>(Istream& is, HashPtrTable<T, Key, Hash>& tbl) Foam::Istream& Foam::operator>>(Istream& is, HashPtrTable<T, Key, Hash>& tbl)
{ {
tbl.clear(); tbl.clear();
tbl.read(is, INew<T>()); tbl.readIstream(is, INew<T>());
return is; return is;
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -69,7 +69,7 @@ class ILList
//- Read from Istream using given Istream constructor class //- Read from Istream using given Istream constructor class
template<class INew> template<class INew>
void read(Istream& is, const INew& inew); void readIstream(Istream& is, const INew& inew);
public: public:
@ -138,7 +138,7 @@ public:
friend Istream& operator>> <LListBase, T> friend Istream& operator>> <LListBase, T>
( (
Istream& is, Istream& is,
ILList<LListBase, T>& lst ILList<LListBase, T>& list
); );
}; };

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -31,13 +31,17 @@ License
template<class LListBase, class T> template<class LListBase, class T>
template<class INew> template<class INew>
void Foam::ILList<LListBase, T>::read(Istream& is, const INew& inew) void Foam::ILList<LListBase, T>::readIstream(Istream& is, const INew& inew)
{ {
is.fatalCheck(FUNCTION_NAME); is.fatalCheck(FUNCTION_NAME);
token firstToken(is); token firstToken(is);
is.fatalCheck("ILList::readList : reading first token"); is.fatalCheck
(
"ILList::readIstream : "
"reading first token"
);
if (firstToken.isLabel()) if (firstToken.isLabel())
{ {
@ -55,7 +59,11 @@ void Foam::ILList<LListBase, T>::read(Istream& is, const INew& inew)
T* p = inew(is).ptr(); T* p = inew(is).ptr();
this->append(p); this->append(p);
is.fatalCheck("ILList::readList : reading entry"); is.fatalCheck
(
"ILList::readIstream : "
"reading entry"
);
} }
} }
else else
@ -63,7 +71,11 @@ void Foam::ILList<LListBase, T>::read(Istream& is, const INew& inew)
T* p = inew(is).ptr(); T* p = inew(is).ptr();
this->append(p); this->append(p);
is.fatalCheck("ILList::readList : reading entry"); is.fatalCheck
(
"ILList::readIstream : "
"reading the single entry"
);
for (label i=1; i<len; ++i) for (label i=1; i<len; ++i)
{ {
@ -122,24 +134,24 @@ template<class LListBase, class T>
template<class INew> template<class INew>
Foam::ILList<LListBase, T>::ILList(Istream& is, const INew& inew) Foam::ILList<LListBase, T>::ILList(Istream& is, const INew& inew)
{ {
this->read(is, inew); this->readIstream(is, inew);
} }
template<class LListBase, class T> template<class LListBase, class T>
Foam::ILList<LListBase, T>::ILList(Istream& is) Foam::ILList<LListBase, T>::ILList(Istream& is)
{ {
this->read(is, INew<T>()); this->readIstream(is, INew<T>());
} }
// * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>
Foam::Istream& Foam::operator>>(Istream& is, ILList<LListBase, T>& lst) Foam::Istream& Foam::operator>>(Istream& is, ILList<LListBase, T>& list)
{ {
lst.clear(); list.clear();
lst.read(is, INew<T>()); list.readIstream(is, INew<T>());
return is; return is;
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -51,14 +51,14 @@ template<class LListBase, class T>
Istream& operator>> Istream& operator>>
( (
Istream& is, Istream& is,
LPtrList<LListBase, T>& lst LPtrList<LListBase, T>& list
); );
template<class LListBase, class T> template<class LListBase, class T>
Ostream& operator<< Ostream& operator<<
( (
Ostream& os, Ostream& os,
const LPtrList<LListBase, T>& lst const LPtrList<LListBase, T>& list
); );
@ -77,7 +77,7 @@ private:
//- Read from Istream using given Istream constructor class //- Read from Istream using given Istream constructor class
template<class INew> template<class INew>
void read(Istream& is, const INew& inew); void readIstream(Istream& is, const INew& inew);
public: public:
@ -419,13 +419,13 @@ public:
friend Istream& operator>> <LListBase, T> friend Istream& operator>> <LListBase, T>
( (
Istream& is, Istream& is,
LPtrList<LListBase, T>& lst LPtrList<LListBase, T>& list
); );
friend Ostream& operator<< <LListBase, T> friend Ostream& operator<< <LListBase, T>
( (
Ostream& os, Ostream& os,
const LPtrList<LListBase, T>& lst const LPtrList<LListBase, T>& list
); );
}; };

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -32,13 +32,17 @@ License
template<class LListBase, class T> template<class LListBase, class T>
template<class INew> template<class INew>
void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& inew) void Foam::LPtrList<LListBase, T>::readIstream(Istream& is, const INew& inew)
{ {
is.fatalCheck(FUNCTION_NAME); is.fatalCheck(FUNCTION_NAME);
token firstToken(is); token firstToken(is);
is.fatalCheck("LPtrList::readList : reading first token"); is.fatalCheck
(
"LPtrList::readIstream : "
"reading first token"
);
if (firstToken.isLabel()) if (firstToken.isLabel())
{ {
@ -56,7 +60,11 @@ void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& inew)
T* p = inew(is).ptr(); T* p = inew(is).ptr();
this->append(p); this->append(p);
is.fatalCheck("LPtrList::readList : reading entry"); is.fatalCheck
(
"LPtrList::readIstream : "
"reading entry"
);
} }
} }
else else
@ -64,7 +72,11 @@ void Foam::LPtrList<LListBase, T>::read(Istream& is, const INew& inew)
T* p = inew(is).ptr(); T* p = inew(is).ptr();
this->append(p); this->append(p);
is.fatalCheck("LPtrList::readList : reading entry"); is.fatalCheck
(
"LPtrList::readIstream : "
"reading the single entry"
);
for (label i=1; i<len; ++i) for (label i=1; i<len; ++i)
{ {
@ -125,24 +137,24 @@ template<class LListBase, class T>
template<class INew> template<class INew>
Foam::LPtrList<LListBase, T>::LPtrList(Istream& is, const INew& inew) Foam::LPtrList<LListBase, T>::LPtrList(Istream& is, const INew& inew)
{ {
this->read(is, inew); this->readIstream(is, inew);
} }
template<class LListBase, class T> template<class LListBase, class T>
Foam::LPtrList<LListBase, T>::LPtrList(Istream& is) Foam::LPtrList<LListBase, T>::LPtrList(Istream& is)
{ {
this->read(is, INew<T>()); this->readIstream(is, INew<T>());
} }
// * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>
Foam::Istream& Foam::operator>>(Istream& is, LPtrList<LListBase, T>& L) Foam::Istream& Foam::operator>>(Istream& is, LPtrList<LListBase, T>& list)
{ {
L.clear(); list.clear();
L.read(is, INew<T>()); list.readIstream(is, INew<T>());
return is; return is;
} }
@ -151,13 +163,17 @@ Foam::Istream& Foam::operator>>(Istream& is, LPtrList<LListBase, T>& L)
// * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Ostream Operators * * * * * * * * * * * * * //
template<class LListBase, class T> template<class LListBase, class T>
Foam::Ostream& Foam::operator<<(Ostream& os, const LPtrList<LListBase, T>& lst) Foam::Ostream& Foam::operator<<
(
Ostream& os,
const LPtrList<LListBase, T>& list
)
{ {
// Size and start delimiter // Size and start delimiter
os << nl << lst.size() << nl << token::BEGIN_LIST << nl; os << nl << list.size() << nl << token::BEGIN_LIST << nl;
// Contents // Contents
for (auto iter = lst.cbegin(); iter != lst.cend(); ++iter) for (auto iter = list.cbegin(); iter != list.cend(); ++iter)
{ {
os << *iter << nl; os << *iter << nl;
} }

View File

@ -73,9 +73,9 @@ protected:
// Protected Member Functions // Protected Member Functions
//- Read from Istream using given Istream constructor class //- Read from Istream using Istream constructor class
template<class INew> template<class INew>
void read(Istream& is, const INew& inew); void readIstream(Istream& is, const INew& inew);
//- Delete the allocated entries, but retain the list size. //- Delete the allocated entries, but retain the list size.
inline void free(); inline void free();

View File

@ -32,7 +32,7 @@ License
template<class T> template<class T>
template<class INew> template<class INew>
void Foam::PtrList<T>::read(Istream& is, const INew& inew) void Foam::PtrList<T>::readIstream(Istream& is, const INew& inew)
{ {
clear(); // Delete old pointers and reset the list size clear(); // Delete old pointers and reset the list size
@ -42,7 +42,7 @@ void Foam::PtrList<T>::read(Istream& is, const INew& inew)
is.fatalCheck is.fatalCheck
( (
"PtrList::read(Istream&) : " "PtrList::readIstream : "
"reading first token" "reading first token"
); );
@ -70,7 +70,7 @@ void Foam::PtrList<T>::read(Istream& is, const INew& inew)
is.fatalCheck is.fatalCheck
( (
"PtrList::read(Istream&) : " "PtrList::readIstream : "
"reading entry" "reading entry"
); );
} }
@ -82,7 +82,7 @@ void Foam::PtrList<T>::read(Istream& is, const INew& inew)
is.fatalCheck is.fatalCheck
( (
"PtrList::read(Istream&) : " "PtrList::readIstream : "
"reading the single entry" "reading the single entry"
); );
@ -167,14 +167,14 @@ template<class T>
template<class INew> template<class INew>
Foam::PtrList<T>::PtrList(Istream& is, const INew& inew) Foam::PtrList<T>::PtrList(Istream& is, const INew& inew)
{ {
read(is, inew); this->readIstream(is, inew);
} }
template<class T> template<class T>
Foam::PtrList<T>::PtrList(Istream& is) Foam::PtrList<T>::PtrList(Istream& is)
{ {
read(is, INew<T>()); this->readIstream(is, INew<T>());
} }
@ -183,7 +183,7 @@ Foam::PtrList<T>::PtrList(Istream& is)
template<class T> template<class T>
Foam::Istream& Foam::operator>>(Istream& is, PtrList<T>& list) Foam::Istream& Foam::operator>>(Istream& is, PtrList<T>& list)
{ {
list.read(is, INew<T>()); list.readIstream(is, INew<T>());
return is; return is;
} }

View File

@ -45,7 +45,7 @@ Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const INew& inewt)
// For if MUST_READ_IF_MODIFIED // For if MUST_READ_IF_MODIFIED
addWatch(); addWatch();
PtrList<T>::read(readStream(typeName), inewt); PtrList<T>::readIstream(readStream(typeName), inewt);
close(); close();
} }
} }
@ -68,7 +68,7 @@ Foam::IOPtrList<T>::IOPtrList(const IOobject& io)
// For if MUST_READ_IF_MODIFIED // For if MUST_READ_IF_MODIFIED
addWatch(); addWatch();
PtrList<T>::read(readStream(typeName), INew<T>()); PtrList<T>::readIstream(readStream(typeName), INew<T>());
close(); close();
} }
} }
@ -106,7 +106,7 @@ Foam::IOPtrList<T>::IOPtrList(const IOobject& io, const PtrList<T>& content)
// For if MUST_READ_IF_MODIFIED // For if MUST_READ_IF_MODIFIED
addWatch(); addWatch();
PtrList<T>::read(readStream(typeName), INew<T>()); PtrList<T>::readIstream(readStream(typeName), INew<T>());
close(); close();
} }
else else
@ -135,7 +135,7 @@ Foam::IOPtrList<T>::IOPtrList(const IOobject& io, PtrList<T>&& content)
// For if MUST_READ_IF_MODIFIED // For if MUST_READ_IF_MODIFIED
addWatch(); addWatch();
PtrList<T>::read(readStream(typeName), INew<T>()); PtrList<T>::readIstream(readStream(typeName), INew<T>());
close(); close();
} }
} }

View File

@ -39,7 +39,7 @@ Description
namespace Foam namespace Foam
{ {
// Forward declaration of classes // Forward declarations
class Istream; class Istream;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
@ -49,32 +49,31 @@ class Istream;
template<class T> template<class T>
class INew class INew
{ {
public: public:
//- Construct null //- Construct null
INew() INew()
{} {}
//- Construct from Istream //- New from Istream
autoPtr<T> operator()(Istream& is) const autoPtr<T> operator()(Istream& is) const
{ {
return T::New(is); return T::New(is);
} }
//- Construct from word and Istream //- New from word (unused) and Istream
autoPtr<T> operator()(const word&, Istream& is) const autoPtr<T> operator()(const word&, Istream& is) const
{ {
return T::New(is); return T::New(is);
} }
//- Construct from dictionary //- New from dictionary
autoPtr<T> operator()(const dictionary& dict) const autoPtr<T> operator()(const dictionary& dict) const
{ {
return T::New(dict); return T::New(dict);
} }
//- Construct from word and dictionary //- New from word (unused) and dictionary
autoPtr<T> operator()(const word&, const dictionary& dict) const autoPtr<T> operator()(const word&, const dictionary& dict) const
{ {
return T::New(dict); return T::New(dict);