本文整理汇总了C++中Dims::isEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ Dims::isEmpty方法的具体用法?C++ Dims::isEmpty怎么用?C++ Dims::isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dims
的用法示例。
在下文中一共展示了Dims::isEmpty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fromString
// ######################################################################
ResizeSpec ResizeSpec::fromString(const std::string& origstr)
{
const std::string str = toLowerCase(origstr);
if (str.length() == 0
|| str.compare("none") == 0
|| str.compare("noop") == 0)
{
return ResizeSpec(); // no-op ResizeSpec
}
else if (str[0] == '*' || str[0] == '/')
{
const Method m = (str[0] == '*' ? SCALE_UP : SCALE_DOWN);
std::vector<std::string> parts;
split(str.substr(1), "x", std::back_inserter(parts));
if (parts.size() == 1)
{
const double f = fromStr<double>(parts[0]);
if (f < 0.0)
LFATAL("while parsing '%s' as a ResizeSpec: expected "
"a non-negative scale factor, but got %s",
origstr.c_str(), parts[0].c_str());
if (f == 0.0 || f == 1.0)
return ResizeSpec(); // no-op ResizeSpec
return ResizeSpec(m, Dims(), f, f);
}
else if (parts.size() == 2)
{
const double fw = fromStr<double>(parts[0]);
const double fh = fromStr<double>(parts[1]);
if (fw < 0.0)
LFATAL("while parsing '%s' as a ResizeSpec: expected "
"a non-negative scale factor, but got %s",
origstr.c_str(), parts[0].c_str());
if (fh < 0.0)
LFATAL("while parsing '%s' as a ResizeSpec: expected "
"a non-negative scale factor, but got %s",
origstr.c_str(), parts[1].c_str());
if ((fw == 0.0 || fw == 1.0) && (fh == 0.0 || fh == 1.0))
return ResizeSpec(); // no-op ResizeSpec
return ResizeSpec(m, Dims(), fw, fh);
}
else
LFATAL("while parsing '%s' as a ResizeSpec: after '%c', "
"expected either one floating-point value or "
"two values separated by 'x', but got '%s'",
origstr.c_str(), str[0], str.substr(1).c_str());
}
else
{
const Dims d = fromStr<Dims>(str);
if (d.isEmpty())
return ResizeSpec(); // no-op ResizeSpec
return ResizeSpec(FIXED, d, 0.0, 0.0);
}
conversion_error::raise<ResizeSpec>(origstr);
ASSERT(0); /* can't happen */ return ResizeSpec();
}