pike.git / lib / modules / ADT.pmod / module.pmod

version» Context lines:

pike.git/lib/modules/ADT.pmod/module.pmod:38:    //! Trims the buffer to only contain the data after the    //! read pointer and returns the contents of the buffer.    string(0..255) contents()    {    return (string(8bit))this;    }       //! Adds the data @[s] verbatim to the end of the buffer.    this_program add_data(string(0..255) s)    { -  add(s); -  return this; +  return [object(this_program)]add(s);    }       //! Return all the data in the buffer and empties it.    string(0..255) pop_data()    {    return read();    }       //! Appends an unsigned integer in network order to the buffer.    //!    //! @param i    //! Unsigned integer to append.    //! @param len    //! Length of integer in bytes.    this_program put_uint(int i, int(0..) len)    { -  add_int(i,len); -  return this; +  return [object(this_program)]add_int(i,len);    }       //! Appends a variable stringĀ @[s] preceded with an unsigned integer    //! of the size @[len_width] declaring the length of the string. The    //! string @[s] should be 8 bits wide.    this_program put_var_string(string(0..255) s, int(0..) len_width)    { -  add_hstring(s,len_width); -  return this; +  return [object(this_program)]add_hstring(s,len_width);    }       //! Appends a bignum @[i] as a variable string preceded with an    //! unsigned integer of the size @[len_width] declaring the length    //! of the string. @[len_width] defaults to 2.    this_program put_bignum(Gmp.mpz i, int(0..)|void len_width)    { -  add_hstring(i->digits(256),len_width||2); -  return this; +  return [object(this_program)]add_hstring(i->digits(256),len_width||2);    }       //! Appends the fix sized string @[s] to the buffer.    this_program put_fix_string(string(0..255) s)    { -  add(s); -  return this; +  return [object(this_program)]add(s);    }       //! Appends an array of unsigned integers of width @[item_size]    //! to the buffer.    this_program put_fix_uint_array(array(int) data, int(0..) item_size)    { -  foreach(data, int i) -  add_int(i, item_size); -  return this; +  return [object(this_program)]add_ints(data,item_size);    }       //! Appends an array of unsigned integers of width @[item_size]    //! to the buffer, preceded with an unsigned integer @[len] declaring    //! the size of the array in bytes.    this_program put_var_uint_array(array(int) data, int(0..) item_size, int(0..) len)    {    add_int(sizeof(data)*item_size, len ); -  put_fix_uint_array(data, item_size); -  return this; +  return [object(this_program)]add_ints(data,item_size);    }       //! Appends an array of variable length strings with @[item_size]    //! bytes hollerith coding, prefixed by a @[len] bytes large integer    //! declaring the total size of the array in bytes.    this_program put_var_string_array(array(string(8bit)) data, int(0..) item_size, int(0..) len)    {    Stdio.IOBuffer sub = Stdio.IOBuffer();    foreach(data, string(8bit) s)    sub->add_hstring(s, item_size);    add_int(sizeof(sub),len); -  add(sub); -  return this; +  return [object(this_program)]add(sub);    }       //! Reads an unsigned integer from the buffer.    int(0..) get_uint(int len)    {    return read_int(len);    }       //! Reads a fixed sized string of length @[len] from the buffer.    string(0..255) get_fix_string(int len)