////////////////////////////////////////////////////////////////////////////////
// Mercury and Colyseus Software Distribution 
// 
// Copyright (C) 2004-2005 Ashwin Bharambe (ashu@cs.cmu.edu)
//               2004-2005 Jeffrey Pang    (jeffpang@cs.cmu.edu)
//                    2004 Mukesh Agrawal  (mukesh@cs.cmu.edu)
// 
// 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, or (at
// your option) any later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
// USA
////////////////////////////////////////////////////////////////////////////////
#if 0 /* -*-perl-*- */


# /*
# This header file was automatically generated by itself.
# (Yup, it's a C++ header file and a perl script.)
#
# $Id: pvartmpl.h 2374 2005-11-03 21:01:25Z ashu $
# 
# Copyright (C) 1998 David Mazieres (dm@uun.org)
# Adapted by Ashwin Bharambe (ashu@cs.cmu.edu)

eval 'exec perl -w -S $0 ${1+"$@"}'
    if 0;

use strict;
use vars qw(@a);

my $NA = 10;

seek DATA, 0, 0;
while (<DATA>) {
    print;
    last if m/^\#endif \/\* perl \*\/$/;
}

print <<'EOF;';

#ifndef _PVARTMPL_H_INCLUDED_
#define _PVARTMPL_H_INCLUDED_ 1

#include <vector>
#include <string>
#include <iostream>

using namespace std;

EOF;

print <<'EOF;';
#define COMMA ,
#define LPAREN (
#define RPAREN )

EOF;

sub jc(@) {
    join (', ', @_);
}

sub nlist ($) {
    my $pat = shift;
    jc (map { my $ret = $pat; $ret =~ s/%/$_/g; $ret; } @a);
}

