English     Español
[Main Index] : Programming : Languages : Perl : CPAN Modules : Language Interfaces : SystemC
 SystemC::Template CPAN (Perl) Module 

Search

 

Documents

SystemC::Template - Replace text in a file with new text (Displayed)

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



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.


SEE ALSO

the SystemC::Netlist::File manpage the Text::Template manpage


AUTHORS

Wilson Snyder <wsnyder@wsnyder.org>

Information

This site is currently in testing, it is not yet operating using the full database. Until it is officially launched you may wish to visit Help-Site Computer Manuals. After launch, this site (HelpSpy) will replace Help-Site. Information about the spider which is currently trawling the Internet looking for links to add to this directory can be found here.
   

©Copyright Nicholas Reynolds 2004