summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/plib/pstream.cpp
diff options
context:
space:
mode:
author couriersud <couriersud@gmx.org>2019-01-13 00:08:47 +0100
committer couriersud <couriersud@gmx.org>2019-01-13 00:08:47 +0100
commit633528eb31e7f318e6934476c85126dcf02fd457 (patch)
tree6256604388cdc207b78e912273ee2cdc23c14415 /src/lib/netlist/plib/pstream.cpp
parent66de2ce663e170cf096ae07a12e82e66cea3b076 (diff)
Improve dealing ownership in pstreams. (nw)
I am not really happy with this. But I am missing some creativity currently.
Diffstat (limited to 'src/lib/netlist/plib/pstream.cpp')
-rw-r--r--src/lib/netlist/plib/pstream.cpp29
1 files changed, 11 insertions, 18 deletions
diff --git a/src/lib/netlist/plib/pstream.cpp b/src/lib/netlist/plib/pstream.cpp
index 50a39685f70..e0094e99e38 100644
--- a/src/lib/netlist/plib/pstream.cpp
+++ b/src/lib/netlist/plib/pstream.cpp
@@ -41,14 +41,6 @@ postream::~postream()
{
}
-void postream::write(pistream &strm)
-{
- char buf[1024];
- pos_type r;
- while ((r=strm.read(buf, 1024)) > 0)
- write(buf, r);
-}
-
// -----------------------------------------------------------------------------
// Input file stream
// -----------------------------------------------------------------------------
@@ -119,7 +111,7 @@ void pifilestream::vseek(const pos_type n)
throw file_e("Generic file operation failed: {}", m_filename);
}
-pifilestream::pos_type pifilestream::vtell()
+pifilestream::pos_type pifilestream::vtell() const
{
long ret = ftell(static_cast<FILE *>(m_file));
if (ret < 0)
@@ -204,7 +196,7 @@ void pofilestream::vseek(const pos_type n)
}
}
-pstream::pos_type pofilestream::vtell()
+pstream::pos_type pofilestream::vtell() const
{
std::ptrdiff_t ret = ftell(static_cast<FILE *>(m_file));
if (ret < 0)
@@ -263,6 +255,11 @@ pimemstream::pimemstream(const void *mem, const pos_type len)
{
}
+pimemstream::pimemstream()
+ : pistream(FLAG_SEEKABLE), m_pos(0), m_len(0), m_mem(static_cast<const char *>(nullptr))
+{
+}
+
pimemstream::pimemstream(const pomemstream &ostrm)
: pistream(FLAG_SEEKABLE), m_pos(0), m_len(ostrm.size()), m_mem(reinterpret_cast<const char *>(ostrm.memory()))
{
@@ -295,7 +292,7 @@ void pimemstream::vseek(const pos_type n)
}
-pimemstream::pos_type pimemstream::vtell()
+pimemstream::pos_type pimemstream::vtell() const
{
return m_pos;
}
@@ -316,7 +313,8 @@ pomemstream::pomemstream()
pomemstream::~pomemstream()
{
- pfree_array(m_mem);
+ if (m_mem != nullptr)
+ pfree_array(m_mem);
}
void pomemstream::vwrite(const void *buf, const pos_type n)
@@ -359,7 +357,7 @@ void pomemstream::vseek(const pos_type n)
}
}
-pstream::pos_type pomemstream::vtell()
+pstream::pos_type pomemstream::vtell() const
{
return m_pos;
}
@@ -386,11 +384,6 @@ bool putf8_reader::readline(pstring &line)
return true;
}
-putf8_fmt_writer::putf8_fmt_writer(postream &strm)
-: pfmt_writer_t()
-, putf8_writer(strm)
-{
-}
putf8_fmt_writer::~putf8_fmt_writer()
{