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/configuration/ConfigurationParser.internal.h b/tools/aapt2/configuration/ConfigurationParser.internal.h
index c541688..42ef5159 100644
--- a/tools/aapt2/configuration/ConfigurationParser.internal.h
+++ b/tools/aapt2/configuration/ConfigurationParser.internal.h
@@ -84,8 +84,8 @@
* have not been able to determine the sort order with the previous comparisons.
*/
template <typename T>
- ComparisonChain& Add(const Group<T>& groups, const Maybe<std::string>& lhs,
- const Maybe<std::string>& rhs) {
+ ComparisonChain& Add(const Group<T>& groups, const std::optional<std::string>& lhs,
+ const std::optional<std::string>& rhs) {
return Add(GetGroupOrder(groups, lhs), GetGroupOrder(groups, rhs));
}
@@ -108,7 +108,7 @@
private:
template <typename T>
- inline size_t GetGroupOrder(const Entry<T>& groups, const Maybe<std::string>& label) {
+ inline size_t GetGroupOrder(const Entry<T>& groups, const std::optional<std::string>& label) {
if (!label) {
return std::numeric_limits<size_t>::max();
}
@@ -122,32 +122,33 @@
/** Output artifact configuration options. */
struct ConfiguredArtifact {
/** Name to use for output of processing foo.apk -> foo.<name>.apk. */
- Maybe<std::string> name;
+ std::optional<std::string> name;
/** If present, uses the ABI group with this name. */
- Maybe<std::string> abi_group;
+ std::optional<std::string> abi_group;
/** If present, uses the screen density group with this name. */
- Maybe<std::string> screen_density_group;
+ std::optional<std::string> screen_density_group;
/** If present, uses the locale group with this name. */
- Maybe<std::string> locale_group;
+ std::optional<std::string> locale_group;
/** If present, uses the Android SDK with this name. */
- Maybe<std::string> android_sdk;
+ std::optional<std::string> android_sdk;
/** If present, uses the device feature group with this name. */
- Maybe<std::string> device_feature_group;
+ std::optional<std::string> device_feature_group;
/** If present, uses the OpenGL texture group with this name. */
- Maybe<std::string> gl_texture_group;
+ std::optional<std::string> gl_texture_group;
/** Convert an artifact name template into a name string based on configuration contents. */
- Maybe<std::string> ToArtifactName(const android::StringPiece& format,
- const android::StringPiece& apk_name, IDiagnostics* diag) const;
+ std::optional<std::string> ToArtifactName(const android::StringPiece& format,
+ const android::StringPiece& apk_name,
+ IDiagnostics* diag) const;
/** Convert an artifact name template into a name string based on configuration contents. */
- Maybe<std::string> Name(const android::StringPiece& apk_name, IDiagnostics* diag) const;
+ std::optional<std::string> Name(const android::StringPiece& apk_name, IDiagnostics* diag) const;
};
/** AAPT2 XML configuration file binary representation. */
struct PostProcessingConfiguration {
std::vector<ConfiguredArtifact> artifacts;
- Maybe<std::string> artifact_format;
+ std::optional<std::string> artifact_format;
Group<Abi> abi_groups;
Group<android::ConfigDescription> screen_density_groups;
@@ -212,9 +213,9 @@
};
/** Parses the provided XML document returning the post processing configuration. */
-Maybe<PostProcessingConfiguration> ExtractConfiguration(const std::string& contents,
- const std::string& config_path,
- IDiagnostics* diag);
+std::optional<PostProcessingConfiguration> ExtractConfiguration(const std::string& contents,
+ const std::string& config_path,
+ IDiagnostics* diag);
namespace handler {