#include "classifierdb.h"
#include <tclap/CmdLine.h>
#include <string>
#include <fstream>

int main( int argc, char *argv[] )
{

#ifndef _NOMAGICK_
  try
    {
      ///set up the command line parsing
      TCLAP::CmdLine cmd("Image alignment program", ' ', "0.001");

      TCLAP::ValueArg<std::string> dbdir("d", "db", "database dirctory", true,
                                         "", "databaase");
      TCLAP::ValueArg<std::string> desfile("t", "text", "classifier type text", true,
                                           "", "text file");

      cmd.add( dbdir );
      cmd.add( desfile );

      cmd.parse(argc, argv);
      std::ifstream f;
      std::string des;
      des = "";
      f.open( desfile.getValue().c_str() );
      char buffer[512];
      while( !f.eof() )
        {
          f.read( buffer, 511 );
          des = des + buffer;
        }
      f.close();
      std::cout << "inserting \"" << des << "\n";
      classifierdb cdb;
      cdb.open( dbdir.getValue() );
      int ret;
      ret = cdb.add_classifiertype( des );
      std::cout << "classifier type inserted as " << ret << "\n";
      cdb.close();
    }
  catch (TCLAP::ArgException &e)
    {
      std::cout << "ERROR: " << e.error() 
                << " for arg " << e.argId() << "\n";
      return 0;
    }
  
#else
  std::cout << "compiled with no image magick\n";
#endif
  return 0;
}

