1
0
Fork 0

src/Viewer/ViewPropertyEvaluator.*: added getBoolValue().

This commit is contained in:
Julian Smith 2020-03-03 00:07:08 +00:00
parent 1e07dab5c5
commit db255233f7
2 changed files with 25 additions and 0 deletions

View file

@ -498,6 +498,17 @@ namespace ViewPropertyEvaluator {
return default_;
}
bool getSequenceBoolValue(Sequence& sequence, bool default_)
{
SGPropertyNode* node = getSequenceNode(sequence);
if (node) {
if (node->getStringValue()[0] != 0) {
return node->getBoolValue();
}
}
return default_;
}
const std::string& getStringValue(const char* spec)
{
std::shared_ptr<Sequence> sequence = getSequence(spec);
@ -515,6 +526,17 @@ namespace ViewPropertyEvaluator {
return ret;
}
bool getBoolValue(const char* spec, bool default_)
{
std::shared_ptr<Sequence> sequence = getSequence(spec);
if (sequence->_nodes.size() != 1 || sequence->_nodes.front()->_begin[0] != '(') {
SG_LOG(SG_VIEW, SG_DEBUG, "bad sequence for getBoolValue() - must have outermost '(...)': '" << spec);
abort();
}
bool ret = getSequenceBoolValue(*sequence, default_);
return ret;
}
std::ostream& operator << (std::ostream& out, const Dump& dump)
{
out << "ViewPropertyEvaluator\n";

View file

@ -106,6 +106,9 @@ namespace ViewPropertyEvaluator {
node, instead it always calls <top-level-node>->getDoubleValue().
*/
double getDoubleValue(const char* spec, double default_=0);
/* Similar to getDoubleValue(). */
bool getBoolValue(const char* spec, bool default_=false);
/* Outputs detailed information about all specs that have been seen.