From c96c9c3aacb1f39f6bffa24966801f440d553d48 Mon Sep 17 00:00:00 2001 From: mutantturkey Date: Fri, 6 Jul 2012 18:11:16 -0400 Subject: initial implement of getops, still need to check properly --- fly-tools/std-deviation/StandardDeviation.cpp | 46 ++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/fly-tools/std-deviation/StandardDeviation.cpp b/fly-tools/std-deviation/StandardDeviation.cpp index 04c301d..da6ed3a 100644 --- a/fly-tools/std-deviation/StandardDeviation.cpp +++ b/fly-tools/std-deviation/StandardDeviation.cpp @@ -10,6 +10,43 @@ vector currentHistogramValues; int main(int argc, char* argv[]) { + int c; + string usage = "standard-deviation -l -i -o -t "; + char *inputFileListName; + char *inputPath; + char *outputFileName; + char *distributionType; + string inputFileList; + + while ((c = getopt (argc, argv, "i:o:l:t:h")) != -1) + switch (c) + { + case 'l': + inputFileListName = optarg; + break; + case 'i': + inputPath = optarg; + break; + case 'o': + outputFileName = optarg; + break; + case 't': + distributionType = optarg; + break; + case 'h': + cout << usage << endl; + exit(1); + break; + default: + break; + } + +// if( (inputFileListName == NULL) || (inputPath == NULL) || (distributionType == NULL) || (outputFileName == NULL) ) { +// cerr << usage << endl; +// exit(1); +// } + + // argv[1] input file containing the list of files // argv[2] output file containing the standard deviation and file name pair // argv[3] data file path @@ -20,10 +57,10 @@ int main(int argc, char* argv[]) { exit(1); } - ifstream inputFileNames(argv[1]); - ofstream outputFile(argv[2]); - string prefixPath(argv[3]); - string metricName(argv[4]); + ifstream inputFileNames(inputFileListName); + ofstream outputFile(outputFileName); + string prefixPath(inputPath); + string metricName(distributionType); if (inputFileNames.fail() == true) { cout << "Input File can not be opened"<