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/ResourceTable.h b/tools/aapt2/ResourceTable.h
index bae1d82..2e17659 100644
--- a/tools/aapt2/ResourceTable.h
+++ b/tools/aapt2/ResourceTable.h
@@ -120,18 +120,18 @@
const std::string name;
// The entry ID for this resource (the EEEE in 0xPPTTEEEE).
- Maybe<ResourceId> id;
+ std::optional<ResourceId> id;
// Whether this resource is public (and must maintain the same entry ID across builds).
Visibility visibility;
- Maybe<AllowNew> allow_new;
+ std::optional<AllowNew> allow_new;
// The declarations of this resource as overlayable for RROs
- Maybe<OverlayableItem> overlayable_item;
+ std::optional<OverlayableItem> overlayable_item;
// The staged resource id for a finalized resource.
- Maybe<StagedId> staged_id;
+ std::optional<StagedId> staged_id;
// The resource's values for each configuration.
std::vector<std::unique_ptr<ResourceConfigValue>> values;
@@ -205,11 +205,11 @@
struct ResourceTableEntryView {
std::string name;
- Maybe<uint16_t> id;
+ std::optional<uint16_t> id;
Visibility visibility;
- Maybe<AllowNew> allow_new;
- Maybe<OverlayableItem> overlayable_item;
- Maybe<StagedId> staged_id;
+ std::optional<AllowNew> allow_new;
+ std::optional<OverlayableItem> overlayable_item;
+ std::optional<StagedId> staged_id;
std::vector<const ResourceConfigValue*> values;
const ResourceConfigValue* FindValue(const android::ConfigDescription& config,
@@ -218,7 +218,7 @@
struct ResourceTableTypeView {
ResourceType type;
- Maybe<uint8_t> id;
+ std::optional<uint8_t> id;
Visibility::Level visibility_level = Visibility::Level::kUndefined;
// Entries sorted in ascending entry id order. If ids have not been assigned, the entries are
@@ -228,7 +228,7 @@
struct ResourceTablePackageView {
std::string name;
- Maybe<uint8_t> id;
+ std::optional<uint8_t> id;
// Types sorted in ascending type id order. If ids have not been assigned, the types are sorted by
// their declaration order in the ResourceType enum.
std::vector<ResourceTableTypeView> types;
@@ -309,8 +309,8 @@
ResourceEntry* entry;
};
- Maybe<SearchResult> FindResource(const ResourceNameRef& name) const;
- Maybe<SearchResult> FindResource(const ResourceNameRef& name, ResourceId id) const;
+ std::optional<SearchResult> FindResource(const ResourceNameRef& name) const;
+ std::optional<SearchResult> FindResource(const ResourceNameRef& name, ResourceId id) const;
bool RemoveResource(const ResourceNameRef& name, ResourceId id) const;
// Returns the package struct with the given name, or nullptr if such a package does not