sub pdef(\@) {
    my $ar = shift;
    foreach $_ (@$ar[0 .. $#$ar - 1]) {
	my $nt = int ((71 - length ($_)) / 8);
	print $_, ($nt > 0 ? "\t" x $nt : ' '), "\n";
    }
    print $$ar[$#$ar], "\n" if @$ar;
}

my @lines;

my $a;
for ($a = 1; $a <= $NA; $a++) {
    local @a = (1 .. $a);
    push @lines, '', sprintf ("template<%s>", nlist 'class A%') if ($a > 0);
    push @lines, sprintf ("ostream& _print_vars (ostream& os, vector<string>& names, %s)", nlist 'const A% &a%');
    push @lines, sprintf ("{");
    foreach my $n (@a) {
	my $m = $n - 1;
	push @lines, "  os << names[$m] << \"=\" << a$n << \" \";";
    }
    push @lines, sprintf ("  return os << endl;");
    push @lines, sprintf ("}");
}
pdef @lines;
print "\n";

@lines = ();


print "\n", '#endif /', '* !_PVARTMPL_H_INCLUDED_ *', '/', "\n";

__END__
# */
#endif /* perl */

#ifndef _PVARTMPL_H_INCLUDED_
#define _PVARTMPL_H_INCLUDED_ 1

#include <vector>
#include <string>
#include <iostream>

using namespace std;

#define COMMA ,
#define LPAREN (
#define RPAREN )

								
template<class A1>						
ostream& _print_vars (ostream& os, vector<string>& names, const A1 &a1) 
{								
  os << names[0] << "=" << a1 << " ";				
  return os << endl;						
}								
								
template<class A1, class A2>					
ostream& _print_vars (ostream& os, vector<string>& names, const A1 &a1, const A2 &a2) 
{								
  os << names[0] << "=" << a1 << " ";				
  os << names[1] << "=" << a2 << " ";				
  return os << endl;						
}								
								
template<class A1, class A2, class A3>				
ostream& _print_vars (ostream& os, vector<string>& names, const A1 &a1, const A2 &a2, const A3 &a3) 
{								
  os << names[0] << "=" << a1 << " ";				
  os << names[1] << "=" << a2 << " ";				
  os << names[2] << "=" << a3 << " ";				
  return os << endl;						
}								
								
template<class A1, class A2, class A3, class A4>		
ostream& _print_vars (ostream& os, vector<string>& names, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) 
{								
  os << names[0] << "=" << a1 << " ";				
  os << names[1] << "=" << a2 << " ";				
  os << names[2] << "=" << a3 << " ";				
  os << names[3] << "=" << a4 << " ";				
  return os << endl;						
}								
								
template<class A1, class A2, class A3, class A4, class A5>	
ostream& _print_vars (ostream& os, vector<string>& names, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) 
{								
  os << names[0] << "=" << a1 << " ";				
  os << names[1] << "=" << a2 << " ";				
  os << names[2] << "=" << a3 << " ";				
  os << names[3] << "=" << a4 << " ";				
  os << names[4] << "=" << a5 << " ";				
  return os << endl;						
}								
								
template<class A1, class A2, class A3, class A4, class A5, class A6> 
ostream& _print_vars (ostream& os, vector<string>& names, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) 
{								
  os << names[0] << "=" << a1 << " ";				
  os << names[1] << "=" << a2 << " ";				
  os << names[2] << "=" << a3 << " ";				
  os << names[3] << "=" << a4 << " ";				
  os << names[4] << "=" << a5 << " ";				
  os << names[5] << "=" << a6 << " ";				
  return os << endl;						
}								
								
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7> 
ostream& _print_vars (ostream& os, vector<string>& names, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) 
{								
  os << names[0] << "=" << a1 << " ";				
  os << names[1] << "=" << a2 << " ";				
  os << names[2] << "=" << a3 << " ";				
  os << names[3] << "=" << a4 << " ";				
  os << names[4] << "=" << a5 << " ";				
  os << names[5] << "=" << a6 << " ";				
  os << names[6] << "=" << a7 << " ";				
  return os << endl;						
}								
								
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8> 
ostream& _print_vars (ostream& os, vector<string>& names, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) 
{								
  os << names[0] << "=" << a1 << " ";				
  os << names[1] << "=" << a2 << " ";				
  os << names[2] << "=" << a3 << " ";				
  os << names[3] << "=" << a4 << " ";				
  os << names[4] << "=" << a5 << " ";				
  os << names[5] << "=" << a6 << " ";				
  os << names[6] << "=" << a7 << " ";				
  os << names[7] << "=" << a8 << " ";				
  return os << endl;						
}								
								
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9> 
ostream& _print_vars (ostream& os, vector<string>& names, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) 
{								
  os << names[0] << "=" << a1 << " ";				
  os << names[1] << "=" << a2 << " ";				
  os << names[2] << "=" << a3 << " ";				
  os << names[3] << "=" << a4 << " ";				
  os << names[4] << "=" << a5 << " ";				
  os << names[5] << "=" << a6 << " ";				
  os << names[6] << "=" << a7 << " ";				
  os << names[7] << "=" << a8 << " ";				
  os << names[8] << "=" << a9 << " ";				
  return os << endl;						
}								
								
template<class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10> 
ostream& _print_vars (ostream& os, vector<string>& names, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9, const A10 &a10) 
{								
  os << names[0] << "=" << a1 << " ";				
  os << names[1] << "=" << a2 << " ";				
  os << names[2] << "=" << a3 << " ";				
  os << names[3] << "=" << a4 << " ";				
  os << names[4] << "=" << a5 << " ";				
  os << names[5] << "=" << a6 << " ";				
  os << names[6] << "=" << a7 << " ";				
  os << names[7] << "=" << a8 << " ";				
  os << names[8] << "=" << a9 << " ";				
  os << names[9] << "=" << a10 << " ";				
  return os << endl;						
}


#endif /* !_PVARTMPL_H_INCLUDED_ */
// vim: set sw=4 sts=4 ts=8 noet: 
// Local Variables:
// Mode: c++
// c-basic-offset: 4
// tab-width: 8
// indent-tabs-mode: t
// End:
