package XML::API::Cache; use strict; use warnings; use Carp qw(croak); use UNIVERSAL qw(isa); use overload '""' => \&content; our $VERSION = '0.24'; sub new { my $proto = shift; my $class = ref($proto) || $proto; my $x = shift || croak 'XML::API::Cache->new($x)'; isa($x, 'XML::API') || croak 'argument must be XML::API derived object'; my $self = { content => $x->_fast_string, langs => [$x->_langs], }; bless($self,$class); return $self; } sub langs { my $self = shift; return @{$self->{langs}}; } sub content { my $self = shift; return $self->{content}; } 1; __END__ =head1 NAME XML::API::Cache - Cached version of an XML::API object =head1 SYNOPSIS use XML::API::Cache; my $cache = XML::API::Cache->new($xml_api_object); # store and then retrieve $cache somewhere # later: use XML::API; my $x = XML::API->new(); $x->tag_open(); $x->_add($cache); $x->tag_close(); =head1 DESCRIPTION B is a class for storing L objects in a cache. L objects are flattened, but their language attributes are kept, so that they can be efficiently stored and retrieved from somewhere but will still allow the caller to use them in the creation of XML. =head1 METHODS =head2 new Create a new L object. The first and only argument must be an L object. =head2 langs Returns the values of the _langs() method from the original L object. This is used by L when _adding() the $cache to another L object. =head2 content Returns the (fast) string value of the original L object. '""' is overloaded so you can also just print $cache. =head1 SEE ALSO L =head1 AUTHOR Mark Lawrence Enomad@null.net =head1 COPYRIGHT AND LICENSE Copyright (C) 2008 Mark Lawrence This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. =cut