Exemple #1
0
int main(int argc, char** argv) {
   checkOptions(options, argc, argv);
   HumdrumStream streamer(options);
   HumdrumFile infile;

   if (summaryQ) {
      Summary.setSize(1000);
      Summary.setAll(0);
   }

   while (streamer.read(infile)) {
      if (!streamer.eof()) {
         // if there are multiple segments, store a segement marker
         // for each segment.  Do not store if only a single segment,
         // unless --segement option is given.
         SEGMENTS = 1;
      }
      processFile(infile, infile.getFileName());
   }

   if (summaryQ) {
      printSummary(Summary);
   }
  
   return 0;
}
Exemple #2
0
int main(int argc, char* argv[]) {
   HumdrumFile infile;

   // process the command-line options
   checkOptions(options, argc, argv);

   // figure out the number of input files to process
   int numinputs = options.getArgCount();

   Array<double> values;
   values.setSize(0);

   Array<double> midibins;
   midibins.setSize(128);
   midibins.setAll(0);
   midibins.allowGrowth(0);

   for (int i=0; i<numinputs || i==0; i++) {
      infile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         infile.read(cin);
      } else {
         infile.read(options.getArg(i+1));
      }

      generateAnalysis(infile, midibins);
   }

   printAnalysis(midibins);

   return 0;
}
Exemple #3
0
int main(int argc, char* argv[]) {
   checkOptions(options, argc, argv);

   Array<PixelRow> picturedata;
   Array<PixelRow> background;
   HumdrumFile infile;

   int numinputs = options.getArgCount();
   if (numinputs > 0) {
      const char* filenameIn  = options.getArg(1).data();
      infile.read(filenameIn);
   } else {
      infile.read(cin);
   }

   if (infile.getFilename().size() == 0) {
      infile.setFilename(optionfilename);
   }

   if (jsonQ) {
      createJsonProll(infile);
   } else {
      int rfactor = generatePicture(infile, picturedata, style);
      generateBackground(infile, rfactor, picturedata, background);
      printPicture(picturedata, background, rfactor, cfactor, 
            gminpitch, gmaxpitch, infile);
   }

   return 0;
}
Exemple #4
0
int main(int argc, char* argv[]) {
   HumdrumFile infile, outfile;

   // process the command-line options
   checkOptions(options, argc, argv);

   // figure out the number of input files to process
   int numinputs = options.getArgCount();

   for (int i=0; i<numinputs || i==0; i++) {
      infile.clear();
      outfile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         infile.read(cin);
      } else {
         infile.read(options.getArg(i+1));
      }
      // analyze the input file according to command-line options
      processRecords(infile, outfile);

      outfile.write(cout);
   }

   return 0;
}
Exemple #5
0
Map::Map(const fs::path& directory, const Options& options)
    : dlock_(directory.string()) {
  checkOptions(options);
  Options partition_options;
  partition_options.readonly = options.readonly;
  partition_options.block_size = options.block_size;
  internal::Descriptor descriptor;
  if (internal::Descriptor::tryReadFromDirectory(directory, &descriptor)) {
    checkDescriptor(descriptor, directory);
    mt::Check::isFalse(options.error_if_exists, "Map in %s already exists",
                       fs::absolute(directory).c_str());
    partitions_.resize(descriptor.num_partitions);

  } else {
    mt::Check::isTrue(options.create_if_missing, "Map in %s does not exist",
                      fs::absolute(directory).c_str());
    partitions_.resize(mt::nextPrime(options.num_partitions));
    descriptor.map_type = internal::Descriptor::TYPE_MAP;
    descriptor.num_partitions = partitions_.size();
    descriptor.writeToDirectory(directory);
  }
  for (size_t i = 0; i != partitions_.size(); i++) {
    const fs::path prefix = directory / getPartitionPrefix(i);
    partitions_[i].reset(new internal::Partition(prefix, partition_options));
  }
}
Exemple #6
0
int main(int argc, char** argv) {
   // process the command-line options
   checkOptions(options, argc, argv);
   HumdrumFile infile;
   int i;

   Array<Array<char> > idtags;
   int idtagQ = 0;
   firstinput.read(options.getArg(1));

   for (i=1; i<=options.getArgCount(); i++) {
      infile.clear();
      infile.read(options.getArg(i));
      if (i ==1) {
         idtagQ = getIdTags(idtags, infile);
      }

      if (idtagQ && i > 1) {
         printFileID(infile, i-1, options.getArgCount(), idtags);
      } else {
         printFile(infile, i-1, options.getArgCount());
      }
   }

   return 0;
}
Exemple #7
0
int main(int argc, char** argv) {
   // process the command-line options
   checkOptions(options, argc, argv);

   HumdrumFile infile;
   infile.read(options.getArg(1));
   if (distQ) {
      infile.analyzeRhythm();
   }
   Array<NoteUnit> notes;
   getNotes(notes, infile);
   scrambleNotes(notes);
   if (transQ) {
      printNotes(notes);
   } else {
      replaceNotes(infile, notes);
      cout << infile;
   }

   if (displaySeedQ) {
      cout << "!!!seed: " << seed << endl;
   }

   return 0;
}
Exemple #8
0
int main(int argc, char** argv) {
   HumdrumFile hfile;

   checkOptions(options, argc, argv);  // process the command-line options

   // figure out the number of input files to process
   int numinputs = options.getArgCount();

   for (int i=0; i<numinputs || i==0; i++) {
      hfile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         hfile.read(cin);
      } else {
         hfile.read(options.getArg(i+1));
      }
      // hfile.analyzeRhythm();

      Array<int> transform;
      getTransformation(hfile, transform);
      if (!determineQ) {
         printTransformation(hfile, transform);
      }

   }

   return 0;
}
Exemple #9
0
int main(int argc, char* argv[]) {
    HumdrumFile infile;

    // process the command-line options
    checkOptions(options, argc, argv);

    // figure out the number of input files to process
    int numinputs = options.getArgCount();

    Array<double> absbeat;
    Array<int> pitch;
    Array<int> testset;
    Array<double> duration;
    Array<double> level;
    Array<double> coef;

    for (int i=0; i<numinputs || i==0; i++) {
        infile.clear();

        // if no command-line arguments read data file from standard input
        if (numinputs < 1) {
            infile.read(cin);
        } else {
            infile.read(options.getArg(i+1));
        }
        infile.analyzeRhythm();
        cout << "(cmn\n";
        convertToCMN(infile);
        cout << ")\n";
    }

    return 0;
}
Exemple #10
0
int main(int argc, char* argv[]) {
   HumdrumFile    infile;
   Array<double>  timings;
   Array<double>  tempo;

   // process the command-line options
   checkOptions(options, argc, argv);

   // figure out the number of input files to process
   int numinputs = options.getArgCount();

   for (int i=0; i<numinputs || i==0; i++) {
      infile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         infile.read(cin);
      } else {
         infile.read(options.getArg(i+1));
      }

      analyzeTiming(infile, timings, tempo);
      generateSwing(infile, timings, percentage);
      printAnalysis(infile, timings, tempo);
   }

   return 0;
}
Exemple #11
0
int LPSolver::run(const Properties& options, const Arguments& arguments) {
    int r = 0;

    if ((r = checkOptions(options)) != 0) {
        return r;
    }

    LOG4CXX_INFO(logger, "solverLP begin");

    size_t loops = options.get< size_t >("l", INT_MAX);
    // input & output opened
    std::istream* is = &std::cin;
    if (options.find("i") != options.not_found()) {
        std::string file = options.get< std::string >("i");
        is = new std::ifstream(file.c_str());

        LOG4CXX_DEBUG(logger, boost::format("input: %s") % file);
    }
    if (is == &std::cin) {
        std::cin.sync_with_stdio(false);
    }
    std::ostream* os = &std::cout;
    if (options.find("o") != options.not_found()) {
        std::string file = options.get< std::string >("o");
        os = new std::ofstream(file.c_str());

        LOG4CXX_DEBUG(logger, boost::format("output: %s") % file);
    }

    Graph graph;

	// read graph data
    if (r == 0 && !Graph_read(graph, *is)) {
        LOG4CXX_ERROR(logger, boost::format("failed to read graph from stream!!!"));
        r = 1;
    }

    PositionList position_tbl(options.get< size_t >("EDGE_CLUSTER_NUM"), 0);
    // divide into connected components and solve them one by one.
    if (r == 0 && !Graph_divide(graph, loops, &position_tbl)) {
        LOG4CXX_ERROR(logger, boost::format("solve LP failed!!!"));
        r = 2;
    }
    // write graph data
    if (r == 0 && !PositionList_write(position_tbl, *os)) {
        LOG4CXX_ERROR(logger, boost::format("failed to write position to stream!!!"));
        r = 3;
    }

    // input & output closed
    if (os != &std::cout) {
        delete os;
    }
    if (is != &std::cin) {
        delete is;
    }

    LOG4CXX_INFO(logger, "solveLP end");
    return r;
}
Exemple #12
0
int main(int argc, char** argv) {
   // process the command-line options
   checkOptions(options, argc, argv);

   // figure out the number of input files to process
   int numinputs = options.getArgCount();

   HumdrumFile hfile;
   for (int i=0; i<numinputs || i==0; i++) {
      hfile.clear();

      // if no command-line arguments read data file from standard input
      if (numinputs < 1) {
         hfile.read(cin);
      } else {
         hfile.read(options.getArg(i+1));
      }

      hfile.analyzeRhythm();
      divisions = hfile.getMinTimeBase();
      if (divisions % 4 == 0) {
         divisions = divisions/4;
      } else {
         // don't know what this case may be
      }
      convertToMusicXML(hfile);

   }

   return 0;
}
Exemple #13
0
int main(int argc, char* argv[]) {
	HumdrumFileSet infiles;

	// process the command-line options
	checkOptions(options, argc, argv);

	// figure out the number of input files to process
	int numinputs = options.getArgCount();

	if (numinputs < 1) {
		infiles.read(cin);
	} else {
		for (int i=0; i<numinputs; i++) {
			infiles.readAppend(options.getArg(i+1));
		}
	}

	for (int i=0; i<infiles.getCount(); i++) {
		if (rhythmQ) {
			printKernOutput(infiles[i]);
		} else {
			printOutput(infiles[i]);
		}
	}

	return 0;
}
/* -------------------------------------------------------------------------
 * main
 * ----------------------------------------------------------------------- */
