Extracted from Pike v7.8 release 866 at 2016-11-06.
pike.ida.liu.se
[Top]
ADT
ADT.Struct

Class ADT.Struct

Description

Implements a struct which can be used for serialization and deserialization of data.

Example

class ID3 { inherit ADT.Struct; Item head = Chars(3); Item title = Chars(30); Item artist = Chars(30); Item album = Chars(30); Item year = Chars(4); Item comment = Chars(30); Item genre = Byte(); }

Stdio.File f = Stdio.File("foo.mp3"); f->seek(-128); ADT.Struct tag = ID3(f); if(tag->head=="TAG") { write("Title: %s\n", tag->title); tag->title = "A new title" + "\0"*19; f->seek(-128); f->write( (string)tag ); }

Example

class HollerithString { inherit ADT.Struct; Item strlen = Word(); Item str = Chars(strlen); }