Rename TextBuffer to DataBuffer
This commit is contained in:
parent
394bbda32f
commit
b2bd75c2b1
@ -1,11 +1,11 @@
|
|||||||
module jes.core.textbuffer;
|
module jes.core.databuffer;
|
||||||
|
|
||||||
import core.stdc.string;
|
import core.stdc.string;
|
||||||
import core.stdc.stdlib;
|
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;
|
enum size_t INITIAL_CAPACITY = 8u;
|
||||||
|
|
||||||
/** Number of extra bytes to allocate when growing. */
|
/** Number of extra bytes to allocate when growing. */
|
||||||
@ -21,7 +21,7 @@ class TextBuffer
|
|||||||
private ubyte * m_data;
|
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.
|
* @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()
|
~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)
|
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 position The index of the data to remove.
|
||||||
* @param n The number of bytes 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 position The index at which to insert the data.
|
||||||
* @param data The data to insert.
|
* @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
|
@property size_t size() const
|
||||||
{
|
{
|
||||||
@ -98,7 +98,7 @@ class TextBuffer
|
|||||||
{
|
{
|
||||||
if ((m_capacity - m_size) < n)
|
if ((m_capacity - m_size) < n)
|
||||||
{
|
{
|
||||||
/* Grow the text buffer. */
|
/* Grow the data buffer. */
|
||||||
m_capacity = m_size + n + GROWTH_CAPACITY;
|
m_capacity = m_size + n + GROWTH_CAPACITY;
|
||||||
ubyte * new_data = cast(ubyte *)malloc(m_capacity);
|
ubyte * new_data = cast(ubyte *)malloc(m_capacity);
|
||||||
memcpy(new_data, m_data, m_size);
|
memcpy(new_data, m_data, m_size);
|
||||||
@ -115,7 +115,7 @@ class TextBuffer
|
|||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
TextBuffer tb = new TextBuffer();
|
DataBuffer tb = new DataBuffer();
|
||||||
assert(tb.size == 0u);
|
assert(tb.size == 0u);
|
||||||
ubyte[20] dat = 5u;
|
ubyte[20] dat = 5u;
|
||||||
tb.insert(0u, dat.ptr, dat.length);
|
tb.insert(0u, dat.ptr, dat.length);
|
Loading…
x
Reference in New Issue
Block a user