Buffer

Undocumented in source.

Constructors

this
this(U[] data)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Aliases

toString
alias toString = data!string
Undocumented in source.

Functions

opCast
string opCast()
Undocumented in source. Be warned that the author may not have intended to support it.
opEquals
bool opEquals(U x)
Undocumented in source. Be warned that the author may not have intended to support it.
opSlice
Buffer!T opSlice(size_t m, size_t n)
Undocumented in source. Be warned that the author may not have intended to support it.
put
auto put(U[] data)

store data. Data copied

putNoCopy
auto putNoCopy(U[] data)
Undocumented in source. Be warned that the author may not have intended to support it.

Properties

back
auto ref back [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
data
auto data [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
empty
auto empty [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
front
auto ref front [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
length
size_t length [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
opDollar
auto opDollar [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
opIndex
size_t opIndex [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
popBack
void popBack [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
popBackN
size_t popBackN [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
popFront
void popFront [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
popFrontN
size_t popFrontN [@property setter]
Undocumented in source. Be warned that the author may not have intended to support it.
save
auto save [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.

Examples

static assert(isInputRange!(Buffer!ubyte));
static assert(isForwardRange!(Buffer!ubyte));
static assert(hasLength!(Buffer!ubyte));
static assert(hasSlicing!(Buffer!ubyte));
static assert(isBidirectionalRange!(Buffer!ubyte));
static assert(isRandomAccessRange!(Buffer!ubyte));

auto b = Buffer!ubyte();
b.put("abc".representation.dup);
b.put("def".representation.dup);
assert(b.length == 6);
assert(b.toString == "abcdef");
assert(b.front == 'a');
assert(b.back == 'f');
assert(equal(b[0..$], "abcdef"));
assert(equal(b[$-2..$], "ef"));
assert(b == "abcdef");
b.popFront;
b.popBack;
assert(b.front == 'b');
assert(b.back == 'e');
assert(b.length == 4);
assert(retro(b).front == 'e');
assert(countUntil(b, 'e') == 3);
assert(equal(splitter(b, 'c').array[1], ['d', 'e'])); // split "bcde" on 'c'
assert(equal(b, "bcde"));
b.popFront; b.popFront;
assert(b.front == 'd');
assert(b.front == b[0]);
assert(b.back == b[$-1]);

auto c = Buffer!ubyte();
c.put("Header0: value0\n".representation.dup);
c.put("Header1: value1\n".representation.dup);
c.put("Header2: value2\n\nbody".representation.dup);
auto c_length = c.length;
auto eoh = countUntil(c, "\n\n");
assert(eoh == 47);
foreach(header; c[0..eoh].splitter('\n') ) {
    writeln(cast(string)header.data);
}
assert(equal(findSplit(c, "\n\n")[2], "body"));
assert(c.length == c_length);

Meta