mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 13:40:20 +03:00
outbuffer: add scope
This commit is contained in:
parent
335a2a114f
commit
2c01a81b7a
1 changed files with 10 additions and 10 deletions
|
@ -41,7 +41,7 @@ class OutBuffer
|
||||||
/*********************************
|
/*********************************
|
||||||
* Convert to array of bytes.
|
* Convert to array of bytes.
|
||||||
*/
|
*/
|
||||||
ubyte[] toBytes() { return data[0 .. offset]; }
|
inout(ubyte)[] toBytes() scope inout { return data[0 .. offset]; }
|
||||||
|
|
||||||
/***********************************
|
/***********************************
|
||||||
* Preallocate nbytes more to the size of the internal buffer.
|
* Preallocate nbytes more to the size of the internal buffer.
|
||||||
|
@ -78,19 +78,19 @@ class OutBuffer
|
||||||
* Append data to the internal buffer.
|
* Append data to the internal buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void write(const(ubyte)[] bytes)
|
void write(scope const(ubyte)[] bytes)
|
||||||
{
|
{
|
||||||
reserve(bytes.length);
|
reserve(bytes.length);
|
||||||
data[offset .. offset + bytes.length] = bytes[];
|
data[offset .. offset + bytes.length] = bytes[];
|
||||||
offset += bytes.length;
|
offset += bytes.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(in wchar[] chars) @trusted
|
void write(scope const(wchar)[] chars) @trusted
|
||||||
{
|
{
|
||||||
write(cast(ubyte[]) chars);
|
write(cast(ubyte[]) chars);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(const(dchar)[] chars) @trusted
|
void write(scope const(dchar)[] chars) @trusted
|
||||||
{
|
{
|
||||||
write(cast(ubyte[]) chars);
|
write(cast(ubyte[]) chars);
|
||||||
}
|
}
|
||||||
|
@ -161,12 +161,12 @@ class OutBuffer
|
||||||
offset += real.sizeof;
|
offset += real.sizeof;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(in char[] s) @trusted /// ditto
|
void write(scope const(char)[] s) @trusted /// ditto
|
||||||
{
|
{
|
||||||
write(cast(ubyte[]) s);
|
write(cast(ubyte[]) s);
|
||||||
}
|
}
|
||||||
|
|
||||||
void write(OutBuffer buf) /// ditto
|
void write(scope const OutBuffer buf) /// ditto
|
||||||
{
|
{
|
||||||
write(buf.toBytes());
|
write(buf.toBytes());
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ class OutBuffer
|
||||||
* Append output of C's vprintf() to internal buffer.
|
* Append output of C's vprintf() to internal buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void vprintf(string format, va_list args) @trusted nothrow
|
void vprintf(scope string format, va_list args) @trusted nothrow
|
||||||
{
|
{
|
||||||
import core.stdc.stdio : vsnprintf;
|
import core.stdc.stdio : vsnprintf;
|
||||||
import core.stdc.stdlib : alloca;
|
import core.stdc.stdlib : alloca;
|
||||||
|
@ -290,7 +290,7 @@ class OutBuffer
|
||||||
* Append output of C's printf() to internal buffer.
|
* Append output of C's printf() to internal buffer.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void printf(string format, ...) @trusted
|
void printf(scope string format, ...) @trusted
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
|
@ -309,7 +309,7 @@ class OutBuffer
|
||||||
* $(REF _writef, std,stdio);
|
* $(REF _writef, std,stdio);
|
||||||
* $(REF formattedWrite, std,format);
|
* $(REF formattedWrite, std,format);
|
||||||
*/
|
*/
|
||||||
void writef(Char, A...)(in Char[] fmt, A args)
|
void writef(Char, A...)(scope const(Char)[] fmt, A args)
|
||||||
{
|
{
|
||||||
import std.format : formattedWrite;
|
import std.format : formattedWrite;
|
||||||
formattedWrite(this, fmt, args);
|
formattedWrite(this, fmt, args);
|
||||||
|
@ -335,7 +335,7 @@ class OutBuffer
|
||||||
* $(REF _writefln, std,stdio);
|
* $(REF _writefln, std,stdio);
|
||||||
* $(REF formattedWrite, std,format);
|
* $(REF formattedWrite, std,format);
|
||||||
*/
|
*/
|
||||||
void writefln(Char, A...)(in Char[] fmt, A args)
|
void writefln(Char, A...)(scope const(Char)[] fmt, A args)
|
||||||
{
|
{
|
||||||
import std.format : formattedWrite;
|
import std.format : formattedWrite;
|
||||||
formattedWrite(this, fmt, args);
|
formattedWrite(this, fmt, args);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue