#!/usr/bin/perl
# Generate debug-output statement to debug C++/Qt programs
#
# Parameters : [-label1] var1 [-label2] var2
# Prints var1 with the optionnal label1, var2 with the optionnal label2
#
# David Faure <faure@kde.org>

if (@ARGV==0 || $ARGV[0] eq "--help") {
  print "Usage : $0 [-label1] var1 [-label2] var2 ... \n";
  print "Simple usage : $0 var1 \n";
  exit 0;
}

$label="";
foreach (@ARGV)
{
  if (m/^-(.*)/) { $label=$1; }   # explicit label
  else
  {
    print "debug(QString(\"" . $label . " : " . $_ . " = '%1'\").arg(" . $_ . "));\n" if ($label);
    print "debug(QString(\"" . $_ . " = '%1'\").arg(" . $_ . "));\n" if (!$label);
    $label="";
  }
}

