summaryrefslogtreecommitdiffstatshomepage
path: root/src/emu/debug/textbuf.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/emu/debug/textbuf.h')
-rw-r--r--src/emu/debug/textbuf.h61
1 files changed, 30 insertions, 31 deletions
diff --git a/src/emu/debug/textbuf.h b/src/emu/debug/textbuf.h
index f7514701eec..20ad94139bb 100644
--- a/src/emu/debug/textbuf.h
+++ b/src/emu/debug/textbuf.h
@@ -11,8 +11,11 @@
#ifndef MAME_EMU_DEBUG_TEXTBUF_H
#define MAME_EMU_DEBUG_TEXTBUF_H
+#include <memory>
+
#include "emucore.h"
+
/***************************************************************************
TYPE DEFINITIONS
***************************************************************************/
@@ -25,29 +28,27 @@ struct text_buffer_line
size_t length;
};
-/* helper class that makes it possible to iterate over the lines of a text_buffer */
+// helper class for iterating over the lines of a text_buffer
class text_buffer_lines
{
private:
- text_buffer &m_buffer;
+ const text_buffer &m_buffer;
public:
- text_buffer_lines(text_buffer& buffer) : m_buffer(buffer) { }
+ text_buffer_lines(const text_buffer& buffer) : m_buffer(buffer) { }
class text_buffer_line_iterator
{
- text_buffer &m_buffer;
+ const text_buffer &m_buffer;
s32 m_lineptr;
public:
- text_buffer_line_iterator(text_buffer &buffer, s32 lineptr) :
+ text_buffer_line_iterator(const text_buffer &buffer, s32 lineptr) :
m_buffer(buffer),
m_lineptr(lineptr)
{
}
- /* technically this isn't a valid forward iterator, because
- * operator * doesn't return a reference
- */
+ // technically this isn't a valid forward iterator, because operator * doesn't return a reference
text_buffer_line operator*() const;
text_buffer_line_iterator &operator++();
@@ -55,7 +56,7 @@ public:
{
return m_lineptr != rhs.m_lineptr;
}
- /* according to C++ spec, only != is needed; == is present for completeness. */
+ // according to C++ spec, only != is needed; == is present for completeness.
bool operator==(const text_buffer_line_iterator& rhs) { return !operator!=(rhs); }
};
@@ -70,34 +71,32 @@ public:
FUNCTION PROTOTYPES
***************************************************************************/
-/* allocate a new text buffer */
-text_buffer *text_buffer_alloc(u32 bytes, u32 lines);
-
-/* free a text buffer */
-void text_buffer_free(text_buffer *text);
+// free a text buffer
+struct text_buffer_deleter { void operator()(text_buffer *text) const; };
+using text_buffer_ptr = std::unique_ptr<text_buffer, text_buffer_deleter>;
-/* clear a text buffer */
-void text_buffer_clear(text_buffer *text);
+// allocate a new text buffer
+text_buffer_ptr text_buffer_alloc(u32 bytes, u32 lines);
-/* "print" data to a text buffer */
-void text_buffer_print(text_buffer *text, const char *data);
+// clear a text buffer
+void text_buffer_clear(text_buffer &text);
-/* "print" data to a text buffer with word wrapping to a given column */
-void text_buffer_print_wrap(text_buffer *text, const char *data, int wrapcol);
+// "print" data to a text buffer
+void text_buffer_print(text_buffer &text, const char *data);
-/* get the maximum width of lines seen so far */
-u32 text_buffer_max_width(text_buffer *text);
+// "print" data to a text buffer with word wrapping to a given column
+void text_buffer_print_wrap(text_buffer &text, const char *data, int wrapcol);
-/* get the current number of lines in the buffer */
-u32 text_buffer_num_lines(text_buffer *text);
+// get the maximum width of lines seen so far
+u32 text_buffer_max_width(const text_buffer &text);
-/* get an absolute sequence number for a given line */
-u32 text_buffer_line_index_to_seqnum(text_buffer *text, u32 index);
+// get the current number of lines in the buffer
+u32 text_buffer_num_lines(const text_buffer &text);
-/* get a sequenced line from the text buffer */
-const char *text_buffer_get_seqnum_line(text_buffer *text, u32 seqnum);
+// get an absolute sequence number for a given line
+u32 text_buffer_line_index_to_seqnum(const text_buffer &text, u32 index);
-/* get an iterable container of the lines in the buffer */
-text_buffer_lines text_buffer_get_lines(text_buffer* text);
+// get a sequenced line from the text buffer
+const char *text_buffer_get_seqnum_line(const text_buffer &text, u32 seqnum);
-#endif /* MAME_EMU_DEBUG_TEXTBUF_H */
+#endif // MAME_EMU_DEBUG_TEXTBUF_H