Replace Maybe with std::optional
With c++17, std::optional provides the functionality that Maybe
provided.
Bug: 183215655
Test: aapt2_tests
Change-Id: I62bb9c2fa4985dc5217a6ed153df92b85ad9a034
diff --git a/tools/aapt2/cmd/Command.h b/tools/aapt2/cmd/Command.h
index d21571d..8678cda 100644
--- a/tools/aapt2/cmd/Command.h
+++ b/tools/aapt2/cmd/Command.h
@@ -18,6 +18,7 @@
#define AAPT_COMMAND_H
#include <functional>
+#include <optional>
#include <ostream>
#include <string>
#include <unordered_set>
@@ -25,19 +26,20 @@
#include "androidfw/StringPiece.h"
-#include "util/Maybe.h"
-
namespace aapt {
class Command {
public:
- explicit Command(const android::StringPiece& name) : name_(name.to_string()),
- short_name_(""),
- full_subcommand_name_(name.to_string()) {}
+ explicit Command(const android::StringPiece& name)
+ : name_(name.to_string()), full_subcommand_name_(name.to_string()){};
explicit Command(const android::StringPiece& name, const android::StringPiece& short_name)
- : name_(name.to_string()), short_name_(short_name.to_string()),
- full_subcommand_name_(name.to_string()) {}
+ : name_(name.to_string()),
+ short_name_(short_name.to_string()),
+ full_subcommand_name_(name.to_string()){};
+
+ Command(Command&&) = default;
+ Command& operator=(Command&&) = default;
virtual ~Command() = default;
@@ -58,7 +60,7 @@
uint32_t flags = 0);
void AddOptionalFlag(const android::StringPiece& name, const android::StringPiece& description,
- Maybe<std::string>* value, uint32_t flags = 0);
+ std::optional<std::string>* value, uint32_t flags = 0);
void AddOptionalFlagList(const android::StringPiece& name,
const android::StringPiece& description, std::vector<std::string>* value,
@@ -87,8 +89,6 @@
virtual int Action(const std::vector<std::string>& args) = 0;
private:
- DISALLOW_COPY_AND_ASSIGN(Command);
-
struct Flag {
explicit Flag(const android::StringPiece& name, const android::StringPiece& description,
const bool is_required, const size_t num_args,
@@ -104,8 +104,8 @@
bool found = false;
};
- const std::string name_;
- const std::string short_name_;
+ std::string name_;
+ std::string short_name_;
std::string description_ = "";
std::string full_subcommand_name_;