本文整理汇总了C++中VTTScanner::scanDigits方法的典型用法代码示例。如果您正苦于以下问题:C++ VTTScanner::scanDigits方法的具体用法?C++ VTTScanner::scanDigits怎么用?C++ VTTScanner::scanDigits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类VTTScanner
的用法示例。
在下文中一共展示了VTTScanner::scanDigits方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseSettingValue
void VTTRegion::parseSettingValue(RegionSetting setting, VTTScanner& input)
{
DEPRECATED_DEFINE_STATIC_LOCAL(const AtomicString, scrollUpValueKeyword, ("up", AtomicString::ConstructFromLiteral));
VTTScanner::Run valueRun = input.collectUntil<isHTMLSpace<UChar>>();
switch (setting) {
case Id: {
String stringValue = input.extractString(valueRun);
if (stringValue.find("-->") == notFound)
m_id = stringValue;
break;
}
case Width: {
float floatWidth;
if (WebVTTParser::parseFloatPercentageValue(input, floatWidth) && parsedEntireRun(input, valueRun))
m_width = floatWidth;
else
LOG(Media, "VTTRegion::parseSettingValue, invalid Width");
break;
}
case Height: {
int number;
if (input.scanDigits(number) && parsedEntireRun(input, valueRun))
m_heightInLines = number;
else
LOG(Media, "VTTRegion::parseSettingValue, invalid Height");
break;
}
case RegionAnchor: {
FloatPoint anchor;
if (WebVTTParser::parseFloatPercentageValuePair(input, ',', anchor) && parsedEntireRun(input, valueRun))
m_regionAnchor = anchor;
else
LOG(Media, "VTTRegion::parseSettingValue, invalid RegionAnchor");
break;
}
case ViewportAnchor: {
FloatPoint anchor;
if (WebVTTParser::parseFloatPercentageValuePair(input, ',', anchor) && parsedEntireRun(input, valueRun))
m_viewportAnchor = anchor;
else
LOG(Media, "VTTRegion::parseSettingValue, invalid ViewportAnchor");
break;
}
case Scroll:
if (input.scanRun(valueRun, scrollUpValueKeyword))
m_scroll = true;
else
LOG(Media, "VTTRegion::parseSettingValue, invalid Scroll");
break;
case None:
break;
}
input.skipRun(valueRun);
}
示例2: collectTimeStamp
bool VTTParser::collectTimeStamp(VTTScanner& input, double& timeStamp)
{
// Collect a WebVTT timestamp (5.3 WebVTT cue timings and settings parsing.)
// Steps 1 - 4 - Initial checks, let most significant units be minutes.
enum Mode { Minutes, Hours };
Mode mode = Minutes;
// Steps 5 - 7 - Collect a sequence of characters that are 0-9.
// If not 2 characters or value is greater than 59, interpret as hours.
int value1;
unsigned value1Digits = input.scanDigits(value1);
if (!value1Digits)
return false;
if (value1Digits != 2 || value1 > 59)
mode = Hours;
// Steps 8 - 11 - Collect the next sequence of 0-9 after ':' (must be 2 chars).
int value2;
if (!input.scan(':') || input.scanDigits(value2) != 2)
return false;
// Step 12 - Detect whether this timestamp includes hours.
int value3;
if (mode == Hours || input.match(':')) {
if (!input.scan(':') || input.scanDigits(value3) != 2)
return false;
} else {
value3 = value2;
value2 = value1;
value1 = 0;
}
// Steps 13 - 17 - Collect next sequence of 0-9 after '.' (must be 3 chars).
int value4;
if (!input.scan('.') || input.scanDigits(value4) != 3)
return false;
if (value2 > 59 || value3 > 59)
return false;
// Steps 18 - 19 - Calculate result.
timeStamp = (value1 * secondsPerHour) + (value2 * secondsPerMinute) + value3 + (value4 * secondsPerMillisecond);
return true;
}