SystemC::Template.3pm

Langue: en

Version: 2010-05-24 (fedora - 01/12/10)

Section: 3 (Bibliothèques de fonctions)

NAME

SystemC::Template - Replace text in a file with new text

SYNOPSIS

   use SystemC::Template;
 
   my $tpl = new SystemC::Template;
   $tpl->read (filename=>'filename',
               ppline=>1,
               );
 
   $tpl->print_ln ("newfilename", 100, "inserted: This is line 100 of newfile\n");
   foreach my $lref (@{$tpl->src_text()}) {
     $tpl->print_ln ($lref->[1], $lref->[2], $lref->[3]);
   }
 
   $tpl->write (filename=>'new_filename',);
 
 

DESCRIPTION

SystemC::Template is the class that SystemC uses to read files and write the file .sp files and expand the contents of them.

It is similar to Text::Template, but uses arrays for speed, understands how to create #line comments for the C preprocessor, and not to write the file if nothing has changed.

First $read is called, which loads the $self->src_text() as a array of [$self, filename, lineno, text] structures. The external code then manipulates this array and loads $self->out_text() probably using $self->printf(). $self->write() is then called to write the results.

For convenience, most methods can be called as non-method calls, this will use the template that was most recently called with write. (This enables functions to simply call SystemC::Template::print and not need to pass the class around.)

ACCESSORS

$self->name
The filename read.
$self->ppline
Insert #line comments for GCC. If set to 'basename' strip the directory off the filename.

MEMBER FUNCTIONS

$self->read
Pass a hash of parameters. Reads the filename=> filename parameter and loads the internal structures.
$self->write
Pass a hash of parameters. Writes the filename=> parameter with the contents of the out_text() array.
$self->print_ln (filename, lineno, text...)
Adds to the out_text the filename, line and given text.
$self->print (text...)
Adds to the out_text the given text.
$self->printf (format, params...)
Adds to the out_text the given formatted text.

DISTRIBUTION

SystemPerl is part of the <http://www.veripool.org/> free SystemC software tool suite. The latest version is available from CPAN and from <http://www.veripool.org/systemperl>.

Copyright 2001-2010 by Wilson Snyder. This package is free software; you can redistribute it and/or modify it under the terms of either the GNU Lesser General Public License Version 3 or the Perl Artistic License Version 2.0.

AUTHORS

Wilson Snyder <wsnyder@wsnyder.org>

SEE ALSO

SystemC::Netlist, SystemC::Netlist::File, Text::Template