bool SerializerElement::GetBoolAttribute(const gd::String& name, bool defaultValue, gd::String deprecatedName) const { if (attributes.find(name) != attributes.end()) { return attributes.find(name)->second.GetBool(); } else if (!deprecatedName.empty() && attributes.find(deprecatedName) != attributes.end()) { return attributes.find(deprecatedName)->second.GetBool(); } else { if (HasChild(name, deprecatedName)) { SerializerElement& child = GetChild(name, 0, deprecatedName); if (!child.IsValueUndefined()) { return child.GetValue().GetBool(); } } } std::cout << "Bool attribute \"" << name << "\" not found, returning " << defaultValue; return defaultValue; }
bool ConfigurationNode::AddNode(Crude::String Key, Crude::String Value) { bool NodeAlreadyExists = false; if (HasChild(Key.Hash())) NodeAlreadyExists = true; if (NodeAlreadyExists) { ConfigurationNode* Node = GetChild(Key.Hash()); Node->Value = Value; } else { ConfigurationNode* InsertNode = new ConfigurationNode(Key, Value); NodeChildren.Insert(InsertNode); } return NodeAlreadyExists; }
bool Job::AddChild( Job* child, MyString &whynot ) { if( !this->CanAddChild( child, whynot ) ) { return false; } if( HasChild( child ) ) { debug_printf( DEBUG_NORMAL, "Warning: parent %s already has child %s\n", GetJobName(), child->GetJobName() ); check_warning_strictness( DAG_STRICT_3 ); return true; } if( !Add( Q_CHILDREN, child->GetJobID() ) ) { whynot = "unknown error appending to CHILDREN queue"; return false; } whynot = "n/a"; return true; }
bool XMLElement::HasChild(const ea::string& name) const { return HasChild(name.c_str()); }
bool XMLElement::HasChild(const String& name) const { return HasChild(name.CString()); }
void TaskEditor::RefreshComboBox(const QString& itemName) { LOGN_DEBUG("taskeditor.cpp", "Refresh Combo Box"); mComboBox->clear(); dtDAL::Map* m = EditorData::GetInstance().getCurrentMap(); if (m == NULL) { LOG_ERROR("Unable read lookup the task actor types because the current map is NULL."); return; } const std::string topLevelProperty("IsTopLevel"); std::vector<dtCore::RefPtr<dtDAL::ActorProxy> > toFill; std::vector<dtDAL::ActorProxy*> selectedActors; m->FindProxies(toFill, "", "dtcore.Tasks", "Task Actor"); EditorData::GetInstance().GetSelectedActors(selectedActors); for (unsigned i = 0; i < toFill.size(); ++i) { dtDAL::ActorProxy* ap = toFill[i].get(); bool isRemoved = mRemovedTasks.find(ap) != mRemovedTasks.end(); // We don't want to see actors with parents unless it has been removed from the current parent actor // or the checkbox has been selected by the user to explicitly show them. if (!isRemoved && mShowTasksWithParents->checkState() == Qt::Unchecked) { dtDAL::BooleanActorProperty* bap = static_cast<dtDAL::BooleanActorProperty*>(ap->GetProperty(topLevelProperty)); if (bap == NULL) { LOG_ERROR("A task actor named \"" + ap->GetName() + "\" with type \"" + ap->GetActorType().GetCategory() + "." + ap->GetActorType().GetName() + "\" was found that doesn't have an \"" + topLevelProperty + "\" property. Ignoring."); continue; } //don't add non-top-level tasks to the list. if (!bap->GetValue()) { continue; } } bool isSelected = false; for (unsigned j = 0; j < selectedActors.size(); ++j) { if (selectedActors[j] == toFill[i].get()) { isSelected = true; break; } } if (!isSelected && !HasChild(*ap)) { //TODO if it's not the currently selected actor QVariant v = QVariant::fromValue(dtCore::RefPtr<dtDAL::ActorProxy>(ap)); mComboBox->addItem(tr(ap->GetName().c_str()), v); } } }
static BOOL TreeSecondWalk(PNODE pThisNode, unsigned nCurrentLevel) { /*------------------------------------------------------ * During a second pre-order walk, each node is given a * final x-coordinate by summing its preliminary * x-coordinate and the modifiers of all the node's * ancestors. The y-coordinate depends on the height of * the tree. (The roles of x and y are reversed for * RootOrientations of EAST or WEST.) * Returns: TRUE if no errors, otherwise returns FALSE. *----------------------------------------- ----------*/ BOOL bResult = TRUE; /* assume innocent */ long lxTemp, lyTemp; /* hold calculations here */ float flNewModsum; /* local modifier value */ static float flModsum = (float)0.0; if (nCurrentLevel <= MAXIMUM_DEPTH) { flNewModsum = flModsum; /* Save the current value */ switch (RootOrientation) { case NORTH: lxTemp = (long)xTopAdjustment + (long)(pThisNode->flPrelim + flModsum); lyTemp = (long)yTopAdjustment + (long)(nCurrentLevel * LEVEL_SEPARATION); break; case SOUTH: lxTemp = (long)xTopAdjustment + (long)(pThisNode->flPrelim + flModsum); lyTemp = (long)yTopAdjustment - (long)(nCurrentLevel * LEVEL_SEPARATION); break; case EAST: lxTemp = (long)xTopAdjustment + (long)(nCurrentLevel * LEVEL_SEPARATION); lyTemp = (long)yTopAdjustment - (long)(pThisNode->flPrelim + flModsum); break; case WEST: lxTemp = (long)xTopAdjustment - (long)(nCurrentLevel * LEVEL_SEPARATION); lyTemp = (long)yTopAdjustment - (long)(pThisNode->flPrelim + flModsum); break; } if (CheckExtentsRange(lxTemp, lyTemp)) { /* The values are within the allowable range */ pThisNode->xCoordinate = (COORD)lxTemp; pThisNode->yCoordinate = (COORD)lyTemp; if (HasChild(pThisNode)) { /* Apply the flModifier value for this */ /* node to all its offspring. */ flModsum = flNewModsum = flNewModsum + pThisNode->flModifier; bResult = TreeSecondWalk( FirstChild(pThisNode), nCurrentLevel + 1); flNewModsum = flNewModsum - pThisNode->flModifier; } if ((HasRightSibling(pThisNode)) && (bResult)) { flModsum = flNewModsum; bResult = TreeSecondWalk( RightSibling(pThisNode), nCurrentLevel); } } else bResult = FALSE; /* outside of extents */ } return (bResult); }
bool TWidget::HasChild(const ChildRef& childRef) const { if (childRef.expired() == true) { return false; } const auto child = childRef.lock(); return HasChild(child->name) && (child->parent.lock().get() == this); }