int
main(int argc, char** argv) {
    OptionsCont& oc = OptionsCont::getOptions();
    // give some application descriptions
    oc.setApplicationDescription("Road network importer / builder for the road traffic simulation SUMO.");
    oc.setApplicationName("netconvert", "SUMO netconvert Version " + (std::string)VERSION_STRING);
    int ret = 0;
    try {
        XMLSubSys::init(false);
        fillOptions();
        OptionsIO::getOptions(true, argc, argv);
        if (oc.processMetaOptions(argc < 2)) {
            SystemFrame::close();
            return 0;
        }
        MsgHandler::initOutputOptions();
        if (!checkOptions()) {
            throw ProcessError();
        }
        RandHelper::initRandGlobal();
        NBNetBuilder nb;
        nb.applyOptions(oc);
        // load data
        NILoader nl(nb);
        nl.load(oc);
        if (oc.getBool("ignore-errors")) {
            MsgHandler::getErrorInstance()->clear();
        }
        // check whether any errors occured
        if (MsgHandler::getErrorInstance()->wasInformed()) {
            throw ProcessError();
        }
        nb.compute(oc);
        if(oc.getAnyVerbosity())
          std::cout<<"Writing output file..."<<std::endl;
        NWFrame::writeNetwork(oc, nb);
        if(oc.getAnyVerbosity())
          std::cout<<"Output file writed"<<std::endl;
    } catch (ProcessError& e) {
        if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
            WRITE_ERROR(e.what());
        }
        MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
        ret = 1;
#ifndef _DEBUG
    } catch (...) {
        MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
        ret = 1;
#endif
    }
    NBDistribution::clear();
    OutputDevice::closeAll();
    SystemFrame::close();
    // report about ending
    if (ret == 0) {
        std::cout << "Success." << std::endl;
    }
    return ret;
}
Exemple #15
0
extern int main (int __unused__ argc, char **argv)
{
	cookedArgs *args;
#ifdef VMS
	extern int getredirection (int *ac, char ***av);

	/* do wildcard expansion and I/O redirection */
	getredirection (&argc, &argv);
#endif

#ifdef AMIGA
	/* This program doesn't work when started from the Workbench */
	if (argc == 0)
		exit (1);
#endif

#ifdef __EMX__
	_wildcard (&argc, &argv);  /* expand wildcards in argument list */
#endif

#if defined (macintosh) && BUILD_MPW_TOOL == 0
	argc = ccommand (&argv);
#endif

	setCurrentDirectory ();
	setExecutableName (*argv++);
	sanitizeEnviron ();
	checkRegex ();

	args = cArgNewFromArgv (argv);
	previewFirstOption (args);
	testEtagsInvocation ();
	initializeParsing ();
	initOptions ();
	readOptionConfiguration ();
	verbose ("Reading initial options from command line\n");
	parseOptions (args);
	checkOptions ();
	unifyLanguageMaps ();
	makeTags (args);

	/*  Clean up.
	 */
	cArgDelete (args);
	freeKeywordTable ();
	freeRoutineResources ();
	freeSourceFileResources ();
	freeTagFileResources ();
	freeOptionResources ();
	freeParserResources ();
	freeRegexResources ();
	freeXcmdResources ();

	if (Option.guessParser)
		return (Option.guessParser == TRUE)? 0: 1;

	exit (0);
	return 0;
}
Exemple #16
0
int main(int argc, char** argv) {
   // process the command-line options
   checkOptions(options, argc, argv);

   HumdrumFile hfile(options.getArg(1).data());
   hfile.analyzeRhythm("4");
   printOutput(hfile);
   return 0;
}
Exemple #17
0
	int Program::run(int argc, char **argv)
	{
		setLocale();
#ifdef WIN32
		auto command_line = po::split_winmain(ucsToUtf8(wstring(GetCommandLine())));
		command_line.erase(command_line.begin());
#else
		vector<string> command_line;
		command_line.resize(argc - 1);
		for (int i = 1; i < argc; i++) {
			command_line[i - 1] = argv[i];
		}
#endif
		auto command_name = getCommandName(command_line);
		if (!command_name.first) return EXIT_FAILURE;

		if (command_name.first && command_name.second == ""){
			printHelp();
			return EXIT_FAILURE;
		}
		auto command = findCommand(command_name.second.c_str());
		if (!command){
			cerr << program_name << ": " << "unknown command '" << command_name.second << "'" << "\n";
			printHelp();
			return EXIT_FAILURE;
		}

		try{
			po::options_description all_options, global_options, options, hidden_options;
			po::positional_options_description positional_options;
			string command_confirm;
			addGlobalOptions(global_options);
			hidden_options.add_options()
				("command",  po::value<string>(&command_confirm), "")
			;
			positional_options.add("command", 1);
			command->addOptions(options, hidden_options);
			command->addPositionalOptions(positional_options);
			all_options.add(global_options).add(options).add(hidden_options);
			auto parsed = po::command_line_parser(command_line).options(all_options).positional(positional_options).run();
			po::variables_map vm;
			po::store(parsed, vm);
			po::notify(vm);
			if (vm.count("help")) {
				printHelp(*command);
				return EXIT_SUCCESS;
			}
			if (!command->checkOptions(vm)){
				printHelp(*command);
				return EXIT_FAILURE;
			}
			return command->run();
		}catch(const exception &e){
			cerr << program_name << ": " << e.what() << "\n";
			return EXIT_FAILURE;
		}
	}
