-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Howto follow modifications on command line userinterface.
- Loading branch information
Showing
8 changed files
with
54 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef DIVIDE_HPP | ||
#define DIVIDE_HPP | ||
|
||
double divide(long numerator, long denominator); | ||
|
||
#endif // DIVIDE_HPP |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "divide.hpp" | ||
|
||
double divide(long numerator, long denominator) | ||
{ | ||
return double(numerator) / double(denominator); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,27 @@ | ||
#include "ArgParser.hpp" | ||
#include "divide.hpp" | ||
|
||
#include <boost/program_options/variables_map.hpp> | ||
|
||
#include <ctype.h> | ||
#include <iostream> | ||
#include <memory> | ||
|
||
namespace { | ||
|
||
int convertCompressionLevel(char level) | ||
{ | ||
if (isdigit(level)) { | ||
return (int(level) - int('0')); | ||
} else { | ||
switch (level) { | ||
case 'n': | ||
case 'N': | ||
return 0; | ||
case 'l': | ||
case 'L': | ||
return 2; | ||
case 'm': | ||
case 'M': | ||
return 5; | ||
case 'h': | ||
case 'H': | ||
return 9; | ||
default: | ||
return -1; | ||
} | ||
} | ||
} | ||
|
||
} | ||
#include <stdlib.h> | ||
#include <vector> | ||
|
||
int main(int argc, char* argv[]) | ||
{ | ||
std::cout << "CodeChecker example program." << '\n'; | ||
std::unique_ptr<boost::program_options::variables_map> programOptionMap = | ||
parseArguments(argc, argv); | ||
if (programOptionMap == nullptr) { | ||
return 0; | ||
} | ||
|
||
int compressionLevel; | ||
compressionLevel = convertCompressionLevel( | ||
(*programOptionMap)["compression"].as<char>()); | ||
if (compressionLevel < 0) { | ||
std::cerr << "Invalid compression level was set." << '\n'; | ||
return 1; | ||
std::vector<int> params; | ||
for (int i = 1; i < argc; ++i) { | ||
long value = strtol(argv[i], nullptr, 10); | ||
if (errno) { | ||
std::cerr << "Invalid parameter at position " << i << ".\n"; | ||
return 1; | ||
} else { | ||
params.push_back(int(value)); | ||
} | ||
} | ||
|
||
std::cout << "Compression level was set to " << compressionLevel << ".\n"; | ||
auto result = divide(params[0], params[1]); | ||
|
||
std::cout << "Division result is: " << result << ".\n"; | ||
|
||
return 0; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters