src/Viewer/ViewPropertyEvaluator.*: added getBoolValue().
This commit is contained in:
parent
1e07dab5c5
commit
db255233f7
2 changed files with 25 additions and 0 deletions
|
@ -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";
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Reference in a new issue