Exemple #18
0
int main(int argc, char* argv[]) {
   HumdrumFileSet infiles;
   checkOptions(options, argc, argv);
   infiles.read(options);
   string filename;

   // for now only deal with a single segment:
   processFile(infiles[0]);
   return 0;
}
Exemple #19
0
int
main(int argc, char** argv) {
    OptionsCont& oc = OptionsCont::getOptions();
    // give some application descriptions
    oc.setApplicationDescription("Road network generator for the microscopic road traffic simulation SUMO.");
    oc.setApplicationName("netgen", "SUMO netgen Version " + (std::string)VERSION_STRING);
    int ret = 0;
    try {
        // initialise the application system (messaging, xml, options)
        XMLSubSys::init(false);
        fillOptions();
        OptionsIO::getOptions(true, argc, argv);
        if (oc.processMetaOptions(argc < 2)) {
            SystemFrame::close();
            return 0;
        }
        MsgHandler::initOutputOptions();
        if (!checkOptions()) {
            throw ProcessError();
        }
        RandHelper::initRandGlobal();
        NBNetBuilder nb;
        nb.applyOptions(oc);
        // build the netgen-network description
        NGNet* net = buildNetwork(nb);
        // ... and we have to do this...
        oc.resetWritable();
        // transfer to the netbuilding structures
        net->toNB();
        delete net;
        // report generated structures
        WRITE_MESSAGE(" Generation done;");
        WRITE_MESSAGE("   " + toString<int>(nb.getNodeCont().size()) + " nodes generated.");
        WRITE_MESSAGE("   " + toString<int>(nb.getEdgeCont().size()) + " edges generated.");
        nb.compute(oc);
        NWFrame::writeNetwork(oc, nb);
    } catch (ProcessError& e) {
        if (std::string(e.what()) != std::string("Process Error") && std::string(e.what()) != std::string("")) {
            WRITE_ERROR(e.what());
        }
        MsgHandler::getErrorInstance()->inform("Quitting (on error).", false);
        ret = 1;
#ifndef _DEBUG
    } catch (...) {
        MsgHandler::getErrorInstance()->inform("Quitting (on unknown error).", false);
        ret = 1;
#endif
    }
    OutputDevice::closeAll();
    SystemFrame::close();
    if (ret == 0) {
        std::cout << "Success." << std::endl;
    }
    return ret;
}
Exemple #20
0
int Prefs::loadFromFile(const char *path) {
  char buffer[512], *line, *key, *value;
  FILE *fd;
  const struct option *opt;

  config_file_path = strdup(path);

  fd = fopen(config_file_path, "r");

  if(fd == NULL) {
    ntop->getTrace()->traceEvent(TRACE_WARNING, "Config file %s not found", config_file_path);
    return(-1);
  }

  while(fd) {
    if(!(line = fgets(buffer, sizeof(buffer), fd)))
      break;

    line = Utils::trim(line);

    if(strlen(line) < 1 || line[0] == '#')
      continue;

    key = line;
    key = Utils::trim(key);

    value = strrchr(line, '=');

    /* Fallback to space */
    if(value == NULL) value = strrchr(line, ' ');

    if(value == NULL)
      value = &line[strlen(line)]; /* empty */
    else
      value[0] = 0, value = &value[1];
    value = Utils::trim(value);

    if(strlen(key) > 2) key = &key[2];
    else key = &key[1];

    opt = long_options;
    while (opt->name != NULL) {
      if((strcmp(opt->name, key) == 0)
	  || ((key[1] == '\0') && (opt->val == key[0]))) {
        setOption(opt->val, value);
        break;
      }
      opt++;
    }
  }

  fclose(fd);

  return(checkOptions());
}
Exemple #21
0
int main(int argc, char** argv) {
   // process the command-line options
   checkOptions(options, argc, argv);
   HumdrumFile infile;
   Array<Array<char> > templatedata;
   Array<Array<char> > sourcedata;
   Array<int> datalines;

   if ((options.getArgCount() < 1) || (options.getArgCount() > 2)) {
      usage(options.getCommand().data());
      exit(1);
   }

   int sourcearg   = 1;
   int templatearg = 2;
   if (reverseQ) {
      sourcearg   = 2;
      templatearg = 1;
   }
   
   if (options.getArgCount() == 2) {
      infile.read(options.getArg(sourcearg));
      readTemplateContents(templatedata, options.getArg(templatearg).data());

   } else {
      // read second file from standard input
      if (sourcearg == 1) {
         infile.read(options.getArg(1));
	 readTemplateContents(templatedata, cin);
      } else {
         infile.read(cin);
	 readTemplateContents(templatedata, options.getArg(1).data());
      }
   }

   int spine = chooseSpine(interp, infile);

   fillSourceData(sourcedata, datalines, infile, spine, nullQ);

   if (debugQ) {
      cout << "SOURCE DATA: " << endl;
      printTemplate(sourcedata);
      cout << "TEMPLATE DATA: " << endl;
      printTemplate(templatedata);
   }
        

   doDamerauLevenshteinAnalysis(sourcedata, templatedata);

   if (pweightQ) {
      printWeights();
   }

   return 0;
}
Exemple #22
0
Metis::Metis(int Ptype, 
	  int Mtype, 
	  int coarsenTo,
	  int Rtype, 
	  int IPtype)
