Skip to content

Commit

Permalink
added addString, addFloat, addDouble on haxe.io.BytesBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
ncannasse committed Mar 27, 2014
1 parent 8aed734 commit 2d45e2d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions std/haxe/io/BytesBuffer.hx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,40 @@ class BytesBuffer {
#end
}

public inline function addString( v : String ) {
#if neko
untyped StringBuf.__add(b, v.__s);
#elseif flash9
b.writeUTFBytes(v);
#else
add(Bytes.ofString(v));
#end
}

public inline function addFloat( v : Float ) {
#if neko
untyped StringBuf.__add(b, Output._float_bytes(v, false));
#elseif flash9
b.writeFloat(v);
#else
var b = new BytesOutput();
b.writeFloat(v);
add(b.getBytes());
#end
}

public inline function addDouble( v : Float ) {
#if neko
untyped StringBuf.__add(b, Output._double_bytes(v, false));
#elseif flash9
b.writeDouble(v);
#else
var b = new BytesOutput();
b.writeDouble(v);
add(b.getBytes());
#end
}

public inline function addBytes( src : Bytes, pos : Int, len : Int ) {
#if !neko
if( pos < 0 || len < 0 || pos + len > src.length ) throw Error.OutsideBounds;
Expand Down

0 comments on commit 2d45e2d

Please sign in to comment.