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

version» Context lines:

pike.git/lib/modules/ADT.pmod/Struct.pike:41:      constant is_struct = 1;   constant is_item = 1;   int id = ADT.get_item_id();      //! @decl void create(void|string|Stdio.File data)   //! @param data   //! Data to be decoded and populate the struct. Can   //! either be a file object or a string.   optional protected void create(void|string|object file) { -  foreach(::_indices(2), string index) { +  foreach(::_indices(this, 0), string index) {    mixed val = ::`[](index, this, 0);    if(objectp(val) && val->is_item) names[index]=val;    }    items = values(names);    sort(items->id, items);       if(file) decode(file);   }      //! @decl void decode(string|Stdio.File data)
pike.git/lib/modules/ADT.pmod/Struct.pike:70:   //! Serializes the struct into a string. This string is equal   //! to the string fed to @[decode] if nothing in the struct   //! has been altered.   string encode() {    return items->encode()*"";   }         // --- LFUN overloading.    - //! @decl static mixed `[](string item) - //! @decl static mixed `->(string item) + //! @decl protected mixed `[](string item) + //! @decl protected mixed `->(string item)   //! The struct can be indexed by item name to get the   //! associated value.    - //! @decl static mixed `[]=(string item) - //! @decl static mixed `->=(string item) + //! @decl protected mixed `[]=(string item) + //! @decl protected mixed `->=(string item)   //! It is possible to assign a new value to a struct   //! item by indexing it by name and assign a value.      protected mixed `[](string id) {    if(names[id]) return names[id]->get();    return ::`[](id, this, 0);   }      this_program get() { return this; }   
pike.git/lib/modules/ADT.pmod/Struct.pike:123:      //! The struct can be casted into a string, which is eqivivalent   //! to running @[encode], or into an array. When casted into an   //! array each array element is the encoded value of that struct   //! item.   protected mixed cast(string to) {    switch(to) {    case "string": return encode();    case "array": return items->encode();    } +  return UNDEFINED;   }         // --- Virtual struct item class      //! Interface class for struct items.   class Item {    int id = ADT.get_item_id();    constant is_item=1;   
pike.git/lib/modules/ADT.pmod/Struct.pike:322:    }   }         //! A string of bytes.   class Chars {    inherit Item;    protected Item dynsize;    protected string value;    -  //! @decl static void create(int|Item size, void|string value) +  //! @decl protected void create(int|Item size, void|string value)    //! @[size] is the number of bytes that are part of this struct    //! item, or optionally an earlier Item that will be looked up in    //! runtime.    //! The initial value of the char string is @[value] or,    //! if not provided, a string of zero bytes.    protected void create(int|Item _size, void|string _value) {    if(intp(_size))    size = _size;    else    {