double NumberParser::parseFloat(const std::string& s, char decSep, char thSep) { double result; if (tryParseFloat(s, result, decSep, thSep)) return result; else throw SyntaxException("Not a valid floating-point number", s); }
std::unique_ptr<Item> parseItemForAttribute( const StringPiece16& value, uint32_t typeMask, std::function<void(const ResourceName&)> onCreateReference) { std::unique_ptr<BinaryPrimitive> nullOrEmpty = tryParseNullOrEmpty(value); if (nullOrEmpty) { return std::move(nullOrEmpty); } bool create = false; std::unique_ptr<Reference> reference = tryParseReference(value, &create); if (reference) { if (create && onCreateReference) { onCreateReference(reference->name.value()); } return std::move(reference); } if (typeMask & android::ResTable_map::TYPE_COLOR) { // Try parsing this as a color. std::unique_ptr<BinaryPrimitive> color = tryParseColor(value); if (color) { return std::move(color); } } if (typeMask & android::ResTable_map::TYPE_BOOLEAN) { // Try parsing this as a boolean. std::unique_ptr<BinaryPrimitive> boolean = tryParseBool(value); if (boolean) { return std::move(boolean); } } if (typeMask & android::ResTable_map::TYPE_INTEGER) { // Try parsing this as an integer. std::unique_ptr<BinaryPrimitive> integer = tryParseInt(value); if (integer) { return std::move(integer); } } const uint32_t floatMask = android::ResTable_map::TYPE_FLOAT | android::ResTable_map::TYPE_DIMENSION | android::ResTable_map::TYPE_FRACTION; if (typeMask & floatMask) { // Try parsing this as a float. std::unique_ptr<BinaryPrimitive> floatingPoint = tryParseFloat(value); if (floatingPoint) { if (typeMask & androidTypeToAttributeTypeMask(floatingPoint->value.dataType)) { return std::move(floatingPoint); } } } return {}; }