Commit 53ae09ad authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: relocate stream allocators to Detail namespace

parent 4cf932b2
......@@ -37,7 +37,7 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
Foam::Detail::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
:
allocatedPtr_(nullptr),
compression_(IOstream::UNCOMPRESSED)
......@@ -61,7 +61,6 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
}
delete allocatedPtr_;
allocatedPtr_ = new igzstream((pathname + ".gz").c_str());
if (allocatedPtr_->good())
......@@ -74,7 +73,7 @@ Foam::IFstreamAllocator::IFstreamAllocator(const fileName& pathname)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::IFstreamAllocator::~IFstreamAllocator()
Foam::Detail::IFstreamAllocator::~IFstreamAllocator()
{
deallocate();
}
......@@ -82,7 +81,7 @@ Foam::IFstreamAllocator::~IFstreamAllocator()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::IFstreamAllocator::deallocate()
void Foam::Detail::IFstreamAllocator::deallocate()
{
if (allocatedPtr_)
{
......@@ -101,7 +100,7 @@ Foam::IFstream::IFstream
versionNumber version
)
:
IFstreamAllocator(pathname),
Detail::IFstreamAllocator(pathname),
ISstream
(
*allocatedPtr_,
......@@ -135,12 +134,6 @@ Foam::IFstream::IFstream
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::IFstream::~IFstream()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
std::istream& Foam::IFstream::stdStream()
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -25,7 +25,7 @@ Class
Foam::IFstream
Description
Input from file stream, using a ISstream
Input from file stream, using an ISstream
SourceFiles
IFstream.C
......@@ -47,8 +47,11 @@ using std::ifstream;
namespace Foam
{
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class IFstreamAllocator Declaration
Class Detail::IFstreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- A std::istream with the ability to handle compressed files
......@@ -82,6 +85,8 @@ protected:
};
} // end namespace Detail
/*---------------------------------------------------------------------------*\
Class IFstream Declaration
......@@ -89,7 +94,7 @@ protected:
class IFstream
:
public IFstreamAllocator,
public Detail::IFstreamAllocator,
public ISstream
{
public:
......@@ -110,18 +115,18 @@ public:
//- Destructor
~IFstream();
~IFstream() = default;
// Member Functions
// Access
// Access
//- Read/write access to the name of the stream
using ISstream::name;
// STL stream
// STL stream
//- Access to underlying std::istream
virtual std::istream& stdStream();
......@@ -133,17 +138,17 @@ public:
virtual void rewind();
// Print
// Print
//- Print description of IOstream to Ostream
virtual void print(Ostream& os) const;
// Member operators
// Member Operators
//- Return a non-const reference to const IFstream
// Needed for read-constructors where the stream argument is temporary:
// e.g. thing thisThing(IFstream("thingFileName")());
// e.g. thing thisThing(IFstream("fileName")());
IFstream& operator()() const;
};
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -34,10 +34,9 @@ namespace Foam
defineTypeNameAndDebug(OFstream, 0);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::OFstreamAllocator::OFstreamAllocator
Foam::Detail::OFstreamAllocator::OFstreamAllocator
(
const fileName& pathname,
IOstream::compressionType compression,
......@@ -100,13 +99,13 @@ Foam::OFstreamAllocator::OFstreamAllocator
}
Foam::OFstreamAllocator::~OFstreamAllocator()
Foam::Detail::OFstreamAllocator::~OFstreamAllocator()
{
deallocate();
}
void Foam::OFstreamAllocator::deallocate()
void Foam::Detail::OFstreamAllocator::deallocate()
{
if (allocatedPtr_)
{
......@@ -127,7 +126,7 @@ Foam::OFstream::OFstream
const bool append
)
:
OFstreamAllocator(pathname, compression, append),
Detail::OFstreamAllocator(pathname, compression, append),
OSstream
(
*allocatedPtr_,
......@@ -160,12 +159,6 @@ Foam::OFstream::OFstream
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::OFstream::~OFstream()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
std::ostream& Foam::OFstream::stdStream()
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -25,7 +25,7 @@ Class
Foam::OFstream
Description
Output to file stream, using a OSstream
Output to file stream, using an OSstream
SourceFiles
OFstream.C
......@@ -47,8 +47,11 @@ using std::ofstream;
namespace Foam
{
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class OFstreamAllocator Declaration
Class Detail::OFstreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- A std::ostream with the ability to handle compressed files
......@@ -84,6 +87,8 @@ protected:
};
} // end namespace Detail
/*---------------------------------------------------------------------------*\
Class OFstream Declaration
......@@ -91,7 +96,7 @@ protected:
class OFstream
:
public OFstreamAllocator,
public Detail::OFstreamAllocator,
public OSstream
{
public:
......@@ -114,18 +119,18 @@ public:
//- Destructor
~OFstream();
~OFstream() = default;
// Member functions
// Access
// Access
//- Read/write access to the name of the stream
using OSstream::name;
// STL stream
// STL stream
//- Access to underlying std::ostream
virtual std::ostream& stdStream();
......@@ -134,7 +139,7 @@ public:
virtual const std::ostream& stdStream() const;
// Print
// Print
//- Print description of IOstream to Ostream
void print(Ostream& os) const;
......
......@@ -44,8 +44,11 @@ SourceFiles
namespace Foam
{
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class StringStreamAllocator Declaration
Class Detail::StringStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- Allocator for variants of a std stringstream
......@@ -96,6 +99,8 @@ public:
}
};
} // end of namespace Detail
/*---------------------------------------------------------------------------*\
Class IStringStream Declaration
......@@ -104,10 +109,10 @@ public:
//- Input from string buffer, using a ISstream
class IStringStream
:
public StringStreamAllocator<std::istringstream>,
public Detail::StringStreamAllocator<std::istringstream>,
public ISstream
{
typedef StringStreamAllocator<std::istringstream> allocator_type;
typedef Detail::StringStreamAllocator<std::istringstream> allocator_type;
public:
......@@ -181,10 +186,10 @@ public:
//- Output to string buffer, using a OSstream
class OStringStream
:
public StringStreamAllocator<std::ostringstream>,
public Detail::StringStreamAllocator<std::ostringstream>,
public OSstream
{
typedef StringStreamAllocator<std::ostringstream> allocator_type;
typedef Detail::StringStreamAllocator<std::ostringstream> allocator_type;
public:
......
......@@ -27,9 +27,6 @@ Class
Description
An output stream for calculating SHA1 digests.
SourceFiles
OSHA1stream.C
\*---------------------------------------------------------------------------*/
#ifndef OSHA1stream_H
......@@ -43,9 +40,6 @@ SourceFiles
namespace Foam
{
class osha1stream;
class OSHA1stream;
/*---------------------------------------------------------------------------*\
Class osha1stream Declaration
\*---------------------------------------------------------------------------*/
......@@ -65,36 +59,30 @@ class osha1stream
SHA1 sha1_;
protected:
// Protected members
//- Put sequence of characters
virtual std::streamsize xsputn(const char* str, std::streamsize n)
{
sha1_.append(str, n);
return n;
}
//- Put sequence of characters
virtual std::streamsize xsputn(const char* s, std::streamsize n)
{
sha1_.append(s, n);
return n;
}
public:
// Constructors
//- Construct null
sha1buf()
{}
//- Construct null
sha1buf()
{}
// Public member functions
//- Full access to the sha1
inline SHA1& sha1()
{
return sha1_;
}
//- Full access to the sha1
inline SHA1& sha1()
{
return sha1_;
}
};
// Private data
// Private Data
//- Reference to the underlying buffer
sha1buf buf_;
......@@ -127,8 +115,11 @@ public:
};
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class OSHA1streamAllocator Declaration
Class Detail::OSHA1streamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- Allocator for an osha1stream
......@@ -136,7 +127,7 @@ class OSHA1streamAllocator
{
protected:
// Protected data
// Protected Data
typedef osha1stream stream_type;
......@@ -179,6 +170,8 @@ public:
};
} // end of namespace Detail
/*---------------------------------------------------------------------------*\
Class OSHA1stream Declaration
......@@ -187,17 +180,17 @@ public:
//- The output stream for calculating SHA1 digests
class OSHA1stream
:
public OSHA1streamAllocator,
public Detail::OSHA1streamAllocator,
public OSstream
{
typedef OSHA1streamAllocator allocator_type;
typedef Detail::OSHA1streamAllocator allocator_type;
// Private Member Functions
//- Disallow default bitwise copy construct
//- No copy construct
OSHA1stream(const OSHA1stream&) = delete;
//- Disallow default bitwise assignment
//- No copy assignment
void operator=(const OSHA1stream&) = delete;
public:
......
......@@ -110,6 +110,7 @@ Foam::base64Layer::base64Layer(std::ostream& os)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::base64Layer::~base64Layer()
{
close();
......
......@@ -47,8 +47,11 @@ See Also
namespace Foam
{
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class IListStreamAllocator Declaration
Class Detail::IListStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- An stream/stream-buffer input allocator with List storage
......@@ -118,6 +121,8 @@ public:
}
};
} // end namespace Detail
/*---------------------------------------------------------------------------*\
Class IListStream Declaration
......@@ -126,10 +131,10 @@ public:
//- An ISstream with internal List storage
class IListStream
:
public IListStreamAllocator,
public Detail::IListStreamAllocator,
public ISstream
{
typedef IListStreamAllocator allocator_type;
typedef Detail::IListStreamAllocator allocator_type;
public:
......
......@@ -134,8 +134,11 @@ public:
};
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class OCountStreamAllocator Declaration
Class Detail::OCountStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- An stream/stream-buffer allocator for counting
......@@ -189,6 +192,8 @@ public:
}
};
} // end of namespace Detail
/*---------------------------------------------------------------------------*\
Class OCountStream Declaration
......@@ -197,10 +202,10 @@ public:
//- An output stream for calculating byte counts
class OCountStream
:
public OCountStreamAllocator,
public Detail::OCountStreamAllocator,
public OSstream
{
typedef OCountStreamAllocator allocator_type;
typedef Detail::OCountStreamAllocator allocator_type;
public:
......@@ -225,7 +230,7 @@ public:
{}
// Member functions
// Member Functions
//- Rewind the stream, reset the count, clearing any old errors
virtual void rewind()
......
......@@ -53,8 +53,11 @@ See Also
namespace Foam
{
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class OListStreamAllocator Declaration
Class Detail::OListStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- An stream/stream-buffer output allocator with DynamicList-like storage
......@@ -358,6 +361,8 @@ public:
}
};
} // end of namespace Detail
/*---------------------------------------------------------------------------*\
Class OListStream Declaration
......@@ -366,10 +371,10 @@ public:
//- An OSstream attached to a List
class OListStream
:
public OListStreamAllocator,
public Detail::OListStreamAllocator,
public OSstream
{
typedef OListStreamAllocator allocator_type;
typedef Detail::OListStreamAllocator allocator_type;
public:
......
......@@ -109,8 +109,11 @@ public:
};
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class UIListStreamAllocator Declaration
Class Detail::UIListStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- An stream/stream-buffer input allocator for a externally allocated list
......@@ -188,6 +191,8 @@ public:
}
};
} // end of namespace Detail
/*---------------------------------------------------------------------------*\
Class UIListStream Declaration
......@@ -195,10 +200,10 @@ public:
class UIListStream
:
public UIListStreamAllocator,
public Detail::UIListStreamAllocator,
public ISstream
{
typedef UIListStreamAllocator allocator_type;
typedef Detail::UIListStreamAllocator allocator_type;
public:
......@@ -260,7 +265,7 @@ public:
{}
// Member functions
// Member Functions
//- Return the current get position in the buffer
std::streampos pos() const
......@@ -279,7 +284,7 @@ public:
virtual void print(Ostream& os) const;
// Member operators
// Member Operators
//- A non-const reference to const Istream
// Needed for read-constructors where the stream argument is temporary
......
......@@ -90,8 +90,11 @@ See Also
namespace Foam
{
namespace Detail
{
/*---------------------------------------------------------------------------*\
Class UOListStreamAllocator Declaration
Class Detail::UOListStreamAllocator Declaration
\*---------------------------------------------------------------------------*/
//- An stream/stream-buffer allocator for external buffers
......@@ -161,6 +164,8 @@ public:
}
};
} // end of namespace Detail