Loading tools/aapt2/AppInfo.h +10 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,16 @@ struct AppInfo { * The App's minimum SDK version. */ Maybe<std::string> minSdkVersion; /** * The Version code of the app. */ Maybe<uint32_t> versionCode; /** * The revision code of the app. */ Maybe<uint32_t> revisionCode; }; } // namespace aapt Loading tools/aapt2/Main.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ namespace aapt { static const char* sMajorVersion = "2"; // Update minor version whenever a feature or flag is added. static const char* sMinorVersion = "0"; static const char* sMinorVersion = "1"; int printVersion() { std::cerr << "Android Asset Packaging Tool (aapt) " Loading tools/aapt2/ResourceParser.cpp +14 −7 Original line number Diff line number Diff line Loading @@ -500,8 +500,8 @@ std::unique_ptr<Item> ResourceParser::parseXml(xml::XmlPullParser* parser, const }; // Process the raw value. std::unique_ptr<Item> processedItem = ResourceUtils::parseItemForAttribute(rawValue, typeMask, onCreateReference); std::unique_ptr<Item> processedItem = ResourceUtils::tryParseItemForAttribute( rawValue, typeMask, onCreateReference); if (processedItem) { // Fix up the reference. if (Reference* ref = valueCast<Reference>(processedItem.get())) { Loading @@ -528,20 +528,24 @@ std::unique_ptr<Item> ResourceParser::parseXml(xml::XmlPullParser* parser, const bool ResourceParser::parseString(xml::XmlPullParser* parser, ParsedResource* outResource) { bool formatted = true; if (Maybe<StringPiece> formattedAttr = xml::findAttribute(parser, "formatted")) { if (!ResourceUtils::tryParseBool(formattedAttr.value(), &formatted)) { Maybe<bool> maybeFormatted = ResourceUtils::parseBool(formattedAttr.value()); if (!maybeFormatted) { mDiag->error(DiagMessage(outResource->source) << "invalid value for 'formatted'. Must be a boolean"); return false; } formatted = maybeFormatted.value(); } bool translateable = mOptions.translatable; if (Maybe<StringPiece> translateableAttr = xml::findAttribute(parser, "translatable")) { if (!ResourceUtils::tryParseBool(translateableAttr.value(), &translateable)) { Maybe<bool> maybeTranslateable = ResourceUtils::parseBool(translateableAttr.value()); if (!maybeTranslateable) { mDiag->error(DiagMessage(outResource->source) << "invalid value for 'translatable'. Must be a boolean"); return false; } translateable = maybeTranslateable.value(); } outResource->value = parseXml(parser, android::ResTable_map::TYPE_STRING, kNoRawString); Loading Loading @@ -590,7 +594,7 @@ bool ResourceParser::parsePublic(xml::XmlPullParser* parser, ParsedResource* out outResource->name.type = *parsedType; if (Maybe<StringPiece> maybeIdStr = xml::findNonEmptyAttribute(parser, "id")) { Maybe<ResourceId> maybeId = ResourceUtils::tryParseResourceId(maybeIdStr.value()); Maybe<ResourceId> maybeId = ResourceUtils::parseResourceId(maybeIdStr.value()); if (!maybeId) { mDiag->error(DiagMessage(outResource->source) << "invalid resource ID '" << maybeId.value() << "' in <public>"); Loading Loading @@ -630,7 +634,7 @@ bool ResourceParser::parsePublicGroup(xml::XmlPullParser* parser, ParsedResource return false; } Maybe<ResourceId> maybeId = ResourceUtils::tryParseResourceId(maybeIdStr.value()); Maybe<ResourceId> maybeId = ResourceUtils::parseResourceId(maybeIdStr.value()); if (!maybeId) { mDiag->error(DiagMessage(outResource->source) << "invalid resource ID '" << maybeIdStr.value() << "' in <public-group>"); Loading Loading @@ -1058,14 +1062,17 @@ bool ResourceParser::parseArrayImpl(xml::XmlPullParser* parser, ParsedResource* bool translateable = mOptions.translatable; if (Maybe<StringPiece> translateableAttr = xml::findAttribute(parser, "translatable")) { if (!ResourceUtils::tryParseBool(translateableAttr.value(), &translateable)) { Maybe<bool> maybeTranslateable = ResourceUtils::parseBool(translateableAttr.value()); if (!maybeTranslateable) { mDiag->error(DiagMessage(outResource->source) << "invalid value for 'translatable'. Must be a boolean"); return false; } translateable = maybeTranslateable.value(); } array->setTranslateable(translateable); bool error = false; const size_t depth = parser->getDepth(); while (xml::XmlPullParser::nextChildNode(parser, depth)) { Loading tools/aapt2/ResourceUtils.cpp +26 −24 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ bool parseResourceName(const StringPiece& str, ResourceNameRef* outRef, bool* ou return true; } bool tryParseReference(const StringPiece& str, ResourceNameRef* outRef, bool* outCreate, bool parseReference(const StringPiece& str, ResourceNameRef* outRef, bool* outCreate, bool* outPrivate) { StringPiece trimmedStr(util::trimWhitespace(str)); if (trimmedStr.empty()) { Loading Loading @@ -171,10 +171,10 @@ bool tryParseReference(const StringPiece& str, ResourceNameRef* outRef, bool* ou } bool isReference(const StringPiece& str) { return tryParseReference(str, nullptr, nullptr, nullptr); return parseReference(str, nullptr, nullptr, nullptr); } bool tryParseAttributeReference(const StringPiece& str, ResourceNameRef* outRef) { bool parseAttributeReference(const StringPiece& str, ResourceNameRef* outRef) { StringPiece trimmedStr(util::trimWhitespace(str)); if (trimmedStr.empty()) { return false; Loading Loading @@ -208,7 +208,7 @@ bool tryParseAttributeReference(const StringPiece& str, ResourceNameRef* outRef) } bool isAttributeReference(const StringPiece& str) { return tryParseAttributeReference(str, nullptr); return parseAttributeReference(str, nullptr); } /* Loading Loading @@ -271,13 +271,13 @@ Maybe<Reference> parseStyleParentReference(const StringPiece& str, std::string* std::unique_ptr<Reference> tryParseReference(const StringPiece& str, bool* outCreate) { ResourceNameRef ref; bool privateRef = false; if (tryParseReference(str, &ref, outCreate, &privateRef)) { if (parseReference(str, &ref, outCreate, &privateRef)) { std::unique_ptr<Reference> value = util::make_unique<Reference>(ref); value->privateReference = privateRef; return value; } if (tryParseAttributeReference(str, &ref)) { if (parseAttributeReference(str, &ref)) { if (outCreate) { *outCreate = false; } Loading Loading @@ -420,23 +420,26 @@ std::unique_ptr<BinaryPrimitive> tryParseColor(const StringPiece& str) { return error ? std::unique_ptr<BinaryPrimitive>() : util::make_unique<BinaryPrimitive>(value); } bool tryParseBool(const StringPiece& str, bool* outValue) { Maybe<bool> parseBool(const StringPiece& str) { StringPiece trimmedStr(util::trimWhitespace(str)); if (trimmedStr == "true" || trimmedStr == "TRUE" || trimmedStr == "True") { if (outValue) { *outValue = true; } return true; return Maybe<bool>(true); } else if (trimmedStr == "false" || trimmedStr == "FALSE" || trimmedStr == "False") { if (outValue) { *outValue = false; return Maybe<bool>(false); } return true; return {}; } return false; Maybe<uint32_t> parseInt(const StringPiece& str) { std::u16string str16 = util::utf8ToUtf16(str); android::Res_value value; if (android::ResTable::stringToInt(str16.data(), str16.size(), &value)) { return value.data; } return {}; } Maybe<ResourceId> tryParseResourceId(const StringPiece& str) { Maybe<ResourceId> parseResourceId(const StringPiece& str) { StringPiece trimmedStr(util::trimWhitespace(str)); std::u16string str16 = util::utf8ToUtf16(trimmedStr); Loading @@ -452,7 +455,7 @@ Maybe<ResourceId> tryParseResourceId(const StringPiece& str) { return {}; } Maybe<int> tryParseSdkVersion(const StringPiece& str) { Maybe<int> parseSdkVersion(const StringPiece& str) { StringPiece trimmedStr(util::trimWhitespace(str)); std::u16string str16 = util::utf8ToUtf16(trimmedStr); Loading @@ -470,12 +473,11 @@ Maybe<int> tryParseSdkVersion(const StringPiece& str) { } std::unique_ptr<BinaryPrimitive> tryParseBool(const StringPiece& str) { bool result = false; if (tryParseBool(str, &result)) { if (Maybe<bool> maybeResult = parseBool(str)) { android::Res_value value = {}; value.dataType = android::Res_value::TYPE_INT_BOOLEAN; if (result) { if (maybeResult.value()) { value.data = 0xffffffffu; } else { value.data = 0; Loading Loading @@ -542,7 +544,7 @@ uint32_t androidTypeToAttributeTypeMask(uint16_t type) { }; } std::unique_ptr<Item> parseItemForAttribute( std::unique_ptr<Item> tryParseItemForAttribute( const StringPiece& value, uint32_t typeMask, const std::function<void(const ResourceName&)>& onCreateReference) { Loading Loading @@ -602,11 +604,11 @@ std::unique_ptr<Item> parseItemForAttribute( * We successively try to parse the string as a resource type that the Attribute * allows. */ std::unique_ptr<Item> parseItemForAttribute( std::unique_ptr<Item> tryParseItemForAttribute( const StringPiece& str, const Attribute* attr, const std::function<void(const ResourceName&)>& onCreateReference) { const uint32_t typeMask = attr->typeMask; std::unique_ptr<Item> value = parseItemForAttribute(str, typeMask, onCreateReference); std::unique_ptr<Item> value = tryParseItemForAttribute(str, typeMask, onCreateReference); if (value) { return value; } Loading tools/aapt2/ResourceUtils.h +19 −14 Original line number Diff line number Diff line Loading @@ -28,11 +28,6 @@ namespace aapt { namespace ResourceUtils { /** * Convert an android::ResTable::resource_name to an aapt::ResourceName struct. */ Maybe<ResourceName> toResourceName(const android::ResTable::resource_name& name); /* * Extracts the package, type, and name from a string of the format: * Loading Loading @@ -60,7 +55,7 @@ bool parseResourceName(const StringPiece& str, ResourceNameRef* outResource, * If '+' was present in the reference, `outCreate` is set to true. * If '*' was present in the reference, `outPrivate` is set to true. */ bool tryParseReference(const StringPiece& str, ResourceNameRef* outReference, bool parseReference(const StringPiece& str, ResourceNameRef* outReference, bool* outCreate = nullptr, bool* outPrivate = nullptr); /* Loading @@ -72,7 +67,7 @@ bool isReference(const StringPiece& str); * Returns true if the string was parsed as an attribute reference (?[package:][type/]name), * with `outReference` set to the parsed reference. */ bool tryParseAttributeReference(const StringPiece& str, ResourceNameRef* outReference); bool parseAttributeReference(const StringPiece& str, ResourceNameRef* outReference); /** * Returns true if the string is in the form of an attribute reference(?[package:][type/]name). Loading @@ -80,19 +75,29 @@ bool tryParseAttributeReference(const StringPiece& str, ResourceNameRef* outRefe bool isAttributeReference(const StringPiece& str); /** * Returns true if the value is a boolean, putting the result in `outValue`. * Convert an android::ResTable::resource_name to an aapt::ResourceName struct. */ Maybe<ResourceName> toResourceName(const android::ResTable::resource_name& name); /** * Returns a boolean value if the string is equal to TRUE, true, True, FALSE, false, or False. */ Maybe<bool> parseBool(const StringPiece& str); /** * Returns a uint32_t if the string is an integer. */ bool tryParseBool(const StringPiece& str, bool* outValue); Maybe<uint32_t> parseInt(const StringPiece& str); /** * Returns an ID if it the string represented a valid ID. */ Maybe<ResourceId> tryParseResourceId(const StringPiece& str); Maybe<ResourceId> parseResourceId(const StringPiece& str); /** * Parses an SDK version, which can be an integer, or a letter from A-Z. */ Maybe<int> tryParseSdkVersion(const StringPiece& str); Maybe<int> parseSdkVersion(const StringPiece& str); /* * Returns a Reference, or None Maybe instance if the string `str` was parsed as a Loading Loading @@ -161,11 +166,11 @@ std::unique_ptr<BinaryPrimitive> tryParseFlagSymbol(const Attribute* enumAttr, * The callback function onCreateReference is called when the parsed item is a * reference to an ID that must be created (@+id/foo). */ std::unique_ptr<Item> parseItemForAttribute( std::unique_ptr<Item> tryParseItemForAttribute( const StringPiece& value, const Attribute* attr, const std::function<void(const ResourceName&)>& onCreateReference = {}); std::unique_ptr<Item> parseItemForAttribute( std::unique_ptr<Item> tryParseItemForAttribute( const StringPiece& value, uint32_t typeMask, const std::function<void(const ResourceName&)>& onCreateReference = {}); Loading Loading
tools/aapt2/AppInfo.h +10 −0 Original line number Diff line number Diff line Loading @@ -37,6 +37,16 @@ struct AppInfo { * The App's minimum SDK version. */ Maybe<std::string> minSdkVersion; /** * The Version code of the app. */ Maybe<uint32_t> versionCode; /** * The revision code of the app. */ Maybe<uint32_t> revisionCode; }; } // namespace aapt Loading
tools/aapt2/Main.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -25,7 +25,7 @@ namespace aapt { static const char* sMajorVersion = "2"; // Update minor version whenever a feature or flag is added. static const char* sMinorVersion = "0"; static const char* sMinorVersion = "1"; int printVersion() { std::cerr << "Android Asset Packaging Tool (aapt) " Loading
tools/aapt2/ResourceParser.cpp +14 −7 Original line number Diff line number Diff line Loading @@ -500,8 +500,8 @@ std::unique_ptr<Item> ResourceParser::parseXml(xml::XmlPullParser* parser, const }; // Process the raw value. std::unique_ptr<Item> processedItem = ResourceUtils::parseItemForAttribute(rawValue, typeMask, onCreateReference); std::unique_ptr<Item> processedItem = ResourceUtils::tryParseItemForAttribute( rawValue, typeMask, onCreateReference); if (processedItem) { // Fix up the reference. if (Reference* ref = valueCast<Reference>(processedItem.get())) { Loading @@ -528,20 +528,24 @@ std::unique_ptr<Item> ResourceParser::parseXml(xml::XmlPullParser* parser, const bool ResourceParser::parseString(xml::XmlPullParser* parser, ParsedResource* outResource) { bool formatted = true; if (Maybe<StringPiece> formattedAttr = xml::findAttribute(parser, "formatted")) { if (!ResourceUtils::tryParseBool(formattedAttr.value(), &formatted)) { Maybe<bool> maybeFormatted = ResourceUtils::parseBool(formattedAttr.value()); if (!maybeFormatted) { mDiag->error(DiagMessage(outResource->source) << "invalid value for 'formatted'. Must be a boolean"); return false; } formatted = maybeFormatted.value(); } bool translateable = mOptions.translatable; if (Maybe<StringPiece> translateableAttr = xml::findAttribute(parser, "translatable")) { if (!ResourceUtils::tryParseBool(translateableAttr.value(), &translateable)) { Maybe<bool> maybeTranslateable = ResourceUtils::parseBool(translateableAttr.value()); if (!maybeTranslateable) { mDiag->error(DiagMessage(outResource->source) << "invalid value for 'translatable'. Must be a boolean"); return false; } translateable = maybeTranslateable.value(); } outResource->value = parseXml(parser, android::ResTable_map::TYPE_STRING, kNoRawString); Loading Loading @@ -590,7 +594,7 @@ bool ResourceParser::parsePublic(xml::XmlPullParser* parser, ParsedResource* out outResource->name.type = *parsedType; if (Maybe<StringPiece> maybeIdStr = xml::findNonEmptyAttribute(parser, "id")) { Maybe<ResourceId> maybeId = ResourceUtils::tryParseResourceId(maybeIdStr.value()); Maybe<ResourceId> maybeId = ResourceUtils::parseResourceId(maybeIdStr.value()); if (!maybeId) { mDiag->error(DiagMessage(outResource->source) << "invalid resource ID '" << maybeId.value() << "' in <public>"); Loading Loading @@ -630,7 +634,7 @@ bool ResourceParser::parsePublicGroup(xml::XmlPullParser* parser, ParsedResource return false; } Maybe<ResourceId> maybeId = ResourceUtils::tryParseResourceId(maybeIdStr.value()); Maybe<ResourceId> maybeId = ResourceUtils::parseResourceId(maybeIdStr.value()); if (!maybeId) { mDiag->error(DiagMessage(outResource->source) << "invalid resource ID '" << maybeIdStr.value() << "' in <public-group>"); Loading Loading @@ -1058,14 +1062,17 @@ bool ResourceParser::parseArrayImpl(xml::XmlPullParser* parser, ParsedResource* bool translateable = mOptions.translatable; if (Maybe<StringPiece> translateableAttr = xml::findAttribute(parser, "translatable")) { if (!ResourceUtils::tryParseBool(translateableAttr.value(), &translateable)) { Maybe<bool> maybeTranslateable = ResourceUtils::parseBool(translateableAttr.value()); if (!maybeTranslateable) { mDiag->error(DiagMessage(outResource->source) << "invalid value for 'translatable'. Must be a boolean"); return false; } translateable = maybeTranslateable.value(); } array->setTranslateable(translateable); bool error = false; const size_t depth = parser->getDepth(); while (xml::XmlPullParser::nextChildNode(parser, depth)) { Loading
tools/aapt2/ResourceUtils.cpp +26 −24 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ bool parseResourceName(const StringPiece& str, ResourceNameRef* outRef, bool* ou return true; } bool tryParseReference(const StringPiece& str, ResourceNameRef* outRef, bool* outCreate, bool parseReference(const StringPiece& str, ResourceNameRef* outRef, bool* outCreate, bool* outPrivate) { StringPiece trimmedStr(util::trimWhitespace(str)); if (trimmedStr.empty()) { Loading Loading @@ -171,10 +171,10 @@ bool tryParseReference(const StringPiece& str, ResourceNameRef* outRef, bool* ou } bool isReference(const StringPiece& str) { return tryParseReference(str, nullptr, nullptr, nullptr); return parseReference(str, nullptr, nullptr, nullptr); } bool tryParseAttributeReference(const StringPiece& str, ResourceNameRef* outRef) { bool parseAttributeReference(const StringPiece& str, ResourceNameRef* outRef) { StringPiece trimmedStr(util::trimWhitespace(str)); if (trimmedStr.empty()) { return false; Loading Loading @@ -208,7 +208,7 @@ bool tryParseAttributeReference(const StringPiece& str, ResourceNameRef* outRef) } bool isAttributeReference(const StringPiece& str) { return tryParseAttributeReference(str, nullptr); return parseAttributeReference(str, nullptr); } /* Loading Loading @@ -271,13 +271,13 @@ Maybe<Reference> parseStyleParentReference(const StringPiece& str, std::string* std::unique_ptr<Reference> tryParseReference(const StringPiece& str, bool* outCreate) { ResourceNameRef ref; bool privateRef = false; if (tryParseReference(str, &ref, outCreate, &privateRef)) { if (parseReference(str, &ref, outCreate, &privateRef)) { std::unique_ptr<Reference> value = util::make_unique<Reference>(ref); value->privateReference = privateRef; return value; } if (tryParseAttributeReference(str, &ref)) { if (parseAttributeReference(str, &ref)) { if (outCreate) { *outCreate = false; } Loading Loading @@ -420,23 +420,26 @@ std::unique_ptr<BinaryPrimitive> tryParseColor(const StringPiece& str) { return error ? std::unique_ptr<BinaryPrimitive>() : util::make_unique<BinaryPrimitive>(value); } bool tryParseBool(const StringPiece& str, bool* outValue) { Maybe<bool> parseBool(const StringPiece& str) { StringPiece trimmedStr(util::trimWhitespace(str)); if (trimmedStr == "true" || trimmedStr == "TRUE" || trimmedStr == "True") { if (outValue) { *outValue = true; } return true; return Maybe<bool>(true); } else if (trimmedStr == "false" || trimmedStr == "FALSE" || trimmedStr == "False") { if (outValue) { *outValue = false; return Maybe<bool>(false); } return true; return {}; } return false; Maybe<uint32_t> parseInt(const StringPiece& str) { std::u16string str16 = util::utf8ToUtf16(str); android::Res_value value; if (android::ResTable::stringToInt(str16.data(), str16.size(), &value)) { return value.data; } return {}; } Maybe<ResourceId> tryParseResourceId(const StringPiece& str) { Maybe<ResourceId> parseResourceId(const StringPiece& str) { StringPiece trimmedStr(util::trimWhitespace(str)); std::u16string str16 = util::utf8ToUtf16(trimmedStr); Loading @@ -452,7 +455,7 @@ Maybe<ResourceId> tryParseResourceId(const StringPiece& str) { return {}; } Maybe<int> tryParseSdkVersion(const StringPiece& str) { Maybe<int> parseSdkVersion(const StringPiece& str) { StringPiece trimmedStr(util::trimWhitespace(str)); std::u16string str16 = util::utf8ToUtf16(trimmedStr); Loading @@ -470,12 +473,11 @@ Maybe<int> tryParseSdkVersion(const StringPiece& str) { } std::unique_ptr<BinaryPrimitive> tryParseBool(const StringPiece& str) { bool result = false; if (tryParseBool(str, &result)) { if (Maybe<bool> maybeResult = parseBool(str)) { android::Res_value value = {}; value.dataType = android::Res_value::TYPE_INT_BOOLEAN; if (result) { if (maybeResult.value()) { value.data = 0xffffffffu; } else { value.data = 0; Loading Loading @@ -542,7 +544,7 @@ uint32_t androidTypeToAttributeTypeMask(uint16_t type) { }; } std::unique_ptr<Item> parseItemForAttribute( std::unique_ptr<Item> tryParseItemForAttribute( const StringPiece& value, uint32_t typeMask, const std::function<void(const ResourceName&)>& onCreateReference) { Loading Loading @@ -602,11 +604,11 @@ std::unique_ptr<Item> parseItemForAttribute( * We successively try to parse the string as a resource type that the Attribute * allows. */ std::unique_ptr<Item> parseItemForAttribute( std::unique_ptr<Item> tryParseItemForAttribute( const StringPiece& str, const Attribute* attr, const std::function<void(const ResourceName&)>& onCreateReference) { const uint32_t typeMask = attr->typeMask; std::unique_ptr<Item> value = parseItemForAttribute(str, typeMask, onCreateReference); std::unique_ptr<Item> value = tryParseItemForAttribute(str, typeMask, onCreateReference); if (value) { return value; } Loading
tools/aapt2/ResourceUtils.h +19 −14 Original line number Diff line number Diff line Loading @@ -28,11 +28,6 @@ namespace aapt { namespace ResourceUtils { /** * Convert an android::ResTable::resource_name to an aapt::ResourceName struct. */ Maybe<ResourceName> toResourceName(const android::ResTable::resource_name& name); /* * Extracts the package, type, and name from a string of the format: * Loading Loading @@ -60,7 +55,7 @@ bool parseResourceName(const StringPiece& str, ResourceNameRef* outResource, * If '+' was present in the reference, `outCreate` is set to true. * If '*' was present in the reference, `outPrivate` is set to true. */ bool tryParseReference(const StringPiece& str, ResourceNameRef* outReference, bool parseReference(const StringPiece& str, ResourceNameRef* outReference, bool* outCreate = nullptr, bool* outPrivate = nullptr); /* Loading @@ -72,7 +67,7 @@ bool isReference(const StringPiece& str); * Returns true if the string was parsed as an attribute reference (?[package:][type/]name), * with `outReference` set to the parsed reference. */ bool tryParseAttributeReference(const StringPiece& str, ResourceNameRef* outReference); bool parseAttributeReference(const StringPiece& str, ResourceNameRef* outReference); /** * Returns true if the string is in the form of an attribute reference(?[package:][type/]name). Loading @@ -80,19 +75,29 @@ bool tryParseAttributeReference(const StringPiece& str, ResourceNameRef* outRefe bool isAttributeReference(const StringPiece& str); /** * Returns true if the value is a boolean, putting the result in `outValue`. * Convert an android::ResTable::resource_name to an aapt::ResourceName struct. */ Maybe<ResourceName> toResourceName(const android::ResTable::resource_name& name); /** * Returns a boolean value if the string is equal to TRUE, true, True, FALSE, false, or False. */ Maybe<bool> parseBool(const StringPiece& str); /** * Returns a uint32_t if the string is an integer. */ bool tryParseBool(const StringPiece& str, bool* outValue); Maybe<uint32_t> parseInt(const StringPiece& str); /** * Returns an ID if it the string represented a valid ID. */ Maybe<ResourceId> tryParseResourceId(const StringPiece& str); Maybe<ResourceId> parseResourceId(const StringPiece& str); /** * Parses an SDK version, which can be an integer, or a letter from A-Z. */ Maybe<int> tryParseSdkVersion(const StringPiece& str); Maybe<int> parseSdkVersion(const StringPiece& str); /* * Returns a Reference, or None Maybe instance if the string `str` was parsed as a Loading Loading @@ -161,11 +166,11 @@ std::unique_ptr<BinaryPrimitive> tryParseFlagSymbol(const Attribute* enumAttr, * The callback function onCreateReference is called when the parsed item is a * reference to an ID that must be created (@+id/foo). */ std::unique_ptr<Item> parseItemForAttribute( std::unique_ptr<Item> tryParseItemForAttribute( const StringPiece& value, const Attribute* attr, const std::function<void(const ResourceName&)>& onCreateReference = {}); std::unique_ptr<Item> parseItemForAttribute( std::unique_ptr<Item> tryParseItemForAttribute( const StringPiece& value, uint32_t typeMask, const std::function<void(const ResourceName&)>& onCreateReference = {}); Loading