Code Search for Developers
 
 
  

commandOptions.cpp.texinfo from marsyas at Krugle


Show commandOptions.cpp.texinfo syntax highlighted

@c Generator: GNU source-highlight, by Lorenzo Bettini, http://www.gnu.org/software/src-highlite
@example
@b{#include} @t{"CommandLineOptions.h"}

@b{using} @b{namespace} std;
@b{using} @b{namespace} Marsyas;

CommandLineOptions cmd_options;

int helpOpt;
int usageOpt;
mrs_natural naturalOpt;
mrs_real realOpt;
mrs_string stringOpt;

void
@b{printUsage}()
@{
       @b{MRSDIAG}(@t{"commandOptions.cpp - printUsage"});
       cerr << @t{"Usage: commandOptions "} << @t{"file1 file2 file3"} << endl;
       cerr << endl;
       cerr << @t{"where file1, ..., fileN are sound files in a MARSYAS supported format"} << endl;
       @b{exit}(1);
@}

void
@b{printHelp}()
@{
       @b{MRSDIAG}(@t{"commandOptions.cpp - printHelp"});
       cerr << @t{"commandOptions: Sample Program"}<< endl;
       cerr << @t{"------------------------------"} << endl;
       cerr << endl;
       cerr << @t{"Usage: commandOptions file1 file2 file3"} << endl;
       cerr << endl;
       cerr << @t{"where file1, ..., fileN are sound files in a Marsyas supported format"} << endl;
       cerr << @t{"Help Options:"} << endl;
       cerr << @t{"-u --usage               : display short usage info"} << endl;
       cerr << @t{"-h --help               : display this information "} << endl;
       cerr << @t{"-n --natural               : sets a `natural' variable "} << endl;
       cerr << @t{"-r --real               : sets a `real' variable "} << endl;
       cerr << @t{"-s --string               : sets a `string' variable "} << endl;
       @b{exit}(1);
@}

void
@b{initOptions}()
@{
       cmd_options.@b{addBoolOption}(@t{"help"}, @t{"h"}, @b{false});
       cmd_options.@b{addBoolOption}(@t{"usage"}, @t{"u"}, @b{false});
       cmd_options.@b{addNaturalOption}(@t{"natural"}, @t{"n"}, 9);
       cmd_options.@b{addRealOption}(@t{"real"}, @t{"r"}, 3.1415927);
       cmd_options.@b{addStringOption}(@t{"string"}, @t{"s"}, @t{"hello world"});
@}

void
@b{loadOptions}()
@{
       helpOpt = cmd_options.@b{getBoolOption}(@t{"help"});
       usageOpt = cmd_options.@b{getBoolOption}(@t{"usage"});
       naturalOpt = cmd_options.@b{getNaturalOption}(@t{"natural"});
       realOpt = cmd_options.@b{getRealOption}(@t{"real"});
       stringOpt = cmd_options.@b{getStringOption}(@t{"string"});
@}



void @b{doStuff}(string printMe)
@{
       cout<<printMe<<endl;
@}

int @b{main}(int argc, @b{const} char **argv)
@{
       @b{initOptions}();
       cmd_options.@b{readOptions}(argc,argv);
       @b{loadOptions}();

       vector<string> soundfiles = cmd_options.@b{getRemaining}();

       @b{if} (helpOpt)
              @b{printHelp}();

       @b{if} ( (usageOpt) || (argc==1) )
              @b{printUsage}();

       cout<<@t{"Command-line options were:"}<<endl;
       cout<<@t{"              --natural: "}<<naturalOpt<<endl;
       cout<<@t{"              --real: "}<<realOpt<<endl;
       cout<<@t{"              --string: "}<<stringOpt<<endl;
       cout<<@t{"(these may simply be the default values)"}<<endl;
       cout<<endl;
       cout<<@t{"The rest of the command-line arguments were: "}<<endl;

       vector<string>::iterator sfi;
       @b{for} (sfi = soundfiles.@b{begin}(); sfi != soundfiles.@b{end}(); ++sfi)
       @{
              @b{doStuff}( *sfi );
       @}
@}


@end example



See more files for this project here

marsyas

Marsyas (Music Analysis, Retrieval and Synthesis for Audio Signals) is a framework for developing systems for audio processing. It provides an general architecture for connecting audio, soundfiles, signal processing blocks and machine learning.

Project homepage: http://sourceforge.net/projects/marsyas
Programming language(s): C++
License: other

  backend.cpp.html
  backend.cpp.texinfo
  backend.h.html
  backend.h.texinfo
  commandOptions.cpp.html
  commandOptions.cpp.texinfo
  controls.cpp.html
  controls.cpp.texinfo
  dataflow-split.cpp.html
  dataflow-split.cpp.texinfo
  gettingdata.cpp.html
  gettingdata.cpp.texinfo
  helloworld.cpp.html
  helloworld.cpp.texinfo
  main.cpp.html
  main.cpp.texinfo
  mainwindow.cpp.html
  mainwindow.cpp.texinfo
  mainwindow.h.html
  mainwindow.h.texinfo
  tutorial.pro.html
  tutorial.pro.texinfo
  writefile.cpp.html
  writefile.cpp.texinfo