How big is my StringBuf?

class My_buffer extends StringBuf
{    
    public var length        : Int;
    
    public function new()
    {
        super();
        this.length = 0;

    }
    
    public function append(t : String)
    {
        this.length += t.length;        
        super.add(t);
    }
}

This allows you to add (append) a string of any size to the current buffer - and let the buffer keep an eye on it's own size like a normal string. Note that the append function cannot override StringBuf's add function as it's inlined in the current (2.07) library.

version #10302, modified 2011-03-12 23:56:26 by Smidoid