diff --git a/applications/test/bufstream/Make/files b/applications/test/bufstream/Make/files
new file mode 100644
index 0000000000000000000000000000000000000000..12ba679121e549ebc286cdfe61fc8c5fe1fb0551
--- /dev/null
+++ b/applications/test/bufstream/Make/files
@@ -0,0 +1,3 @@
+Test-bufstream.C
+
+EXE = $(FOAM_USER_APPBIN)/Test-bufstream
diff --git a/applications/test/bufstream/Make/options b/applications/test/bufstream/Make/options
new file mode 100644
index 0000000000000000000000000000000000000000..6a9e9810b3d5ce6684bdaf03143933480ff45e42
--- /dev/null
+++ b/applications/test/bufstream/Make/options
@@ -0,0 +1,2 @@
+/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
+/* EXE_LIBS = -lfiniteVolume */
diff --git a/applications/test/bufstream/Test-bufstream.C b/applications/test/bufstream/Test-bufstream.C
new file mode 100644
index 0000000000000000000000000000000000000000..25bff7727c40d235355766e965aff3c22edad2d6
--- /dev/null
+++ b/applications/test/bufstream/Test-bufstream.C
@@ -0,0 +1,154 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Description
+    Test some string functionality
+
+\*---------------------------------------------------------------------------*/
+
+#include "IBufStream.H"
+#include "OBufStream.H"
+#include "IStringStream.H"
+#include "OStringStream.H"
+
+#include "IOstreams.H"
+#include "fileNameList.H"
+#include "stringList.H"
+#include "wordList.H"
+#include "token.H"
+
+using namespace Foam;
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+
+// Helper functions
+
+//- Convert number of bytes into an integral length for the type
+template<class T>
+static size_t integral_size(size_t nbytes)
+{
+    size_t unit = sizeof(T);
+    return (nbytes / unit) + ((nbytes % unit) ? 1 : 0);
+}
+
+
+// Main program:
+
+int main(int argc, char *argv[])
+{
+    List<char> bufChar1(64);
+    List<long> bufLong1(8);
+
+    DynamicList<char> bufChar2;
+    DynamicList<long> bufLong2;
+    bufChar2.reserve(64);
+    bufLong2.reserve(8);
+
+    {
+        OBufStream osc1(bufChar1);
+        OBufStream osc2(bufChar2);
+        OBufStream osl1(bufLong1);
+        OBufStream osl2(bufLong2);
+
+        std::string str1("The quick brown fox jumps over the lazy dog");
+        std::string str2(" more");
+
+        osc1 << str1;
+        osc2 << str1;
+        osl1 << str1;
+        osl2 << str1.c_str();
+
+        Info<< "size =>>" << osc1.size() << nl;
+        Info<< "size =>>" << osc2.size() << nl;
+
+        Info<< "len=" << integral_size<long>(osc2.size())
+            << " of=" << sizeof(long) << nl;
+
+        Info<< "len=" << integral_size<long>(osc2.size())
+            << " of=" << sizeof(long) << nl;
+
+        // read back
+        // IBufStream2 is(bufLong2.cdata(), osc2.size());
+        // bufLong2.setSize(osl2.size() / sizeof(long));
+
+        IBufStream is(bufLong2, osl2.size());
+
+        // string readback(is);
+
+        // Info<<"read in " << readback << "\n";
+
+        is.rewind();
+        Info<< "eof " << is.eof() << endl;
+
+//        List<token> tokens(is);
+        token tok;
+        is >> tok;
+        Info<<"tok: " << tok.info() << endl;
+        Info<< "at " << is.pos() << endl;
+
+        is.rewind();
+        Info<< "at " << is.pos() << endl;
+
+        int i=0;
+        while (is.good() && !is.eof() && i++ < 15)
+        {
+            is >> tok;
+
+            Info<<"tok: " << tok.info() << endl;
+        }
+
+        osc1 << "more ";
+        Info<< "size =>>" << osc1.size() << nl;
+
+        Info<< "call rewind" << endl;
+        osc1.rewind();
+        Info<< "size =>>" << osc1.size() << nl;
+
+        osc1 << "Some test data";
+        Info<< "size =>>" << osc1.size() << nl;
+
+//        Info<< str1 << nl;
+//        Info<< "bufChar1: " << osc1.size() << " good=" << osc1.good() << nl;
+//        Info<< "bufChar2: " << osc2.size() << " good=" << osc2.good() << nl;
+//        Info<< "bufLong1: " << osl1.size() << " good=" << osl1.good() << nl;
+//        Info<< "bufLong2: " << osl2.size() << " good=" << osl2.good() << nl;
+//
+//        osc1 << str2 << str1 << str1;
+//        osc2 << str2 << str1 << str1;
+//        osl1 << str2 << str1 << str1;
+//        osl2 << str2 << str1 << str1;
+//
+//        Info<< str2 << nl;
+//        Info<< "bufChar1: " << osc1.size() << " good=" << osc1.good() << nl;
+//        Info<< "bufChar2: " << osc2.size() << " good=" << osc2.good() << nl;
+//        Info<< "bufLong1: " << osl1.size() << " good=" << osl1.good() << nl;
+//        Info<< "bufLong2: " << osl2.size() << " good=" << osl2.good() << nl;
+    }
+
+
+    return 0;
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/memory/IBufStream.H b/src/OpenFOAM/db/IOstreams/memory/IBufStream.H
new file mode 100644
index 0000000000000000000000000000000000000000..3643201dc96be69e0eba7c687e05e621257fe901
--- /dev/null
+++ b/src/OpenFOAM/db/IOstreams/memory/IBufStream.H
@@ -0,0 +1,264 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::IBufStream
+
+Description
+    Similar to IStringStream but using an externally managed buffer for its
+    input. This allows the input buffer to be filled (and refilled) from
+    various sources.
+
+    Note that this stream will normally be used as a "one-shot" reader.
+    Caution must be exercised that the referenced buffer remains valid and
+    without any intermediate resizing for the duration of the stream's use.
+
+    An example of possible use:
+    \code
+        DynamicList<char> buffer(4096);   // allocate some large buffer
+
+        nread = something.read(buffer.data(),1024); // fill with content
+        buffer.setSize(nread);            // content size
+
+        // construct dictionary, or do something else
+        IBufStream is(buffer)
+        dictionary dict1(is);
+
+        // sometime later
+        nread = something.read(buffer.data(),2048); // fill with content
+        buffer.setSize(nread);              // content size
+
+        // without intermediate variable
+        dictionary dict2(IBufStream(buffer)());
+    \endcode
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef IBufStream_H
+#define IBufStream_H
+
+#include "OBufStream.H"
+
+#include "ISstream.H"
+#include "UList.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                     Class IBufStreamAllocator Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An allocator for std::istream with external buffers
+class IBufStreamAllocator
+{
+private:
+
+    // Private data
+
+        //- Reference to the underlying buffer
+        memorybuf::input buf_;
+
+protected:
+
+    // Protected data
+
+        //- The stream pointer
+        std::istream* strPtr_;
+
+public:
+
+    // Constructors
+
+        //- Construct with buffer and number of bytes
+        IBufStreamAllocator(const char *buffer, size_t nbytes)
+        :
+            buf_(buffer, nbytes),
+            strPtr_(new std::istream(&buf_))
+        {}
+
+
+        //- Construct with buffer and number of bytes
+        IBufStreamAllocator(const void *buffer, size_t nbytes)
+        :
+            buf_(buffer, nbytes),
+            strPtr_(new std::istream(&buf_))
+        {}
+
+
+        //- Construct using specified buffer and its inherent storage size
+        template<class T>
+        IBufStreamAllocator(const UList<T>& buffer)
+        :
+            buf_(buffer),
+            strPtr_(new std::istream(&buf_))
+        {}
+
+
+    //- Destructor
+    ~IBufStreamAllocator()
+    {
+        delete strPtr_;
+    }
+
+
+    // Member functions
+
+        //- Return the current get position in the buffer
+        std::streampos pos() const
+        {
+            return strPtr_->tellg();
+        }
+
+
+        //- Move to buffer start, clear errors
+        void rewind()
+        {
+            strPtr_->rdbuf()->pubseekpos(0);
+            strPtr_->clear(); // for safety, clear any old errors
+        }
+
+};
+
+
+/*---------------------------------------------------------------------------*\
+                         Class IBufStream Declaration
+\*---------------------------------------------------------------------------*/
+
+class IBufStream
+:
+    private IBufStreamAllocator,
+    public ISstream
+{
+public:
+
+    // Constructors
+
+        //- Construct using specified buffer and number of bytes
+        IBufStream
+        (
+            const char* buffer,
+            size_t nbytes,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            IBufStreamAllocator(buffer, nbytes),
+            ISstream
+            (
+                *strPtr_,
+                "IBufStream.source",
+                format,
+                version
+            )
+        {}
+
+
+        //- Construct using data area from buffer and number of bytes
+        template<class T>
+        IBufStream
+        (
+            const UList<T>& buffer,
+            size_t nbytes,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            IBufStreamAllocator(buffer.cdata(), nbytes),
+            ISstream
+            (
+                *strPtr_,
+                "IBufStream.source",
+                format,
+                version
+            )
+        {}
+
+
+        //- Construct using specified buffer and its inherent storage size
+        //  Uses addressed size, thus no special treatment for a DynamicList
+        template<class T>
+        IBufStream
+        (
+            const UList<T>& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            IBufStreamAllocator(buffer),
+            ISstream
+            (
+                *strPtr_,
+                "IBufStream.source",
+                format,
+                version
+            )
+        {}
+
+
+    //- Destructor
+    ~IBufStream()
+    {}
+
+
+    // Member functions
+
+        //- Return the current input position in the buffer
+        using IBufStreamAllocator::pos;
+
+
+        //- Rewind the stream, clearing any old errors
+        virtual Istream& rewind()
+        {
+            IBufStreamAllocator::rewind();
+            setGood();  // resynchronize with internal state
+
+            return *this;
+        }
+
+
+    // Member operators
+
+        //- Return a non-const reference to const Istream
+        //  Needed for read-constructors where the stream argument is temporary:
+        //  e.g. thing thisThing(IFstream("thingFileName")());
+        Istream& operator()() const
+        {
+            return const_cast<Istream&>(static_cast<const Istream&>(*this));
+        }
+
+};
+
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/memory/OBufStream.H b/src/OpenFOAM/db/IOstreams/memory/OBufStream.H
new file mode 100644
index 0000000000000000000000000000000000000000..5f837f287db51b03868d62ea2ae29cd1fcaea34e
--- /dev/null
+++ b/src/OpenFOAM/db/IOstreams/memory/OBufStream.H
@@ -0,0 +1,542 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::OBufStream
+
+Description
+    Similar to OStringStream but using an externally managed buffer for
+    its output.
+
+    This allows the output buffer to be reused and can make it easier when
+    writing out data.  It is the user's responsibility to ensure proper
+    synchronization in the sizes. Provided that the external buffer is large
+    enough that overflow does not occur, the following usage pattern
+    should work.
+
+    \code
+        DynamicList<char> buffer(4096);     // allocate some large buffer
+
+        {
+            OBufStream os(buffer);
+            os << "content1" << " and more content";
+            buffer.setSize(os.size());      // synchronize sizes
+        }
+
+        something.write(buffer, buffer.size());
+    \endcode
+
+    Although the OBufStream is quite lightweight, there may be cases
+    where it is preferable to reuse the stream as well.
+    \code
+        DynamicList<char> buffer(4096);     // allocate some large buffer
+
+        OBufStream os(buffer);
+        os << "content1" << " and more content";
+        buffer.setSize(os.size());          // synchronize sizes
+
+        something.write(buffer, buffer.size());
+
+        os.rewind();
+        os << "content2";
+        buffer.setSize(os.size());      // synchronize sizes
+
+        something.write(buffer, buffer.size());
+
+        // or simply using the output size directly (without sync)
+        os.rewind();
+        os << "content3";
+
+        something.write(buffer, os.size());
+    \endcode
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef OBufStream_H
+#define OBufStream_H
+
+#include "OStringStream.H"
+#include "DynamicList.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+//- A streambuf class for using externally allocated memory for its buffer
+class memorybuf
+:
+    public std::streambuf
+{
+    // Private data
+
+        //- Storage location
+        char *buf_;
+
+        //- The number of bytes in the storage
+        std::streamsize len_;
+
+protected:
+    // Protected members
+
+        //- Set position pointer to relative position
+        virtual std::streampos seekoff
+        (
+            std::streamoff off,
+            std::ios_base::seekdir way,
+            std::ios_base::openmode which = std::ios_base::in | std::ios_base::out
+        )
+        {
+            const bool testin  = which & std::ios_base::in;
+            const bool testout = which & std::ios_base::out;
+
+            if (way == std::ios_base::beg)
+            {
+                if (testin)
+                {
+                    setg(eback(), eback(), egptr());
+                    gbump(off);
+                }
+                if (testout)
+                {
+                    setp(pbase(), epptr());
+                    pbump(off);
+                }
+
+                return off;
+            }
+
+            if (way == std::ios_base::cur)
+            {
+                if (testin)
+                {
+                    gbump(off);
+                }
+                if (testout)
+                {
+                    pbump(off);
+                }
+            }
+            else if (way == std::ios_base::end)
+            {
+                if (testin)
+                {
+                    gbump(off);
+                }
+                if (testout)
+                {
+                    pbump(off);
+                }
+            }
+
+            if (testin)
+            {
+                return gptr() - eback();
+            }
+            if (testout)
+            {
+                return pptr() - pbase();
+            }
+
+            return -1;
+        }
+
+
+        //- Set position pointer to absolute position
+        virtual std::streampos seekpos
+        (
+            std::streampos pos,
+            std::ios_base::openmode which = std::ios_base::in | std::ios_base::out
+        )
+        {
+            return seekoff(pos, std::ios_base::beg, which);
+        }
+
+
+        //- Get sequence of characters
+        virtual std::streamsize xsgetn(char* s, std::streamsize n)
+        {
+            std::streamsize count = 0;
+
+            // some optimization could be possible here
+            while (count < n && gptr() < egptr())
+            {
+                *(s + count++) = *(gptr());
+                gbump(1);
+            }
+
+            return count;
+        }
+
+
+        //- Put sequence of characters
+        virtual std::streamsize xsputn(const char* s, std::streamsize n)
+        {
+            std::streamsize count = 0;
+
+            // some optimization could be possible here
+            while (count < n && pptr() < epptr())
+            {
+                *(pptr()) = *(s + count++);
+                pbump(1);
+            }
+
+            return count;
+        }
+
+
+public:
+
+    // Forward declarations of adapters
+
+        class input;
+        class output;
+
+
+    // Constructors
+
+        //- Construct for specified buffer
+        memorybuf(char* buffer, std::streamsize num)
+        :
+            buf_(buffer),
+            len_(num)
+        {
+            setg(buf_, buf_, buf_ + len_);
+            setp(buf_, buf_ + len_);
+        }
+
+};
+
+
+//- An allocation adapter for input
+struct memorybuf::input : public memorybuf
+{
+    //- Construct with buffer and size
+    input(const char *buffer, size_t nbytes)
+    :
+        memorybuf(const_cast<char*>(buffer), nbytes)
+    {}
+
+
+    //- Construct with buffer and size
+    input(const void *buffer, size_t nbytes)
+    :
+        memorybuf
+        (
+            const_cast<char*>
+            (
+                reinterpret_cast<const char*>(buffer)
+            ),
+            nbytes
+        )
+    {}
+
+
+    //- Construct with buffer and its inherent size
+    template<class T>
+    input(const UList<T>& buffer)
+    :
+        memorybuf
+        (
+            const_cast<char*>
+            (
+                reinterpret_cast<const char*>(buffer.cdata())
+            ),
+            buffer.size() * sizeof(T)
+        )
+    {}
+
+
+    //- Construct with buffer and size
+    template<class T>
+    input(const UList<T>& buffer, label listSize)
+    :
+        memorybuf
+        (
+            const_cast<char*>
+            (
+                reinterpret_cast<const char*>(buffer.cdata())
+            ),
+            listSize * sizeof(T)
+        )
+    {}
+};
+
+
+//- An allocation adapter for output
+struct memorybuf::output : public memorybuf
+{
+    //- Construct with buffer and size
+    output(char *buffer, size_t nbytes)
+    :
+        memorybuf(buffer, nbytes)
+    {}
+
+
+    //- Construct with buffer and size
+    output(void *buffer, size_t nbytes)
+    :
+        memorybuf
+        (
+            reinterpret_cast<char*>(buffer),
+            nbytes
+        )
+    {}
+
+
+    //- Construct with buffer and its inherent size
+    template<class T>
+    output(UList<T>& buffer)
+    :
+        memorybuf
+        (
+            reinterpret_cast<char*>(buffer.data()),
+            buffer.size() * sizeof(T)
+        )
+    {}
+
+
+    //- Construct with buffer and size
+    template<class T>
+    output(UList<T>& buffer, label listSize)
+    :
+        memorybuf
+        (
+            reinterpret_cast<char*>(buffer.data()),
+            listSize * sizeof(T)
+        )
+    {}
+};
+
+
+/*---------------------------------------------------------------------------*\
+                     Class OBufStreamAllocator Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An allocator for std::ostream with external buffers
+class OBufStreamAllocator
+{
+private:
+
+    // Private data
+
+        //- Reference to the underlying buffer
+        memorybuf::output buf_;
+
+protected:
+
+    // Protected data
+
+        //- The stream pointer
+        std::ostream* strPtr_;
+
+public:
+
+    // Constructors
+
+        //- Construct with buffer and number of bytes
+        OBufStreamAllocator(char *buffer, size_t nbytes)
+        :
+            buf_(buffer, nbytes),
+            strPtr_(new std::ostream(&buf_))
+        {}
+
+
+        //- Construct with buffer and number of bytes
+        OBufStreamAllocator(void *buffer, size_t nbytes)
+        :
+            buf_(buffer, nbytes),
+            strPtr_(new std::ostream(&buf_))
+        {}
+
+
+        //- Construct using specified buffer and its inherent storage size
+        template<class T>
+        OBufStreamAllocator(UList<T>& buffer)
+        :
+            buf_(buffer),
+            strPtr_(new std::ostream(&buf_))
+        {}
+
+
+        //- Construct with buffer and size
+        template<class T>
+        OBufStreamAllocator(UList<T>& buffer, label listSize)
+        :
+            buf_(buffer, listSize),
+            strPtr_(new std::ostream(&buf_))
+        {}
+
+
+    //- Destructor
+    ~OBufStreamAllocator()
+    {
+        delete strPtr_;
+    }
+
+
+    // Member functions
+
+        //- Return the current output position in the buffer
+        std::streampos size() const
+        {
+            return strPtr_->tellp();
+        }
+
+
+        //- Move to buffer start, clear errors
+        void rewind()
+        {
+            strPtr_->rdbuf()->pubseekpos(0);
+            strPtr_->clear(); // for safety, clear any old errors
+        }
+
+};
+
+
+/*---------------------------------------------------------------------------*\
+                         Class OBufStream Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An OSstream with an attached external buffer
+class OBufStream
+:
+    private OBufStreamAllocator,
+    public OSstream
+{
+public:
+
+    // Constructors
+
+        //- Construct using specified buffer and number of bytes
+        OBufStream
+        (
+            char* buffer,
+            size_t nbytes,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            OBufStreamAllocator(buffer, nbytes),
+            OSstream
+            (
+                *strPtr_,
+                "OBufStream.sink",
+                format,
+                version
+            )
+        {}
+
+
+        //- Construct using data area from buffer and number of bytes
+        template<class T>
+        OBufStream
+        (
+            UList<T>& buffer,
+            size_t nbytes,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            OBufStreamAllocator(buffer.data(), nbytes),
+            OSstream
+            (
+                *strPtr_,
+                "OBufStream.sink",
+                format,
+                version
+            )
+        {}
+
+
+        //- Construct using specified buffer and its inherent storage size
+        template<class T>
+        OBufStream
+        (
+            UList<T>& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            OBufStreamAllocator(buffer),
+            OSstream
+            (
+                *strPtr_,
+                "OBufStream.sink",
+                format,
+                version
+            )
+        {}
+
+
+        //- Construct using specified buffer and its storage capacity
+        template<class T>
+        OBufStream
+        (
+            DynamicList<T>& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            OBufStreamAllocator(buffer, buffer.capacity()),
+            OSstream
+            (
+                *strPtr_,
+                "OBufStream.sink",
+                format,
+                version
+            )
+        {}
+
+
+    //- Destructor
+    ~OBufStream()
+    {}
+
+
+    // Member functions
+
+        //- Return the current output position in the buffer
+        using OBufStreamAllocator::size;
+
+        //- Rewind the stream, clearing any old errors
+        Ostream& rewind()
+        {
+            OBufStreamAllocator::rewind();
+            setGood();  // resynchronize with internal state
+
+            return *this;
+        }
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/IOstreams/memory/OCompactBufStream.H b/src/OpenFOAM/db/IOstreams/memory/OCompactBufStream.H
new file mode 100644
index 0000000000000000000000000000000000000000..3e678a619bf56843697821eef5220d2c405a2575
--- /dev/null
+++ b/src/OpenFOAM/db/IOstreams/memory/OCompactBufStream.H
@@ -0,0 +1,240 @@
+/*---------------------------------------------------------------------------*\
+  =========                 |
+  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
+   \\    /   O peration     |
+    \\  /    A nd           | Copyright (C) 2016 OpenCFD Ltd.
+     \\/     M anipulation  |
+-------------------------------------------------------------------------------
+License
+    This file is part of OpenFOAM.
+
+    OpenFOAM is free software: you can redistribute it and/or modify it
+    under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+    for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
+
+Class
+    Foam::OCompactBufStream
+
+Description
+    Similar to OStringStream but using an externally managed buffer for
+    its output and using a more compact output (fewer spaces)
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef OCompactBufStream_H
+#define OCompactBufStream_H
+
+#include "OBufStream.H"
+#include "OCompactStream.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+                      Class OCompactBufStream Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An OSstream with an attached external buffer and compact output
+class OCompactBufStream
+:
+    private OBufStreamAllocator,
+    public OCompactStream
+{
+public:
+
+    // Constructors
+
+        //- Construct using specified buffer and number of bytes
+        OCompactBufStream
+        (
+            char* buffer,
+            size_t nbytes,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            OBufStreamAllocator(buffer, nbytes),
+            OCompactStream
+            (
+                *strPtr_,
+                "OBufStream.sink",
+                format,
+                version
+            )
+        {}
+
+
+        //- Construct using data area from buffer and number of bytes
+        template<class T>
+        OCompactBufStream
+        (
+            UList<T>& buffer,
+            size_t nbytes,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            OBufStreamAllocator(buffer.data(), nbytes),
+            OCompactStream
+            (
+                *strPtr_,
+                "OBufStream.sink",
+                format,
+                version
+            )
+        {}
+
+
+        //- Construct using specified buffer and its inherent storage size
+        template<class T>
+        OCompactBufStream
+        (
+            UList<T>& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            OBufStreamAllocator(buffer),
+            OCompactStream
+            (
+                *strPtr_,
+                "OBufStream.sink",
+                format,
+                version
+            )
+        {}
+
+
+        //- Construct using specified buffer and its storage capacity
+        template<class T>
+        OCompactBufStream
+        (
+            DynamicList<T>& buffer,
+            streamFormat format=ASCII,
+            versionNumber version=currentVersion
+        )
+        :
+            OBufStreamAllocator(buffer, buffer.capacity()),
+            OCompactStream
+            (
+                *strPtr_,
+                "OBufStream.sink",
+                format,
+                version
+            )
+        {}
+
+
+    //- Destructor
+    ~OCompactBufStream()
+    {}
+
+
+    // Member functions
+
+        //- Return the current output position in the buffer
+        using OBufStreamAllocator::size;
+
+        //- Rewind the output buffer
+        using OBufStreamAllocator::rewind;
+
+};
+
+
+/*---------------------------------------------------------------------------*\
+                        Class ORawBufStream Declaration
+\*---------------------------------------------------------------------------*/
+
+//- An OSstream with an attached external buffer using a more compact output
+//  (fewer spaces) and raw binary output
+class ORawBufStream
+:
+    public OCompactBufStream
+{
+public:
+
+    // Constructors
+
+        //- Construct using specified buffer and number of bytes
+        ORawBufStream
+        (
+            char* buffer,
+            size_t nbytes,
+            streamFormat format=BINARY,
+            versionNumber version=currentVersion
+        )
+        :
+            OCompactBufStream(buffer, nbytes, format, version)
+        {
+            raw(true);
+        }
+
+
+        //- Construct using data area from buffer and number of bytes
+        template<class T>
+        ORawBufStream
+        (
+            UList<T>& buffer,
+            size_t nbytes,
+            streamFormat format=BINARY,
+            versionNumber version=currentVersion
+        )
+        :
+            OCompactBufStream(buffer, nbytes, format, version)
+        {
+            raw(true);
+        }
+
+
+        //- Construct using specified buffer and its inherent storage size
+        template<class T>
+        ORawBufStream
+        (
+            UList<T>& buffer,
+            streamFormat format=BINARY,
+            versionNumber version=currentVersion
+        )
+        :
+            OCompactBufStream(buffer, format, version)
+        {
+            raw(true);
+        }
+
+
+        //- Construct using specified buffer and its storage capacity
+        template<class T>
+        ORawBufStream
+        (
+            DynamicList<T>& buffer,
+            streamFormat format=BINARY,
+            versionNumber version=currentVersion
+        )
+        :
+            OCompactBufStream(buffer, format, version)
+        {
+            raw(true);
+        }
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //