aboutsummaryrefslogtreecommitdiffstats
path: root/native/dicttoolkit/src/utils/arguments_and_options.h
diff options
context:
space:
mode:
authorKeisuke Kuroyanagi <ksk@google.com>2014-11-09 03:47:30 +0900
committerKeisuke Kuroyanagi <ksk@google.com>2014-11-21 12:25:30 +0900
commit1f8d4f47e445bd4316f3e09228cff6de64105f13 (patch)
tree82959f0819a17ce57d237271be191ce4aa416486 /native/dicttoolkit/src/utils/arguments_and_options.h
parent681dbc295b07b9db6c32d1b7074e99d9e2fa651d (diff)
downloadlatinime-1f8d4f47e445bd4316f3e09228cff6de64105f13.tar.gz
latinime-1f8d4f47e445bd4316f3e09228cff6de64105f13.tar.xz
latinime-1f8d4f47e445bd4316f3e09228cff6de64105f13.zip
Implement ArgumentsParser::parseArguments and add tests.
Bug: 10059681 Change-Id: I6511a46c879d7a52d0bb4fcab445a66bc40db98c
Diffstat (limited to 'native/dicttoolkit/src/utils/arguments_and_options.h')
-rw-r--r--native/dicttoolkit/src/utils/arguments_and_options.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/native/dicttoolkit/src/utils/arguments_and_options.h b/native/dicttoolkit/src/utils/arguments_and_options.h
index d8f5985e5..2d81b1ecb 100644
--- a/native/dicttoolkit/src/utils/arguments_and_options.h
+++ b/native/dicttoolkit/src/utils/arguments_and_options.h
@@ -42,6 +42,29 @@ class ArgumentsAndOptions {
return mOptions.find(optionName) != mOptions.end();
}
+ const std::string &getOptionValue(const std::string &optionName) const {
+ const auto &it = mOptions.find(optionName);
+ ASSERT(it != mOptions.end());
+ return it->second;
+ }
+
+ bool hasArgument(const std::string &name) const {
+ const auto &it = mArguments.find(name);
+ return it != mArguments.end() && !it->second.empty();
+ }
+
+ const std::string &getSingleArgument(const std::string &name) const {
+ const auto &it = mArguments.find(name);
+ ASSERT(it != mArguments.end() && !it->second.empty());
+ return it->second.front();
+ }
+
+ const std::vector<std::string> &getVariableLengthArguments(const std::string &name) const {
+ const auto &it = mArguments.find(name);
+ ASSERT(it != mArguments.end());
+ return it->second;
+ }
+
private:
DISALLOW_ASSIGNMENT_OPERATOR(ArgumentsAndOptions);