From b2bd75c2b1b05c094891b886734b6de8054ad6c6 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Fri, 19 Mar 2021 19:14:34 -0400 Subject: [PATCH] Rename TextBuffer to DataBuffer --- src/jes/core/{textbuffer.d => databuffer.d} | 24 ++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) rename src/jes/core/{textbuffer.d => databuffer.d} (87%) diff --git a/src/jes/core/textbuffer.d b/src/jes/core/databuffer.d similarity index 87% rename from src/jes/core/textbuffer.d rename to src/jes/core/databuffer.d index b278669..e059cda 100644 --- a/src/jes/core/textbuffer.d +++ b/src/jes/core/databuffer.d @@ -1,11 +1,11 @@ -module jes.core.textbuffer; +module jes.core.databuffer; import core.stdc.string; import core.stdc.stdlib; -class TextBuffer +class DataBuffer { - /** Number of bytes to initially allocate for an empty text buffer. */ + /** Number of bytes to initially allocate for an empty data buffer. */ enum size_t INITIAL_CAPACITY = 8u; /** Number of extra bytes to allocate when growing. */ @@ -21,7 +21,7 @@ class TextBuffer private ubyte * m_data; /** - * Construct a TextBuffer object that is initially empty. + * Construct a DataBuffer object that is initially empty. * * @param capacity The number of bytes to initially allocate. */ @@ -31,7 +31,7 @@ class TextBuffer } /** - * Destructor for a TextBuffer object. + * Destructor for a DataBuffer object. */ ~this() { @@ -39,9 +39,9 @@ class TextBuffer } /** - * Get the address of a byte in the text buffer. + * Get the address of a byte in the data buffer. * - * @param offset Byte offset into the text buffer. + * @param offset Byte offset into the data buffer. */ ubyte * address(size_t offset) { @@ -49,7 +49,7 @@ class TextBuffer } /** - * Erase data from the text buffer. + * Erase data from the data buffer. * * @param position The index of the data to remove. * @param n The number of bytes to remove. @@ -64,7 +64,7 @@ class TextBuffer } /** - * Insert data into the text buffer. + * Insert data into the data buffer. * * @param position The index at which to insert the data. * @param data The data to insert. @@ -82,7 +82,7 @@ class TextBuffer } /** - * Get the size of the data in the text buffer. + * Get the size of the data in the data buffer. */ @property size_t size() const { @@ -98,7 +98,7 @@ class TextBuffer { if ((m_capacity - m_size) < n) { - /* Grow the text buffer. */ + /* Grow the data buffer. */ m_capacity = m_size + n + GROWTH_CAPACITY; ubyte * new_data = cast(ubyte *)malloc(m_capacity); memcpy(new_data, m_data, m_size); @@ -115,7 +115,7 @@ class TextBuffer unittest { - TextBuffer tb = new TextBuffer(); + DataBuffer tb = new DataBuffer(); assert(tb.size == 0u); ubyte[20] dat = 5u; tb.insert(0u, dat.ptr, dat.length);