本文整理汇总了C++中Split::toDouble方法的典型用法代码示例。如果您正苦于以下问题:C++ Split::toDouble方法的具体用法?C++ Split::toDouble怎么用?C++ Split::toDouble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Split
的用法示例。
在下文中一共展示了Split::toDouble方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ostr
void
Date::addTime(std::string time, std::string unit)
{
Split splt;
// default for units: inherent units
if( unit.size() == 0 )
unit = unitStr;
// It is save to append units (even if empty) to time
// Note: time-unit overrules parameter unit.
time += unit;
// Split string at positions where digits and characters alternate.
splt.setSeparator(":alnum:");
splt = time ;
// If there is a mix of digits and non-digits, splt.size() >= 2:
// isNonDigit && size == 1 is an error.
// size == 0 is an error.
// But, for !isNonDigit && size == 1 we got the default
bool isNon = ! hdhC::isDigit(time);
if( (splt.size() == 1 && isNon) || (splt.size() == 0) )
{
std::ostringstream ostr(std::ios::app);
ostr << "Date::addTime()"
<< "\nerror in 2nd parameter (time=" << time << ")" ;
exceptionError( ostr.str() );
}
// unitStr and int strings are empty.
// Pure digits are always converted to days.
if( splt.size() == 1 )
{
addDays( splt.toDouble(0) ) ;
return;
}
std::string str(splt[1]);
if( str[0] == 'y' )
addYears( splt.toDouble(0) );
else if( str.substr(0,2) == "mo" )
addMonths( splt.toDouble(0) );
else if( str[0] == 'd' )
addDays( splt.toDouble(0) );
else if( str[0] == 'h' )
addHours( splt.toDouble(0) );
else if( str.substr(0,2) == "mi" )
addMinutes( splt.toDouble(0) );
else if( str[0] == 's' )
addSeconds( splt.toDouble(0) );
return;
}