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.h b/tools/aapt2/configuration/ConfigurationParser.h
index b9e3be9..195b4ba 100644
--- a/tools/aapt2/configuration/ConfigurationParser.h
+++ b/tools/aapt2/configuration/ConfigurationParser.h
@@ -17,6 +17,7 @@
#ifndef AAPT2_CONFIGURATION_H
#define AAPT2_CONFIGURATION_H
+#include <optional>
#include <set>
#include <string>
#include <unordered_map>
@@ -25,7 +26,6 @@
#include "androidfw/ConfigDescription.h"
#include "Diagnostics.h"
-#include "util/Maybe.h"
namespace aapt {
@@ -55,9 +55,9 @@
*/
struct Locale {
/** The ISO<?> standard locale language code. */
- Maybe<std::string> lang;
+ std::optional<std::string> lang;
/** The ISO<?> standard locale region code. */
- Maybe<std::string> region;
+ std::optional<std::string> region;
inline friend bool operator==(const Locale& lhs, const Locale& rhs) {
return lhs.lang == rhs.lang && lhs.region == rhs.region;
@@ -74,9 +74,9 @@
struct AndroidSdk {
std::string label;
int min_sdk_version; // min_sdk_version is mandatory if splitting by SDK.
- Maybe<int> target_sdk_version;
- Maybe<int> max_sdk_version;
- Maybe<AndroidManifest> manifest;
+ std::optional<int> target_sdk_version;
+ std::optional<int> max_sdk_version;
+ std::optional<AndroidManifest> manifest;
static AndroidSdk ForMinSdk(int min_sdk) {
AndroidSdk sdk;
@@ -112,7 +112,7 @@
std::vector<Abi> abis;
std::vector<android::ConfigDescription> screen_densities;
std::vector<android::ConfigDescription> locales;
- Maybe<AndroidSdk> android_sdk;
+ std::optional<AndroidSdk> android_sdk;
std::vector<DeviceFeature> features;
std::vector<GlTexture> textures;
@@ -136,7 +136,7 @@
public:
/** Returns a ConfigurationParser for the file located at the provided path. */
- static Maybe<ConfigurationParser> ForPath(const std::string& path);
+ static std::optional<ConfigurationParser> ForPath(const std::string& path);
/** Returns a ConfigurationParser for the configuration in the provided file contents. */
static ConfigurationParser ForContents(const std::string& contents, const std::string& path) {
@@ -154,7 +154,8 @@
* Parses the configuration file and returns the results. If the configuration could not be parsed
* the result is empty and any errors will be displayed with the provided diagnostics context.
*/
- Maybe<std::vector<configuration::OutputArtifact>> Parse(const android::StringPiece& apk_path);
+ std::optional<std::vector<configuration::OutputArtifact>> Parse(
+ const android::StringPiece& apk_path);
protected:
/**