:myPtype(Ptype), myMtype(Mtype), myCoarsenTo(coarsenTo), myRtype(Rtype), 
 myIPtype(IPtype), defaultOptions(false)
{
    // check the options are valid
    checkOptions();
}    
Exemple #23
0
int Prefs::loadFromCLI(int argc, char *argv[]) {
  u_char c;

  while((c = getopt_long(argc, argv, "c:eg:hi:w:r:sg:m:n:p:qd:x:1:2:3:lvA:B:CD:E:FG:HS:U:X:W:",
			 long_options, NULL)) != '?') {
    if(c == 255) break;
    setOption(c, optarg);
  }

  return(checkOptions());
}
Exemple #24
0
Network::Network(int ac, char** av, SafeQueue<Event>* safeEvents)
  : _entryGetter(std::cin),
    _safeEvents(safeEvents),
    _commands(safeEvents),
    _remain("")
{
  if (!checkOptions(ac, av))
    throw ZappyError::ArgumentsError(USAGE);
  _timeOut.tv_sec = 3;
  _timeOut.tv_usec = 0;
}
Exemple #25
0
void InitD3DExports(const char *vboxName, const char *msName)
{
    const char *dllName;
    HANDLE hDLL;

    if (isVBox3DEnabled() && checkOptions())
        dllName = vboxName;
    else
        dllName = msName;

    hDLL = loadSystemDll(dllName);
    FillD3DExports(hDLL); 
}
Exemple #26
0
int main(int argc, char** argv) {
   // process the command-line options
   checkOptions(options, argc, argv);
   HumdrumStream streamer(options);
   HumdrumFile hfile;
   if (!streamer.read(hfile)) {
      // no data could be read
      exit(1);
   }
   hfile.analyzeRhythm("4");
   printOutput(hfile);
   return 0;
}
Exemple #27
0
int mainU (int argc, SAP_UC ** argv)
{
    OPTIONS options = {};
    if(!parseCommand(argc, argv, &options))
        return 0;
    if(!checkOptions(&options))
    {
        showHelp();
        return 1;
    }
    RFC_RC rc = startRfc(&options);
    return rc;
}
int main(int argc, char* argv[]) {
   checkOptions(options, argc, argv);
   HumdrumFile infile;
   infile.read(options.getArg(1));
   MidiFile midifile;
   createMidiFile(midifile, infile);

   if (strcmp(filename, "") == 0) {
      cout << midifile;
   } else {
      midifile.write(filename);
   }

   return 0;
}
Exemple #29
0
void InitD3DExports(const char *vboxName, const char *msName)
{
    const char *dllName;
    HANDLE hDLL;

    if (isVBox3DEnabled() && checkOptions())
    {
        dllName = vboxName;
    } else
    {
        dllName = msName;
    }

    hDLL = LoadLibrary(dllName);
    FillD3DExports(hDLL); 
}
Exemple #30
0
bool
Metis::setOptions(int Ptype, 
		  int Mtype,
		  int coarsenTo,
		  int Rtype, 
		  int IPtype)
{
    myPtype=Ptype; 
    myMtype = Mtype; 
    myCoarsenTo = coarsenTo; 
    myRtype = Rtype; 
    myIPtype = IPtype; 

    defaultOptions = false;
    
    return checkOptions();
    
}