ContentCollection
- Class to hold a collection of Content-instances and manipulation of that collection.
my $content=Content::JSON->new();
my $coll=ContentCollection->new(type=>$content);
$coll->resetnext();
while (my $c=$coll->next()) {
my $hash=$c->decode();
}
$coll->size();
$coll->type();
A class to hold a collection of Content-instances of a given type (no mixing). The type is set upon instantiation. It has methods to iterate over the contents of the collection and add- or remove from it.
Constructor of ContentCollection-class.
Input is type-parameter that sets the Content-class type to use in the collection. The type parameter must be a Content-class.
Creates ContentCollection instance. If wrong or no type of content-instance is specified, an empty Content-class is created.
After Content-class type has been saved it is expected that all additions of Content-classes are of the same type. If one wants to change type one needs to call the reset()-method (see description).
Return value is the instance of ContentCollection.
Resets the ContentCollection list of Content-instances.
No input is required, but if one wants one can add an instance of a Content-class. The ContentCollection will then expect all future classes that are added to be of this type.
If no Content-class is specified the reset()-method keeps the already set Content-class type.
Return value is 1 for success.
Adds a Content-class instance to the ContentCollection list.
Return value is 1 upon success and 0 upon failure. Please check the error()-method to establish exact reason.
Removes a Content-class instance from the ContentCollection list.
A parameter that gives the Content-class instance is expected as input. If no input is given or wrong Content-class type it will result in failure.
Return valyes are 1 upon success and 0 upon failure. Please call the error()-method to establish the full reason.
Returns the Content-class type that the ContentCollection consists of or expects to be used.
No input required.
Resets the next()-methods position counter, so that one can start giving out Content-class from the beginning of the list.
Return value is 1 for success.
Retrives the next Content-class instance from the ContentCollection list.
Return the Content-class instance upon success and undef upon failure.
No input needed. Returns the number of Content-class elements in the collection.
Returns the last error message from the ContentCollection-class.
No input is required.