aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/utils/file_cmd_parser.hpp
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2017-06-25 19:56:14 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2017-06-25 19:56:14 +0300
commita151a774f4ce6c4b13c819502efcfe919bbf050b (patch)
tree5cbed50713e2ea176c04327560b51df65bcd8b54 /utils/file_cmd_parser.hpp
parentutils: code style (diff)
downloadaes-tools-a151a774f4ce6c4b13c819502efcfe919bbf050b.tar.gz
aes-tools-a151a774f4ce6c4b13c819502efcfe919bbf050b.zip
code style
Diffstat (limited to 'utils/file_cmd_parser.hpp')
-rw-r--r--utils/file_cmd_parser.hpp117
1 files changed, 57 insertions, 60 deletions
diff --git a/utils/file_cmd_parser.hpp b/utils/file_cmd_parser.hpp
index 6d7a962..e199409 100644
--- a/utils/file_cmd_parser.hpp
+++ b/utils/file_cmd_parser.hpp
@@ -17,70 +17,67 @@
#include <string>
#include <utility>
-namespace
+class FileSettings : public command_line::SettingsParser
{
- class FileSettings : public command_line::SettingsParser
- {
- public:
- aes::Algorithm algorithm = AES_AES128;
- aes::Mode mode = AES_ECB;
+public:
+ aes::Algorithm algorithm = AES_AES128;
+ aes::Mode mode = AES_ECB;
- std::string input_path;
- std::string output_path;
- std::string key;
- std::string iv;
+ std::string input_path;
+ std::string output_path;
+ std::string key;
+ std::string iv;
- explicit FileSettings(const std::string& argv0)
- : SettingsParser{argv0}
- {
- visible.add_options()
- ("algorithm,a",
- boost::program_options::value<aes::Algorithm>(&algorithm)
- ->required()
- ->value_name("NAME"),
- "set algorithm")
- ("mode,m",
- boost::program_options::value<aes::Mode>(&mode)
- ->required()
- ->value_name("MODE"),
- "set mode of operation")
- ("key,k",
- boost::program_options::value<std::string>(&key)
- ->required()
- ->value_name("KEY"),
- "set encryption key")
- ("iv,v",
- boost::program_options::value<std::string>(&iv)
- ->value_name("BLOCK"),
- "set initialization vector")
- ("input,i",
- boost::program_options::value<std::string>(&input_path)
- ->required()
- ->value_name("PATH"),
- "set input file path")
- ("output,o",
- boost::program_options::value<std::string>(&output_path)
- ->required()
- ->value_name("PATH"),
- "set output file path");
- }
+ explicit FileSettings(const std::string& argv0)
+ : SettingsParser{argv0}
+ {
+ visible.add_options()
+ ("algorithm,a",
+ boost::program_options::value<aes::Algorithm>(&algorithm)
+ ->required()
+ ->value_name("NAME"),
+ "set algorithm")
+ ("mode,m",
+ boost::program_options::value<aes::Mode>(&mode)
+ ->required()
+ ->value_name("MODE"),
+ "set mode of operation")
+ ("key,k",
+ boost::program_options::value<std::string>(&key)
+ ->required()
+ ->value_name("KEY"),
+ "set encryption key")
+ ("iv,v",
+ boost::program_options::value<std::string>(&iv)
+ ->value_name("BLOCK"),
+ "set initialization vector")
+ ("input,i",
+ boost::program_options::value<std::string>(&input_path)
+ ->required()
+ ->value_name("PATH"),
+ "set input file path")
+ ("output,o",
+ boost::program_options::value<std::string>(&output_path)
+ ->required()
+ ->value_name("PATH"),
+ "set output file path");
+ }
- const char* get_short_description() const override
- {
- return "[-h|--help] [-a|--algorithm NAME] [-m|--mode MODE]"
- " [-k|--key KEY] [-v|--iv BLOCK]"
- " [-i|--input PATH] [-o|--output PATH]";
- }
+ const char* get_short_description() const override
+ {
+ return "[-h|--help] [-a|--algorithm NAME] [-m|--mode MODE]"
+ " [-k|--key KEY] [-v|--iv BLOCK]"
+ " [-i|--input PATH] [-o|--output PATH]";
+ }
- void parse(int argc, char** argv) override
- {
- SettingsParser::parse(argc, argv);
+ void parse(int argc, char** argv) override
+ {
+ SettingsParser::parse(argc, argv);
- if (aes::mode_requires_init_vector(mode) && iv.empty())
- {
- throw boost::program_options::error{
- "an initialization vector is required for the selected mode of operation"};
- }
+ if (aes::mode_requires_init_vector(mode) && iv.empty())
+ {
+ throw boost::program_options::error{
+ "an initialization vector is required for the selected mode of operation"};
}
- };
-}
+ }
+};