Parse the main function arguments

Posted on 2013-11-28 17:12  leon_ALiang  阅读(248)  评论(0编辑  收藏  举报
 1 int main(int argc, char **argv) {
 2 
 3     std::string reportDir;
 4     std::string transURL;
 5     std::string visualElement; 
 6     std::string outputFile;
 7     std::string outputType;
 8     static std::string SASFontsLoc;
 9     static std::string SASResLoc;
10     static std::string SASLocale;
11     int width=640, height=480; /* default */
12     int dpi=96; /* Default DPI */
13     int kpiIndex=0, rowIndex=0, colIndex=0, section=0;
14     
15     /* Parse the arguments */
16     int idx=0;
17     while (idx < argc)
18     {
19       if (strcmp(argv[idx], "-report") == 0)
20         reportDir = argv[++idx];
21       else if (strcmp(argv[idx], "-ve") == 0)
22         visualElement = argv[++idx];
23       else if (strcmp(argv[idx], "-section") == 0)
24         section = atoi(argv[++idx]);
25       else if (strcmp(argv[idx], "-outfile") == 0)
26         outputFile = argv[++idx];
27       else if (strcmp(argv[idx], "-outtype") == 0)
28         outputType = argv[++idx];
29       else if (strcmp(argv[idx], "-fontsloc") == 0)
30         SASFontsLoc = argv[++idx];
31       else if (strcmp(argv[idx], "-resourceloc") == 0)
32         SASResLoc = argv[++idx];
33       else if (strcmp(argv[idx], "-locale") == 0)
34         SASLocale = argv[++idx];
35       else if (strcmp(argv[idx], "-dpi") == 0)
36         dpi = atoi(argv[++idx]);
37       else if (strcmp(argv[idx], "-width") == 0)
38         width = atoi(argv[++idx]);
39       else if (strcmp(argv[idx], "-height") == 0)
40         height = atoi(argv[++idx]);
41       else if (strcmp(argv[idx], "-kpiindex") == 0)
42         kpiIndex = atoi(argv[++idx]);
43       else if (strcmp(argv[idx], "-rowindex") == 0)
44         rowIndex = atoi(argv[++idx]);
45       else if (strcmp(argv[idx], "-colindex") == 0)
46         colIndex = atoi(argv[++idx]);
47       else if (strcmp(argv[idx], "-tsurl") == 0)
48         transURL = argv[++idx];
49       idx++;
50     }
51    
52     return 0;
53 }

 

Copyright © 2024 leon_ALiang
Powered by .NET 8.0 on Kubernetes