本文整理汇总了C++中Option::hasValue方法的典型用法代码示例。如果您正苦于以下问题:C++ Option::hasValue方法的具体用法?C++ Option::hasValue怎么用?C++ Option::hasValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Option
的用法示例。
在下文中一共展示了Option::hasValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
Option<Vec2> sb::Intersection::get(const Ray& a, const Polygon& b) {
Option<Vec2> pt = nullptr;
Option<bool> inside = nullptr;
float t = std::numeric_limits<float>::max();
auto eCount = b.edgeCount();
for (ptrdiff_t i = 0; i < eCount; i++) {
const auto ed = b.edge(i);
auto r = Intersection::get(a, ed);
if (!r)
continue;
if (aeq(r.value(), ed.pointA())) {
if (!inside.hasValue())
inside = test(b, a.m_point);
if (!inside.value() && !(-a.direction()).isBetween(b.normal(i), b.normal(i - 1)))
continue;
}
else if (aeq(r.value(), ed.pointB())) {
if (!inside.hasValue())
inside = test(b, a.m_point);
if (!inside.value() && !(-a.direction()).isBetween(b.normal(i), b.normal(i + 1)))
continue;
}
auto u = a.computeT(r.value());
if (u < t) {
t = u;
pt = r;
}
}
return pt;
}
示例2: glCreateProgram
Option<Shader*> Shader::combine(const Option<uint>& vs, const Option<uint>& fs, const Option<uint>& gs)
{
if(!vs.hasValue() || !fs.hasValue())
{
_lastLinkError.clear();
if(!vs.hasValue())
_lastLinkError += "Vertex shader missing.\n";
if(!fs.hasValue())
_lastLinkError += "Fragment shader missing.\n";
return Option<Shader*>();
}
uint id = glCreateProgram();
glAttachShader(id, vs.value());
glAttachShader(id, fs.value());
if(gs.hasValue() && fs.value() != 0)
glAttachShader(id, gs.value());
glBindAttribLocation(id, 0, "vertex");
glBindAttribLocation(id, 1, "normal");
glBindAttribLocation(id, 2, "texCoord");
glBindAttribLocation(id, 3, "tangent");
glBindAttribLocation(id, 4, "drawId");
glLinkProgram(id);
int linkStatus = GL_TRUE;
glGetProgramiv(id, GL_LINK_STATUS, &linkStatus);
if(linkStatus != GL_TRUE)
{
int logSize;
glGetProgramiv(id, GL_INFO_LOG_LENGTH, &logSize);
char* log = new char[logSize];
glGetProgramInfoLog(id, logSize, &logSize, log);
_lastLinkError = std::string(log);
delete[] log;
glDeleteProgram(id);
return Option<Shader*>();
}
Shader* prog = new Shader;
prog->_id = id;
prog->loadEngineUniform();
return Option<Shader*>(prog);
}
示例3: action
int EnumerationManager::action(Option &option) {
if (option.hasValue()) print(cout, String::toLower(option.toString()));
else for (enums_t::iterator it = enums.begin(); it != enums.end(); it++)
cout << it->first << '\n';
cout << flush;
exit(0); // TODO Option calls the action so we have to exit(). FIXME!
return -1;
}
示例4: usageAction
int CommandLine::usageAction(Option &option) {
if (option.hasValue()) {
string name = option.toString();
SmartPointer<Option> opt;
if (has(string("--") + name)) opt = get(string("--") + name);
else if (keywords && keywords->has(name)) opt = keywords->get(name);
else THROWS("Unrecognized command line option or keyword '" << name << "'");
opt->printHelp(cout) << endl;
} else usage(cout, name);
exit(0); // TODO cb::Option calls this action so we have to exit(0). FIXME!
return -1;
}