Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Perl Modules

    Stlgen 0.012

    Download button

    No screenshots available
    Downloads: 196  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Greg London | More programs
    Perl Artistic License / FREE
    July 6th, 2010, 05:51 GMT
    ROOT / Programming / Perl Modules

     Read user reviews (0)  Refer to a friend  Subscribe

    Stlgen description

    Create "Standard Template Library" (STL) C++ type containers but generate code in other languages

    Stlgen is a Perl module Create "Standard Template Library" (STL) C++ type containers but generate code in other languages.

    SYNOPSIS

    Stlgen is based off the Standard Template Library (STL) for C++ here:

     http://www.cplusplus.com/reference/stl/

    The difference is that Stlgen will generate instances of STL templates in a different language. The default language is c.

    This example below uses Stlgen to generate list_uint.(c/h) files which will implement a linked list container coded in the c language.

     #!/usr/bin/perl -w

     use Stlgen;

     my $inst = Stlgen->New(
     Template=>'list',
     Instancename => 'uint',
     payload => [
     {name=>'uint', type=>'unsigned int', dumper=>'printf("\t\tuint = %u\n", currelement->uint);'},
     ],
     );

     $inst->Instantiate();

    You could use these files in a main.c program like this:

     #include < stdio.h >
     #include "list_uint.h"

     int main (void) {

     struct list_uint_list *mylist;

     mylist = list_uint_constructor();
     
     list_uint_push_back(mylist, 21);
     list_uint_push_back(mylist, 99);
     list_uint_push_back(mylist, 33);
     list_uint_push_back(mylist, 34);
     list_uint_push_back(mylist, 67);
     list_uint_push_back(mylist, 12);
     list_uint_push_back(mylist, 28);
     list_uint_push_back(mylist, 55);
     list_uint_push_back(mylist, 76);

     list_uint_sort(mylist);

     printf("\n\n\nThis is the sorted list\n");
     list_uint_list_dumper(mylist);

     return 0;
     }


    The above c program currently works and produces the following output when you compile and execute it:

     This is the sorted list
     // list at address 140644360{
     'beforefirst' marker:
     // element at address 8621018
     prev = 0
     next = 8621088
     uint = 0
     user elements:
     // element at address 8621088
     prev = 8621018
     next = 8621038
     uint = 12
     // element at address 8621038
     prev = 8621088
     next = 8621098
     uint = 21
     // element at address 8621098
     prev = 8621038
     next = 8621058
     uint = 28
     // element at address 8621058
     prev = 8621098
     next = 8621068
     uint = 33
     // element at address 8621068
     prev = 8621058
     next = 86210a8
     uint = 34
     // element at address 86210a8
     prev = 8621068
     next = 8621078
     uint = 55
     // element at address 8621078
     prev = 86210a8
     next = 86210b8
     uint = 67
     // element at address 86210b8
     prev = 8621078
     next = 8621048
     uint = 76
     // element at address 8621048
     prev = 86210b8
     next = 8621028
     uint = 99
     'afterlast' marker:
     // element at address 8621028
     prev = 8621048
     next = 0
     uint = 0


    Note: this is a pre-alpha version. Currently the only STL container implemented is the linked list. And that hasn't been tested very well yet. The "push", "pop", "size", "sort", and "dumper" functions are known to work.


    Product's homepage

    Requirements:

    · Perl

      


    TAGS:

    Standard Template Library | C++ type containers | Perl module | STL | C++ | containers

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM