mirror of
https://github.com/holub/mame
synced 2025-04-26 18:23:08 +03:00
More stream enhancement
This commit is contained in:
parent
42ea682852
commit
ed88fd30a1
@ -370,10 +370,7 @@ bool debug_view_disasm::recompute(offs_t pc, int startline, int lines)
|
|||||||
|
|
||||||
// allocate disassembly buffer
|
// allocate disassembly buffer
|
||||||
const auto total_bytes = m_total.x * m_total.y;
|
const auto total_bytes = m_total.x * m_total.y;
|
||||||
m_dasm.reserve(total_bytes);
|
m_dasm.reserve(total_bytes).seekp(total_bytes);
|
||||||
const auto current_bytes = m_dasm.seekp(0, util::ovectorstream::end).tellp();
|
|
||||||
if (current_bytes < util::ovectorstream::pos_type(total_bytes))
|
|
||||||
util::stream_format(m_dasm, "%*s", total_bytes - int(current_bytes), "");
|
|
||||||
|
|
||||||
// iterate over lines
|
// iterate over lines
|
||||||
for (int line = 0; line < lines; line++)
|
for (int line = 0; line < lines; line++)
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#ifndef __MAME_UTIL_VECSTREAM_H__
|
#ifndef __MAME_UTIL_VECSTREAM_H__
|
||||||
#define __MAME_UTIL_VECSTREAM_H__
|
#define __MAME_UTIL_VECSTREAM_H__
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <streambuf>
|
#include <streambuf>
|
||||||
@ -26,6 +27,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace util {
|
namespace util {
|
||||||
|
|
||||||
template <typename CharT, typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT> >
|
template <typename CharT, typename Traits = std::char_traits<CharT>, typename Allocator = std::allocator<CharT> >
|
||||||
class basic_vectorbuf : public std::basic_streambuf<CharT, Traits>
|
class basic_vectorbuf : public std::basic_streambuf<CharT, Traits>
|
||||||
{
|
{
|
||||||
@ -99,6 +101,14 @@ public:
|
|||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void swap(basic_vectorbuf &that)
|
||||||
|
{
|
||||||
|
std::basic_streambuf<CharT, Traits>::swap(that);
|
||||||
|
std::swap(m_mode, that.m_mode);
|
||||||
|
m_storage.swap(that.m_storage);
|
||||||
|
std::swap(m_threshold, that.m_threshold);
|
||||||
|
}
|
||||||
|
|
||||||
void reserve(typename vector_type::size_type size)
|
void reserve(typename vector_type::size_type size)
|
||||||
{
|
{
|
||||||
if ((m_mode & std::ios_base::out) && (m_storage.size() < size))
|
if ((m_mode & std::ios_base::out) && (m_storage.size() < size))
|
||||||
@ -155,13 +165,22 @@ protected:
|
|||||||
default:
|
default:
|
||||||
return pos_type(off_type(-1));
|
return pos_type(off_type(-1));
|
||||||
}
|
}
|
||||||
if ((off_type(0) > off) || (end < off) || ((m_mode & std::ios_base::app) && out && (end != off)))
|
if ((off_type(0) > off) || ((m_mode & std::ios_base::app) && out && (end != off))) return pos_type(off_type(-1));
|
||||||
return pos_type(off_type(-1));
|
if ((out ? off_type(this->epptr() - this->pbase()) : end) < off) return pos_type(off_type(-1));
|
||||||
if (in) this->setg(this->eback(), this->eback() + off, this->egptr());
|
|
||||||
if (out)
|
if (out)
|
||||||
{
|
{
|
||||||
this->setp(this->pbase(), this->epptr());
|
this->setp(this->pbase(), this->epptr());
|
||||||
this->pbump(off);
|
this->pbump(off);
|
||||||
|
if (m_threshold < this->pptr()) m_threshold = this->pptr();
|
||||||
|
if (m_mode & std::ios_base::in)
|
||||||
|
{
|
||||||
|
if (in) this->setg(this->eback(), this->eback() + off, m_threshold);
|
||||||
|
else if (this->egptr() < m_threshold) this->setg(this->eback(), this->gptr(), m_threshold);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (in)
|
||||||
|
{
|
||||||
|
this->setg(this->eback(), this->eback() + off, this->egptr());
|
||||||
}
|
}
|
||||||
return pos_type(off);
|
return pos_type(off);
|
||||||
}
|
}
|
||||||
@ -300,7 +319,9 @@ public:
|
|||||||
vector_type const &vec() const { return rdbuf()->vec(); }
|
vector_type const &vec() const { return rdbuf()->vec(); }
|
||||||
void vec(const vector_type &content) { rdbuf()->vec(content); }
|
void vec(const vector_type &content) { rdbuf()->vec(content); }
|
||||||
void vec(vector_type &&content) { rdbuf()->vec(std::move(content)); }
|
void vec(vector_type &&content) { rdbuf()->vec(std::move(content)); }
|
||||||
void clear() { rdbuf()->clear(); }
|
basic_ivectorstream &clear() { rdbuf()->clear(); return *this; }
|
||||||
|
|
||||||
|
void swap(basic_ivectorstream &that) { std::basic_istream<CharT, Traits>::swap(that); rdbuf()->swap(*that.rdbuf()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
basic_vectorbuf<CharT, Traits, Allocator> m_rdbuf;
|
basic_vectorbuf<CharT, Traits, Allocator> m_rdbuf;
|
||||||
@ -321,8 +342,10 @@ public:
|
|||||||
vector_type const &vec() const { return rdbuf()->vec(); }
|
vector_type const &vec() const { return rdbuf()->vec(); }
|
||||||
void vec(const vector_type &content) { rdbuf()->vec(content); }
|
void vec(const vector_type &content) { rdbuf()->vec(content); }
|
||||||
void vec(vector_type &&content) { rdbuf()->vec(std::move(content)); }
|
void vec(vector_type &&content) { rdbuf()->vec(std::move(content)); }
|
||||||
void clear() { rdbuf()->clear(); }
|
basic_ovectorstream &clear() { rdbuf()->clear(); return *this; }
|
||||||
void reserve(typename vector_type::size_type size) { rdbuf()->reserve(size); }
|
basic_ovectorstream &reserve(typename vector_type::size_type size) { rdbuf()->reserve(size); return *this; }
|
||||||
|
|
||||||
|
void swap(basic_ovectorstream &that) { std::basic_ostream<CharT, Traits>::swap(that); rdbuf()->swap(*that.rdbuf()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
basic_vectorbuf<CharT, Traits, Allocator> m_rdbuf;
|
basic_vectorbuf<CharT, Traits, Allocator> m_rdbuf;
|
||||||
@ -343,8 +366,10 @@ public:
|
|||||||
vector_type const &vec() const { return rdbuf()->vec(); }
|
vector_type const &vec() const { return rdbuf()->vec(); }
|
||||||
void vec(const vector_type &content) { rdbuf()->vec(content); }
|
void vec(const vector_type &content) { rdbuf()->vec(content); }
|
||||||
void vec(vector_type &&content) { rdbuf()->vec(std::move(content)); }
|
void vec(vector_type &&content) { rdbuf()->vec(std::move(content)); }
|
||||||
void clear() { rdbuf()->clear(); }
|
basic_vectorstream &clear() { rdbuf()->clear(); return *this; }
|
||||||
void reserve(typename vector_type::size_type size) { rdbuf()->reserve(size); }
|
basic_vectorstream &reserve(typename vector_type::size_type size) { rdbuf()->reserve(size); return *this; }
|
||||||
|
|
||||||
|
void swap(basic_vectorstream &that) { std::basic_iostream<CharT, Traits>::swap(that); rdbuf()->swap(*that.rdbuf()); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
basic_vectorbuf<CharT, Traits, Allocator> m_rdbuf;
|
basic_vectorbuf<CharT, Traits, Allocator> m_rdbuf;
|
||||||
|
Loading…
Reference in New Issue
Block a user