/* Copyright (c) 1997-2004
   Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Berlin, Germany)
   http://www.math.tu-berlin.de/polymake,  mailto:polymake@math.tu-berlin.de

   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: http://www.gnu.org/licenses/gpl.txt.

   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.
*/

#ident "$Project: polymake $$Id: transform.cc,v 1.18 2004/09/20 16:07:32 gawrilow Exp $"

#include <transform.h>
#include <Array.h>
#include <Poly.h>
#include <ctime>
#include <cstdlib>
#include <sstream>

namespace polymake { namespace polytope {

void transform_copy_labels (Poly& p_out, Poly& p_in,
			    const std::string& comment,
			    const char* out_section, const char* in_section)
{
   Array<std::string> labels;
   if (!in_section) in_section=out_section;
   if (p_in.lookup(in_section) >> labels)
      p_out.take(out_section) << comment << labels;
}

std::string transform_comment(const char* program, const char* in_name)
{
   time_t t;
   time(&t);
   char *time_stamp = asctime(localtime(&t));

   std::ostringstream comment;
   comment << "# " << program << ": from " << in_name << ": " << time_stamp;
   return comment.str();
}

} } // end namespace polymake
