//
// Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Wed Apr 6 14:58:35 PDT 2005
// Last Modified: Wed Apr 6 14:58:44 PDT 2005
// Filename: ...sig/examples/all/metertype.cpp
// Web Address: http://sig.sapp.org/examples/museinfo/humdrum/metertype.cpp
// Syntax: C++; museinfo
//
// Description: Summarizes metric data in a **kern file
//
// Note: Not complete yet.
//
#include "humdrum.h"
// function declarations
void checkOptions(Options& opts, int argc, char* argv[]);
void example(void);
void usage(const char* command);
// global variables
Options options; // database for command-line arguments
int debugQ = 0; // used with the --debug option
int shortQ = 0; // used with the -D option
int pitchesQ = 0; // used with the -p option
///////////////////////////////////////////////////////////////////////////
int main(int argc, char* argv[]) {
HumdrumFile infile;
// process the command-line options
checkOptions(options, argc, argv);
int numinputs = options.getArgCount();
const char* filename = "";
int i;
if (numinputs < 1) {
// if no command-line arguments read data file from standard input
infile.read(cin);
} else if (options.getArgCount() == 1) {
infile.read(options.getArg(1));
} else {
for (i=0; i<options.getArgCount(); i++) {
filename = options.getArg(i+1);
infile.read(filename);
}
}
return 0;
}
///////////////////////////////////////////////////////////////////////////
//////////////////////////////
//
// checkOptions -- validate and process command-line options.
//
void checkOptions(Options& opts, int argc, char* argv[]) {
opts.define("p|pitches=b", "display used pitches classes");
opts.define("D|no-directory=b", "do not display directory in filename");
opts.define("debug=b", "trace input parsing");
opts.define("author=b", "author of the program");
opts.define("version=b", "compilation information");
opts.define("example=b", "example usage");
opts.define("h|help=b", "short description");
opts.process(argc, argv);
// handle basic options:
if (opts.getBoolean("author")) {
cout << "Written by Craig Stuart Sapp, "
<< "craig@ccrma.stanford.edu, Apr 2005" << endl;
exit(0);
} else if (opts.getBoolean("version")) {
cout << argv[0] << ", version: 5 Apr 2005" << endl;
cout << "compiled: " << __DATE__ << endl;
cout << MUSEINFO_VERSION << endl;
exit(0);
} else if (opts.getBoolean("help")) {
usage(opts.getCommand());
exit(0);
} else if (opts.getBoolean("example")) {
example();
exit(0);
}
debugQ = opts.getBoolean("debug");
shortQ = opts.getBoolean("no-directory");
pitchesQ = opts.getBoolean("pitches");
}
//////////////////////////////
//
// example -- example usage of the program
//
void example(void) {
cout <<
" \n"
<< endl;
}
//////////////////////////////
//
// usage -- gives the usage statement for the program
//
void usage(const char* command) {
cout <<
" \n"
<< endl;
}
// md5sum: 0ebddf3aa3e642b5ab14429c1ab7000e metertype.cpp [20050406]