// // Programmer: Craig Stuart Sapp // Creation Date: Fri May 31 09:46:08 PDT 2013 // Last Modified: Fri May 31 09:46:12 PDT 2013 // Filename: ...sig/examples/all/markov.cpp // Web Address: http://sig.sapp.org/examples/museinfo/humdrum/markov.cpp // Syntax: C++; museinfo // // Description: Measure the root of a previously marked region of music. // #include "humdrum.h" #include "SigString.h" #include using namespace std; template class AssociativeArray { public: AssociativeArray(void) {}; Value& operator[](Key& aKey); private: unordered_map data; }; template Value& AssociativeArray::operator[](const Key& aKey) { return data[aKey]; } // function declarations void checkOptions (Options& opts, int argc, char* argv[]); void example (void); void usage (const char* command); /////////////////////////////////////////////////////////////////////////// int main(int argc, char* argv[]) { AssociativeArray items; items["foo"] = 42; cout << items["foo"] << endl; return 0; } /////////////////////////////////////////////////////////////////////////// ////////////////////////////// // // checkOptions -- validate and process command-line options. // void checkOptions(Options& opts, int argc, char* argv[]) { 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, May 2000" << endl; exit(0); } else if (opts.getBoolean("version")) { cout << argv[0] << ", version: 20 May 2001" << 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); } } ////////////////////////////// // // example -- example usage of the markana program // void example(void) { cout << " \n" << endl; } ////////////////////////////// // // usage -- gives the usage statement for the markana program // void usage(const char* command) { cout << " \n" << endl; } // md5sum: 5a38f564e91ecacb438b408ec04be688 markov.cpp [20130725]