Lines Matching refs:struct
15 @EXPORT = qw(struct);
58 # do we ever export anything else than 'struct'...?
61 goto &struct;
65 sub struct {
68 # struct( class => [ element-list ])
69 # struct( class => { element-list })
70 # struct( element-list )
71 # Latter form assumes current package name as struct name.
177 croak "'$type' is not a valid struct element type";
190 warnings::warnif("function '$name' already defined, overrides struct accessor method");
235 confess "struct usage error";
239 croak 'struct class cannot be a subclass (@ISA not allowed)';
249 Class::Struct - declare struct-like datatypes as Perl classes
254 # declare struct, based on array:
255 struct( CLASS_NAME => [ ELEMENT_NAME => ELEMENT_TYPE, ... ]);
256 # declare struct, based on hash:
257 struct( CLASS_NAME => { ELEMENT_NAME => ELEMENT_TYPE, ... });
261 # declare struct, based on array, implicit class name:
262 struct( ELEMENT_NAME => ELEMENT_TYPE, ... );
264 # Declare struct at compile time
268 # declare struct at compile time, based on array, implicit
275 # declare struct with four types of elements:
276 struct( s => '$', a => '@', h => '%', c => 'My_Other_Class' );
301 C<Class::Struct> exports a single function, C<struct>.
303 a class name, C<struct> creates a Perl 5 class that implements
304 a "struct-like" data structure.
307 struct objects.
309 Each element in the struct data has an accessor method, which is
316 =head2 The C<struct()> function
318 The C<struct> function has three forms of parameter-list.
320 struct( CLASS_NAME => [ ELEMENT_LIST ]);
321 struct( CLASS_NAME => { ELEMENT_LIST });
322 struct( ELEMENT_LIST );
334 The class created by C<struct> must not be a subclass of another
343 created by C<struct>.
349 Each name-type pair declares one element of the struct. Each
370 The accessor method provided by C<struct> for an element depends
441 C<struct> always creates a constructor called C<new>. That constructor
443 struct.
462 Giving a struct element a class type that is also a struct is how
469 struct( Rusage => {
474 struct( Timeval => [
500 # declare the struct
501 struct ( 'MyObj', { count => '$', stuff => '%' } );
528 of I<element>=>I<value> pairs, with which to initialize the struct.
535 that are passed on to the nested struct's constructor.
539 struct Breed =>
545 struct Cat =>
581 struct { mother => 'Person', father => 'Person'};
598 Corrected behaviour of accessors for '*@' and '*%' struct
608 Use of struct() in a subclass prohibited.
612 Class name to struct() made optional.
617 # Template.pm --- struct/member template builder