// XML configuration settings parsing bool CAreaConfiguration::serializeXmlSettings(CXmlElement& xmlConfigurableElementSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) { // Assign blackboard to configuration context configurationAccessContext.setParameterBlackboard(&_blackboard); // Assign base offset to configuration context configurationAccessContext.setBaseOffset(_pConfigurableElement->getOffset()); // Parse configuration settings (element contents) if (_pConfigurableElement->serializeXmlSettings(xmlConfigurableElementSettingsElementContent, configurationAccessContext)) { if (!configurationAccessContext.serializeOut()) { // Serialized-in areas are valid _bValid = true; } return true; } return false; }
// XML Serialization value space handling // Value space handling for configuration import void CFixedPointParameterType::handleValueSpaceAttribute(CXmlElement& xmlConfigurableElementSettingsElement, CConfigurationAccessContext& configurationAccessContext) const { // Direction? if (!configurationAccessContext.serializeOut()) { // Get Value space from XML if (xmlConfigurableElementSettingsElement.hasAttribute("ValueSpace")) { configurationAccessContext.setValueSpaceRaw(xmlConfigurableElementSettingsElement.getAttributeBoolean("ValueSpace", "Raw")); } else { configurationAccessContext.setValueSpaceRaw(false); } } else { // Provide value space only if not the default one if (configurationAccessContext.valueSpaceIsRaw()) { xmlConfigurableElementSettingsElement.setAttributeString("ValueSpace", "Raw"); } } }
// XML configuration settings parsing bool CConfigurableElement::serializeXmlSettings(CXmlElement& xmlConfigurationSettingsElementContent, CConfigurationAccessContext& configurationAccessContext) const { uint32_t uiIndex; uint32_t uiNbChildren = getNbChildren(); if (!configurationAccessContext.serializeOut()) { // Just do basic checks and propagate to children CXmlElement::CChildIterator it(xmlConfigurationSettingsElementContent); CXmlElement xmlChildConfigurableElementSettingsElement; // Propagate to children for (uiIndex = 0; uiIndex < uiNbChildren; uiIndex++) { // Get child const CConfigurableElement* pChildConfigurableElement = static_cast<const CConfigurableElement*>(getChild(uiIndex)); if (!it.next(xmlChildConfigurableElementSettingsElement)) { // Structure error configurationAccessContext.setError("Configuration settings parsing: Settings don't conform to structure of configurable element " + getName()); return false; } // Check element type matches in type if (xmlChildConfigurableElementSettingsElement.getType() != pChildConfigurableElement->getKind()) { // Type error configurationAccessContext.setError("Configuration settings parsing: Settings for configurable element " + pChildConfigurableElement->getName() + " does not match expected type: " + xmlChildConfigurableElementSettingsElement.getType() + " instead of " + pChildConfigurableElement->getKind()); return false; } // Check element type matches in name if (xmlChildConfigurableElementSettingsElement.getNameAttribute() != pChildConfigurableElement->getName()) { // Name error configurationAccessContext.setError("Configuration settings parsing: Under configurable elememnt " + getName() + ", expected element name " + pChildConfigurableElement->getName() + " but found " + xmlChildConfigurableElementSettingsElement.getNameAttribute() + " instead"); return false; } // Parse child configurable element's settings if (!pChildConfigurableElement->serializeXmlSettings(xmlChildConfigurableElementSettingsElement, configurationAccessContext)) { return false; } } // There should remain no configurable element to parse if (it.next(xmlChildConfigurableElementSettingsElement)) { // Structure error configurationAccessContext.setError("Configuration settings parsing: Settings don't conform to structure of configurable element " + getName()); return false; } } else { // Propagate to children for (uiIndex = 0; uiIndex < uiNbChildren; uiIndex++) { const CConfigurableElement* pChildConfigurableElement = static_cast<const CConfigurableElement*>(getChild(uiIndex)); // Create corresponding child element CXmlElement xmlChildConfigurableElementSettingsElement; xmlConfigurationSettingsElementContent.createChild(xmlChildConfigurableElementSettingsElement, pChildConfigurableElement->getKind()); // Handle element name attribute xmlChildConfigurableElementSettingsElement.setNameAttribute(pChildConfigurableElement->getName()); // Propagate pChildConfigurableElement->serializeXmlSettings(xmlChildConfigurableElementSettingsElement, configurationAccessContext); } } // Done return true; }